From 5ab0208a381ab4f7ea5aa9b621ea6dcab8e0e86d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:17:13 -0700 Subject: [PATCH 001/862] Clean up some garbage. --- Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs | 7 +------ Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs | 5 +---- Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs | 5 +---- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs index e615a66fd6..a35fce8454 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs @@ -2,11 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - namespace System.Collections.Generic { /// @@ -22,4 +17,4 @@ public interface IAsyncEnumerable /// Enumerator for asynchronous enumeration over the sequence. IAsyncEnumerator GetEnumerator(); } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index 74c258b19c..18b9faa211 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -2,9 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -32,4 +29,4 @@ public interface IAsyncEnumerator : IDisposable /// Task MoveNext(CancellationToken cancellationToken); } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs index b02b98399b..b2d740abb5 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -13,4 +10,4 @@ public interface IAsyncGrouping : IAsyncEnumerable Date: Wed, 30 Aug 2017 15:24:22 -0700 Subject: [PATCH 002/862] Rename GetEnumerator to GetAsyncEnumerator. --- .../AsyncEnumerableQuery.cs | 4 +- .../System.Interactive.Async/Aggregate.cs | 4 +- .../Source/System.Interactive.Async/AnyAll.cs | 6 +- .../System.Interactive.Async/AppendPrepend.cs | 10 +- .../AsyncEnumerableHelpers.cs | 2 +- .../System.Interactive.Async/AsyncIterator.cs | 2 +- .../System.Interactive.Async/Average.cs | 20 +- .../Source/System.Interactive.Async/Buffer.cs | 2 +- .../Source/System.Interactive.Async/Catch.cs | 6 +- .../System.Interactive.Async/Concatenate.cs | 8 +- .../Source/System.Interactive.Async/Create.cs | 4 +- .../DefaultIfEmpty.cs | 2 +- .../Source/System.Interactive.Async/Defer.cs | 2 +- .../System.Interactive.Async/Distinct.cs | 14 +- Ix.NET/Source/System.Interactive.Async/Do.cs | 2 +- .../System.Interactive.Async/ElementAt.cs | 4 +- .../Source/System.Interactive.Async/Except.cs | 2 +- .../Source/System.Interactive.Async/Expand.cs | 2 +- .../System.Interactive.Async/Finally.cs | 2 +- .../Source/System.Interactive.Async/First.cs | 4 +- .../System.Interactive.Async/ForEach.cs | 2 +- .../System.Interactive.Async/GroupJoin.cs | 4 +- .../System.Interactive.Async/Grouping.cs | 4 +- .../IAsyncEnumerable.cs | 2 +- .../IgnoreElements.cs | 2 +- .../System.Interactive.Async/Intersect.cs | 2 +- .../Source/System.Interactive.Async/Join.cs | 2 +- .../Source/System.Interactive.Async/Last.cs | 4 +- .../Source/System.Interactive.Async/Lookup.cs | 10 +- Ix.NET/Source/System.Interactive.Async/Min.cs | 2 +- .../OnErrorResumeNext.cs | 2 +- .../OrderedAsyncEnumerable.cs | 2 +- .../Source/System.Interactive.Async/Repeat.cs | 2 +- .../Source/System.Interactive.Async/Scan.cs | 4 +- .../Source/System.Interactive.Async/Select.cs | 4 +- .../System.Interactive.Async/SelectMany.cs | 16 +- .../System.Interactive.Async/SequenceEqual.cs | 4 +- .../Source/System.Interactive.Async/Single.cs | 4 +- .../Source/System.Interactive.Async/Skip.cs | 8 +- .../Source/System.Interactive.Async/Take.cs | 8 +- .../ToAsyncEnumerable.cs | 2 +- .../System.Interactive.Async/ToObservable.cs | 2 +- .../Source/System.Interactive.Async/Using.cs | 2 +- .../Source/System.Interactive.Async/Where.cs | 6 +- Ix.NET/Source/System.Interactive.Async/Zip.cs | 4 +- Ix.NET/Source/Tests/AppendPrependTests.cs | 12 +- Ix.NET/Source/Tests/AsyncTests.Bugs.cs | 16 +- Ix.NET/Source/Tests/AsyncTests.Conversions.cs | 16 +- Ix.NET/Source/Tests/AsyncTests.Creation.cs | 46 +-- Ix.NET/Source/Tests/AsyncTests.Exceptions.cs | 52 +-- Ix.NET/Source/Tests/AsyncTests.Multiple.cs | 76 ++--- Ix.NET/Source/Tests/AsyncTests.Single.cs | 322 +++++++++--------- Ix.NET/Source/Tests/AsyncTests.cs | 4 +- 53 files changed, 375 insertions(+), 375 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs index 67de84e6a2..d58722353d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs @@ -144,7 +144,7 @@ Task IAsyncQueryProvider.ExecuteAsync(Expression expression, C /// Gets an enumerator to enumerate the elements in the sequence. /// /// A new enumerator instance used to enumerate the elements in the sequence. - public IAsyncEnumerator GetEnumerator() + public IAsyncEnumerator GetAsyncEnumerator() { if (_enumerable == null) { @@ -152,7 +152,7 @@ public IAsyncEnumerator GetEnumerator() _enumerable = expression.Compile()(); } - return _enumerable.GetEnumerator(); + return _enumerable.GetAsyncEnumerator(); } /// diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index 19ff41c430..9593a5c879 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -81,7 +81,7 @@ private static async Task Aggregate_(IAs { var acc = seed; - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -98,7 +98,7 @@ private static async Task Aggregate_(IAsyncEnumerable var first = true; var acc = default(TSource); - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs index 8eb14de9a1..117bb6a2d3 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs @@ -65,7 +65,7 @@ public static async Task Any(this IAsyncEnumerable sourc if (source == null) throw new ArgumentNullException(nameof(source)); - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { return await e.MoveNext(cancellationToken).ConfigureAwait(false); } @@ -73,7 +73,7 @@ public static async Task Any(this IAsyncEnumerable sourc private static async Task All_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -87,7 +87,7 @@ private static async Task All_(IAsyncEnumerable source, private static async Task Any_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index 2f962db6cd..0ebf6cd96a 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -54,7 +54,7 @@ protected AppendPrepentAsyncIterator(IAsyncEnumerable source) protected void GetSourceEnumerator() { Debug.Assert(enumerator == null); - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); } public abstract AppendPrepentAsyncIterator Append(TSource item); @@ -201,7 +201,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } else { - using (var en = source.GetEnumerator()) + using (var en = source.GetAsyncEnumerator()) { while (await en.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -231,7 +231,7 @@ public override async Task> ToListAsync(CancellationToken cancella } - using (var en = source.GetEnumerator()) + using (var en = source.GetAsyncEnumerator()) { while (await en.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -435,7 +435,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } else { - using (var en = source.GetEnumerator()) + using (var en = source.GetAsyncEnumerator()) { while (await en.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -465,7 +465,7 @@ public override async Task> ToListAsync(CancellationToken cancella list.Add(n.Item); } - using (var en = source.GetEnumerator()) + using (var en = source.GetAsyncEnumerator()) { while (await en.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs index 9b51912ff9..c01f18de6a 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs @@ -43,7 +43,7 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer } else { - using (var en = source.GetEnumerator()) + using (var en = source.GetAsyncEnumerator()) { if (await en.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 7ff317f687..d2c30b35fd 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -25,7 +25,7 @@ protected AsyncIterator() threadId = Environment.CurrentManagedThreadId; } - public IAsyncEnumerator GetEnumerator() + public IAsyncEnumerator GetAsyncEnumerator() { var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? this : diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index abe0b4a12e..a9a6d517d7 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -383,7 +383,7 @@ public static Task Average(this IAsyncEnumerable sour private static async Task Average_(this IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (!await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -409,7 +409,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -443,7 +443,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (!await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -469,7 +469,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -503,7 +503,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (!await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -529,7 +529,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -563,7 +563,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (!await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -586,7 +586,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -620,7 +620,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (!await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -643,7 +643,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/Buffer.cs index 58a170f8d9..b931adc293 100644 --- a/Ix.NET/Source/System.Interactive.Async/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Buffer.cs @@ -76,7 +76,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); buffers = new Queue>(); index = 0; stopped = false; diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/Catch.cs index 531dd8e765..79303405cc 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/Catch.cs @@ -92,7 +92,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); isDone = false; state = AsyncIteratorState.Iterating; @@ -118,7 +118,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT // invoking the handler, but we use this order to preserve // current behavior var err = handler(ex) - .GetEnumerator(); + .GetAsyncEnumerator(); enumerator?.Dispose(); enumerator = err; isDone = true; @@ -207,7 +207,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT } error = null; - enumerator = sourcesEnumerator.Current.GetEnumerator(); + enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(); } try diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs index fbdfe31f11..444c694bfe 100644 --- a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs @@ -105,7 +105,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { // make sure we dispose the previous one if we're about to replace it currentEnumerator?.Dispose(); - currentEnumerator = outerEnumerator.Current.GetEnumerator(); + currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); mode = State_While; goto case State_While; @@ -191,7 +191,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken { break; } - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -245,7 +245,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (state == AsyncIteratorState.Allocated) { enumerator = GetAsyncEnumerable(0) - .GetEnumerator(); + .GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; counter = 2; } @@ -266,7 +266,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (next != null) { enumerator.Dispose(); - enumerator = next.GetEnumerator(); + enumerator = next.GetAsyncEnumerator(); continue; } diff --git a/Ix.NET/Source/System.Interactive.Async/Create.cs b/Ix.NET/Source/System.Interactive.Async/Create.cs index ee943a4b0b..f4e1a6935a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Create.cs +++ b/Ix.NET/Source/System.Interactive.Async/Create.cs @@ -65,7 +65,7 @@ public AnonymousAsyncEnumerable(Func> getEnumerator) this.getEnumerator = getEnumerator; } - public IAsyncEnumerator GetEnumerator() + public IAsyncEnumerator GetAsyncEnumerator() { return getEnumerator(); } @@ -87,7 +87,7 @@ public AnonymousAsyncIterator(Func> moveNext, Func this.dispose = dispose; // Explicit call to initialize enumerator mode - GetEnumerator(); + GetAsyncEnumerator(); } public override AsyncIterator Clone() diff --git a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs index 8ff55477d0..789274f207 100644 --- a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs @@ -64,7 +64,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); if (await enumerator.MoveNext(cancellationToken) .ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Interactive.Async/Defer.cs b/Ix.NET/Source/System.Interactive.Async/Defer.cs index 3d76879739..c2b8021521 100644 --- a/Ix.NET/Source/System.Interactive.Async/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Defer.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Defer(Func factory() - .GetEnumerator()); + .GetAsyncEnumerator()); } } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index c74b02a976..d280f1bd6e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -139,7 +139,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell var count = 0; var s = new Set(comparer); - using (var enu = source.GetEnumerator()) + using (var enu = source.GetAsyncEnumerator()) { while (await enu.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -177,7 +177,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); if (!await enumerator.MoveNext(cancellationToken) .ConfigureAwait(false)) { @@ -215,7 +215,7 @@ private async Task> FillSet(CancellationToken cancellationToken) { var s = new Set(comparer); var r = new List(); - using (var enu = source.GetEnumerator()) + using (var enu = source.GetAsyncEnumerator()) { while (await enu.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -290,7 +290,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); if (!await enumerator.MoveNext(cancellationToken) .ConfigureAwait(false)) { @@ -327,7 +327,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT private async Task> FillSet(CancellationToken cancellationToken) { var s = new Set(comparer); - using (var enu = source.GetEnumerator()) + using (var enu = source.GetAsyncEnumerator()) { while (await enu.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -380,7 +380,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -451,7 +451,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/Do.cs index da03b1817d..7511ed290a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/Do.cs @@ -115,7 +115,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index db030aa5b5..d55397a156 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -58,7 +58,7 @@ private static async Task ElementAt_(IAsyncEnumerable if (index >= 0) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -80,7 +80,7 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable { if (index >= 0) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Interactive.Async/Except.cs index 64fe28c28d..dccc330c88 100644 --- a/Ix.NET/Source/System.Interactive.Async/Except.cs +++ b/Ix.NET/Source/System.Interactive.Async/Except.cs @@ -80,7 +80,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetEnumerator(); + firstEnumerator = first.GetAsyncEnumerator(); set = new Set(comparer); setFilled = false; fillSetTask = FillSet(cancellationToken); diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index 053ad45353..a5e4bb174a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -78,7 +78,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT var src = queue.Dequeue(); enumerator?.Dispose(); - enumerator = src.GetEnumerator(); + enumerator = src.GetAsyncEnumerator(); continue; // loop } diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/Finally.cs index e3e084771a..bf9f0361ab 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/Finally.cs @@ -60,7 +60,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index ebac898506..bda638d3b5 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -94,7 +94,7 @@ private static async Task First_(IAsyncEnumerable sou return list[0]; } - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -113,7 +113,7 @@ private static async Task FirstOrDefault_(IAsyncEnumerable(this IAsyncEnumerable source, private static async Task ForEachAsync_(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { var index = 0; - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs index de5aa737aa..14086edb83 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs @@ -75,9 +75,9 @@ public GroupJoinAsyncEnumerable( _comparer = comparer; } - public IAsyncEnumerator GetEnumerator() + public IAsyncEnumerator GetAsyncEnumerator() => new GroupJoinAsyncEnumerator( - _outer.GetEnumerator(), + _outer.GetAsyncEnumerator(), _inner, _outerKeySelector, _innerKeySelector, diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Interactive.Async/Grouping.cs index 797c8e5f1e..8ddad54129 100644 --- a/Ix.NET/Source/System.Interactive.Async/Grouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/Grouping.cs @@ -504,9 +504,9 @@ internal void Trim() } } - IAsyncEnumerator IAsyncEnumerable.GetEnumerator() + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() { - return this.ToAsyncEnumerable().GetEnumerator(); + return this.ToAsyncEnumerable().GetAsyncEnumerator(); } } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs index a35fce8454..b48233057a 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs @@ -15,6 +15,6 @@ public interface IAsyncEnumerable /// Gets an asynchronous enumerator over the sequence. /// /// Enumerator for asynchronous enumeration over the sequence. - IAsyncEnumerator GetEnumerator(); + IAsyncEnumerator GetAsyncEnumerator(); } } diff --git a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs index 4cbd23ddf2..33bcd8e3f1 100644 --- a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs @@ -52,7 +52,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Interactive.Async/Intersect.cs index 24cc36bf67..23ce235edc 100644 --- a/Ix.NET/Source/System.Interactive.Async/Intersect.cs +++ b/Ix.NET/Source/System.Interactive.Async/Intersect.cs @@ -81,7 +81,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetEnumerator(); + firstEnumerator = first.GetAsyncEnumerator(); set = new Set(comparer); setFilled = false; fillSetTask = FillSet(cancellationToken); diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index e59faa76aa..df24fdb558 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -107,7 +107,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = outer.GetEnumerator(); + outerEnumerator = outer.GetAsyncEnumerator(); mode = State_If; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index d24c0b386f..793ff9fe51 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -100,7 +100,7 @@ private static async Task Last_(IAsyncEnumerable sour } } - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -128,7 +128,7 @@ private static async Task LastOrDefault_(IAsyncEnumerable> CreateAsync(IAsyncEn Debug.Assert(elementSelector != null); var lookup = new Lookup(comparer); - using (var enu = source.GetEnumerator()) + using (var enu = source.GetAsyncEnumerator()) { while (await enu.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -215,7 +215,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< Debug.Assert(keySelector != null); var lookup = new Lookup(comparer); - using (var enu = source.GetEnumerator()) + using (var enu = source.GetAsyncEnumerator()) { while (await enu.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -231,7 +231,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { var lookup = new Lookup(comparer); - using (var enu = source.GetEnumerator()) + using (var enu = source.GetAsyncEnumerator()) { while (await enu.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -357,9 +357,9 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT return Task.FromResult(Count); } - IAsyncEnumerator> IAsyncEnumerable>.GetEnumerator() + IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator() { - return Enumerable.Cast>(this).ToAsyncEnumerable().GetEnumerator(); + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(); } Task>> IIListProvider>.ToListAsync(CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 306080cad1..20c3ba8837 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -493,7 +493,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (!await e.MoveNext(cancellationToken) .ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs index fe61e47871..68d10fc407 100644 --- a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs @@ -100,7 +100,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; // while -- done, nothing else to do } - enumerator = sourcesEnumerator.Current.GetEnumerator(); + enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(); } try diff --git a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs index 70884e442d..635dcdc532 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs @@ -104,7 +104,7 @@ internal override async Task Initialize(CancellationToken cancellationToken) } else { - parentEnumerator = parent.GetEnumerator(); + parentEnumerator = parent.GetAsyncEnumerator(); await parent.Initialize(cancellationToken) .ConfigureAwait(false); enumerable = parent.enumerable.CreateOrderedEnumerable(keySelector, comparer, @descending); diff --git a/Ix.NET/Source/System.Interactive.Async/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/Repeat.cs index 9aee8cb2f1..442121ca2a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/Repeat.cs @@ -114,7 +114,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (!isInfinite && currentCount-- == 0) break; - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index d179cec1e5..8781a4517c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -72,7 +72,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); accumulated = seed; state = AsyncIteratorState.Iterating; @@ -138,7 +138,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); hasSeed = false; accumulated = default(TSource); diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Interactive.Async/Select.cs index c6becab7e2..e8333cbd81 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Interactive.Async/Select.cs @@ -88,7 +88,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -145,7 +145,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index 4be956e58e..d9d2db8532 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -114,7 +114,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(); mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -128,7 +128,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { resultEnumerator?.Dispose(); resultEnumerator = selector(sourceEnumerator.Current) - .GetEnumerator(); + .GetAsyncEnumerator(); mode = State_Result; goto case State_Result; @@ -209,7 +209,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(); mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -224,7 +224,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT resultEnumerator?.Dispose(); currentSource = sourceEnumerator.Current; resultEnumerator = collectionSelector(currentSource) - .GetEnumerator(); + .GetAsyncEnumerator(); mode = State_Result; goto case State_Result; @@ -306,7 +306,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(); index = -1; mode = State_Source; state = AsyncIteratorState.Iterating; @@ -328,7 +328,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT } resultEnumerator = collectionSelector(currentSource, index) - .GetEnumerator(); + .GetAsyncEnumerator(); mode = State_Result; goto case State_Result; @@ -404,7 +404,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(); index = -1; mode = State_Source; state = AsyncIteratorState.Iterating; @@ -423,7 +423,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT index++; } resultEnumerator = selector(sourceEnumerator.Current, index) - .GetEnumerator(); + .GetAsyncEnumerator(); mode = State_Result; goto case State_Result; diff --git a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs index 4bdf610bbc..c5cbd4b3c2 100644 --- a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs +++ b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs @@ -68,8 +68,8 @@ private static async Task SequenceEqual_(IAsyncEnumerable Single_(IAsyncEnumerable so throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { if (!await e.MoveNext(cancellationToken) .ConfigureAwait(false)) @@ -128,7 +128,7 @@ private static async Task SingleOrDefault_(IAsyncEnumerable MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); // skip elements as requested while (currentCount > 0 && await enumerator.MoveNext(cancellationToken) @@ -180,7 +180,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); queue = new Queue(); state = AsyncIteratorState.Iterating; @@ -246,7 +246,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); // skip elements as requested while (await enumerator.MoveNext(cancellationToken) @@ -323,7 +323,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); index = -1; // skip elements as requested diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index 7ecf2c2656..d93c93bbcc 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -96,7 +96,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -158,7 +158,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); queue = new Queue(); isDone = false; @@ -249,7 +249,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -314,7 +314,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs index 28e3f90479..159e5ac266 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs @@ -63,7 +63,7 @@ public static IEnumerable ToEnumerable(this IAsyncEnumerable ToEnumerable_(IAsyncEnumerable source) { - using (var e = source.GetEnumerator()) + using (var e = source.GetAsyncEnumerator()) { while (true) { diff --git a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs index 1a2fca8b6f..38c7c910f8 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs @@ -182,7 +182,7 @@ public ToObservableObservable(IAsyncEnumerable source) public IDisposable Subscribe(IObserver observer) { var ctd = new CancellationTokenDisposable(); - var e = source.GetEnumerator(); + var e = source.GetAsyncEnumerator(); var f = default(Action); f = () => e.MoveNext(ctd.Token) diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/Using.cs index 86fe43fa4e..f77c0d325f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/Using.cs @@ -66,7 +66,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = enumerable.GetEnumerator(); + enumerator = enumerable.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Interactive.Async/Where.cs index 06cf77a1d8..c18a18f2ab 100644 --- a/Ix.NET/Source/System.Interactive.Async/Where.cs +++ b/Ix.NET/Source/System.Interactive.Async/Where.cs @@ -88,7 +88,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -149,7 +149,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -223,7 +223,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Interactive.Async/Zip.cs index 7d170142e4..04610ddaa2 100644 --- a/Ix.NET/Source/System.Interactive.Async/Zip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Zip.cs @@ -69,8 +69,8 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetEnumerator(); - secondEnumerator = second.GetEnumerator(); + firstEnumerator = first.GetAsyncEnumerator(); + secondEnumerator = second.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/Tests/AppendPrependTests.cs b/Ix.NET/Source/Tests/AppendPrependTests.cs index a797f3dc2e..c8fd63e5c5 100644 --- a/Ix.NET/Source/Tests/AppendPrependTests.cs +++ b/Ix.NET/Source/Tests/AppendPrependTests.cs @@ -27,7 +27,7 @@ public void Append1() var res = xs.Append(4); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); @@ -125,7 +125,7 @@ public void AppendN1() .Append(5) .Append(6); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); @@ -243,7 +243,7 @@ public void Prepend1() var res = xs.Prepend(4); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 4); HasNext(e, 1); @@ -355,7 +355,7 @@ public void PrependN1() .Prepend(5) .Prepend(6); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 6); HasNext(e, 5); @@ -479,7 +479,7 @@ public void AppendPrepend1() .Prepend(9) .Prepend(10); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 10); @@ -614,7 +614,7 @@ public void AppendPrepend8() var res = xs.Append(4) .Prepend(5); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 5); HasNext(e, 1); diff --git a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs index ff01795c03..2752747a40 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs @@ -110,7 +110,7 @@ public async void CorrectDispose() var ys = xs.Select(x => x + 1); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); // We have to call move next because otherwise the internal enumerator is never allocated await e.MoveNext(); @@ -139,7 +139,7 @@ public async Task DisposesUponError() var ex = new Exception("Bang!"); var ys = xs.Select(x => { if (x == 1) throw ex; return x; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); await Assert.ThrowsAsync(() => e.MoveNext()); var result = await disposed.Task; @@ -158,7 +158,7 @@ public async Task CorrectCancel() var ys = xs.Select(x => x + 1).Where(x => true); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); var cts = new CancellationTokenSource(); var t = e.MoveNext(cts.Token); @@ -193,7 +193,7 @@ public void CanCancelMoveNext() { var xs = new CancellationTestAsyncEnumerable().Select(x => x).Where(x => true); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); var cts = new CancellationTokenSource(); var t = e.MoveNext(cts.Token); @@ -221,7 +221,7 @@ public CancellationTestAsyncEnumerable(int iterationsBeforeDelay = 0) { this.iterationsBeforeDelay = iterationsBeforeDelay; } - IAsyncEnumerator IAsyncEnumerable.GetEnumerator() => GetEnumerator(); + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() => GetEnumerator(); public TestEnumerator GetEnumerator() => new TestEnumerator(iterationsBeforeDelay); @@ -313,7 +313,7 @@ public void ToAsyncEnumeratorCannotCancelOnceRunning() var isRunningEvent = new ManualResetEvent(false); var xs = Blocking(evt, isRunningEvent).ToAsyncEnumerable(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); var cts = new CancellationTokenSource(); @@ -397,7 +397,7 @@ private class DisposeCounter : IAsyncEnumerable { public int DisposeCount { get; private set; } - public IAsyncEnumerator GetEnumerator() + public IAsyncEnumerator GetAsyncEnumerator() { return new Enumerator(this); } @@ -441,7 +441,7 @@ public static IAsyncEnumerable WithDispose(this IAsyncEnumerable source { return AsyncEnumerable.CreateEnumerable(() => { - var e = source.GetEnumerator(); + var e = source.GetAsyncEnumerator(); return AsyncEnumerable.CreateEnumerator(e.MoveNext, () => e.Current, () => { e.Dispose(); a(); }); }); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs index e79c8bbf96..733a7d5aac 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs @@ -27,7 +27,7 @@ public void ToAsyncEnumerable_Null() public void ToAsyncEnumerable1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -40,7 +40,7 @@ public void ToAsyncEnumerable2() { var ex = new Exception("Bang"); var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 42); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); } @@ -68,7 +68,7 @@ public void ToAsyncEnumerable3() Assert.False(subscribed); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.True(subscribed); @@ -93,7 +93,7 @@ public void ToAsyncEnumerable4() Assert.False(subscribed); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.True(subscribed); @@ -106,7 +106,7 @@ public void ToAsyncEnumerable5() var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -231,7 +231,7 @@ public void ToAsyncEnumerable_With_Completed_Task() var task = Task.Factory.StartNew(() => 36); var xs = task.ToAsyncEnumerable(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); Assert.Equal(36, e.Current); @@ -246,7 +246,7 @@ public void ToAsyncEnumerable_With_Faulted_Task() tcs.SetException(ex); var xs = tcs.Task.ToAsyncEnumerable(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); } @@ -258,7 +258,7 @@ public void ToAsyncEnumerable_With_Canceled_Task() tcs.SetCanceled(); var xs = tcs.Task.ToAsyncEnumerable(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() is TaskCanceledException); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index 37093ca431..b5d4b6a1ec 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -31,7 +31,7 @@ public void Create_Iterator_Throws() var enu = (IAsyncEnumerable)iter; - AssertThrows(() => enu.GetEnumerator()); + AssertThrows(() => enu.GetAsyncEnumerator()); } @@ -39,7 +39,7 @@ public void Create_Iterator_Throws() public void Return() { var xs = AsyncEnumerable.Return(42); - HasNext(xs.GetEnumerator(), 42); + HasNext(xs.GetAsyncEnumerator(), 42); } [Fact] @@ -47,7 +47,7 @@ public void Never() { var xs = AsyncEnumerable.Never(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.False(e.MoveNext().IsCompleted); // Very rudimentary check AssertThrows(() => Nop(e.Current)); e.Dispose(); @@ -64,7 +64,7 @@ public async Task Empty_Null() public void Empty1() { var xs = AsyncEnumerable.Empty(); - NoNext(xs.GetEnumerator()); + NoNext(xs.GetAsyncEnumerator()); } [Fact] @@ -72,7 +72,7 @@ public void Empty2() { var xs = AsyncEnumerable.Empty(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.False(e.MoveNext().Result); AssertThrows(() => Nop(e.Current)); } @@ -89,7 +89,7 @@ public void Throw() var ex = new Exception("Bang"); var xs = AsyncEnumerable.Throw(ex); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); AssertThrows(() => Nop(e.Current)); } @@ -109,7 +109,7 @@ public void Range1() { var xs = AsyncEnumerable.Range(2, 5); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 3); HasNext(e, 4); @@ -123,7 +123,7 @@ public void Range2() { var xs = AsyncEnumerable.Range(2, 0); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -138,7 +138,7 @@ public void Repeat1() { var xs = AsyncEnumerable.Repeat(2, 5); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 2); HasNext(e, 2); @@ -152,7 +152,7 @@ public void Repeat2() { var xs = AsyncEnumerable.Repeat(2, 0); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -161,7 +161,7 @@ public void Repeat3() { var xs = AsyncEnumerable.Repeat(2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 2); HasNext(e, 2); @@ -191,14 +191,14 @@ public void Defer1() var xs = AsyncEnumerable.Defer(() => new[] { x }.ToAsyncEnumerable()); { - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 0); NoNext(e); } { x++; - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); NoNext(e); } @@ -217,7 +217,7 @@ public void Generate1() { var xs = AsyncEnumerable.Generate(0, x => x < 5, x => x + 1, x => x * x); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 0); HasNext(e, 1); HasNext(e, 4); @@ -233,7 +233,7 @@ public void Generate2() var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Generate(0, x => { throw ex; }, x => x + 1, x => x * x); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); } @@ -243,7 +243,7 @@ public void Generate3() var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Generate(0, x => true, x => x + 1, x => { if (x == 1) throw ex; return x * x; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 0); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); } @@ -254,7 +254,7 @@ public void Generate4() var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Generate(0, x => true, x => { throw ex; }, x => x * x); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 0); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); } @@ -291,7 +291,7 @@ public void Using1() Assert.Equal(0, i); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); } @@ -312,7 +312,7 @@ public void Using2() Assert.Equal(0, i); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); e.Dispose(); @@ -337,7 +337,7 @@ public void Using3() Assert.Equal(0, i); - AssertThrows(() => xs.GetEnumerator(), ex_ => ex_ == ex); + AssertThrows(() => xs.GetAsyncEnumerator(), ex_ => ex_ == ex); Assert.Equal(1, d); } @@ -359,7 +359,7 @@ public void Using4() Assert.Equal(0, i); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); HasNext(e, 42); @@ -386,7 +386,7 @@ public void Using5() Assert.Equal(0, i); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -411,7 +411,7 @@ public async Task Using6() Assert.Equal(0, i); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); HasNext(e, 0); diff --git a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs index 442f542ac4..05fdbf492d 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs @@ -35,7 +35,7 @@ public void Catch1() var res = xs.Catch(ex_ => { err = true; return ys; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -55,7 +55,7 @@ public void Catch2() var res = xs.Catch(ex_ => { err = true; return ys; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -82,7 +82,7 @@ public void Catch3() var res = xs.Catch(ex_ => { err = true; return ys; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -109,7 +109,7 @@ public void Catch4() var res = xs.Catch(ex_ => { err = true; return ys; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -130,7 +130,7 @@ public void Catch5() var res = xs.Catch(ex_ => { if (ex_.Message == "Bang!") throw ex2; return ys; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -148,7 +148,7 @@ public void Catch6() var res = xs.Catch(ex_ => { err = true; return xs; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -173,7 +173,7 @@ public void Catch7() var res = AsyncEnumerable.Catch(xs, ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -190,7 +190,7 @@ public void Catch8() var res = AsyncEnumerable.Catch(xs, ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -210,7 +210,7 @@ public void Catch9() var res = AsyncEnumerable.Catch(new[] { xs, xs, ys, ys }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -228,7 +228,7 @@ public void Catch10() { var res = CatchXss().Catch(); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -251,7 +251,7 @@ public void Catch11() var res = AsyncEnumerable.Catch(new[] { xs, xs }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -267,7 +267,7 @@ public void Catch12() { var res = AsyncEnumerable.Catch(Enumerable.Empty>()); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); NoNext(e); } @@ -312,7 +312,7 @@ public void Finally1() var xs = AsyncEnumerable.Empty().Finally(() => { b = true; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.False(b); NoNext(e); @@ -327,7 +327,7 @@ public void Finally2() var xs = AsyncEnumerable.Return(42).Finally(() => { b = true; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.False(b); HasNext(e, 42); @@ -347,7 +347,7 @@ public void Finally3() var xs = AsyncEnumerable.Throw(ex).Finally(() => { b = true; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.False(b); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -362,7 +362,7 @@ public void Finally4() var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.False(b); HasNext(e, 1); @@ -383,7 +383,7 @@ public void Finally5() var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.False(b); HasNext(e, 1); @@ -400,7 +400,7 @@ public void Finally6() var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); var cts = new CancellationTokenSource(); @@ -439,7 +439,7 @@ public void OnErrorResumeNext7() var res = AsyncEnumerable.OnErrorResumeNext(xs, ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -459,7 +459,7 @@ public void OnErrorResumeNext8() var res = AsyncEnumerable.OnErrorResumeNext(xs, ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -479,7 +479,7 @@ public void OnErrorResumeNext9() var res = AsyncEnumerable.OnErrorResumeNext(new[] { xs, xs, ys, ys }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -500,7 +500,7 @@ public void OnErrorResumeNext10() { var res = OnErrorResumeNextXss().OnErrorResumeNext(); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -523,7 +523,7 @@ public void OnErrorResumeNext11() var res = AsyncEnumerable.OnErrorResumeNext(new[] { xs, xs }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -538,7 +538,7 @@ public void OnErrorResumeNext12() { var res = AsyncEnumerable.OnErrorResumeNext(Enumerable.Empty>()); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); NoNext(e); } @@ -569,7 +569,7 @@ public void Retry1() var res = xs.Retry(); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -585,7 +585,7 @@ public void Retry2() var res = xs.Retry(); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); diff --git a/Ix.NET/Source/Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/Tests/AsyncTests.Multiple.cs index 6203ec6315..7e9b773b06 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Multiple.cs @@ -29,7 +29,7 @@ public void Concat1() { var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -45,7 +45,7 @@ public void Concat2() var ex = new Exception("Bang"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -58,7 +58,7 @@ public void Concat3() var ex = new Exception("Bang"); var ys = AsyncEnumerable.Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -71,7 +71,7 @@ public void Concat4() var res = AsyncEnumerable.Concat(xs, ys, zs); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -93,7 +93,7 @@ public void Concat5() var res = AsyncEnumerable.Concat(xs, ys, zs); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -107,7 +107,7 @@ public void Concat6() { var res = AsyncEnumerable.Concat(ConcatXss()); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -126,7 +126,7 @@ public void Concat7() var res = ws.Concat(xs).Concat(ys).Concat(zs); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -227,7 +227,7 @@ public void Zip1() var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1 * 4); HasNext(e, 2 * 5); HasNext(e, 3 * 6); @@ -241,7 +241,7 @@ public void Zip2() var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1 * 4); HasNext(e, 2 * 5); HasNext(e, 3 * 6); @@ -255,7 +255,7 @@ public void Zip3() var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1 * 4); HasNext(e, 2 * 5); HasNext(e, 3 * 6); @@ -270,7 +270,7 @@ public void Zip4() var ys = AsyncEnumerable.Throw(ex); var res = xs.Zip(ys, (x, y) => x * y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -282,7 +282,7 @@ public void Zip5() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -294,7 +294,7 @@ public void Zip6() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -326,7 +326,7 @@ public void Union1() var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); var res = xs.Union(ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -342,7 +342,7 @@ public void Union2() var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); var res = xs.Union(ys, new Eq()); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, -3); @@ -369,7 +369,7 @@ public void Intersect1() var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); var res = xs.Intersect(ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 3); NoNext(e); @@ -382,7 +382,7 @@ public void Intersect2() var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); var res = xs.Intersect(ys, new Eq()); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, -3); NoNext(e); @@ -417,7 +417,7 @@ public void Except1() var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); var res = xs.Except(ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 2); NoNext(e); } @@ -429,7 +429,7 @@ public void Except2() var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); var res = xs.Except(ys, new Eq()); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 2); NoNext(e); } @@ -648,7 +648,7 @@ public void GroupJoin1() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, "0 - 639"); HasNext(e, "1 - 474"); HasNext(e, "2 - 28"); @@ -663,7 +663,7 @@ public void GroupJoin2() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, "0 - 36"); HasNext(e, "1 - 4"); HasNext(e, "2 - "); @@ -679,7 +679,7 @@ public void GroupJoin3() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -692,7 +692,7 @@ public void GroupJoin4() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -705,7 +705,7 @@ public void GroupJoin5() var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -718,7 +718,7 @@ public void GroupJoin6() var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -735,7 +735,7 @@ public void GroupJoin7() return x + " - " + i.Aggregate("", (s, j) => s + j).Result; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, "0 - 36"); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -765,7 +765,7 @@ public void Join1() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 0 + 3); HasNext(e, 0 + 6); HasNext(e, 1 + 4); @@ -780,7 +780,7 @@ public void Join2() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 3 + 0); HasNext(e, 6 + 0); HasNext(e, 4 + 1); @@ -795,7 +795,7 @@ public void Join3() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 0 + 3); HasNext(e, 0 + 6); NoNext(e); @@ -809,7 +809,7 @@ public void Join4() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 3 + 0); HasNext(e, 6 + 0); NoNext(e); @@ -824,7 +824,7 @@ public void Join5() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -837,7 +837,7 @@ public void Join6() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -850,7 +850,7 @@ public void Join7() var res = xs.Join(ys, x => { throw ex; }, y => y, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -863,7 +863,7 @@ public void Join8() var res = xs.Join(ys, x => x, y => { throw ex; }, (x, y) => x + y); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -876,7 +876,7 @@ public void Join9() var res = xs.Join(ys, x => x, y => y, (x, y) => { throw ex; }); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -915,7 +915,7 @@ public void Join11() .Join(orders.ToAsyncEnumerable(), c => c.CustomerId, o => o.CustomerId, (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); - var e = asyncResult.GetEnumerator(); + var e = asyncResult.GetAsyncEnumerator(); HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); @@ -948,7 +948,7 @@ public void Join12() .Join(orders.ToAsyncEnumerable(), c => c.CustomerId, o => o.CustomerId, (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); - var e = asyncResult.GetEnumerator(); + var e = asyncResult.GetAsyncEnumerator(); HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); @@ -974,7 +974,7 @@ public void SelectManyMultiple1() var res = xs.SelectMany(ys); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 4); HasNext(e, 3); diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index c3ce3cdd9b..f96eef9c8a 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -50,7 +50,7 @@ public void Select1() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(x => (char)('a' + x)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 'a'); HasNext(e, 'b'); HasNext(e, 'c'); @@ -63,7 +63,7 @@ public void Select2() var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); var ys = xs.Select((x, i) => (char)('a' + i)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 'a'); HasNext(e, 'b'); HasNext(e, 'c'); @@ -76,7 +76,7 @@ public void Select3() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(x => 1 / x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); } @@ -86,7 +86,7 @@ public void Select4() var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); var ys = xs.Select((x, i) => 1 / i); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); } @@ -96,7 +96,7 @@ public void Select5() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 'd'); HasNext(e, 'e'); HasNext(e, 'f'); @@ -109,7 +109,7 @@ public void Select6() var xs = new CancellationTestAsyncEnumerable(10); var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 'd'); HasNext(e, 'e'); HasNext(e, 'f'); @@ -140,7 +140,7 @@ public void SelectWhere1() var xs = new CancellationTestAsyncEnumerable(10); var ys = xs.Select(i => i + 2).Where(i => i % 2 == 0); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 4); HasNext(e, 6); @@ -152,7 +152,7 @@ public void WhereSelect1() var xs = new CancellationTestAsyncEnumerable(10); var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 4); HasNext(e, 6); @@ -165,7 +165,7 @@ public void SelectWhere2() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(i => i + 2).Where(i => i % 2 == 0); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 4); NoNext(e); @@ -178,7 +178,7 @@ public void WhereSelect2() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 4); NoNext(e); @@ -190,7 +190,7 @@ public void WhereSelect3() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2).Select(i => i + 2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 4); HasNext(e, 6); NoNext(e); @@ -219,7 +219,7 @@ public void Where1() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 8); HasNext(e, 4); HasNext(e, 6); @@ -234,7 +234,7 @@ public void Where2() var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where((x, i) => i % 2 == 0); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 8); HasNext(e, 7); HasNext(e, 6); @@ -250,7 +250,7 @@ public void Where3() var ex = new Exception("Bang"); var ys = xs.Where(x => { if (x == 4) throw ex; return true; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 8); HasNext(e, 5); HasNext(e, 7); @@ -264,7 +264,7 @@ public void Where4() var ex = new Exception("Bang"); var ys = xs.Where((x, i) => { if (i == 3) throw ex; return true; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 8); HasNext(e, 5); HasNext(e, 7); @@ -278,7 +278,7 @@ public void Where5() var xs = AsyncEnumerable.Throw(ex); var ys = xs.Where(x => true); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -289,7 +289,7 @@ public void Where6() var xs = AsyncEnumerable.Throw(ex); var ys = xs.Where((x, i) => true); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -299,7 +299,7 @@ public void Where7() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0).Where(x => x > 5); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 8); HasNext(e, 6); NoNext(e); @@ -346,7 +346,7 @@ public void SelectMany1() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); @@ -369,7 +369,7 @@ public void SelectMany2() return AsyncEnumerable.Throw(ex); }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); @@ -383,7 +383,7 @@ public void SelectMany3() var xs = AsyncEnumerable.Throw(ex); var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -400,7 +400,7 @@ public void SelectMany4() throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); @@ -413,7 +413,7 @@ public void SelectMany5() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 5, x).ToAsyncEnumerable()); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 5); HasNext(e, 6); HasNext(e, 7); @@ -436,7 +436,7 @@ public void SelectMany6() return AsyncEnumerable.Throw(ex); }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); @@ -450,7 +450,7 @@ public void SelectMany7() var xs = AsyncEnumerable.Throw(ex); var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -467,7 +467,7 @@ public void SelectMany8() throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); @@ -480,7 +480,7 @@ public void SelectMany9() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => x * y); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 6); HasNext(e, 8); @@ -496,7 +496,7 @@ public void SelectMany10() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => x * y); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 8); HasNext(e, 10); @@ -518,7 +518,7 @@ public void SelectMany11() return x * y; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 6); HasNext(e, 8); @@ -538,7 +538,7 @@ public void SelectMany12() return x * y; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 8); HasNext(e, 10); @@ -593,7 +593,7 @@ public void OfType() var xs = new object[] { 1, 1.2, true, 4, "" }.ToAsyncEnumerable(); var ys = xs.OfType(); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 4); NoNext(e); @@ -611,7 +611,7 @@ public void Cast1() var xs = new object[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Cast(); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -676,7 +676,7 @@ public void Do1() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Do(x => sum += x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); Assert.Equal(1, sum); HasNext(e, 2); @@ -695,7 +695,7 @@ public void Do2() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Do(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -708,7 +708,7 @@ public void Do3() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Do(x => sum += x, ex => { fail = true; }, () => { done = true; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); Assert.Equal(1, sum); HasNext(e, 2); @@ -731,7 +731,7 @@ public void Do4() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Do(x => sum += x, () => { done = true; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); Assert.Equal(1, sum); HasNext(e, 2); @@ -755,7 +755,7 @@ public void Do5() var xs = AsyncEnumerable.Throw(ex); var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }, () => { done = true; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ex_.InnerException == ex); Assert.False(hasv); @@ -772,7 +772,7 @@ public void Do6() var xs = AsyncEnumerable.Throw(ex); var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ex_.InnerException == ex); Assert.False(hasv); @@ -943,7 +943,7 @@ public void Take0() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(-2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -953,7 +953,7 @@ public void Take1() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); NoNext(e); @@ -965,7 +965,7 @@ public void Take2() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(10); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -979,7 +979,7 @@ public void Take3() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(0); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -990,7 +990,7 @@ public void Take4() var xs = AsyncEnumerable.Throw(ex); var ys = xs.Take(2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1018,7 +1018,7 @@ public void TakeWhile1() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => x < 3); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); NoNext(e); @@ -1030,7 +1030,7 @@ public void TakeWhile2() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => false); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -1040,7 +1040,7 @@ public void TakeWhile3() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => true); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1054,7 +1054,7 @@ public void TakeWhile4() var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => x < 3); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); NoNext(e); @@ -1067,7 +1067,7 @@ public void TakeWhile5() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1077,7 +1077,7 @@ public void TakeWhile6() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => i < 2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); NoNext(e); @@ -1089,7 +1089,7 @@ public void TakeWhile7() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => false); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -1099,7 +1099,7 @@ public void TakeWhile8() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => true); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1114,7 +1114,7 @@ public void TakeWhile9() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1159,7 +1159,7 @@ public void Skip1() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Skip(2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 4); NoNext(e); @@ -1171,7 +1171,7 @@ public void Skip2() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Skip(10); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -1181,7 +1181,7 @@ public void Skip3() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Skip(0); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1196,7 +1196,7 @@ public void Skip4() var xs = AsyncEnumerable.Throw(ex); var ys = xs.Skip(2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1224,7 +1224,7 @@ public void SkipWhile1() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => x < 3); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 4); NoNext(e); @@ -1236,7 +1236,7 @@ public void SkipWhile2() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => false); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1250,7 +1250,7 @@ public void SkipWhile3() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => true); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -1260,7 +1260,7 @@ public void SkipWhile4() var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => x < 3); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 4); HasNext(e, 3); @@ -1276,7 +1276,7 @@ public void SkipWhile5() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1286,7 +1286,7 @@ public void SkipWhile6() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => i < 2); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 4); NoNext(e); @@ -1298,7 +1298,7 @@ public void SkipWhile7() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => false); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1312,7 +1312,7 @@ public void SkipWhile8() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => true); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -1323,7 +1323,7 @@ public void SkipWhile9() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1357,7 +1357,7 @@ public void DefaultIfEmpty1() { var xs = AsyncEnumerable.Empty().DefaultIfEmpty(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 0); NoNext(e); } @@ -1367,7 +1367,7 @@ public void DefaultIfEmpty2() { var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 42); NoNext(e); } @@ -1377,7 +1377,7 @@ public void DefaultIfEmpty3() { var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 42); NoNext(e); } @@ -1387,7 +1387,7 @@ public void DefaultIfEmpty4() { var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(24); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 42); NoNext(e); } @@ -1397,7 +1397,7 @@ public void DefaultIfEmpty5() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1410,7 +1410,7 @@ public void DefaultIfEmpty6() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1424,7 +1424,7 @@ public void DefaultIfEmpty7() var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1434,7 +1434,7 @@ public void DefaultIfEmpty8() var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(24); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1545,7 +1545,7 @@ public void Distinct1() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -1559,7 +1559,7 @@ public void Distinct2() { var xs = new[] { 1, -2, -1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(new Eq()); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, -2); HasNext(e, 3); @@ -1641,7 +1641,7 @@ public void Distinct11() { var xs = AsyncEnumerable.Empty().Distinct(k => k); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -1651,7 +1651,7 @@ public void Distinct12() { var xs = AsyncEnumerable.Empty().Distinct(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -1668,7 +1668,7 @@ public void Reverse1() var xs = AsyncEnumerable.Empty(); var ys = xs.Reverse(); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -1678,7 +1678,7 @@ public void Reverse2() var xs = AsyncEnumerable.Return(42); var ys = xs.Reverse(); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 42); NoNext(e); } @@ -1689,7 +1689,7 @@ public void Reverse3() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.Reverse(); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 2); HasNext(e, 1); @@ -1703,7 +1703,7 @@ public void Reverse4() var xs = AsyncEnumerable.Throw(ex); var ys = xs.Reverse(); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1821,7 +1821,7 @@ public void OrderBy1() var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(x => x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); for (var i = 0; i < 10; i++) HasNext(e, i); NoNext(e); @@ -1834,7 +1834,7 @@ public void OrderBy2() var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1854,7 +1854,7 @@ public void ThenBy2() var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(x => x).ThenBy(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1864,7 +1864,7 @@ public void OrderByDescending1() var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderByDescending(x => x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); for (var i = 9; i >= 0; i--) HasNext(e, i); NoNext(e); @@ -1877,7 +1877,7 @@ public void OrderByDescending2() var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderByDescending(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1897,7 +1897,7 @@ public void ThenByDescending2() var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(x => x).ThenByDescending(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -2042,11 +2042,11 @@ public void GroupBy1() var res = ys.GroupBy(x => x.Age / 10); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); Assert.Equal(2, e.Current.Key); - var g1 = e.Current.GetEnumerator(); + var g1 = e.Current.GetAsyncEnumerator(); HasNext(g1, xs[0]); HasNext(g1, xs[2]); HasNext(g1, xs[4]); @@ -2055,19 +2055,19 @@ public void GroupBy1() Assert.True(e.MoveNext().Result); Assert.Equal(6, e.Current.Key); - var g2 = e.Current.GetEnumerator(); + var g2 = e.Current.GetAsyncEnumerator(); HasNext(g2, xs[1]); NoNext(g2); Assert.True(e.MoveNext().Result); Assert.Equal(1, e.Current.Key); - var g3 = e.Current.GetEnumerator(); + var g3 = e.Current.GetAsyncEnumerator(); HasNext(g3, xs[3]); NoNext(g3); Assert.True(e.MoveNext().Result); Assert.Equal(4, e.Current.Key); - var g4 = e.Current.GetEnumerator(); + var g4 = e.Current.GetAsyncEnumerator(); HasNext(g4, xs[6]); NoNext(g4); @@ -2091,7 +2091,7 @@ public void GroupBy2() var res = ys.GroupBy(x => x.Age / 10); - var e = res.GetEnumerator(); + var e = res.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); var g1 = e.Current; @@ -2111,22 +2111,22 @@ public void GroupBy2() NoNext(e); - var g1e = g1.GetEnumerator(); + var g1e = g1.GetAsyncEnumerator(); HasNext(g1e, xs[0]); HasNext(g1e, xs[2]); HasNext(g1e, xs[4]); HasNext(g1e, xs[5]); NoNext(g1e); - var g2e = g2.GetEnumerator(); + var g2e = g2.GetAsyncEnumerator(); HasNext(g2e, xs[1]); NoNext(g2e); - var g3e = g3.GetEnumerator(); + var g3e = g3.GetAsyncEnumerator(); HasNext(g3e, xs[3]); NoNext(g3e); - var g4e = g4.GetEnumerator(); + var g4e = g4.GetAsyncEnumerator(); HasNext(g4e, xs[6]); NoNext(g4e); } @@ -2137,7 +2137,7 @@ public void GroupBy3() var xs = AsyncEnumerable.Empty(); var ys = xs.GroupBy(x => x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); NoNext(e); } @@ -2148,7 +2148,7 @@ public void GroupBy4() var xs = AsyncEnumerable.Throw(ex); var ys = xs.GroupBy(x => x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -2158,7 +2158,7 @@ public void GroupBy5() var xs = GetXs().ToAsyncEnumerable(); var ys = xs.GroupBy(x => x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); @@ -2185,7 +2185,7 @@ public void GroupBy6() var xs = GetXs().ToAsyncEnumerable(); var ys = xs.GroupBy(x => x); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); @@ -2213,7 +2213,7 @@ public void GroupBy7() var xs = AsyncEnumerable.Return(42); var ys = xs.GroupBy(x => { throw ex; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -2224,7 +2224,7 @@ public void GroupBy8() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.GroupBy(x => { if (x == 3) throw ex; return x; }); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -2251,12 +2251,12 @@ public void GroupBy9() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); - var g1e = g1.GetEnumerator(); + var g1e = g1.GetAsyncEnumerator(); HasNext(g1e, 'a'); HasNext(g1e, 'd'); HasNext(g1e, 'g'); @@ -2266,7 +2266,7 @@ public void GroupBy9() Assert.True(e.MoveNext().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); - var g2e = g2.GetEnumerator(); + var g2e = g2.GetAsyncEnumerator(); HasNext(g2e, 'b'); HasNext(g2e, 'e'); HasNext(g2e, 'h'); @@ -2275,7 +2275,7 @@ public void GroupBy9() Assert.True(e.MoveNext().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); - var g3e = g3.GetEnumerator(); + var g3e = g3.GetAsyncEnumerator(); HasNext(g3e, 'c'); HasNext(g3e, 'f'); HasNext(g3e, 'i'); @@ -2290,7 +2290,7 @@ public void GroupBy10() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, "0 - adgj"); HasNext(e, "1 - beh"); HasNext(e, "2 - cfi"); @@ -2303,7 +2303,7 @@ public void GroupBy11() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, "0 - 0369"); HasNext(e, "1 - 147"); HasNext(e, "2 - 258"); @@ -2316,12 +2316,12 @@ public void GroupBy12() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, new EqMod(3)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); - var g1e = g1.GetEnumerator(); + var g1e = g1.GetAsyncEnumerator(); HasNext(g1e, 0); HasNext(g1e, 3); HasNext(g1e, 6); @@ -2331,7 +2331,7 @@ public void GroupBy12() Assert.True(e.MoveNext().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); - var g2e = g2.GetEnumerator(); + var g2e = g2.GetAsyncEnumerator(); HasNext(g2e, 1); HasNext(g2e, 4); HasNext(g2e, 7); @@ -2340,7 +2340,7 @@ public void GroupBy12() Assert.True(e.MoveNext().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); - var g3e = g3.GetEnumerator(); + var g3e = g3.GetAsyncEnumerator(); HasNext(g3e, 2); HasNext(g3e, 5); HasNext(g3e, 8); @@ -2355,12 +2355,12 @@ public void GroupBy13() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); - var g1e = g1.GetEnumerator(); + var g1e = g1.GetAsyncEnumerator(); HasNext(g1e, 'a'); HasNext(g1e, 'd'); HasNext(g1e, 'g'); @@ -2370,7 +2370,7 @@ public void GroupBy13() Assert.True(e.MoveNext().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); - var g2e = g2.GetEnumerator(); + var g2e = g2.GetAsyncEnumerator(); HasNext(g2e, 'b'); HasNext(g2e, 'e'); HasNext(g2e, 'h'); @@ -2379,7 +2379,7 @@ public void GroupBy13() Assert.True(e.MoveNext().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); - var g3e = g3.GetEnumerator(); + var g3e = g3.GetAsyncEnumerator(); HasNext(g3e, 'c'); HasNext(g3e, 'f'); HasNext(g3e, 'i'); @@ -2394,7 +2394,7 @@ public void GroupBy14() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, "0 - adgj"); HasNext(e, "1 - beh"); HasNext(e, "2 - cfi"); @@ -2407,7 +2407,7 @@ public void GroupBy15() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); HasNext(e, "0 - 0369"); HasNext(e, "1 - 147"); HasNext(e, "2 - 258"); @@ -2420,12 +2420,12 @@ public void GroupBy16() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); - var g1e = g1.GetEnumerator(); + var g1e = g1.GetAsyncEnumerator(); HasNext(g1e, 'a'); HasNext(g1e, 'd'); HasNext(g1e, 'g'); @@ -2436,7 +2436,7 @@ public void GroupBy16() Assert.True(e.MoveNext().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); - var g2e = g2.GetEnumerator(); + var g2e = g2.GetAsyncEnumerator(); HasNext(g2e, 'b'); HasNext(g2e, 'e'); HasNext(g2e, 'h'); @@ -2446,7 +2446,7 @@ public void GroupBy16() Assert.True(e.MoveNext().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); - var g3e = g3.GetEnumerator(); + var g3e = g3.GetAsyncEnumerator(); HasNext(g3e, 'c'); HasNext(g3e, 'f'); HasNext(g3e, 'i'); @@ -2464,7 +2464,7 @@ public void GroupBy17() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); e.Dispose(); Assert.False(e.MoveNext().Result); @@ -2476,12 +2476,12 @@ public void GroupBy18() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - var e = ys.GetEnumerator(); + var e = ys.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); - var g1e = g1.GetEnumerator(); + var g1e = g1.GetAsyncEnumerator(); HasNext(g1e, 'a'); e.Dispose(); @@ -2878,7 +2878,7 @@ public void AsAsyncEnumerable1() Assert.NotSame(xs, ys); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 42); NoNext(e); } @@ -2896,7 +2896,7 @@ public void RepeatSeq1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -2913,7 +2913,7 @@ public void RepeatSeq2() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -2932,7 +2932,7 @@ public void RepeatSeq3() var i = 0; var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(3); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 1); @@ -2950,7 +2950,7 @@ public void RepeatSeq0() var i = 0; var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(0); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -2976,7 +2976,7 @@ public void RepeatSeq4() { var xs = new FailRepeat().ToAsyncEnumerable().Repeat(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); } @@ -2985,7 +2985,7 @@ public void RepeatSeq5() { var xs = new FailRepeat().ToAsyncEnumerable().Repeat(3); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); } @@ -3013,7 +3013,7 @@ public void IgnoreElements1() { var xs = AsyncEnumerable.Empty().IgnoreElements(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); AssertThrows(() => { var ignored = e.Current; }); @@ -3024,7 +3024,7 @@ public void IgnoreElements2() { var xs = AsyncEnumerable.Return(42).IgnoreElements(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); AssertThrows(() => { var ignored = e.Current; }); @@ -3035,7 +3035,7 @@ public void IgnoreElements3() { var xs = AsyncEnumerable.Range(0, 10).IgnoreElements(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); AssertThrows(() => { var ignored = e.Current; }); @@ -3047,7 +3047,7 @@ public void IgnoreElements4() var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Throw(ex).IgnoreElements(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -3071,7 +3071,7 @@ public void StartWith1() { var xs = AsyncEnumerable.Empty().StartWith(1, 2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); NoNext(e); @@ -3082,7 +3082,7 @@ public void StartWith2() { var xs = AsyncEnumerable.Return(0).StartWith(1, 2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 0); @@ -3095,7 +3095,7 @@ public void StartWith3() var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Throw(ex).StartWith(1, 2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -3117,7 +3117,7 @@ public void Buffer1() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); @@ -3136,7 +3136,7 @@ public void Buffer2() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); Assert.True(e.Current.SequenceEqual(new[] { 1, 2, 3 })); @@ -3155,7 +3155,7 @@ public void Buffer3() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2, 3); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); Assert.True(e.MoveNext().Result); Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); @@ -3195,7 +3195,7 @@ public void DistinctUntilChanged1() { var xs = new[] { 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 6, 7, 3, 2, 2, 1, 1 }.ToAsyncEnumerable().DistinctUntilChanged(); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -3214,7 +3214,7 @@ public void DistinctUntilChanged2() { var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => (x + 1) / 2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 3); HasNext(e, 5); @@ -3228,7 +3228,7 @@ public void DistinctUntilChanged3() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => { if (x == 4) throw ex; return x; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -3263,7 +3263,7 @@ public void Expand1() { var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerable.Return(x - 1).Repeat(x - 1)); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 3); HasNext(e, 1); @@ -3280,7 +3280,7 @@ public void Expand2() var ex = new Exception("Bang!"); var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => { throw ex; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -3289,7 +3289,7 @@ public void Expand3() { var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => null); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 3); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NullReferenceException); @@ -3318,7 +3318,7 @@ public void Scan1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => x + y); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 9); HasNext(e, 11); HasNext(e, 14); @@ -3330,7 +3330,7 @@ public void Scan2() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => x + y); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 6); NoNext(e); @@ -3342,7 +3342,7 @@ public void Scan3() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => { throw ex; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -3352,7 +3352,7 @@ public void Scan4() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => { throw ex; }); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -3388,7 +3388,7 @@ public void DistinctKey1() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Distinct(x => x / 2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 4); @@ -3406,7 +3406,7 @@ public void TakeLast0() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(-2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -3415,7 +3415,7 @@ public void TakeLast1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 3); HasNext(e, 4); NoNext(e); @@ -3426,7 +3426,7 @@ public void TakeLast2() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(5); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); @@ -3455,7 +3455,7 @@ public void TakeLast_BugFix_TakeLast_Zero_TakesForever() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(0); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -3471,7 +3471,7 @@ public void SkipLast1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); NoNext(e); @@ -3482,7 +3482,7 @@ public void SkipLast2() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(5); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); NoNext(e); } @@ -3499,7 +3499,7 @@ public void SkipLast4() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(0); - var e = xs.GetEnumerator(); + var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); diff --git a/Ix.NET/Source/Tests/AsyncTests.cs b/Ix.NET/Source/Tests/AsyncTests.cs index 9cf7c7b28e..657b21010c 100644 --- a/Ix.NET/Source/Tests/AsyncTests.cs +++ b/Ix.NET/Source/Tests/AsyncTests.cs @@ -67,8 +67,8 @@ public void HasNext(IAsyncEnumerator e, T value) public async Task SequenceIdentity(IAsyncEnumerable enumerable) { - var en1 = enumerable.GetEnumerator(); - var en2 = enumerable.GetEnumerator(); + var en1 = enumerable.GetAsyncEnumerator(); + var en2 = enumerable.GetAsyncEnumerator(); Assert.Equal(en1.GetType(), en2.GetType()); From 01f0f7fe748d336f4eaf82e61eb6e6a8def69e7b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:25:14 -0700 Subject: [PATCH 003/862] Add IAsyncDisposable. --- .../System.Interactive.Async/IAsyncDisposable.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs new file mode 100644 index 0000000000..823320f08e --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading.Tasks; + +namespace System +{ + public interface IAsyncDisposable + { + Task DisposeAsync(); + } +} From 222d160811c3f2a97dce58cc00d7c689033292ec Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:29:21 -0700 Subject: [PATCH 004/862] Rename MoveNext to MoveNextAsync. --- .../System.Interactive.Async/Aggregate.cs | 4 +- .../Source/System.Interactive.Async/AnyAll.cs | 6 +-- .../System.Interactive.Async/AppendPrepend.cs | 10 ++--- .../AsyncEnumerableHelpers.cs | 4 +- .../AsyncEnumerator.cs | 2 +- .../System.Interactive.Async/AsyncIterator.cs | 2 +- .../System.Interactive.Async/Average.cs | 40 +++++++++---------- .../Source/System.Interactive.Async/Buffer.cs | 2 +- .../Source/System.Interactive.Async/Catch.cs | 6 +-- .../System.Interactive.Async/Concatenate.cs | 6 +-- .../DefaultIfEmpty.cs | 4 +- .../System.Interactive.Async/Distinct.cs | 18 ++++----- Ix.NET/Source/System.Interactive.Async/Do.cs | 2 +- .../System.Interactive.Async/ElementAt.cs | 4 +- .../Source/System.Interactive.Async/Except.cs | 4 +- .../Source/System.Interactive.Async/Expand.cs | 2 +- .../System.Interactive.Async/Finally.cs | 2 +- .../Source/System.Interactive.Async/First.cs | 4 +- .../System.Interactive.Async/ForEach.cs | 2 +- .../System.Interactive.Async/GroupJoin.cs | 4 +- .../IAsyncEnumerator.cs | 2 +- .../IgnoreElements.cs | 2 +- .../System.Interactive.Async/Intersect.cs | 4 +- .../Source/System.Interactive.Async/Join.cs | 4 +- .../Source/System.Interactive.Async/Last.cs | 4 +- .../Source/System.Interactive.Async/Lookup.cs | 6 +-- Ix.NET/Source/System.Interactive.Async/Min.cs | 4 +- .../OnErrorResumeNext.cs | 2 +- .../Source/System.Interactive.Async/Repeat.cs | 2 +- .../Source/System.Interactive.Async/Scan.cs | 4 +- .../Source/System.Interactive.Async/Select.cs | 4 +- .../System.Interactive.Async/SelectMany.cs | 16 ++++---- .../System.Interactive.Async/SequenceEqual.cs | 6 +-- .../Source/System.Interactive.Async/Single.cs | 8 ++-- .../Source/System.Interactive.Async/Skip.cs | 14 +++---- .../Source/System.Interactive.Async/Take.cs | 8 ++-- .../ToAsyncEnumerable.cs | 2 +- .../System.Interactive.Async/ToObservable.cs | 2 +- .../Source/System.Interactive.Async/Using.cs | 2 +- .../Source/System.Interactive.Async/Where.cs | 6 +-- Ix.NET/Source/System.Interactive.Async/Zip.cs | 4 +- Ix.NET/Source/Tests/AsyncTests.Bugs.cs | 12 +++--- Ix.NET/Source/Tests/AsyncTests.Creation.cs | 2 +- Ix.NET/Source/Tests/AsyncTests.Exceptions.cs | 2 +- 44 files changed, 125 insertions(+), 125 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index 9593a5c879..b6d23b27e6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -83,7 +83,7 @@ private static async Task Aggregate_(IAs using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { acc = accumulator(acc, e.Current); @@ -100,7 +100,7 @@ private static async Task Aggregate_(IAsyncEnumerable using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { acc = first ? e.Current : accumulator(acc, e.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs index 117bb6a2d3..938ead9153 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs @@ -67,7 +67,7 @@ public static async Task Any(this IAsyncEnumerable sourc using (var e = source.GetAsyncEnumerator()) { - return await e.MoveNext(cancellationToken).ConfigureAwait(false); + return await e.MoveNextAsync(cancellationToken).ConfigureAwait(false); } } @@ -75,7 +75,7 @@ private static async Task All_(IAsyncEnumerable source, { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (!predicate(e.Current)) @@ -89,7 +89,7 @@ private static async Task Any_(IAsyncEnumerable source, { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (predicate(e.Current)) diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index 0ebf6cd96a..421495d1a6 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -62,7 +62,7 @@ protected void GetSourceEnumerator() protected async Task LoadFromEnumerator(CancellationToken cancellationToken) { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; @@ -203,7 +203,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio { using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNext(cancellationToken) + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { array[index] = en.Current; @@ -233,7 +233,7 @@ public override async Task> ToListAsync(CancellationToken cancella using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNext(cancellationToken) + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { list.Add(en.Current); @@ -437,7 +437,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio { using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNext(cancellationToken) + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { array[index] = en.Current; @@ -467,7 +467,7 @@ public override async Task> ToListAsync(CancellationToken cancella using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNext(cancellationToken) + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { list.Add(en.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs index c01f18de6a..649e7099a5 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs @@ -45,7 +45,7 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer { using (var en = source.GetAsyncEnumerator()) { - if (await en.MoveNext(cancellationToken) + if (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { const int DefaultCapacity = 4; @@ -53,7 +53,7 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer arr[0] = en.Current; var count = 1; - while (await en.MoveNext(cancellationToken) + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (count == arr.Length) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs index 71fd60b2f0..0466199319 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs @@ -22,7 +22,7 @@ public static Task MoveNext(this IAsyncEnumerator enumerator) if (enumerator == null) throw new ArgumentNullException(nameof(enumerator)); - return enumerator.MoveNext(CancellationToken.None); + return enumerator.MoveNextAsync(CancellationToken.None); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index d2c30b35fd..b82d494955 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -73,7 +73,7 @@ public TSource Current } } - public async Task MoveNext(CancellationToken cancellationToken) + public async Task MoveNextAsync(CancellationToken cancellationToken) { // Note: MoveNext *must* be implemented as an async method to ensure // that any exceptions thrown from the MoveNextCore call are handled diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index a9a6d517d7..50c4154f12 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -385,7 +385,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNext(cancellationToken) + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -395,7 +395,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -411,7 +411,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -421,7 +421,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -445,7 +445,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNext(cancellationToken) + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -455,7 +455,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -471,7 +471,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -481,7 +481,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -505,7 +505,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNext(cancellationToken) + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -513,7 +513,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc var sum = e.Current; long count = 1; - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -531,7 +531,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -541,7 +541,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc long count = 1; checked { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -565,7 +565,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNext(cancellationToken) + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -573,7 +573,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel double sum = e.Current; long count = 1; - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -588,7 +588,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -598,7 +598,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -622,7 +622,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNext(cancellationToken) + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -630,7 +630,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca var sum = e.Current; long count = 1; - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -645,7 +645,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -653,7 +653,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/Buffer.cs index b931adc293..a56ae47197 100644 --- a/Ix.NET/Source/System.Interactive.Async/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Buffer.cs @@ -89,7 +89,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { if (!stopped) { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/Catch.cs index 79303405cc..6c3a722c6a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/Catch.cs @@ -105,7 +105,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { try { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; @@ -126,7 +126,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT } } - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; @@ -212,7 +212,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT try { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs index 444c694bfe..8a6fcec415 100644 --- a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs @@ -113,7 +113,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_While: - if (await currentEnumerator.MoveNext(cancellationToken) + if (await currentEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = currentEnumerator.Current; @@ -193,7 +193,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken } using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { list.Add(e.Current); @@ -254,7 +254,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { while (true) { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs index 789274f207..59d6cf18f4 100644 --- a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs @@ -65,7 +65,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; @@ -82,7 +82,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index d280f1bd6e..1bd5a96307 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -141,7 +141,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell var s = new Set(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNext(cancellationToken) + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enu.Current; @@ -178,7 +178,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (!await enumerator.MoveNext(cancellationToken) + if (!await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { Dispose(); @@ -193,7 +193,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { element = enumerator.Current; @@ -217,7 +217,7 @@ private async Task> FillSet(CancellationToken cancellationToken) var r = new List(); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNext(cancellationToken) + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enu.Current; @@ -291,7 +291,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (!await enumerator.MoveNext(cancellationToken) + if (!await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { Dispose(); @@ -306,7 +306,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { element = enumerator.Current; @@ -329,7 +329,7 @@ private async Task> FillSet(CancellationToken cancellationToken) var s = new Set(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNext(cancellationToken) + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { s.Add(enu.Current); @@ -385,7 +385,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; @@ -456,7 +456,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/Do.cs index 7511ed290a..d7f3bd5e5c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/Do.cs @@ -122,7 +122,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: try { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index d55397a156..ae75595478 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -60,7 +60,7 @@ private static async Task ElementAt_(IAsyncEnumerable { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (index == 0) @@ -82,7 +82,7 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (index == 0) diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Interactive.Async/Except.cs index dccc330c88..749c53ac6e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Except.cs +++ b/Ix.NET/Source/System.Interactive.Async/Except.cs @@ -95,7 +95,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (!setFilled) { // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = firstEnumerator.MoveNext(cancellationToken); + var moveNextTask = firstEnumerator.MoveNextAsync(cancellationToken); await Task.WhenAll(moveNextTask, fillSetTask) .ConfigureAwait(false); setFilled = true; @@ -103,7 +103,7 @@ await Task.WhenAll(moveNextTask, fillSetTask) } else { - moveNext = await firstEnumerator.MoveNext(cancellationToken) + moveNext = await firstEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index a5e4bb174a..aa800304bb 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -86,7 +86,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; // while } - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/Finally.cs index bf9f0361ab..9af433637e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/Finally.cs @@ -65,7 +65,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index bda638d3b5..242b520940 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -96,7 +96,7 @@ private static async Task First_(IAsyncEnumerable sou using (var e = source.GetAsyncEnumerator()) { - if (await e.MoveNext(cancellationToken) + if (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { return e.Current; @@ -115,7 +115,7 @@ private static async Task FirstOrDefault_(IAsyncEnumerable(IAsyncEnumerable sourc var index = 0; using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { action(e.Current, checked(index++)); diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs index 14086edb83..b8db550d88 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs @@ -111,10 +111,10 @@ public GroupJoinAsyncEnumerator( _comparer = comparer; } - public async Task MoveNext(CancellationToken cancellationToken) + public async Task MoveNextAsync(CancellationToken cancellationToken) { // nothing to do - if (!await _outer.MoveNext(cancellationToken) + if (!await _outer.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { return false; diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index 18b9faa211..c15c8f4537 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -27,6 +27,6 @@ public interface IAsyncEnumerator : IDisposable /// Task containing the result of the operation: true if the enumerator was successfully advanced /// to the next element; false if the enumerator has passed the end of the sequence. /// - Task MoveNext(CancellationToken cancellationToken); + Task MoveNextAsync(CancellationToken cancellationToken); } } diff --git a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs index 33bcd8e3f1..e37f4670a1 100644 --- a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs @@ -57,7 +57,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { // Do nothing, we're ignoring these elements diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Interactive.Async/Intersect.cs index 23ce235edc..53c700dcd0 100644 --- a/Ix.NET/Source/System.Interactive.Async/Intersect.cs +++ b/Ix.NET/Source/System.Interactive.Async/Intersect.cs @@ -97,7 +97,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (!setFilled) { // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = firstEnumerator.MoveNext(cancellationToken); + var moveNextTask = firstEnumerator.MoveNextAsync(cancellationToken); await Task.WhenAll(moveNextTask, fillSetTask) .ConfigureAwait(false); setFilled = true; @@ -105,7 +105,7 @@ await Task.WhenAll(moveNextTask, fillSetTask) } else { - moveNext = await firstEnumerator.MoveNext(cancellationToken) + moveNext = await firstEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index df24fdb558..daeab29dfb 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -116,7 +116,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_If: - if (await outerEnumerator.MoveNext(cancellationToken) + if (await outerEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); @@ -155,7 +155,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case State_While: - var hasNext = await outerEnumerator.MoveNext(cancellationToken).ConfigureAwait(false); + var hasNext = await outerEnumerator.MoveNextAsync(cancellationToken).ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index 793ff9fe51..6ffc5043df 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -102,7 +102,7 @@ private static async Task Last_(IAsyncEnumerable sour using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { hasLast = true; @@ -130,7 +130,7 @@ private static async Task LastOrDefault_(IAsyncEnumerable> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNext(cancellationToken) + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { lookup.GetGrouping(keySelector(enu.Current), create: true) @@ -217,7 +217,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNext(cancellationToken) + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { lookup.GetGrouping(keySelector(enu.Current), create: true) @@ -233,7 +233,7 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNext(cancellationToken) + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var key = keySelector(enu.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 20c3ba8837..ae37e623e0 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -495,7 +495,7 @@ private static async Task> ExtremaBy(IAsyncEnumera using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNext(cancellationToken) + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -503,7 +503,7 @@ private static async Task> ExtremaBy(IAsyncEnumera var resKey = keySelector(current); result.Add(current); - while (await e.MoveNext(cancellationToken) + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var cur = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs index 68d10fc407..d65da31d96 100644 --- a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs @@ -105,7 +105,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT try { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/Repeat.cs index 442121ca2a..c7d17729a5 100644 --- a/Ix.NET/Source/System.Interactive.Async/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/Repeat.cs @@ -119,7 +119,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index 8781a4517c..00d124d033 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -79,7 +79,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; @@ -147,7 +147,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Interactive.Async/Select.cs index e8333cbd81..bdd1f1cc4b 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Interactive.Async/Select.cs @@ -93,7 +93,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = selector(enumerator.Current); @@ -151,7 +151,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { checked diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index d9d2db8532..bfe2250a36 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -123,7 +123,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNext(cancellationToken) + if (await sourceEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -136,7 +136,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNext(cancellationToken) + if (await resultEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = resultEnumerator.Current; @@ -218,7 +218,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNext(cancellationToken) + if (await sourceEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -232,7 +232,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNext(cancellationToken) + if (await resultEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = resultSelector(currentSource, resultEnumerator.Current); @@ -316,7 +316,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNext(cancellationToken) + if (await sourceEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -336,7 +336,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNext(cancellationToken) + if (await resultEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = resultSelector(currentSource, resultEnumerator.Current); @@ -414,7 +414,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNext(cancellationToken) + if (await sourceEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -431,7 +431,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNext(cancellationToken) + if (await resultEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = resultEnumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs index c5cbd4b3c2..ccf594534a 100644 --- a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs +++ b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs @@ -71,17 +71,17 @@ private static async Task SequenceEqual_(IAsyncEnumerable Single_(IAsyncEnumerable so using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNext(cancellationToken) + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var result = e.Current; - if (await e.MoveNext(cancellationToken) + if (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); @@ -130,14 +130,14 @@ private static async Task SingleOrDefault_(IAsyncEnumerable MoveNextCore(CancellationToken cancellationT enumerator = source.GetAsyncEnumerator(); // skip elements as requested - while (currentCount > 0 && await enumerator.MoveNext(cancellationToken) + while (currentCount > 0 && await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { currentCount--; @@ -126,7 +126,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; @@ -188,7 +188,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; @@ -249,7 +249,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT enumerator = source.GetAsyncEnumerator(); // skip elements as requested - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var element = enumerator.Current; @@ -263,7 +263,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNext(cancellationToken) + if (doMoveNext && await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; @@ -327,7 +327,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT index = -1; // skip elements as requested - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { checked @@ -346,7 +346,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNext(cancellationToken) + if (doMoveNext && await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index d93c93bbcc..d2eee984ab 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -102,7 +102,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (currentCount > 0 && await enumerator.MoveNext(cancellationToken) + if (currentCount > 0 && await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; @@ -171,7 +171,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { if (!isDone) { - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (count > 0) @@ -256,7 +256,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; @@ -321,7 +321,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - if (await enumerator.MoveNext(cancellationToken) + if (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs index 159e5ac266..f99d4da622 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs @@ -67,7 +67,7 @@ private static IEnumerable ToEnumerable_(IAsyncEnumerable observer) var e = source.GetAsyncEnumerator(); var f = default(Action); - f = () => e.MoveNext(ctd.Token) + f = () => e.MoveNextAsync(ctd.Token) .ContinueWith(t => { if (t.IsFaulted) diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/Using.cs index f77c0d325f..0160236f3d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/Using.cs @@ -71,7 +71,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Interactive.Async/Where.cs index c18a18f2ab..5130cf198a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Where.cs +++ b/Ix.NET/Source/System.Interactive.Async/Where.cs @@ -93,7 +93,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; @@ -155,7 +155,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { checked @@ -228,7 +228,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNext(cancellationToken) + while (await enumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Interactive.Async/Zip.cs index 04610ddaa2..55300c7a3c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Zip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Zip.cs @@ -78,8 +78,8 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: // We kick these off and join so they can potentially run in parallel - var ft = firstEnumerator.MoveNext(cancellationToken); - var st = secondEnumerator.MoveNext(cancellationToken); + var ft = firstEnumerator.MoveNextAsync(cancellationToken); + var st = secondEnumerator.MoveNextAsync(cancellationToken); await Task.WhenAll(ft, st) .ConfigureAwait(false); diff --git a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs index 2752747a40..3d8a1d1770 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs @@ -160,7 +160,7 @@ public async Task CorrectCancel() var e = ys.GetAsyncEnumerator(); var cts = new CancellationTokenSource(); - var t = e.MoveNext(cts.Token); + var t = e.MoveNextAsync(cts.Token); cts.Cancel(); @@ -195,7 +195,7 @@ public void CanCancelMoveNext() var e = xs.GetAsyncEnumerator(); var cts = new CancellationTokenSource(); - var t = e.MoveNext(cts.Token); + var t = e.MoveNextAsync(cts.Token); cts.Cancel(); @@ -244,7 +244,7 @@ public void Dispose() public int Current => i; - public async Task MoveNext(CancellationToken cancellationToken) + public async Task MoveNextAsync(CancellationToken cancellationToken) { LastToken = cancellationToken; MoveNextWasCalled = true; @@ -322,7 +322,7 @@ public void ToAsyncEnumeratorCannotCancelOnceRunning() () => { // This call *will* block - t = e.MoveNext(cts.Token); + t = e.MoveNextAsync(cts.Token); }); @@ -416,7 +416,7 @@ public void Dispose() _disposeCounter.DisposeCount++; } - public Task MoveNext(CancellationToken _) + public Task MoveNextAsync(CancellationToken _) { return Task.Factory.StartNew(() => false); } @@ -442,7 +442,7 @@ public static IAsyncEnumerable WithDispose(this IAsyncEnumerable source return AsyncEnumerable.CreateEnumerable(() => { var e = source.GetAsyncEnumerator(); - return AsyncEnumerable.CreateEnumerator(e.MoveNext, () => e.Current, () => { e.Dispose(); a(); }); + return AsyncEnumerable.CreateEnumerator(e.MoveNextAsync, () => e.Current, () => { e.Dispose(); a(); }); }); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index b5d4b6a1ec..ec97ec543e 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -418,7 +418,7 @@ public async Task Using6() HasNext(e, 1); var cts = new CancellationTokenSource(); - var t = e.MoveNext(cts.Token); + var t = e.MoveNextAsync(cts.Token); cts.Cancel(); try diff --git a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs index 05fdbf492d..dbe315cc80 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs @@ -404,7 +404,7 @@ public void Finally6() var cts = new CancellationTokenSource(); - var t = e.MoveNext(cts.Token); + var t = e.MoveNextAsync(cts.Token); cts.Cancel(); t.Wait(WaitTimeoutMs); From c36206ae8da7f59e98ffe6142357d467cd632efb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:36:03 -0700 Subject: [PATCH 005/862] Minimal work to remove CancellationToken from MoveNextAsync. --- .../System.Interactive.Async/AsyncIterator.cs | 31 +++++++------------ .../System.Interactive.Async/GroupJoin.cs | 6 ++-- .../IAsyncEnumerator.cs | 21 ++++++++++++- .../Source/System.Interactive.Async/Join.cs | 2 +- .../Source/System.Interactive.Async/Lookup.cs | 4 +-- Ix.NET/Source/Tests/AsyncTests.Bugs.cs | 10 +++--- Ix.NET/Source/Tests/AsyncTests.Single.cs | 1 - 7 files changed, 42 insertions(+), 33 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index b82d494955..adf57c29a2 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -73,7 +73,7 @@ public TSource Current } } - public async Task MoveNextAsync(CancellationToken cancellationToken) + public async Task MoveNextAsync() { // Note: MoveNext *must* be implemented as an async method to ensure // that any exceptions thrown from the MoveNextCore call are handled @@ -84,27 +84,20 @@ public async Task MoveNextAsync(CancellationToken cancellationToken) return false; } - using (cancellationToken.Register(Dispose)) - using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, cancellationTokenSource.Token)) + try { - try - { - // Short circuit and don't even call MoveNexCore - cancellationToken.ThrowIfCancellationRequested(); - - var result = await MoveNextCore(cts.Token) - .ConfigureAwait(false); + var result = await MoveNextCore(default(CancellationToken)) + .ConfigureAwait(false); - currentIsInvalid = !result; // if move next is false, invalid otherwise valid + currentIsInvalid = !result; // if move next is false, invalid otherwise valid - return result; - } - catch - { - currentIsInvalid = true; - Dispose(); - throw; - } + return result; + } + catch + { + currentIsInvalid = true; + Dispose(); + throw; } } diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs index b8db550d88..4212469ba1 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs @@ -111,10 +111,10 @@ public GroupJoinAsyncEnumerator( _comparer = comparer; } - public async Task MoveNextAsync(CancellationToken cancellationToken) + public async Task MoveNextAsync() { // nothing to do - if (!await _outer.MoveNextAsync(cancellationToken) + if (!await _outer.MoveNextAsync() .ConfigureAwait(false)) { return false; @@ -122,7 +122,7 @@ public async Task MoveNextAsync(CancellationToken cancellationToken) if (_lookup == null) { - _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, cancellationToken) + _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer) .ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index c15c8f4537..2a8f181aff 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -22,11 +22,30 @@ public interface IAsyncEnumerator : IDisposable /// /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. /// + /// + /// Task containing the result of the operation: true if the enumerator was successfully advanced + /// to the next element; false if the enumerator has passed the end of the sequence. + /// + Task MoveNextAsync(); + } + + /// + /// Provides a set of extension methods for . + /// + public static class AsyncEnumeratorExtensions + { + /// + /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. + /// + /// The enumerator to advance. /// Cancellation token that can be used to cancel the operation. /// /// Task containing the result of the operation: true if the enumerator was successfully advanced /// to the next element; false if the enumerator has passed the end of the sequence. /// - Task MoveNextAsync(CancellationToken cancellationToken); + public static Task MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) + { + return source.MoveNextAsync(); + } } } diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index daeab29dfb..1cd9359e33 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -119,7 +119,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (await outerEnumerator.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { - lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer).ConfigureAwait(false); if (lookup.Count != 0) { diff --git a/Ix.NET/Source/System.Interactive.Async/Lookup.cs b/Ix.NET/Source/System.Interactive.Async/Lookup.cs index 54ff6575bf..ad05fa1d25 100644 --- a/Ix.NET/Source/System.Interactive.Async/Lookup.cs +++ b/Ix.NET/Source/System.Interactive.Async/Lookup.cs @@ -228,12 +228,12 @@ internal static async Task> CreateAsync(IAsyncEnumerable< return lookup; } - internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync(cancellationToken) + while (await enu.MoveNextAsync() .ConfigureAwait(false)) { var key = keySelector(enu.Current); diff --git a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs index 3d8a1d1770..02e6c45cbe 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs @@ -239,22 +239,20 @@ public void Dispose() { } - public CancellationToken LastToken { get; private set; } public bool MoveNextWasCalled { get; private set; } public int Current => i; - public async Task MoveNextAsync(CancellationToken cancellationToken) + public async Task MoveNextAsync() { - LastToken = cancellationToken; MoveNextWasCalled = true; i++; if (Current >= iterationsBeforeDelay) { - await Task.Delay(WaitTimeoutMs, cancellationToken); + await Task.Delay(WaitTimeoutMs); } - cancellationToken.ThrowIfCancellationRequested(); + return true; } } @@ -416,7 +414,7 @@ public void Dispose() _disposeCounter.DisposeCount++; } - public Task MoveNextAsync(CancellationToken _) + public Task MoveNextAsync() { return Task.Factory.StartNew(() => false); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index f96eef9c8a..9657b7dd70 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -32,7 +32,6 @@ public void MoveNextExtension() en.MoveNext(); Assert.True(en.MoveNextWasCalled); - Assert.Equal(CancellationToken.None, en.LastToken); } [Fact] From 5f0371628f5552f36e59d1fef0963f4e97ceeecf Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:49:46 -0700 Subject: [PATCH 006/862] Remove more CancellationToken stuff. --- .../System.Interactive.Async/Aggregate.cs | 4 +- .../Source/System.Interactive.Async/AnyAll.cs | 6 +- .../System.Interactive.Async/AppendPrepend.cs | 10 +- .../AsyncEnumerableHelpers.cs | 4 +- .../AsyncEnumerator.cs | 2 +- .../System.Interactive.Async/Average.cs | 40 ++-- .../Source/System.Interactive.Async/Buffer.cs | 2 +- .../Source/System.Interactive.Async/Catch.cs | 6 +- .../System.Interactive.Async/Concatenate.cs | 6 +- .../DefaultIfEmpty.cs | 4 +- .../System.Interactive.Async/Distinct.cs | 18 +- Ix.NET/Source/System.Interactive.Async/Do.cs | 2 +- .../System.Interactive.Async/ElementAt.cs | 4 +- .../Source/System.Interactive.Async/Except.cs | 4 +- .../Source/System.Interactive.Async/Expand.cs | 2 +- .../System.Interactive.Async/Finally.cs | 2 +- .../Source/System.Interactive.Async/First.cs | 4 +- .../System.Interactive.Async/ForEach.cs | 2 +- .../IgnoreElements.cs | 2 +- .../System.Interactive.Async/Intersect.cs | 4 +- .../Source/System.Interactive.Async/Join.cs | 4 +- .../Source/System.Interactive.Async/Last.cs | 4 +- .../Source/System.Interactive.Async/Lookup.cs | 4 +- Ix.NET/Source/System.Interactive.Async/Min.cs | 4 +- .../OnErrorResumeNext.cs | 2 +- .../Source/System.Interactive.Async/Repeat.cs | 2 +- .../Source/System.Interactive.Async/Scan.cs | 4 +- .../Source/System.Interactive.Async/Select.cs | 4 +- .../System.Interactive.Async/SelectMany.cs | 16 +- .../System.Interactive.Async/SequenceEqual.cs | 6 +- .../Source/System.Interactive.Async/Single.cs | 8 +- .../Source/System.Interactive.Async/Skip.cs | 14 +- .../Source/System.Interactive.Async/Take.cs | 8 +- .../ToAsyncEnumerable.cs | 2 +- .../System.Interactive.Async/ToObservable.cs | 2 +- .../Source/System.Interactive.Async/Using.cs | 2 +- .../Source/System.Interactive.Async/Where.cs | 6 +- Ix.NET/Source/System.Interactive.Async/Zip.cs | 4 +- Ix.NET/Source/Tests/AsyncTests.Aggregates.cs | 9 - Ix.NET/Source/Tests/AsyncTests.Bugs.cs | 197 ------------------ Ix.NET/Source/Tests/AsyncTests.Exceptions.cs | 18 -- Ix.NET/Source/Tests/AsyncTests.Single.cs | 11 - Ix.NET/Source/Tests/AsyncTests.cs | 48 +++++ 43 files changed, 160 insertions(+), 347 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index b6d23b27e6..27dc638051 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -83,7 +83,7 @@ private static async Task Aggregate_(IAs using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { acc = accumulator(acc, e.Current); @@ -100,7 +100,7 @@ private static async Task Aggregate_(IAsyncEnumerable using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { acc = first ? e.Current : accumulator(acc, e.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs index 938ead9153..d9f92bd51b 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs @@ -67,7 +67,7 @@ public static async Task Any(this IAsyncEnumerable sourc using (var e = source.GetAsyncEnumerator()) { - return await e.MoveNextAsync(cancellationToken).ConfigureAwait(false); + return await e.MoveNextAsync().ConfigureAwait(false); } } @@ -75,7 +75,7 @@ private static async Task All_(IAsyncEnumerable source, { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { if (!predicate(e.Current)) @@ -89,7 +89,7 @@ private static async Task Any_(IAsyncEnumerable source, { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { if (predicate(e.Current)) diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index 421495d1a6..3a5b97a9d8 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -62,7 +62,7 @@ protected void GetSourceEnumerator() protected async Task LoadFromEnumerator(CancellationToken cancellationToken) { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; @@ -203,7 +203,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio { using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync(cancellationToken) + while (await en.MoveNextAsync() .ConfigureAwait(false)) { array[index] = en.Current; @@ -233,7 +233,7 @@ public override async Task> ToListAsync(CancellationToken cancella using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync(cancellationToken) + while (await en.MoveNextAsync() .ConfigureAwait(false)) { list.Add(en.Current); @@ -437,7 +437,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio { using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync(cancellationToken) + while (await en.MoveNextAsync() .ConfigureAwait(false)) { array[index] = en.Current; @@ -467,7 +467,7 @@ public override async Task> ToListAsync(CancellationToken cancella using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync(cancellationToken) + while (await en.MoveNextAsync() .ConfigureAwait(false)) { list.Add(en.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs index 649e7099a5..4572c6a83b 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs @@ -45,7 +45,7 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer { using (var en = source.GetAsyncEnumerator()) { - if (await en.MoveNextAsync(cancellationToken) + if (await en.MoveNextAsync() .ConfigureAwait(false)) { const int DefaultCapacity = 4; @@ -53,7 +53,7 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer arr[0] = en.Current; var count = 1; - while (await en.MoveNextAsync(cancellationToken) + while (await en.MoveNextAsync() .ConfigureAwait(false)) { if (count == arr.Length) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs index 0466199319..80f820cbff 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs @@ -22,7 +22,7 @@ public static Task MoveNext(this IAsyncEnumerator enumerator) if (enumerator == null) throw new ArgumentNullException(nameof(enumerator)); - return enumerator.MoveNextAsync(CancellationToken.None); + return enumerator.MoveNextAsync(); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index 50c4154f12..6afc3d6ca6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -385,7 +385,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync(cancellationToken) + if (!await e.MoveNextAsync() .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -395,7 +395,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { sum += e.Current; @@ -411,7 +411,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { var v = e.Current; @@ -421,7 +421,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { v = e.Current; @@ -445,7 +445,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync(cancellationToken) + if (!await e.MoveNextAsync() .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -455,7 +455,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { sum += e.Current; @@ -471,7 +471,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { var v = e.Current; @@ -481,7 +481,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { v = e.Current; @@ -505,7 +505,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync(cancellationToken) + if (!await e.MoveNextAsync() .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -513,7 +513,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc var sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -531,7 +531,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { var v = e.Current; @@ -541,7 +541,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { v = e.Current; @@ -565,7 +565,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync(cancellationToken) + if (!await e.MoveNextAsync() .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -573,7 +573,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel double sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { sum += e.Current; @@ -588,7 +588,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { var v = e.Current; @@ -598,7 +598,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { v = e.Current; @@ -622,7 +622,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync(cancellationToken) + if (!await e.MoveNextAsync() .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -630,7 +630,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca var sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { sum += e.Current; @@ -645,7 +645,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { var v = e.Current; @@ -653,7 +653,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { v = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/Buffer.cs index a56ae47197..5fd5e436a4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Buffer.cs @@ -89,7 +89,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { if (!stopped) { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/Catch.cs index 6c3a722c6a..1eeae2e03e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/Catch.cs @@ -105,7 +105,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { try { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; @@ -126,7 +126,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT } } - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; @@ -212,7 +212,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT try { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs index 8a6fcec415..5e2bccf8b6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs @@ -113,7 +113,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_While: - if (await currentEnumerator.MoveNextAsync(cancellationToken) + if (await currentEnumerator.MoveNextAsync() .ConfigureAwait(false)) { current = currentEnumerator.Current; @@ -193,7 +193,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken } using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { list.Add(e.Current); @@ -254,7 +254,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { while (true) { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs index 59d6cf18f4..16603a0b4d 100644 --- a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs @@ -65,7 +65,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; @@ -82,7 +82,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index 1bd5a96307..7d1b96dee0 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -141,7 +141,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell var s = new Set(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync(cancellationToken) + while (await enu.MoveNextAsync() .ConfigureAwait(false)) { var item = enu.Current; @@ -178,7 +178,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (!await enumerator.MoveNextAsync(cancellationToken) + if (!await enumerator.MoveNextAsync() .ConfigureAwait(false)) { Dispose(); @@ -193,7 +193,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { element = enumerator.Current; @@ -217,7 +217,7 @@ private async Task> FillSet(CancellationToken cancellationToken) var r = new List(); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync(cancellationToken) + while (await enu.MoveNextAsync() .ConfigureAwait(false)) { var item = enu.Current; @@ -291,7 +291,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (!await enumerator.MoveNextAsync(cancellationToken) + if (!await enumerator.MoveNextAsync() .ConfigureAwait(false)) { Dispose(); @@ -306,7 +306,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { element = enumerator.Current; @@ -329,7 +329,7 @@ private async Task> FillSet(CancellationToken cancellationToken) var s = new Set(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync(cancellationToken) + while (await enu.MoveNextAsync() .ConfigureAwait(false)) { s.Add(enu.Current); @@ -385,7 +385,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; @@ -456,7 +456,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/Do.cs index d7f3bd5e5c..9dfede700f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/Do.cs @@ -122,7 +122,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: try { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index ae75595478..197a3ce85d 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -60,7 +60,7 @@ private static async Task ElementAt_(IAsyncEnumerable { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { if (index == 0) @@ -82,7 +82,7 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { if (index == 0) diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Interactive.Async/Except.cs index 749c53ac6e..d6b06ef7aa 100644 --- a/Ix.NET/Source/System.Interactive.Async/Except.cs +++ b/Ix.NET/Source/System.Interactive.Async/Except.cs @@ -95,7 +95,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (!setFilled) { // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = firstEnumerator.MoveNextAsync(cancellationToken); + var moveNextTask = firstEnumerator.MoveNextAsync(); await Task.WhenAll(moveNextTask, fillSetTask) .ConfigureAwait(false); setFilled = true; @@ -103,7 +103,7 @@ await Task.WhenAll(moveNextTask, fillSetTask) } else { - moveNext = await firstEnumerator.MoveNextAsync(cancellationToken) + moveNext = await firstEnumerator.MoveNextAsync() .ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index aa800304bb..618cda5ff0 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -86,7 +86,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; // while } - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/Finally.cs index 9af433637e..6bf5c4176f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/Finally.cs @@ -65,7 +65,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index 242b520940..40459e0051 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -96,7 +96,7 @@ private static async Task First_(IAsyncEnumerable sou using (var e = source.GetAsyncEnumerator()) { - if (await e.MoveNextAsync(cancellationToken) + if (await e.MoveNextAsync() .ConfigureAwait(false)) { return e.Current; @@ -115,7 +115,7 @@ private static async Task FirstOrDefault_(IAsyncEnumerable(IAsyncEnumerable sourc var index = 0; using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { action(e.Current, checked(index++)); diff --git a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs index e37f4670a1..ab83d470a1 100644 --- a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs @@ -57,7 +57,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { // Do nothing, we're ignoring these elements diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Interactive.Async/Intersect.cs index 53c700dcd0..b4cc01385b 100644 --- a/Ix.NET/Source/System.Interactive.Async/Intersect.cs +++ b/Ix.NET/Source/System.Interactive.Async/Intersect.cs @@ -97,7 +97,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (!setFilled) { // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = firstEnumerator.MoveNextAsync(cancellationToken); + var moveNextTask = firstEnumerator.MoveNextAsync(); await Task.WhenAll(moveNextTask, fillSetTask) .ConfigureAwait(false); setFilled = true; @@ -105,7 +105,7 @@ await Task.WhenAll(moveNextTask, fillSetTask) } else { - moveNext = await firstEnumerator.MoveNextAsync(cancellationToken) + moveNext = await firstEnumerator.MoveNextAsync() .ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index 1cd9359e33..c3f52d3d0a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -116,7 +116,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_If: - if (await outerEnumerator.MoveNextAsync(cancellationToken) + if (await outerEnumerator.MoveNextAsync() .ConfigureAwait(false)) { lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer).ConfigureAwait(false); @@ -155,7 +155,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT return true; case State_While: - var hasNext = await outerEnumerator.MoveNextAsync(cancellationToken).ConfigureAwait(false); + var hasNext = await outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index 6ffc5043df..5de7832971 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -102,7 +102,7 @@ private static async Task Last_(IAsyncEnumerable sour using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { hasLast = true; @@ -130,7 +130,7 @@ private static async Task LastOrDefault_(IAsyncEnumerable> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync(cancellationToken) + while (await enu.MoveNextAsync() .ConfigureAwait(false)) { lookup.GetGrouping(keySelector(enu.Current), create: true) @@ -217,7 +217,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync(cancellationToken) + while (await enu.MoveNextAsync() .ConfigureAwait(false)) { lookup.GetGrouping(keySelector(enu.Current), create: true) diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index ae37e623e0..67da0d1e78 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -495,7 +495,7 @@ private static async Task> ExtremaBy(IAsyncEnumera using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync(cancellationToken) + if (!await e.MoveNextAsync() .ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -503,7 +503,7 @@ private static async Task> ExtremaBy(IAsyncEnumera var resKey = keySelector(current); result.Add(current); - while (await e.MoveNextAsync(cancellationToken) + while (await e.MoveNextAsync() .ConfigureAwait(false)) { var cur = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs index d65da31d96..417c8ca7e1 100644 --- a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs @@ -105,7 +105,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT try { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/Repeat.cs index c7d17729a5..6c8dbcbe72 100644 --- a/Ix.NET/Source/System.Interactive.Async/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/Repeat.cs @@ -119,7 +119,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index 00d124d033..d3adc2e1a9 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -79,7 +79,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; @@ -147,7 +147,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Interactive.Async/Select.cs index bdd1f1cc4b..db10ac7096 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Interactive.Async/Select.cs @@ -93,7 +93,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = selector(enumerator.Current); @@ -151,7 +151,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { checked diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index bfe2250a36..0a79a6c6a4 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -123,7 +123,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync(cancellationToken) + if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -136,7 +136,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNextAsync(cancellationToken) + if (await resultEnumerator.MoveNextAsync() .ConfigureAwait(false)) { current = resultEnumerator.Current; @@ -218,7 +218,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync(cancellationToken) + if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -232,7 +232,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNextAsync(cancellationToken) + if (await resultEnumerator.MoveNextAsync() .ConfigureAwait(false)) { current = resultSelector(currentSource, resultEnumerator.Current); @@ -316,7 +316,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync(cancellationToken) + if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -336,7 +336,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNextAsync(cancellationToken) + if (await resultEnumerator.MoveNextAsync() .ConfigureAwait(false)) { current = resultSelector(currentSource, resultEnumerator.Current); @@ -414,7 +414,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync(cancellationToken) + if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { resultEnumerator?.Dispose(); @@ -431,7 +431,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case State_Result: - if (await resultEnumerator.MoveNextAsync(cancellationToken) + if (await resultEnumerator.MoveNextAsync() .ConfigureAwait(false)) { current = resultEnumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs index ccf594534a..1f89f0fd58 100644 --- a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs +++ b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs @@ -71,17 +71,17 @@ private static async Task SequenceEqual_(IAsyncEnumerable Single_(IAsyncEnumerable so using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync(cancellationToken) + if (!await e.MoveNextAsync() .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var result = e.Current; - if (await e.MoveNextAsync(cancellationToken) + if (await e.MoveNextAsync() .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); @@ -130,14 +130,14 @@ private static async Task SingleOrDefault_(IAsyncEnumerable MoveNextCore(CancellationToken cancellationT enumerator = source.GetAsyncEnumerator(); // skip elements as requested - while (currentCount > 0 && await enumerator.MoveNextAsync(cancellationToken) + while (currentCount > 0 && await enumerator.MoveNextAsync() .ConfigureAwait(false)) { currentCount--; @@ -126,7 +126,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; @@ -188,7 +188,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; @@ -249,7 +249,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT enumerator = source.GetAsyncEnumerator(); // skip elements as requested - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var element = enumerator.Current; @@ -263,7 +263,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync(cancellationToken) + if (doMoveNext && await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; @@ -327,7 +327,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT index = -1; // skip elements as requested - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { checked @@ -346,7 +346,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync(cancellationToken) + if (doMoveNext && await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index d2eee984ab..58f2f76f7a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -102,7 +102,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (currentCount > 0 && await enumerator.MoveNextAsync(cancellationToken) + if (currentCount > 0 && await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; @@ -171,7 +171,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT { if (!isDone) { - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { if (count > 0) @@ -256,7 +256,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; @@ -321,7 +321,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync(cancellationToken) + if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs index f99d4da622..95ade54126 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs @@ -67,7 +67,7 @@ private static IEnumerable ToEnumerable_(IAsyncEnumerable observer) var e = source.GetAsyncEnumerator(); var f = default(Action); - f = () => e.MoveNextAsync(ctd.Token) + f = () => e.MoveNextAsync() .ContinueWith(t => { if (t.IsFaulted) diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/Using.cs index 0160236f3d..76a99c42ee 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/Using.cs @@ -71,7 +71,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Interactive.Async/Where.cs index 5130cf198a..28a6e36831 100644 --- a/Ix.NET/Source/System.Interactive.Async/Where.cs +++ b/Ix.NET/Source/System.Interactive.Async/Where.cs @@ -93,7 +93,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; @@ -155,7 +155,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { checked @@ -228,7 +228,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync(cancellationToken) + while (await enumerator.MoveNextAsync() .ConfigureAwait(false)) { var item = enumerator.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Interactive.Async/Zip.cs index 55300c7a3c..928d96db7f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Zip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Zip.cs @@ -78,8 +78,8 @@ protected override async Task MoveNextCore(CancellationToken cancellationT case AsyncIteratorState.Iterating: // We kick these off and join so they can potentially run in parallel - var ft = firstEnumerator.MoveNextAsync(cancellationToken); - var st = secondEnumerator.MoveNextAsync(cancellationToken); + var ft = firstEnumerator.MoveNextAsync(); + var st = secondEnumerator.MoveNextAsync(); await Task.WhenAll(ft, st) .ConfigureAwait(false); diff --git a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs index e6c2918834..8d57302668 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs @@ -943,15 +943,6 @@ public void ElementAt6() AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public async Task ElementAt7() - { - var en = new CancellationTestAsyncEnumerable(10); - - var res = en.ElementAt(1); - Assert.Equal(1, await res); - } - [Fact] public async Task ElementAtOrDefault_Null() { diff --git a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs index 02e6c45cbe..3be068fd0c 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs @@ -146,203 +146,6 @@ public async Task DisposesUponError() Assert.True(result); } - [Fact] - public async Task CorrectCancel() - { - var disposed = new TaskCompletionSource(); - - var xs = new CancellationTestAsyncEnumerable().WithDispose(() => - { - disposed.TrySetResult(true); - }); - - var ys = xs.Select(x => x + 1).Where(x => true); - - var e = ys.GetAsyncEnumerator(); - var cts = new CancellationTokenSource(); - var t = e.MoveNextAsync(cts.Token); - - cts.Cancel(); - - try - { - t.Wait(WaitTimeoutMs); - } - catch - { - // Don't care about the outcome; we could have made it to element 1 - // but we could also have cancelled the MoveNext-calling task. Either - // way, we want to wait for the task to be completed and check that - } - finally - { - // the cancellation bubbled all the way up to the source to dispose - // it. This design is chosen because cancelling a MoveNext call leaves - // the enumerator in an indeterminate state. Further interactions with - // it should be forbidden. - - var result = await disposed.Task; - Assert.True(result); - } - - Assert.False(await e.MoveNext()); - } - - [Fact] - public void CanCancelMoveNext() - { - var xs = new CancellationTestAsyncEnumerable().Select(x => x).Where(x => true); - - var e = xs.GetAsyncEnumerator(); - var cts = new CancellationTokenSource(); - var t = e.MoveNextAsync(cts.Token); - - cts.Cancel(); - - try - { - t.Wait(WaitTimeoutMs); - Assert.True(false); - } - catch - { - Assert.True(t.IsCanceled); - } - } - - /// - /// Waits WaitTimeoutMs or until cancellation is requested. If cancellation was not requested, MoveNext returns true. - /// - internal sealed class CancellationTestAsyncEnumerable : IAsyncEnumerable - { - private readonly int iterationsBeforeDelay; - - public CancellationTestAsyncEnumerable(int iterationsBeforeDelay = 0) - { - this.iterationsBeforeDelay = iterationsBeforeDelay; - } - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() => GetEnumerator(); - - public TestEnumerator GetEnumerator() => new TestEnumerator(iterationsBeforeDelay); - - - internal sealed class TestEnumerator : IAsyncEnumerator - { - private readonly int iterationsBeforeDelay; - - public TestEnumerator(int iterationsBeforeDelay) - { - this.iterationsBeforeDelay = iterationsBeforeDelay; - } - int i = -1; - public void Dispose() - { - } - - public bool MoveNextWasCalled { get; private set; } - - public int Current => i; - - public async Task MoveNextAsync() - { - MoveNextWasCalled = true; - - i++; - if (Current >= iterationsBeforeDelay) - { - await Task.Delay(WaitTimeoutMs); - } - - return true; - } - } - } - - /// - /// Waits WaitTimeoutMs or until cancellation is requested. If cancellation was not requested, MoveNext returns true. - /// - private sealed class CancellationTestEnumerable : IEnumerable - { - public CancellationTestEnumerable() - { - } - public IEnumerator GetEnumerator() => new TestEnumerator(); - - private sealed class TestEnumerator : IEnumerator - { - private readonly CancellationTokenSource cancellationTokenSource; - - public TestEnumerator() - { - cancellationTokenSource = new CancellationTokenSource(); - } - public void Dispose() - { - cancellationTokenSource.Cancel(); - } - - public void Reset() - { - - } - - object IEnumerator.Current => Current; - - public T Current { get; } - - public bool MoveNext() - { - Task.Delay(WaitTimeoutMs, cancellationTokenSource.Token).Wait(); - cancellationTokenSource.Token.ThrowIfCancellationRequested(); - return true; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } - - [Fact] - public void ToAsyncEnumeratorCannotCancelOnceRunning() - { - var evt = new ManualResetEvent(false); - var isRunningEvent = new ManualResetEvent(false); - var xs = Blocking(evt, isRunningEvent).ToAsyncEnumerable(); - - var e = xs.GetAsyncEnumerator(); - var cts = new CancellationTokenSource(); - - - Task t = null; - var tMoveNext =Task.Run( - () => - { - // This call *will* block - t = e.MoveNextAsync(cts.Token); - }); - - - isRunningEvent.WaitOne(); - cts.Cancel(); - - try - { - tMoveNext.Wait(0); - Assert.False(t.IsCanceled); - } - catch - { - // T will still be null - Assert.Null(t); - } - - - // enable it to finish - evt.Set(); - } - static IEnumerable Blocking(ManualResetEvent evt, ManualResetEvent blockingStarted) { blockingStarted.Set(); diff --git a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs index dbe315cc80..8669119c40 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs @@ -393,24 +393,6 @@ public void Finally5() Assert.True(b); } - //[Fact] - public void Finally6() - { - var b = false; - - var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); - - var e = xs.GetAsyncEnumerator(); - - var cts = new CancellationTokenSource(); - - var t = e.MoveNextAsync(cts.Token); - cts.Cancel(); - t.Wait(WaitTimeoutMs); - - Assert.True(b); - } - [Fact] public async Task Finally7() { diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index 9657b7dd70..a62baab4fa 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -23,17 +23,6 @@ public void MoveNextExtension_Null() Assert.ThrowsAsync(() => en.MoveNext()); } - [Fact] - public void MoveNextExtension() - { - var enumerable = new CancellationTestAsyncEnumerable(); - var en = enumerable.GetEnumerator(); - - en.MoveNext(); - - Assert.True(en.MoveNextWasCalled); - } - [Fact] public void Select_Null() { diff --git a/Ix.NET/Source/Tests/AsyncTests.cs b/Ix.NET/Source/Tests/AsyncTests.cs index 657b21010c..53f9902262 100644 --- a/Ix.NET/Source/Tests/AsyncTests.cs +++ b/Ix.NET/Source/Tests/AsyncTests.cs @@ -87,5 +87,53 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) e1Result.ShouldAllBeEquivalentTo(e2Result); } #pragma warning restore xUnit1013 // Public method should be marked as test + + /// + /// Waits WaitTimeoutMs or until cancellation is requested. If cancellation was not requested, MoveNext returns true. + /// + internal sealed class CancellationTestAsyncEnumerable : IAsyncEnumerable + { + private readonly int iterationsBeforeDelay; + + public CancellationTestAsyncEnumerable(int iterationsBeforeDelay = 0) + { + this.iterationsBeforeDelay = iterationsBeforeDelay; + } + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() => GetEnumerator(); + + public TestEnumerator GetEnumerator() => new TestEnumerator(iterationsBeforeDelay); + + + internal sealed class TestEnumerator : IAsyncEnumerator + { + private readonly int iterationsBeforeDelay; + + public TestEnumerator(int iterationsBeforeDelay) + { + this.iterationsBeforeDelay = iterationsBeforeDelay; + } + int i = -1; + public void Dispose() + { + } + + public bool MoveNextWasCalled { get; private set; } + + public int Current => i; + + public async Task MoveNextAsync() + { + MoveNextWasCalled = true; + + i++; + if (Current >= iterationsBeforeDelay) + { + await Task.Delay(WaitTimeoutMs); + } + + return true; + } + } + } } } \ No newline at end of file From 2d2ec8d939752240d4c650871288664a900dc9d6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:50:37 -0700 Subject: [PATCH 007/862] Improving compat MoveNext async extension method to honor cancellation. --- Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index 2a8f181aff..53c6e46e33 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -45,6 +45,11 @@ public static class AsyncEnumeratorExtensions /// public static Task MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + cancellationToken.ThrowIfCancellationRequested(); + return source.MoveNextAsync(); } } From 58b8bef8a4335c2919e236b5c50e331b91166209 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:54:44 -0700 Subject: [PATCH 008/862] Remove CancellationTestAsyncEnumerable. --- Ix.NET/Source/Tests/AsyncTests.Creation.cs | 40 -------- Ix.NET/Source/Tests/AsyncTests.Single.cs | 104 --------------------- Ix.NET/Source/Tests/AsyncTests.cs | 48 ---------- 3 files changed, 192 deletions(-) diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index ec97ec543e..015d484461 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -394,46 +394,6 @@ public void Using5() Assert.True(disposed.Task.Result); } - [Fact] - public async Task Using6() - { - var i = 0; - var disposed = new TaskCompletionSource(); - - var xs = AsyncEnumerable.Using( - () => - { - i++; - return new MyD(() => { disposed.TrySetResult(true); }); - }, - _ => new CancellationTestAsyncEnumerable(2) // need to use this to verify we actually cancel - ); - - Assert.Equal(0, i); - - var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); - - HasNext(e, 0); - HasNext(e, 1); - - var cts = new CancellationTokenSource(); - var t = e.MoveNextAsync(cts.Token); - cts.Cancel(); - - try - { - t.Wait(WaitTimeoutMs); - } - catch (AggregateException ex) - { - ex.Flatten().Handle(inner => inner is TaskCanceledException); - } - - Assert.True(disposed.Task.IsCompleted); - Assert.True(await disposed.Task); - } - [Fact] public async Task Using7() { diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index a62baab4fa..7720e81a61 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -91,18 +91,6 @@ public void Select5() NoNext(e); } - [Fact] - public void Select6() - { - var xs = new CancellationTestAsyncEnumerable(10); - var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x)); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 'd'); - HasNext(e, 'e'); - HasNext(e, 'f'); - } - [Fact] public async Task Select7() { @@ -121,32 +109,6 @@ public async Task Select8() await SequenceIdentity(ys); } - - [Fact] - public void SelectWhere1() - { - var xs = new CancellationTestAsyncEnumerable(10); - var ys = xs.Select(i => i + 2).Where(i => i % 2 == 0); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 4); - HasNext(e, 6); - } - - [Fact] - public void WhereSelect1() - { - var xs = new CancellationTestAsyncEnumerable(10); - var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 4); - HasNext(e, 6); - } - - [Fact] public void SelectWhere2() { @@ -184,15 +146,6 @@ public void WhereSelect3() NoNext(e); } - [Fact] - public async Task WhereSelect4() - { - var xs = new CancellationTestAsyncEnumerable(10).Take(5); - var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2); - - await SequenceIdentity(ys); - } - [Fact] public void Where_Null() { @@ -1491,34 +1444,6 @@ public async Task DefaultIfEmpty15() await SequenceIdentity(xs); } - [Fact] - public async Task DefaultIfEmpty16() - { - var xs = new CancellationTestAsyncEnumerable(10) - .Take(5) - .Reverse() // so we have an ilist provider - .DefaultIfEmpty(24) - .Append(5); // for the onlyIsCheap to true - - var r = new[] { 4, 3, 2, 1, 0, 5 }; - - Assert.Equal(r, await xs.ToArray()); - } - - [Fact] - public async Task DefaultIfEmpty17() - { - var xs = new CancellationTestAsyncEnumerable(10) - .Take(5) - .DefaultIfEmpty(24) - .Append(5); // for the onlyIsCheap to true - - var r = new[] { 0, 1, 2, 3, 4, 5}; - - Assert.Equal(r, await xs.ToArray()); - } - - [Fact] public void Distinct_Null() { @@ -1740,35 +1665,6 @@ public async Task Reverse9() Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArray()); } - [Fact] - public async Task Reverse10() - { - var xs = new CancellationTestAsyncEnumerable(10).Skip(1).Take(3); - var ys = xs.Reverse().Prepend(4); // to trigger onlyIfCheap - - Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArray()); - } - - [Fact] - public async Task Reverse11() - { - var xs = new CancellationTestAsyncEnumerable(10).Skip(1).Take(3); - var ys = xs.Reverse().Prepend(4); // to trigger onlyIfCheap - - Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToList()); - } - - - [Fact] - public async Task Reverse12() - { - var xs = new CancellationTestAsyncEnumerable(10).Skip(1).Take(3); - var ys = xs.Reverse().Prepend(4).Prepend(5); // to trigger onlyIfCheap - - Assert.Equal(new[] { 5, 4, 3, 2, 1 }, await ys.ToArray()); - } - - [Fact] public void OrderBy_Null() { diff --git a/Ix.NET/Source/Tests/AsyncTests.cs b/Ix.NET/Source/Tests/AsyncTests.cs index 53f9902262..657b21010c 100644 --- a/Ix.NET/Source/Tests/AsyncTests.cs +++ b/Ix.NET/Source/Tests/AsyncTests.cs @@ -87,53 +87,5 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) e1Result.ShouldAllBeEquivalentTo(e2Result); } #pragma warning restore xUnit1013 // Public method should be marked as test - - /// - /// Waits WaitTimeoutMs or until cancellation is requested. If cancellation was not requested, MoveNext returns true. - /// - internal sealed class CancellationTestAsyncEnumerable : IAsyncEnumerable - { - private readonly int iterationsBeforeDelay; - - public CancellationTestAsyncEnumerable(int iterationsBeforeDelay = 0) - { - this.iterationsBeforeDelay = iterationsBeforeDelay; - } - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() => GetEnumerator(); - - public TestEnumerator GetEnumerator() => new TestEnumerator(iterationsBeforeDelay); - - - internal sealed class TestEnumerator : IAsyncEnumerator - { - private readonly int iterationsBeforeDelay; - - public TestEnumerator(int iterationsBeforeDelay) - { - this.iterationsBeforeDelay = iterationsBeforeDelay; - } - int i = -1; - public void Dispose() - { - } - - public bool MoveNextWasCalled { get; private set; } - - public int Current => i; - - public async Task MoveNextAsync() - { - MoveNextWasCalled = true; - - i++; - if (Current >= iterationsBeforeDelay) - { - await Task.Delay(WaitTimeoutMs); - } - - return true; - } - } - } } } \ No newline at end of file From e986e8d25e513e33c5b2e01db2b3ebff08ffd91c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:55:10 -0700 Subject: [PATCH 009/862] Remove more garbage. --- Ix.NET/Source/Tests/AsyncTests.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/Tests/AsyncTests.cs b/Ix.NET/Source/Tests/AsyncTests.cs index 657b21010c..74cfc30d4b 100644 --- a/Ix.NET/Source/Tests/AsyncTests.cs +++ b/Ix.NET/Source/Tests/AsyncTests.cs @@ -3,22 +3,17 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Reflection; -using System.Threading; using System.Threading.Tasks; -using Xunit; using FluentAssertions; - +using Xunit; namespace Tests { public partial class AsyncTests { -#pragma warning disable xUnit1013 // Public method should be marked as test +#pragma warning disable xUnit1013 // Public method should be marked as test public void AssertThrows(Action a) where E : Exception { @@ -86,6 +81,6 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) e1Result.ShouldAllBeEquivalentTo(e2Result); } -#pragma warning restore xUnit1013 // Public method should be marked as test +#pragma warning restore xUnit1013 // Public method should be marked as test } -} \ No newline at end of file +} From 73aae2ed1eefff96d48e1187f1892cf1bd21ceb9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 15:59:36 -0700 Subject: [PATCH 010/862] Remove MoveNextAsync extension method. --- .../AsyncEnumerator.cs | 28 ---- Ix.NET/Source/Tests/AsyncTests.Bugs.cs | 8 +- Ix.NET/Source/Tests/AsyncTests.Conversions.cs | 12 +- Ix.NET/Source/Tests/AsyncTests.Creation.cs | 14 +- Ix.NET/Source/Tests/AsyncTests.Exceptions.cs | 14 +- Ix.NET/Source/Tests/AsyncTests.Multiple.cs | 34 ++-- Ix.NET/Source/Tests/AsyncTests.Single.cs | 158 +++++++++--------- Ix.NET/Source/Tests/AsyncTests.cs | 4 +- 8 files changed, 122 insertions(+), 150 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs deleted file mode 100644 index 80f820cbff..0000000000 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. -using System; -using System.Linq; -using System.Threading.Tasks; -using System.Threading; - -namespace System.Collections.Generic -{ - public static class AsyncEnumerator - { - /// - /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. - /// - /// - /// Task containing the result of the operation: true if the enumerator was successfully advanced - /// to the next element; false if the enumerator has passed the end of the sequence. - /// - public static Task MoveNext(this IAsyncEnumerator enumerator) - { - if (enumerator == null) - throw new ArgumentNullException(nameof(enumerator)); - - return enumerator.MoveNextAsync(); - } - } -} diff --git a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs index 3be068fd0c..956451edf4 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs @@ -113,16 +113,16 @@ public async void CorrectDispose() var e = ys.GetAsyncEnumerator(); // We have to call move next because otherwise the internal enumerator is never allocated - await e.MoveNext(); + await e.MoveNextAsync(); e.Dispose(); await disposed.Task; Assert.True(disposed.Task.Result); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); - var next = await e.MoveNext(); + var next = await e.MoveNextAsync(); Assert.False(next); } @@ -140,7 +140,7 @@ public async Task DisposesUponError() var ys = xs.Select(x => { if (x == 1) throw ex; return x; }); var e = ys.GetAsyncEnumerator(); - await Assert.ThrowsAsync(() => e.MoveNext()); + await Assert.ThrowsAsync(() => e.MoveNextAsync()); var result = await disposed.Task; Assert.True(result); diff --git a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs index 733a7d5aac..3f1c23aac5 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs @@ -42,7 +42,7 @@ public void ToAsyncEnumerable2() var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); HasNext(e, 42); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } private IEnumerable ToAsyncEnumerable_Sequence(Exception e) @@ -97,7 +97,7 @@ public void ToAsyncEnumerable4() Assert.True(subscribed); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } [Fact] @@ -233,9 +233,9 @@ public void ToAsyncEnumerable_With_Completed_Task() var xs = task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.Equal(36, e.Current); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); } [Fact] @@ -248,7 +248,7 @@ public void ToAsyncEnumerable_With_Faulted_Task() var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } [Fact] @@ -260,7 +260,7 @@ public void ToAsyncEnumerable_With_Canceled_Task() var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() is TaskCanceledException); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() is TaskCanceledException); } class MyObservable : IObservable diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index 015d484461..90e2e6fc78 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -48,7 +48,7 @@ public void Never() var xs = AsyncEnumerable.Never(); var e = xs.GetAsyncEnumerator(); - Assert.False(e.MoveNext().IsCompleted); // Very rudimentary check + Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check AssertThrows(() => Nop(e.Current)); e.Dispose(); } @@ -73,7 +73,7 @@ public void Empty2() var xs = AsyncEnumerable.Empty(); var e = xs.GetAsyncEnumerator(); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); AssertThrows(() => Nop(e.Current)); } @@ -90,7 +90,7 @@ public void Throw() var xs = AsyncEnumerable.Throw(ex); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); AssertThrows(() => Nop(e.Current)); } @@ -234,7 +234,7 @@ public void Generate2() var xs = AsyncEnumerable.Generate(0, x => { throw ex; }, x => x + 1, x => x * x); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } [Fact] @@ -245,7 +245,7 @@ public void Generate3() var e = xs.GetAsyncEnumerator(); HasNext(e, 0); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } [Fact] @@ -256,7 +256,7 @@ public void Generate4() var e = xs.GetAsyncEnumerator(); HasNext(e, 0); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } [Fact] @@ -389,7 +389,7 @@ public void Using5() var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); Assert.True(disposed.Task.Result); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs index 8669119c40..fc237fd093 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs @@ -114,7 +114,7 @@ public void Catch4() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); Assert.False(err); } @@ -135,7 +135,7 @@ public void Catch5() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex2); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex2); } [Fact] @@ -162,7 +162,7 @@ public void Catch6() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -233,7 +233,7 @@ public void Catch10() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); } private IEnumerable> CatchXss() @@ -259,7 +259,7 @@ public void Catch11() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -350,7 +350,7 @@ public void Finally3() var e = xs.GetAsyncEnumerator(); Assert.False(b); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); Assert.True(b); } @@ -487,7 +487,7 @@ public void OnErrorResumeNext10() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); } private IEnumerable> OnErrorResumeNextXss() diff --git a/Ix.NET/Source/Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/Tests/AsyncTests.Multiple.cs index 7e9b773b06..f346f14b8b 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Multiple.cs @@ -49,7 +49,7 @@ public void Concat2() HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -59,7 +59,7 @@ public void Concat3() var ys = AsyncEnumerable.Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -99,7 +99,7 @@ public void Concat5() HasNext(e, 3); HasNext(e, 4); HasNext(e, 5); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -113,7 +113,7 @@ public void Concat6() HasNext(e, 3); HasNext(e, 4); HasNext(e, 5); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); } [Fact] @@ -271,7 +271,7 @@ public void Zip4() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -283,7 +283,7 @@ public void Zip5() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -295,7 +295,7 @@ public void Zip6() var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; }); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -680,7 +680,7 @@ public void GroupJoin3() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -693,7 +693,7 @@ public void GroupJoin4() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -706,7 +706,7 @@ public void GroupJoin5() var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -719,7 +719,7 @@ public void GroupJoin6() var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -737,7 +737,7 @@ public void GroupJoin7() var e = res.GetAsyncEnumerator(); HasNext(e, "0 - 36"); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -825,7 +825,7 @@ public void Join5() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -838,7 +838,7 @@ public void Join6() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -851,7 +851,7 @@ public void Join7() var res = xs.Join(ys, x => { throw ex; }, y => y, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -864,7 +864,7 @@ public void Join8() var res = xs.Join(ys, x => x, y => { throw ex; }, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -877,7 +877,7 @@ public void Join9() var res = xs.Join(ys, x => x, y => y, (x, y) => { throw ex; }); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index 7720e81a61..f565e1dd08 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -20,7 +20,7 @@ public void MoveNextExtension_Null() { var en = default(IAsyncEnumerator); - Assert.ThrowsAsync(() => en.MoveNext()); + Assert.ThrowsAsync(() => en.MoveNextAsync()); } [Fact] @@ -65,7 +65,7 @@ public void Select3() var ys = xs.Select(x => 1 / x); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); } [Fact] @@ -75,7 +75,7 @@ public void Select4() var ys = xs.Select((x, i) => 1 / i); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); } [Fact] @@ -195,7 +195,7 @@ public void Where3() HasNext(e, 8); HasNext(e, 5); HasNext(e, 7); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -209,7 +209,7 @@ public void Where4() HasNext(e, 8); HasNext(e, 5); HasNext(e, 7); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -220,7 +220,7 @@ public void Where5() var ys = xs.Where(x => true); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -231,7 +231,7 @@ public void Where6() var ys = xs.Where((x, i) => true); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -314,7 +314,7 @@ public void SelectMany2() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -325,7 +325,7 @@ public void SelectMany3() var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -345,7 +345,7 @@ public void SelectMany4() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -381,7 +381,7 @@ public void SelectMany6() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -392,7 +392,7 @@ public void SelectMany7() var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -412,7 +412,7 @@ public void SelectMany8() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -464,7 +464,7 @@ public void SelectMany11() HasNext(e, 6); HasNext(e, 8); HasNext(e, 9); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -483,7 +483,7 @@ public void SelectMany12() HasNext(e, 3); HasNext(e, 8); HasNext(e, 10); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -637,7 +637,7 @@ public void Do2() var ys = xs.Do(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -697,7 +697,7 @@ public void Do5() var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }, () => { done = true; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ex_.InnerException == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); Assert.False(hasv); Assert.False(done); @@ -714,7 +714,7 @@ public void Do6() var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ex_.InnerException == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); Assert.False(hasv); Assert.Same(exa, ex); @@ -932,7 +932,7 @@ public void Take4() var ys = xs.Take(2); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1009,7 +1009,7 @@ public void TakeWhile5() var ys = xs.TakeWhile(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1056,7 +1056,7 @@ public void TakeWhile9() var ys = xs.TakeWhile((x, i) => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -1138,7 +1138,7 @@ public void Skip4() var ys = xs.Skip(2); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1218,7 +1218,7 @@ public void SkipWhile5() var ys = xs.SkipWhile(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1265,7 +1265,7 @@ public void SkipWhile9() var ys = xs.SkipWhile((x, i) => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1366,7 +1366,7 @@ public void DefaultIfEmpty7() var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1376,7 +1376,7 @@ public void DefaultIfEmpty8() var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1617,7 +1617,7 @@ public void Reverse4() var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1719,7 +1719,7 @@ public void OrderBy2() var ys = xs.OrderBy(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1739,7 +1739,7 @@ public void ThenBy2() var ys = xs.OrderBy(x => x).ThenBy(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1762,7 +1762,7 @@ public void OrderByDescending2() var ys = xs.OrderByDescending(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1782,7 +1782,7 @@ public void ThenByDescending2() var ys = xs.OrderBy(x => x).ThenByDescending(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -1928,7 +1928,7 @@ public void GroupBy1() var e = res.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.Equal(2, e.Current.Key); var g1 = e.Current.GetAsyncEnumerator(); HasNext(g1, xs[0]); @@ -1937,19 +1937,19 @@ public void GroupBy1() HasNext(g1, xs[5]); NoNext(g1); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.Equal(6, e.Current.Key); var g2 = e.Current.GetAsyncEnumerator(); HasNext(g2, xs[1]); NoNext(g2); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.Equal(1, e.Current.Key); var g3 = e.Current.GetAsyncEnumerator(); HasNext(g3, xs[3]); NoNext(g3); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.Equal(4, e.Current.Key); var g4 = e.Current.GetAsyncEnumerator(); HasNext(g4, xs[6]); @@ -1977,19 +1977,19 @@ public void GroupBy2() var e = res.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g1 = e.Current; Assert.Equal(2, g1.Key); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(6, g2.Key); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(1, g3.Key); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g4 = e.Current; Assert.Equal(4, g4.Key); @@ -2033,7 +2033,7 @@ public void GroupBy4() var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -2044,7 +2044,7 @@ public void GroupBy5() var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); //Assert.True(e.MoveNext().Result); //var g1 = e.Current; @@ -2071,7 +2071,7 @@ public void GroupBy6() var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); //Assert.True(e.MoveNext().Result); //var g1 = e.Current; @@ -2098,7 +2098,7 @@ public void GroupBy7() var ys = xs.GroupBy(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -2110,7 +2110,7 @@ public void GroupBy8() var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); //Assert.True(e.MoveNext().Result); //var g1 = e.Current; @@ -2137,7 +2137,7 @@ public void GroupBy9() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -2147,7 +2147,7 @@ public void GroupBy9() HasNext(g1e, 'j'); NoNext(g1e); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -2156,7 +2156,7 @@ public void GroupBy9() HasNext(g2e, 'h'); NoNext(g2e); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -2202,7 +2202,7 @@ public void GroupBy12() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -2212,7 +2212,7 @@ public void GroupBy12() HasNext(g1e, 9); NoNext(g1e); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -2221,7 +2221,7 @@ public void GroupBy12() HasNext(g2e, 7); NoNext(g2e); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -2241,7 +2241,7 @@ public void GroupBy13() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -2251,7 +2251,7 @@ public void GroupBy13() HasNext(g1e, 'j'); NoNext(g1e); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -2260,7 +2260,7 @@ public void GroupBy13() HasNext(g2e, 'h'); NoNext(g2e); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -2306,7 +2306,7 @@ public void GroupBy16() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -2317,7 +2317,7 @@ public void GroupBy16() NoNext(g1e); g1e.Dispose(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -2327,7 +2327,7 @@ public void GroupBy16() NoNext(g2e); g2e.Dispose(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -2351,7 +2351,7 @@ public void GroupBy17() var e = ys.GetAsyncEnumerator(); e.Dispose(); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); } [Fact] @@ -2362,7 +2362,7 @@ public void GroupBy18() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -2376,7 +2376,7 @@ public void GroupBy18() NoNext(g1e); g1e.Dispose(); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); } [Fact] @@ -2861,7 +2861,7 @@ public void RepeatSeq4() var xs = new FailRepeat().ToAsyncEnumerable().Repeat(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); } [Fact] @@ -2870,7 +2870,7 @@ public void RepeatSeq5() var xs = new FailRepeat().ToAsyncEnumerable().Repeat(3); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); } class FailRepeat : IEnumerable @@ -2932,7 +2932,7 @@ public void IgnoreElements4() var xs = AsyncEnumerable.Throw(ex).IgnoreElements(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -2982,7 +2982,7 @@ public void StartWith3() var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -3003,16 +3003,16 @@ public void Buffer1() var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 3, 4 })); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 5 })); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); } [Fact] @@ -3022,16 +3022,16 @@ public void Buffer2() var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 1, 2, 3 })); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 3, 4, 5 })); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 5 })); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); } [Fact] @@ -3041,13 +3041,13 @@ public void Buffer3() var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.True(e.Current.SequenceEqual(new[] { 4, 5 })); - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); } [Fact] @@ -3116,7 +3116,7 @@ public void DistinctUntilChanged3() HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -3165,7 +3165,7 @@ public void Expand2() var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => { throw ex; }); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -3176,7 +3176,7 @@ public void Expand3() var e = xs.GetAsyncEnumerator(); HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NullReferenceException); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NullReferenceException); } [Fact] @@ -3227,7 +3227,7 @@ public void Scan3() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => { throw ex; }); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] @@ -3237,7 +3237,7 @@ public void Scan4() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => { throw ex; }); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } [Fact] diff --git a/Ix.NET/Source/Tests/AsyncTests.cs b/Ix.NET/Source/Tests/AsyncTests.cs index 74cfc30d4b..db86345485 100644 --- a/Ix.NET/Source/Tests/AsyncTests.cs +++ b/Ix.NET/Source/Tests/AsyncTests.cs @@ -51,12 +51,12 @@ public void AssertThrows(Action a, Func assert) public void NoNext(IAsyncEnumerator e) { - Assert.False(e.MoveNext().Result); + Assert.False(e.MoveNextAsync().Result); } public void HasNext(IAsyncEnumerator e, T value) { - Assert.True(e.MoveNext().Result); + Assert.True(e.MoveNextAsync().Result); Assert.Equal(value, e.Current); } From 68ad7f4b4078030106867bfa728e7e3da9698b35 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 16:15:01 -0700 Subject: [PATCH 011/862] Remove CancellationToken from MoveNextCore. --- .../System.Interactive.Async/AppendPrepend.cs | 10 +++---- .../AsyncEnumerable.cs | 2 +- .../System.Interactive.Async/AsyncIterator.cs | 4 +-- .../Source/System.Interactive.Async/Buffer.cs | 2 +- .../Source/System.Interactive.Async/Catch.cs | 4 +-- .../System.Interactive.Async/Concatenate.cs | 4 +-- .../Source/System.Interactive.Async/Create.cs | 21 ++++++------- .../DefaultIfEmpty.cs | 2 +- .../System.Interactive.Async/Distinct.cs | 8 ++--- Ix.NET/Source/System.Interactive.Async/Do.cs | 2 +- .../Source/System.Interactive.Async/Except.cs | 8 ++--- .../Source/System.Interactive.Async/Expand.cs | 2 +- .../System.Interactive.Async/Finally.cs | 2 +- .../System.Interactive.Async/Generate.cs | 2 +- .../System.Interactive.Async/Grouping.cs | 30 +++++++++---------- .../IgnoreElements.cs | 2 +- .../System.Interactive.Async/Intersect.cs | 8 ++--- .../Source/System.Interactive.Async/Join.cs | 2 +- .../Source/System.Interactive.Async/Lookup.cs | 6 ++-- .../OnErrorResumeNext.cs | 2 +- .../OrderedAsyncEnumerable.cs | 12 ++++---- .../Source/System.Interactive.Async/Repeat.cs | 4 +-- .../System.Interactive.Async/Reverse.cs | 4 +-- .../Source/System.Interactive.Async/Scan.cs | 4 +-- .../Source/System.Interactive.Async/Select.cs | 6 ++-- .../System.Interactive.Async/SelectMany.cs | 8 ++--- .../Source/System.Interactive.Async/Skip.cs | 8 ++--- .../Source/System.Interactive.Async/Take.cs | 8 ++--- .../ToAsyncEnumerable.cs | 6 ++-- .../System.Interactive.Async/ToObservable.cs | 2 +- .../Source/System.Interactive.Async/Using.cs | 2 +- .../Source/System.Interactive.Async/Where.cs | 6 ++-- Ix.NET/Source/System.Interactive.Async/Zip.cs | 2 +- Ix.NET/Source/Tests/AsyncTests.Conversions.cs | 6 ++-- Ix.NET/Source/Tests/AsyncTests.Creation.cs | 2 +- 35 files changed, 100 insertions(+), 103 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index 3a5b97a9d8..fd31704b70 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -60,7 +60,7 @@ protected void GetSourceEnumerator() public abstract AppendPrepentAsyncIterator Append(TSource item); public abstract AppendPrepentAsyncIterator Prepend(TSource item); - protected async Task LoadFromEnumerator(CancellationToken cancellationToken) + protected async Task LoadFromEnumerator() { if (await enumerator.MoveNextAsync() .ConfigureAwait(false)) @@ -111,7 +111,7 @@ public override AsyncIterator Clone() } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -135,7 +135,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT if (enumerator != null) { - if (await LoadFromEnumerator(cancellationToken) + if (await LoadFromEnumerator() .ConfigureAwait(false)) { return true; @@ -341,7 +341,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -371,7 +371,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case 3; case 3: - if (await LoadFromEnumerator(cancellationToken) + if (await LoadFromEnumerator() .ConfigureAwait(false)) { return true; diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs index 8e012c93ec..68746bccdd 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs @@ -48,7 +48,7 @@ public static IAsyncEnumerable Never() { return CreateEnumerable( () => CreateEnumerator( - (ct, tcs) => tcs.Task, + tcs => tcs.Task, null, null) ); diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index adf57c29a2..12529f63ba 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -86,7 +86,7 @@ public async Task MoveNextAsync() try { - var result = await MoveNextCore(default(CancellationToken)) + var result = await MoveNextCore() .ConfigureAwait(false); currentIsInvalid = !result; // if move next is false, invalid otherwise valid @@ -113,7 +113,7 @@ public virtual IAsyncEnumerable Where(Func predicate) return new WhereEnumerableAsyncIterator(this, predicate); } - protected abstract Task MoveNextCore(CancellationToken cancellationToken); + protected abstract Task MoveNextCore(); protected virtual void OnGetEnumerator() { diff --git a/Ix.NET/Source/System.Interactive.Async/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/Buffer.cs index 5fd5e436a4..a71fc303f4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Buffer.cs @@ -71,7 +71,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/Catch.cs index 1eeae2e03e..dc0e0da6e6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/Catch.cs @@ -87,7 +87,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -184,7 +184,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs index 5e2bccf8b6..0a9ecb0f1c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs @@ -86,7 +86,7 @@ public override void Dispose() const int State_OuterNext = 1; const int State_While = 4; - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) @@ -240,7 +240,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { if (state == AsyncIteratorState.Allocated) { diff --git a/Ix.NET/Source/System.Interactive.Async/Create.cs b/Ix.NET/Source/System.Interactive.Async/Create.cs index f4e1a6935a..d2bd26ad69 100644 --- a/Ix.NET/Source/System.Interactive.Async/Create.cs +++ b/Ix.NET/Source/System.Interactive.Async/Create.cs @@ -19,7 +19,7 @@ public static IAsyncEnumerable CreateEnumerable(Func> return new AnonymousAsyncEnumerable(getEnumerator); } - public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Action dispose) + public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Action dispose) { if (moveNext == null) throw new ArgumentNullException(nameof(moveNext)); @@ -29,10 +29,10 @@ public static IAsyncEnumerator CreateEnumerator(Func(moveNext, current, dispose); } - private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Action dispose) + private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Action dispose) { var self = new AnonymousAsyncIterator( - async ct => + async () => { var tcs = new TaskCompletionSource(); @@ -42,11 +42,8 @@ private static IAsyncEnumerator CreateEnumerator(Func : AsyncIterator { private readonly Func currentFunc; private readonly Action dispose; - private readonly Func> moveNext; + private readonly Func> moveNext; - public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Action dispose) + public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Action dispose) { Debug.Assert(moveNext != null); @@ -102,7 +99,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -111,7 +108,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await moveNext(cancellationToken).ConfigureAwait(false)) + if (await moveNext().ConfigureAwait(false)) { current = currentFunc(); return true; diff --git a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs index 16603a0b4d..79ef1babca 100644 --- a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs @@ -59,7 +59,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index 7d1b96dee0..543f215965 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -172,7 +172,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -285,7 +285,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -375,7 +375,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -446,7 +446,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/Do.cs index 9dfede700f..284d5d9c67 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/Do.cs @@ -110,7 +110,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Interactive.Async/Except.cs index d6b06ef7aa..fc68cef81e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Except.cs +++ b/Ix.NET/Source/System.Interactive.Async/Except.cs @@ -75,7 +75,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -83,7 +83,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT firstEnumerator = first.GetAsyncEnumerator(); set = new Set(comparer); setFilled = false; - fillSetTask = FillSet(cancellationToken); + fillSetTask = FillSet(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -127,9 +127,9 @@ await Task.WhenAll(moveNextTask, fillSetTask) return false; } - private async Task FillSet(CancellationToken cancellationToken) + private async Task FillSet() { - var array = await second.ToArray(cancellationToken) + var array = await second.ToArray() .ConfigureAwait(false); foreach (var t in array) { diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index 618cda5ff0..9a66ed1a67 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -57,7 +57,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/Finally.cs index 6bf5c4176f..08c78d60cb 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/Finally.cs @@ -55,7 +55,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Generate.cs b/Ix.NET/Source/System.Interactive.Async/Generate.cs index 3d2b8809a5..e1a15686bf 100644 --- a/Ix.NET/Source/System.Interactive.Async/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Generate.cs @@ -58,7 +58,7 @@ public override void Dispose() base.Dispose(); } - protected override Task MoveNextCore(CancellationToken cancellationToken) + protected override Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Interactive.Async/Grouping.cs index 8ddad54129..d014fd3c3b 100644 --- a/Ix.NET/Source/System.Interactive.Async/Grouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/Grouping.cs @@ -159,12 +159,12 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); enumerator = lookup.ApplyResultSelector(resultSelector).GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -185,13 +185,13 @@ protected override async Task MoveNextCore(CancellationToken cancellationT public async Task ToArrayAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); return l.ToArray(resultSelector); } public async Task> ToListAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); return l.ToList(resultSelector); } @@ -202,7 +202,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); return l.Count; } @@ -248,12 +248,12 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); enumerator = lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -274,13 +274,13 @@ protected override async Task MoveNextCore(CancellationToken cancellationT public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -291,7 +291,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); return l.Count; } @@ -333,12 +333,12 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); enumerator = lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -359,13 +359,13 @@ protected override async Task MoveNextCore(CancellationToken cancellationT public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -376,7 +376,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); return l.Count; } diff --git a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs index ab83d470a1..9066040e28 100644 --- a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs @@ -47,7 +47,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Interactive.Async/Intersect.cs index b4cc01385b..e45f19de45 100644 --- a/Ix.NET/Source/System.Interactive.Async/Intersect.cs +++ b/Ix.NET/Source/System.Interactive.Async/Intersect.cs @@ -76,7 +76,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -84,7 +84,7 @@ protected override async Task MoveNextCore(CancellationToken cancellationT firstEnumerator = first.GetAsyncEnumerator(); set = new Set(comparer); setFilled = false; - fillSetTask = FillSet(cancellationToken); + fillSetTask = FillSet(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -127,9 +127,9 @@ await Task.WhenAll(moveNextTask, fillSetTask) return false; } - private async Task FillSet(CancellationToken cancellationToken) + private async Task FillSet() { - var array = await second.ToArray(cancellationToken) + var array = await second.ToArray() .ConfigureAwait(false); for (var i = 0; i < array.Length; i++) { diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index c3f52d3d0a..6311f49229 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -102,7 +102,7 @@ public override void Dispose() const int State_For = 3; const int State_While = 4; - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Lookup.cs b/Ix.NET/Source/System.Interactive.Async/Lookup.cs index e36d92fcac..a507c1602a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Lookup.cs +++ b/Ix.NET/Source/System.Interactive.Async/Lookup.cs @@ -74,7 +74,7 @@ public static async Task> ToLookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken) + var lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer) .ConfigureAwait(false); return lookup; @@ -189,7 +189,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -209,7 +209,7 @@ internal static async Task> CreateAsync(IAsyncEn return lookup; } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { Debug.Assert(source != null); Debug.Assert(keySelector != null); diff --git a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs index 417c8ca7e1..e897c0e28a 100644 --- a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs @@ -80,7 +80,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs index 635dcdc532..4bd764ccd2 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs @@ -19,7 +19,7 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere return new OrderedAsyncEnumerable(source, keySelector, comparer, descending, this); } - internal abstract Task Initialize(CancellationToken cancellationToken); + internal abstract Task Initialize(); } internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnumerable @@ -67,13 +67,13 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { case AsyncEnumerable.AsyncIteratorState.Allocated: - await Initialize(cancellationToken) + await Initialize() .ConfigureAwait(false); enumerator = enumerable.GetEnumerator(); @@ -94,18 +94,18 @@ await Initialize(cancellationToken) return false; } - internal override async Task Initialize(CancellationToken cancellationToken) + internal override async Task Initialize() { if (parent == null) { - var buffer = await source.ToList(cancellationToken) + var buffer = await source.ToList() .ConfigureAwait(false); enumerable = (!@descending ? buffer.OrderBy(keySelector, comparer) : buffer.OrderByDescending(keySelector, comparer)); } else { parentEnumerator = parent.GetAsyncEnumerator(); - await parent.Initialize(cancellationToken) + await parent.Initialize() .ConfigureAwait(false); enumerable = parent.enumerable.CreateOrderedEnumerable(keySelector, comparer, @descending); } diff --git a/Ix.NET/Source/System.Interactive.Async/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/Repeat.cs index 6c8dbcbe72..8f49eaf1c4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/Repeat.cs @@ -57,7 +57,7 @@ public override AsyncIterator Clone() return new RepeatElementAsyncIterator(element); } - protected override Task MoveNextCore(CancellationToken cancellationToken) + protected override Task MoveNextCore() { current = element; return TaskExt.True; @@ -99,7 +99,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Reverse.cs b/Ix.NET/Source/System.Interactive.Async/Reverse.cs index 170eee2dac..c4653b18f5 100644 --- a/Ix.NET/Source/System.Interactive.Async/Reverse.cs +++ b/Ix.NET/Source/System.Interactive.Async/Reverse.cs @@ -90,12 +90,12 @@ public override void Dispose() } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { case AsyncIteratorState.Allocated: - items = await source.ToArray(cancellationToken) + items = await source.ToArray() .ConfigureAwait(false); index = items.Length - 1; diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index d3adc2e1a9..a3ff48cd21 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -67,7 +67,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -133,7 +133,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Interactive.Async/Select.cs index db10ac7096..7d4b2658d3 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Interactive.Async/Select.cs @@ -83,7 +83,7 @@ public override IAsyncEnumerable Select(Func(source, CombineSelectors(this.selector, selector)); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -140,7 +140,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -206,7 +206,7 @@ public override IAsyncEnumerable Select(Func(source, CombineSelectors(this.selector, selector)); } - protected override Task MoveNextCore(CancellationToken cancellationToken) + protected override Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index 0a79a6c6a4..4afba2a48d 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -109,7 +109,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -204,7 +204,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -301,7 +301,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -399,7 +399,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Skip.cs b/Ix.NET/Source/System.Interactive.Async/Skip.cs index 4d1a3a01aa..e61469f4b8 100644 --- a/Ix.NET/Source/System.Interactive.Async/Skip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Skip.cs @@ -105,7 +105,7 @@ public override void Dispose() } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -175,7 +175,7 @@ public override void Dispose() } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -241,7 +241,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -318,7 +318,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index 58f2f76f7a..3fe32a5d77 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -91,7 +91,7 @@ public override void Dispose() } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -153,7 +153,7 @@ public override void Dispose() } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -244,7 +244,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -309,7 +309,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs index 95ade54126..9643f2855f 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs @@ -105,7 +105,7 @@ public override void Dispose() base.Dispose(); } - protected override Task MoveNextCore(CancellationToken cancellationToken) + protected override Task MoveNextCore() { switch (state) { @@ -174,7 +174,7 @@ public override void Dispose() base.Dispose(); } - protected override Task MoveNextCore(CancellationToken cancellationToken) + protected override Task MoveNextCore() { switch (state) { @@ -276,7 +276,7 @@ public override void Dispose() base.Dispose(); } - protected override Task MoveNextCore(CancellationToken cancellationToken) + protected override Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs index 6631e6c08b..eb123521cb 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs @@ -24,7 +24,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva var subscription = source.Subscribe(observer); return CreateEnumerator( - (ct, tcs) => + tcs => { var hasValue = false; var hasCompleted = false; diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/Using.cs index 76a99c42ee..ba38c17a82 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/Using.cs @@ -61,7 +61,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Interactive.Async/Where.cs index 28a6e36831..2255b3b8cd 100644 --- a/Ix.NET/Source/System.Interactive.Async/Where.cs +++ b/Ix.NET/Source/System.Interactive.Async/Where.cs @@ -83,7 +83,7 @@ public override IAsyncEnumerable Where(Func predicate) return new WhereEnumerableAsyncIterator(source, CombinePredicates(this.predicate, predicate)); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -144,7 +144,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { @@ -218,7 +218,7 @@ public override IAsyncEnumerable Select(Func(source, predicate, CombineSelectors(this.selector, selector)); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Interactive.Async/Zip.cs index 928d96db7f..4219302a2c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Zip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Zip.cs @@ -64,7 +64,7 @@ public override void Dispose() base.Dispose(); } - protected override async Task MoveNextCore(CancellationToken cancellationToken) + protected override async Task MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs index 3f1c23aac5..10470add7b 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs @@ -451,7 +451,7 @@ public void ToObservable_disposes_enumerator_on_completion() var ae = AsyncEnumerable.CreateEnumerable( () => AsyncEnumerable.CreateEnumerator( - ct => Task.FromResult(false), + () => Task.FromResult(false), () => { throw new InvalidOperationException(); }, () => { evt.Set(); })); @@ -485,7 +485,7 @@ public void ToObservable_disposes_enumerator_when_subscription_is_disposed() var ae = AsyncEnumerable.CreateEnumerable( () => AsyncEnumerable.CreateEnumerator( - async ct => + async () => { await subscriptionAssignedTcs.Task; return true; @@ -527,7 +527,7 @@ public void ToObservable_does_not_call_MoveNext_again_when_subscription_is_dispo var ae = AsyncEnumerable.CreateEnumerable( () => AsyncEnumerable.CreateEnumerator( - async ct => + async () => { await subscriptionAssignedTcs.Task; diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index 90e2e6fc78..cbdc41bffe 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -27,7 +27,7 @@ public void Create_Null() public void Create_Iterator_Throws() { - var iter = AsyncEnumerable.CreateEnumerator(c => Task.FromResult(true), () => 3, () => { }); + var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => { }); var enu = (IAsyncEnumerable)iter; From 1f4c74bee7bd52022abc0b07398543a06c75ec26 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 16:29:07 -0700 Subject: [PATCH 012/862] Honoring cancellation in aggregates. --- .../System.Interactive.Async/Aggregate.cs | 4 +- .../Source/System.Interactive.Async/AnyAll.cs | 6 +-- .../AsyncEnumerableHelpers.cs | 4 +- .../System.Interactive.Async/Average.cs | 40 +++++++++---------- .../System.Interactive.Async/ElementAt.cs | 4 +- .../Source/System.Interactive.Async/First.cs | 4 +- .../System.Interactive.Async/ForEach.cs | 2 +- .../Source/System.Interactive.Async/Last.cs | 4 +- .../Source/System.Interactive.Async/Single.cs | 8 ++-- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index 27dc638051..b6d23b27e6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -83,7 +83,7 @@ private static async Task Aggregate_(IAs using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { acc = accumulator(acc, e.Current); @@ -100,7 +100,7 @@ private static async Task Aggregate_(IAsyncEnumerable using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { acc = first ? e.Current : accumulator(acc, e.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs index d9f92bd51b..938ead9153 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs @@ -67,7 +67,7 @@ public static async Task Any(this IAsyncEnumerable sourc using (var e = source.GetAsyncEnumerator()) { - return await e.MoveNextAsync().ConfigureAwait(false); + return await e.MoveNextAsync(cancellationToken).ConfigureAwait(false); } } @@ -75,7 +75,7 @@ private static async Task All_(IAsyncEnumerable source, { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (!predicate(e.Current)) @@ -89,7 +89,7 @@ private static async Task Any_(IAsyncEnumerable source, { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (predicate(e.Current)) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs index 4572c6a83b..649e7099a5 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs @@ -45,7 +45,7 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer { using (var en = source.GetAsyncEnumerator()) { - if (await en.MoveNextAsync() + if (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { const int DefaultCapacity = 4; @@ -53,7 +53,7 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer arr[0] = en.Current; var count = 1; - while (await en.MoveNextAsync() + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (count == arr.Length) diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index 6afc3d6ca6..50c4154f12 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -385,7 +385,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync() + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -395,7 +395,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -411,7 +411,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -421,7 +421,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -445,7 +445,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync() + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -455,7 +455,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -471,7 +471,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -481,7 +481,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -505,7 +505,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync() + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -513,7 +513,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc var sum = e.Current; long count = 1; - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -531,7 +531,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -541,7 +541,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc long count = 1; checked { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -565,7 +565,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync() + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -573,7 +573,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel double sum = e.Current; long count = 1; - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -588,7 +588,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -598,7 +598,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; @@ -622,7 +622,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync() + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -630,7 +630,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca var sum = e.Current; long count = 1; - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { sum += e.Current; @@ -645,7 +645,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var v = e.Current; @@ -653,7 +653,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca { var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { v = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index 197a3ce85d..ae75595478 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -60,7 +60,7 @@ private static async Task ElementAt_(IAsyncEnumerable { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (index == 0) @@ -82,7 +82,7 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable { using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { if (index == 0) diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index 40459e0051..242b520940 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -96,7 +96,7 @@ private static async Task First_(IAsyncEnumerable sou using (var e = source.GetAsyncEnumerator()) { - if (await e.MoveNextAsync() + if (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { return e.Current; @@ -115,7 +115,7 @@ private static async Task FirstOrDefault_(IAsyncEnumerable(IAsyncEnumerable sourc var index = 0; using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { action(e.Current, checked(index++)); diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index 5de7832971..6ffc5043df 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -102,7 +102,7 @@ private static async Task Last_(IAsyncEnumerable sour using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { hasLast = true; @@ -130,7 +130,7 @@ private static async Task LastOrDefault_(IAsyncEnumerable Single_(IAsyncEnumerable so using (var e = source.GetAsyncEnumerator()) { - if (!await e.MoveNextAsync() + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var result = e.Current; - if (await e.MoveNextAsync() + if (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); @@ -130,14 +130,14 @@ private static async Task SingleOrDefault_(IAsyncEnumerable Date: Wed, 30 Aug 2017 16:30:51 -0700 Subject: [PATCH 013/862] Renaming AsyncEnumeratorExtensions. --- Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index 53c6e46e33..28db7278a6 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -32,7 +32,7 @@ public interface IAsyncEnumerator : IDisposable /// /// Provides a set of extension methods for . /// - public static class AsyncEnumeratorExtensions + public static class AsyncEnumerator { /// /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. From 6ebcbef4131ba85e433ffcca4ebd4faacd0e63ce Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 16:32:13 -0700 Subject: [PATCH 014/862] Splitting types in different files. --- .../AsyncEnumerator.cs | 34 +++++++++++++++++++ .../IAsyncEnumerator.cs | 26 -------------- 2 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs new file mode 100644 index 0000000000..a5d919dff3 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using System.Threading.Tasks; + +namespace System.Collections.Generic +{ + /// + /// Provides a set of extension methods for . + /// + public static class AsyncEnumerator + { + /// + /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. + /// + /// The enumerator to advance. + /// Cancellation token that can be used to cancel the operation. + /// + /// Task containing the result of the operation: true if the enumerator was successfully advanced + /// to the next element; false if the enumerator has passed the end of the sequence. + /// + public static Task MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + cancellationToken.ThrowIfCancellationRequested(); + + return source.MoveNextAsync(); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index 28db7278a6..f70a5bdf48 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Threading; using System.Threading.Tasks; namespace System.Collections.Generic @@ -28,29 +27,4 @@ public interface IAsyncEnumerator : IDisposable /// Task MoveNextAsync(); } - - /// - /// Provides a set of extension methods for . - /// - public static class AsyncEnumerator - { - /// - /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. - /// - /// The enumerator to advance. - /// Cancellation token that can be used to cancel the operation. - /// - /// Task containing the result of the operation: true if the enumerator was successfully advanced - /// to the next element; false if the enumerator has passed the end of the sequence. - /// - public static Task MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - cancellationToken.ThrowIfCancellationRequested(); - - return source.MoveNextAsync(); - } - } } From 999cb82af650809d707f975cdc6b6f31ea857bf9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 16:39:58 -0700 Subject: [PATCH 015/862] Honoring cancellation for ToList and ToArray. --- .../System.Interactive.Async/AppendPrepend.cs | 8 ++++---- .../System.Interactive.Async/Concatenate.cs | 2 +- .../Source/System.Interactive.Async/Distinct.cs | 4 ++-- .../Source/System.Interactive.Async/Grouping.cs | 16 ++++++++-------- Ix.NET/Source/System.Interactive.Async/Lookup.cs | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index fd31704b70..0ea1ad2cde 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -203,7 +203,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio { using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync() + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { array[index] = en.Current; @@ -233,7 +233,7 @@ public override async Task> ToListAsync(CancellationToken cancella using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync() + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { list.Add(en.Current); @@ -437,7 +437,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio { using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync() + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { array[index] = en.Current; @@ -467,7 +467,7 @@ public override async Task> ToListAsync(CancellationToken cancella using (var en = source.GetAsyncEnumerator()) { - while (await en.MoveNextAsync() + while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { list.Add(en.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs index 0a9ecb0f1c..1c84dc3347 100644 --- a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs @@ -193,7 +193,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken } using (var e = source.GetAsyncEnumerator()) { - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { list.Add(e.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index 543f215965..9389bd3c37 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -217,7 +217,7 @@ private async Task> FillSet(CancellationToken cancellationToken) var r = new List(); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync() + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var item = enu.Current; @@ -329,7 +329,7 @@ private async Task> FillSet(CancellationToken cancellationToken) var s = new Set(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync() + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { s.Add(enu.Current); diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Interactive.Async/Grouping.cs index d014fd3c3b..062e078e66 100644 --- a/Ix.NET/Source/System.Interactive.Async/Grouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/Grouping.cs @@ -185,13 +185,13 @@ protected override async Task MoveNextCore() public async Task ToArrayAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return l.ToArray(resultSelector); } public async Task> ToListAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return l.ToList(resultSelector); } @@ -202,7 +202,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -274,13 +274,13 @@ protected override async Task MoveNextCore() public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -291,7 +291,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -359,13 +359,13 @@ protected override async Task MoveNextCore() public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/Lookup.cs b/Ix.NET/Source/System.Interactive.Async/Lookup.cs index a507c1602a..b0fc4cbdd9 100644 --- a/Ix.NET/Source/System.Interactive.Async/Lookup.cs +++ b/Ix.NET/Source/System.Interactive.Async/Lookup.cs @@ -189,7 +189,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -198,7 +198,7 @@ internal static async Task> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync() + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { lookup.GetGrouping(keySelector(enu.Current), create: true) @@ -209,7 +209,7 @@ internal static async Task> CreateAsync(IAsyncEn return lookup; } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -217,7 +217,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); using (var enu = source.GetAsyncEnumerator()) { - while (await enu.MoveNextAsync() + while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { lookup.GetGrouping(keySelector(enu.Current), create: true) From 2659fb7e97b38df6cd30d8bda5a0c39eedf49944 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 17:48:08 -0700 Subject: [PATCH 016/862] Switch to IAsyncDisposable. --- .../System.Interactive.Async/Aggregate.cs | 17 +++- .../Source/System.Interactive.Async/AnyAll.cs | 26 +++++- .../System.Interactive.Async/AppendPrepend.cs | 62 +++++++++----- .../AsyncEnumerableHelpers.cs | 8 +- .../System.Interactive.Async/AsyncIterator.cs | 10 ++- .../System.Interactive.Async/Average.cs | 80 ++++++++++++++++--- .../Source/System.Interactive.Async/Buffer.cs | 10 +-- .../Source/System.Interactive.Async/Catch.cs | 27 ++++--- .../System.Interactive.Async/Concatenate.cs | 33 +++++--- .../Source/System.Interactive.Async/Create.cs | 19 +++-- .../DefaultIfEmpty.cs | 10 +-- .../System.Interactive.Async/Disposables.cs | 17 ++++ .../System.Interactive.Async/Distinct.cs | 63 ++++++++++----- Ix.NET/Source/System.Interactive.Async/Do.cs | 8 +- .../System.Interactive.Async/ElementAt.cs | 16 +++- .../Source/System.Interactive.Async/Except.cs | 10 +-- .../Source/System.Interactive.Async/Expand.cs | 16 ++-- .../System.Interactive.Async/Finally.cs | 8 +- .../Source/System.Interactive.Async/First.cs | 18 ++++- .../System.Interactive.Async/ForEach.cs | 9 ++- .../System.Interactive.Async/Generate.cs | 13 +-- .../System.Interactive.Async/GroupJoin.cs | 5 +- .../System.Interactive.Async/Grouping.cs | 18 ++--- .../IAsyncEnumerator.cs | 2 +- .../IgnoreElements.cs | 8 +- .../System.Interactive.Async/Intersect.cs | 8 +- .../Source/System.Interactive.Async/Join.cs | 8 +- .../Source/System.Interactive.Async/Last.cs | 18 ++++- .../Source/System.Interactive.Async/Lookup.cs | 27 ++++++- Ix.NET/Source/System.Interactive.Async/Min.cs | 8 +- .../OnErrorResumeNext.cs | 12 +-- .../OrderedAsyncEnumerable.cs | 8 +- .../Source/System.Interactive.Async/Repeat.cs | 10 +-- .../System.Interactive.Async/Reverse.cs | 6 +- .../Source/System.Interactive.Async/Scan.cs | 16 ++-- .../Source/System.Interactive.Async/Select.cs | 28 +++---- .../System.Interactive.Async/SelectMany.cs | 64 +++++++++------ .../System.Interactive.Async/SequenceEqual.cs | 34 +++++--- .../Source/System.Interactive.Async/Single.cs | 17 +++- .../Source/System.Interactive.Async/Skip.cs | 32 ++++---- .../Source/System.Interactive.Async/Take.cs | 34 ++++---- .../ToAsyncEnumerable.cs | 48 ++++++----- .../System.Interactive.Async/ToObservable.cs | 11 +-- .../Source/System.Interactive.Async/Using.cs | 8 +- .../Source/System.Interactive.Async/Where.cs | 24 +++--- Ix.NET/Source/System.Interactive.Async/Zip.cs | 10 +-- Ix.NET/Source/Tests/AsyncTests.Bugs.cs | 7 +- Ix.NET/Source/Tests/AsyncTests.Conversions.cs | 6 +- Ix.NET/Source/Tests/AsyncTests.Creation.cs | 20 ++--- Ix.NET/Source/Tests/AsyncTests.Exceptions.cs | 4 +- Ix.NET/Source/Tests/AsyncTests.Single.cs | 20 ++--- Ix.NET/Source/Tests/AsyncTests.cs | 4 +- 52 files changed, 659 insertions(+), 346 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index b6d23b27e6..54cfabb139 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -81,7 +81,9 @@ private static async Task Aggregate_(IAs { var acc = seed; - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -89,6 +91,10 @@ private static async Task Aggregate_(IAs acc = accumulator(acc, e.Current); } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } return resultSelector(acc); } @@ -98,7 +104,9 @@ private static async Task Aggregate_(IAsyncEnumerable var first = true; var acc = default(TSource); - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -107,6 +115,11 @@ private static async Task Aggregate_(IAsyncEnumerable first = false; } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + if (first) throw new InvalidOperationException(Strings.NO_ELEMENTS); return acc; diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs index 938ead9153..6670e8028f 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs @@ -65,15 +65,23 @@ public static async Task Any(this IAsyncEnumerable sourc if (source == null) throw new ArgumentNullException(nameof(source)); - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { return await e.MoveNextAsync(cancellationToken).ConfigureAwait(false); } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } private static async Task All_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -82,12 +90,19 @@ private static async Task All_(IAsyncEnumerable source, return false; } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + return true; } private static async Task Any_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -96,6 +111,11 @@ private static async Task Any_(IAsyncEnumerable source, return true; } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index 0ea1ad2cde..a09872393e 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -69,21 +69,24 @@ protected async Task LoadFromEnumerator() return true; } - enumerator?.Dispose(); - enumerator = null; + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } return false; } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } public abstract Task ToArrayAsync(CancellationToken cancellationToken); @@ -151,7 +154,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } @@ -201,7 +204,9 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } else { - using (var en = source.GetAsyncEnumerator()) + var en = source.GetAsyncEnumerator(); + + try { while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -210,6 +215,10 @@ public override async Task ToArrayAsync(CancellationToken cancellatio ++index; } } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } } if (appending) @@ -231,7 +240,9 @@ public override async Task> ToListAsync(CancellationToken cancella } - using (var en = source.GetAsyncEnumerator()) + var en = source.GetAsyncEnumerator(); + + try { while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -239,6 +250,10 @@ public override async Task> ToListAsync(CancellationToken cancella list.Add(en.Current); } } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } if (appending) { @@ -330,7 +345,7 @@ public override AsyncIterator Clone() int mode; IEnumerator appendedEnumerator; - public override void Dispose() + public override async Task DisposeAsync() { if (appendedEnumerator != null) { @@ -338,7 +353,7 @@ public override void Dispose() appendedEnumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -399,7 +414,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } @@ -435,7 +450,9 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } else { - using (var en = source.GetAsyncEnumerator()) + var en = source.GetAsyncEnumerator(); + + try { while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -444,6 +461,10 @@ public override async Task ToArrayAsync(CancellationToken cancellatio ++index; } } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } } index = array.Length; @@ -465,7 +486,9 @@ public override async Task> ToListAsync(CancellationToken cancella list.Add(n.Item); } - using (var en = source.GetAsyncEnumerator()) + var en = source.GetAsyncEnumerator(); + + try { while (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -473,15 +496,18 @@ public override async Task> ToListAsync(CancellationToken cancella list.Add(en.Current); } } - - if (appended != null) + finally { + await en.DisposeAsync().ConfigureAwait(false); + } - using (var en = appended.GetEnumerator()) + if (appended != null) + { + using (var en2 = appended.GetEnumerator()) { - while (en.MoveNext()) + while (en2.MoveNext()) { - list.Add(en.Current); + list.Add(en2.Current); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs index 649e7099a5..854c89d2e0 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs @@ -43,7 +43,9 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer } else { - using (var en = source.GetAsyncEnumerator()) + var en = source.GetAsyncEnumerator(); + + try { if (await en.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -92,6 +94,10 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer return result; } } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } } result.length = 0; diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 12529f63ba..6e8843a530 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -10,6 +10,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { + private static readonly Task CompletedTask = Task.FromResult(true); // TODO: Change to Task.CompletedTask when all build targets allow. + internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator { private readonly int threadId; @@ -40,7 +42,7 @@ public IAsyncEnumerator GetAsyncEnumerator() } catch { - enumerator.Dispose(); + enumerator.DisposeAsync(); // REVIEW: fire-and-forget? throw; } @@ -48,7 +50,7 @@ public IAsyncEnumerator GetAsyncEnumerator() } - public virtual void Dispose() + public virtual Task DisposeAsync() { if (cancellationTokenSource != null) { @@ -61,6 +63,8 @@ public virtual void Dispose() current = default(TSource); state = AsyncIteratorState.Disposed; + + return CompletedTask; } public TSource Current @@ -96,7 +100,7 @@ public async Task MoveNextAsync() catch { currentIsInvalid = true; - Dispose(); + await DisposeAsync().ConfigureAwait(false); throw; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index 50c4154f12..684a6b33d1 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -383,7 +383,9 @@ public static Task Average(this IAsyncEnumerable sour private static async Task Average_(this IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -405,11 +407,17 @@ private static async Task Average_(this IAsyncEnumerable source, Ca return (double)sum/count; } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -437,13 +445,19 @@ private static async Task Average_(this IAsyncEnumerable source, Ca } } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } return null; } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -465,11 +479,17 @@ private static async Task Average_(IAsyncEnumerable source, Cancel return (double)sum/count; } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -497,13 +517,19 @@ private static async Task Average_(IAsyncEnumerable source, Cancel } } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } return null; } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -525,11 +551,17 @@ private static async Task Average_(IAsyncEnumerable source, Canc return sum/count; } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -557,13 +589,19 @@ private static async Task Average_(IAsyncEnumerable source, Canc } } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } return null; } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -582,11 +620,17 @@ private static async Task Average_(IAsyncEnumerable source, Cancel return (float)(sum/count); } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -614,13 +658,19 @@ private static async Task Average_(IAsyncEnumerable source, Cancel } } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } return null; } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -639,11 +689,17 @@ private static async Task Average_(IAsyncEnumerable source, Ca return sum/count; } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -668,6 +724,10 @@ private static async Task Average_(IAsyncEnumerable source, Ca } } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } return null; } diff --git a/Ix.NET/Source/System.Interactive.Async/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/Buffer.cs index a71fc303f4..838c5529c7 100644 --- a/Ix.NET/Source/System.Interactive.Async/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Buffer.cs @@ -58,17 +58,17 @@ public override AsyncIterator> Clone() return new BufferAsyncIterator(source, count, skip); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } buffers = null; - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -113,7 +113,7 @@ protected override async Task MoveNextCore() continue; // loop } stopped = true; - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; continue; // loop @@ -131,7 +131,7 @@ protected override async Task MoveNextCore() break; // case } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/Catch.cs index dc0e0da6e6..b35a1bd8ef 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/Catch.cs @@ -76,15 +76,15 @@ public override AsyncIterator Clone() return new CatchAsyncIterator(source, handler); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -119,7 +119,12 @@ protected override async Task MoveNextCore() // current behavior var err = handler(ex) .GetAsyncEnumerator(); - enumerator?.Dispose(); + + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + enumerator = err; isDone = true; continue; // loop so we hit the catch state @@ -139,7 +144,7 @@ protected override async Task MoveNextCore() break; // case } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -165,7 +170,7 @@ public override AsyncIterator Clone() return new CatchAsyncIterator(sources); } - public override void Dispose() + public override async Task DisposeAsync() { if (sourcesEnumerator != null) { @@ -175,13 +180,13 @@ public override void Dispose() if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } error = null; - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -222,7 +227,7 @@ protected override async Task MoveNextCore() catch (Exception ex) { // Done with the current one, go to the next - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; error = ExceptionDispatchInfo.Capture(ex); continue; @@ -233,8 +238,8 @@ protected override async Task MoveNextCore() break; // case } - - Dispose(); + + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs index 1c84dc3347..3260e2912e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs @@ -61,7 +61,7 @@ public override AsyncIterator Clone() return new ConcatEnumerableAsyncIterator(source); } - public override void Dispose() + public override async Task DisposeAsync() { if (outerEnumerator != null) { @@ -71,11 +71,11 @@ public override void Dispose() if (currentEnumerator != null) { - currentEnumerator.Dispose(); + await currentEnumerator.DisposeAsync().ConfigureAwait(false); currentEnumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } // State machine vars @@ -104,7 +104,11 @@ protected override async Task MoveNextCore() if (outerEnumerator.MoveNext()) { // make sure we dispose the previous one if we're about to replace it - currentEnumerator?.Dispose(); + if (currentEnumerator != null) + { + await currentEnumerator.DisposeAsync().ConfigureAwait(false); + } + currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); mode = State_While; @@ -125,7 +129,7 @@ protected override async Task MoveNextCore() } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } @@ -191,7 +195,10 @@ public async Task> ToListAsync(CancellationToken cancellationToken { break; } - using (var e = source.GetAsyncEnumerator()) + + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -199,6 +206,10 @@ public async Task> ToListAsync(CancellationToken cancellationToken list.Add(e.Current); } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } return list; @@ -229,15 +240,15 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return count; } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -265,12 +276,12 @@ protected override async Task MoveNextCore() var next = GetAsyncEnumerable(counter++ - 1); if (next != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = next.GetAsyncEnumerator(); continue; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Create.cs b/Ix.NET/Source/System.Interactive.Async/Create.cs index d2bd26ad69..ebd3ea6459 100644 --- a/Ix.NET/Source/System.Interactive.Async/Create.cs +++ b/Ix.NET/Source/System.Interactive.Async/Create.cs @@ -19,7 +19,7 @@ public static IAsyncEnumerable CreateEnumerable(Func> return new AnonymousAsyncEnumerable(getEnumerator); } - public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Action dispose) + public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Func dispose) { if (moveNext == null) throw new ArgumentNullException(nameof(moveNext)); @@ -29,7 +29,7 @@ public static IAsyncEnumerator CreateEnumerator(Func> moveNext, return new AnonymousAsyncIterator(moveNext, current, dispose); } - private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Action dispose) + private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Func dispose) { var self = new AnonymousAsyncIterator( async () => @@ -71,11 +71,11 @@ public IAsyncEnumerator GetAsyncEnumerator() private sealed class AnonymousAsyncIterator : AsyncIterator { private readonly Func currentFunc; - private readonly Action dispose; + private readonly Func dispose; private readonly Func> moveNext; - public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Action dispose) + public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) { Debug.Assert(moveNext != null); @@ -92,11 +92,14 @@ public override AsyncIterator Clone() throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator."); } - public override void Dispose() + public override async Task DisposeAsync() { - dispose?.Invoke(); + if (dispose != null) + { + await dispose().ConfigureAwait(false); + } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -114,7 +117,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs index 79ef1babca..e1df242281 100644 --- a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs @@ -48,15 +48,15 @@ public override AsyncIterator Clone() return new DefaultIfEmptyAsyncIterator(source, defaultValue); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -74,7 +74,7 @@ protected override async Task MoveNextCore() else { current = defaultValue; - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; state = AsyncIteratorState.Disposed; @@ -91,7 +91,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } diff --git a/Ix.NET/Source/System.Interactive.Async/Disposables.cs b/Ix.NET/Source/System.Interactive.Async/Disposables.cs index 90b8c2b1b0..79dcb144de 100644 --- a/Ix.NET/Source/System.Interactive.Async/Disposables.cs +++ b/Ix.NET/Source/System.Interactive.Async/Disposables.cs @@ -32,6 +32,11 @@ public static IDisposable Create(IDisposable d1, IDisposable d2) { return new BinaryDisposable(d1, d2); } + + public static IDisposable Create(Action action) + { + return new AnonymousDisposable(action); + } } class BinaryDisposable : IDisposable @@ -60,4 +65,16 @@ public void Dispose() } } } + + class AnonymousDisposable : IDisposable + { + private Action _action; + + public AnonymousDisposable(Action action) + { + _action = action; + } + + public void Dispose() => _action(); + } } diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index 9389bd3c37..06aa5e8d9c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -139,7 +139,10 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell var count = 0; var s = new Set(comparer); - using (var enu = source.GetAsyncEnumerator()) + + var enu = source.GetAsyncEnumerator(); + + try { while (await enu.MoveNextAsync() .ConfigureAwait(false)) @@ -151,6 +154,10 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } return count; } @@ -160,16 +167,16 @@ public override AsyncIterator Clone() return new DistinctAsyncIterator(source, keySelector, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; set = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -181,7 +188,7 @@ protected override async Task MoveNextCore() if (!await enumerator.MoveNextAsync() .ConfigureAwait(false)) { - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } @@ -207,7 +214,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } @@ -215,7 +222,10 @@ private async Task> FillSet(CancellationToken cancellationToken) { var s = new Set(comparer); var r = new List(); - using (var enu = source.GetAsyncEnumerator()) + + var enu = source.GetAsyncEnumerator(); + + try { while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -227,6 +237,10 @@ private async Task> FillSet(CancellationToken cancellationToken) } } } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } return r; } @@ -273,16 +287,16 @@ public override AsyncIterator Clone() return new DistinctAsyncIterator(source, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; set = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -294,7 +308,7 @@ protected override async Task MoveNextCore() if (!await enumerator.MoveNextAsync() .ConfigureAwait(false)) { - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } @@ -320,14 +334,17 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } private async Task> FillSet(CancellationToken cancellationToken) { var s = new Set(comparer); - using (var enu = source.GetAsyncEnumerator()) + + var enu = source.GetAsyncEnumerator(); + + try { while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -335,6 +352,10 @@ private async Task> FillSet(CancellationToken cancellationToken) s.Add(enu.Current); } } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } return s; } @@ -363,16 +384,16 @@ public override AsyncIterator Clone() return new DistinctUntilChangedAsyncIterator(source, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; currentValue = default(TSource); } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -407,7 +428,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -434,16 +455,16 @@ public override AsyncIterator Clone() return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; currentKeyValue = default(TKey); } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -479,7 +500,7 @@ protected override async Task MoveNextCore() break; // case } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/Do.cs index 284d5d9c67..777d998a73 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/Do.cs @@ -99,15 +99,15 @@ public override AsyncIterator Clone() return new DoAsyncIterator(source, onNext, onError, onCompleted); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -143,7 +143,7 @@ protected override async Task MoveNextCore() onCompleted?.Invoke(); - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index ae75595478..7b7ee9d3e9 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -58,7 +58,9 @@ private static async Task ElementAt_(IAsyncEnumerable if (index >= 0) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -71,6 +73,10 @@ private static async Task ElementAt_(IAsyncEnumerable index--; } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } throw new ArgumentOutOfRangeException(nameof(index)); @@ -80,7 +86,9 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable { if (index >= 0) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -93,6 +101,10 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable index--; } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } return default(TSource); diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Interactive.Async/Except.cs index fc68cef81e..55366cef71 100644 --- a/Ix.NET/Source/System.Interactive.Async/Except.cs +++ b/Ix.NET/Source/System.Interactive.Async/Except.cs @@ -62,17 +62,17 @@ public override AsyncIterator Clone() return new ExceptAsyncIterator(first, second, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (firstEnumerator != null) { - firstEnumerator.Dispose(); + await firstEnumerator.DisposeAsync().ConfigureAwait(false); firstEnumerator = null; } set = null; - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -118,9 +118,9 @@ await Task.WhenAll(moveNextTask, fillSetTask) } } while (moveNext); - - Dispose(); + + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index 9a66ed1a67..5e0d85e67f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -44,17 +44,17 @@ public override AsyncIterator Clone() return new ExpandAsyncIterator(source, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } queue = null; - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -77,7 +77,11 @@ protected override async Task MoveNextCore() { var src = queue.Dequeue(); - enumerator?.Dispose(); + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + enumerator = src.GetAsyncEnumerator(); continue; // loop @@ -95,14 +99,14 @@ protected override async Task MoveNextCore() current = item; return true; } - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } break; // case } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/Finally.cs index 08c78d60cb..3933054c11 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/Finally.cs @@ -42,17 +42,17 @@ public override AsyncIterator Clone() return new FinallyAsyncIterator(source, finallyAction); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; finallyAction(); } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -72,7 +72,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index 242b520940..36023dacb8 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -94,7 +94,9 @@ private static async Task First_(IAsyncEnumerable sou return list[0]; } - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -102,6 +104,11 @@ private static async Task First_(IAsyncEnumerable sou return e.Current; } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + throw new InvalidOperationException(Strings.NO_ELEMENTS); } @@ -113,7 +120,9 @@ private static async Task FirstOrDefault_(IAsyncEnumerable FirstOrDefault_(IAsyncEnumerable(this IAsyncEnumerable source, private static async Task ForEachAsync_(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { var index = 0; - using (var e = source.GetAsyncEnumerator()) + + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -106,6 +109,10 @@ private static async Task ForEachAsync_(IAsyncEnumerable sourc action(e.Current, checked(index++)); } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/Generate.cs b/Ix.NET/Source/System.Interactive.Async/Generate.cs index e1a15686bf..f6918f40e8 100644 --- a/Ix.NET/Source/System.Interactive.Async/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Generate.cs @@ -51,14 +51,14 @@ public override AsyncIterator Clone() return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); } - public override void Dispose() + public override async Task DisposeAsync() { currentState = default(TState); - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } - protected override Task MoveNextCore() + protected override async Task MoveNextCore() { switch (state) { @@ -80,13 +80,14 @@ protected override Task MoveNextCore() if (condition(currentState)) { current = resultSelector(currentState); - return TaskExt.True; + return true; } break; } - Dispose(); - return TaskExt.False; + await DisposeAsync().ConfigureAwait(false); + + return false; } } } diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs index 4212469ba1..8ccf7eaab2 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs @@ -133,10 +133,7 @@ public async Task MoveNextAsync() public TResult Current { get; private set; } - public void Dispose() - { - _outer.Dispose(); - } + public Task DisposeAsync() => _outer.DisposeAsync(); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Interactive.Async/Grouping.cs index 062e078e66..3b2ef3fae8 100644 --- a/Ix.NET/Source/System.Interactive.Async/Grouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/Grouping.cs @@ -147,7 +147,7 @@ public override AsyncIterator Clone() return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { @@ -156,7 +156,7 @@ public override void Dispose() lookup = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -176,7 +176,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } @@ -236,7 +236,7 @@ public override AsyncIterator> Clone() return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { @@ -245,7 +245,7 @@ public override void Dispose() lookup = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -265,7 +265,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } @@ -321,7 +321,7 @@ public override AsyncIterator> Clone() { return new GroupedAsyncEnumerable(source, keySelector, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { @@ -330,7 +330,7 @@ public override void Dispose() lookup = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -350,7 +350,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index f70a5bdf48..c69e31413d 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -11,7 +11,7 @@ namespace System.Collections.Generic /// retrieved asynchronously. /// /// Element type. - public interface IAsyncEnumerator : IDisposable + public interface IAsyncEnumerator : IAsyncDisposable { /// /// Gets the current element in the iteration. diff --git a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs index 9066040e28..52c41a6a77 100644 --- a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs @@ -36,15 +36,15 @@ public override AsyncIterator Clone() return new IgnoreElementsAsyncIterator(source); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -66,7 +66,7 @@ protected override async Task MoveNextCore() break; // case } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Interactive.Async/Intersect.cs index e45f19de45..2ed30f0165 100644 --- a/Ix.NET/Source/System.Interactive.Async/Intersect.cs +++ b/Ix.NET/Source/System.Interactive.Async/Intersect.cs @@ -63,17 +63,17 @@ public override AsyncIterator Clone() return new IntersectAsyncIterator(first, second, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (firstEnumerator != null) { - firstEnumerator.Dispose(); + await firstEnumerator.DisposeAsync().ConfigureAwait(false); firstEnumerator = null; } set = null; - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -120,7 +120,7 @@ await Task.WhenAll(moveNextTask, fillSetTask) } } while (moveNext); - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index 6311f49229..feb3ddb329 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -78,15 +78,15 @@ public override AsyncIterator Clone() return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } - public override void Dispose() + public override async Task DisposeAsync() { if (outerEnumerator != null) { - outerEnumerator.Dispose(); + await outerEnumerator.DisposeAsync().ConfigureAwait(false); outerEnumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } // State machine vars @@ -165,7 +165,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index 6ffc5043df..fd3b07778f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -100,7 +100,9 @@ private static async Task Last_(IAsyncEnumerable sour } } - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -109,6 +111,11 @@ private static async Task Last_(IAsyncEnumerable sour last = e.Current; } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + if (!hasLast) throw new InvalidOperationException(Strings.NO_ELEMENTS); return last; @@ -128,7 +135,9 @@ private static async Task LastOrDefault_(IAsyncEnumerable LastOrDefault_(IAsyncEnumerable ApplyResultSelector(Func(comparer); - using (var enu = source.GetAsyncEnumerator()) + + var enu = source.GetAsyncEnumerator(); + + try { while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -205,6 +208,10 @@ public IEnumerable ApplyResultSelector(Func ApplyResultSelector(Func(comparer); - using (var enu = source.GetAsyncEnumerator()) + + var enu = source.GetAsyncEnumerator(); + + try { while (await enu.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -224,6 +234,10 @@ public IEnumerable ApplyResultSelector(Func ApplyResultSelector(Func> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { var lookup = new Lookup(comparer); - using (var enu = source.GetAsyncEnumerator()) + + var enu = source.GetAsyncEnumerator(); + + try { while (await enu.MoveNextAsync() .ConfigureAwait(false)) @@ -244,6 +261,10 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum } } } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } return lookup; } diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 67da0d1e78..b3f18dd681 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -493,7 +493,9 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (!await e.MoveNextAsync() .ConfigureAwait(false)) @@ -524,6 +526,10 @@ private static async Task> ExtremaBy(IAsyncEnumera } } } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } return result; } diff --git a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs index e897c0e28a..6be099630a 100644 --- a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs @@ -63,7 +63,7 @@ public override AsyncIterator Clone() return new OnErrorResumeNextAsyncIterator(sources); } - public override void Dispose() + public override async Task DisposeAsync() { if (sourcesEnumerator != null) { @@ -73,11 +73,11 @@ public override void Dispose() if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -118,15 +118,15 @@ protected override async Task MoveNextCore() } // Done with the current one, go to the next - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } break; // case } - - Dispose(); + + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs index 4bd764ccd2..fda3a1c29d 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs @@ -51,7 +51,7 @@ public override AsyncEnumerable.AsyncIterator Clone() } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { @@ -61,10 +61,10 @@ public override void Dispose() if (parentEnumerator != null) { - parentEnumerator.Dispose(); + await parentEnumerator.DisposeAsync().ConfigureAwait(false); parentEnumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -87,7 +87,7 @@ await Initialize() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/Repeat.cs index 8f49eaf1c4..77fbd051a4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/Repeat.cs @@ -88,15 +88,15 @@ public override AsyncIterator Clone() return new RepeatSequenceAsyncIterator(source, count); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -107,7 +107,7 @@ protected override async Task MoveNextCore() if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } @@ -130,7 +130,7 @@ protected override async Task MoveNextCore() } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } diff --git a/Ix.NET/Source/System.Interactive.Async/Reverse.cs b/Ix.NET/Source/System.Interactive.Async/Reverse.cs index c4653b18f5..d4b36d9b14 100644 --- a/Ix.NET/Source/System.Interactive.Async/Reverse.cs +++ b/Ix.NET/Source/System.Interactive.Async/Reverse.cs @@ -83,10 +83,10 @@ public override AsyncIterator Clone() return new ReverseAsyncIterator(source); } - public override void Dispose() + public override async Task DisposeAsync() { items = null; // Just in case this ends up being long-lived, allow the memory to be reclaimed. - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } @@ -113,7 +113,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index a3ff48cd21..1b2a064347 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -55,16 +55,16 @@ public override AsyncIterator Clone() return new ScanAsyncEnumerable(source, seed, accumulator); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; accumulated = default(TAccumulate); } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -92,7 +92,7 @@ protected override async Task MoveNextCore() } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -121,16 +121,16 @@ public override AsyncIterator Clone() return new ScanAsyncEnumerable(source, accumulator); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; accumulated = default(TSource); } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -167,7 +167,7 @@ protected override async Task MoveNextCore() } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Interactive.Async/Select.cs index 7d4b2658d3..595a96fe72 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Interactive.Async/Select.cs @@ -67,15 +67,15 @@ public override AsyncIterator Clone() return new SelectEnumerableAsyncIterator(source, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } public override IAsyncEnumerable Select(Func selector) @@ -100,7 +100,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } @@ -129,15 +129,15 @@ public override AsyncIterator Clone() return new SelectEnumerableWithIndexAsyncIterator(source, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -162,7 +162,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } @@ -190,7 +190,7 @@ public override AsyncIterator Clone() return new SelectIListIterator(source, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { @@ -198,7 +198,7 @@ public override void Dispose() enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } public override IAsyncEnumerable Select(Func selector) @@ -206,7 +206,7 @@ public override IAsyncEnumerable Select(Func(source, CombineSelectors(this.selector, selector)); } - protected override Task MoveNextCore() + protected override async Task MoveNextCore() { switch (state) { @@ -219,14 +219,14 @@ protected override Task MoveNextCore() if (enumerator.MoveNext()) { current = selector(enumerator.Current); - return Task.FromResult(true); + return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } - return Task.FromResult(false); + return false; } } } diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index 4afba2a48d..9193f272c3 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -92,21 +92,21 @@ public override AsyncIterator Clone() return new SelectManyAsyncIterator(source, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (sourceEnumerator != null) { - sourceEnumerator.Dispose(); + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); sourceEnumerator = null; } if (resultEnumerator != null) { - resultEnumerator.Dispose(); + await resultEnumerator.DisposeAsync().ConfigureAwait(false); resultEnumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -126,7 +126,11 @@ protected override async Task MoveNextCore() if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { - resultEnumerator?.Dispose(); + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + resultEnumerator = selector(sourceEnumerator.Current) .GetAsyncEnumerator(); @@ -150,7 +154,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -185,23 +189,23 @@ public override AsyncIterator Clone() return new SelectManyAsyncIterator(source, collectionSelector, resultSelector); } - public override void Dispose() + public override async Task DisposeAsync() { if (sourceEnumerator != null) { - sourceEnumerator.Dispose(); + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); sourceEnumerator = null; } if (resultEnumerator != null) { - resultEnumerator.Dispose(); + await resultEnumerator.DisposeAsync().ConfigureAwait(false); resultEnumerator = null; } currentSource = default(TSource); - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -221,7 +225,11 @@ protected override async Task MoveNextCore() if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { - resultEnumerator?.Dispose(); + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + currentSource = sourceEnumerator.Current; resultEnumerator = collectionSelector(currentSource) .GetAsyncEnumerator(); @@ -246,7 +254,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -282,23 +290,23 @@ public override AsyncIterator Clone() return new SelectManyWithIndexAsyncIterator(source, collectionSelector, resultSelector); } - public override void Dispose() + public override async Task DisposeAsync() { if (sourceEnumerator != null) { - sourceEnumerator.Dispose(); + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); sourceEnumerator = null; } if (resultEnumerator != null) { - resultEnumerator.Dispose(); + await resultEnumerator.DisposeAsync().ConfigureAwait(false); resultEnumerator = null; } currentSource = default(TSource); - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -319,7 +327,11 @@ protected override async Task MoveNextCore() if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { - resultEnumerator?.Dispose(); + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + currentSource = sourceEnumerator.Current; checked @@ -350,7 +362,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -382,21 +394,21 @@ public override AsyncIterator Clone() return new SelectManyWithIndexAsyncIterator(source, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (sourceEnumerator != null) { - sourceEnumerator.Dispose(); + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); sourceEnumerator = null; } if (resultEnumerator != null) { - resultEnumerator.Dispose(); + await resultEnumerator.DisposeAsync().ConfigureAwait(false); resultEnumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -417,7 +429,11 @@ protected override async Task MoveNextCore() if (await sourceEnumerator.MoveNextAsync() .ConfigureAwait(false)) { - resultEnumerator?.Dispose(); + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + checked { index++; @@ -445,7 +461,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs index 1f89f0fd58..865d801ea0 100644 --- a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs +++ b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs @@ -68,21 +68,35 @@ private static async Task SequenceEqual_(IAsyncEnumerable Single_(IAsyncEnumerable so throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) @@ -114,6 +116,10 @@ private static async Task Single_(IAsyncEnumerable so } return result; } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } private static async Task SingleOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -128,7 +134,9 @@ private static async Task SingleOrDefault_(IAsyncEnumerable SingleOrDefault_(IAsyncEnumerable Clone() return new SkipAsyncIterator(source, count); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } @@ -136,7 +136,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -162,16 +162,16 @@ public override AsyncIterator Clone() return new SkipLastAsyncIterator(source, count); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } queue = null; // release the memory - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } @@ -203,7 +203,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -230,15 +230,15 @@ public override AsyncIterator Clone() return new SkipWhileAsyncIterator(source, predicate); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -279,7 +279,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -307,15 +307,15 @@ public override AsyncIterator Clone() return new SkipWhileWithIndexAsyncIterator(source, predicate); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -362,7 +362,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index 3fe32a5d77..57de7b0281 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -79,15 +79,15 @@ public override AsyncIterator Clone() return new TakeAsyncIterator(source, count); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } @@ -113,7 +113,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -140,16 +140,16 @@ public override AsyncIterator Clone() return new TakeLastAsyncIterator(source, count); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } queue = null; // release the memory - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } @@ -188,7 +188,7 @@ protected override async Task MoveNextCore() { isDone = true; // Dispose early here as we can - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } @@ -207,7 +207,7 @@ protected override async Task MoveNextCore() break; // case } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -233,15 +233,15 @@ public override AsyncIterator Clone() return new TakeWhileAsyncIterator(source, predicate); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -271,7 +271,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -298,15 +298,15 @@ public override AsyncIterator Clone() return new TakeWhileWithIndexAsyncIterator(source, predicate); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -341,7 +341,7 @@ protected override async Task MoveNextCore() break; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); return false; } } diff --git a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs index 9643f2855f..e3eefafc03 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs @@ -49,7 +49,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task value, - () => { }); + () => TaskExt.True); }); } @@ -63,7 +63,9 @@ public static IEnumerable ToEnumerable(this IAsyncEnumerable ToEnumerable_(IAsyncEnumerable source) { - using (var e = source.GetAsyncEnumerator()) + var e = source.GetAsyncEnumerator(); + + try { while (true) { @@ -74,6 +76,10 @@ private static IEnumerable ToEnumerable_(IAsyncEnumerable : AsyncIterator, IIListProvider @@ -94,7 +100,7 @@ public override AsyncIterator Clone() return new AsyncEnumerableAdapter(source); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { @@ -102,10 +108,10 @@ public override void Dispose() enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } - protected override Task MoveNextCore() + protected override async Task MoveNextCore() { switch (state) { @@ -118,14 +124,14 @@ protected override Task MoveNextCore() if (enumerator.MoveNext()) { current = enumerator.Current; - return Task.FromResult(true); + return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } - - return Task.FromResult(false); + + return false; } // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize @@ -163,7 +169,7 @@ public override AsyncIterator Clone() return new AsyncIListEnumerableAdapter(source); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { @@ -171,10 +177,10 @@ public override void Dispose() enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } - protected override Task MoveNextCore() + protected override async Task MoveNextCore() { switch (state) { @@ -187,14 +193,14 @@ protected override Task MoveNextCore() if (enumerator.MoveNext()) { current = enumerator.Current; - return Task.FromResult(true); + return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } - return Task.FromResult(false); + return false; } public override IAsyncEnumerable Select(Func selector) @@ -266,17 +272,17 @@ public override AsyncIterator Clone() return new AsyncICollectionEnumerableAdapter(source); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { enumerator.Dispose(); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } - protected override Task MoveNextCore() + protected override async Task MoveNextCore() { switch (state) { @@ -288,12 +294,12 @@ protected override Task MoveNextCore() if (enumerator.MoveNext()) { current = enumerator.Current; - return Task.FromResult(true); + return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } - return Task.FromResult(false); + return false; } // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize diff --git a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs index eb123521cb..9d82b1e695 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs @@ -71,6 +71,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva { subscription.Dispose(); // Should we cancel in-flight operations somehow? + return TaskExt.True; }); }); } @@ -186,16 +187,16 @@ public IDisposable Subscribe(IObserver observer) var f = default(Action); f = () => e.MoveNextAsync() - .ContinueWith(t => + .ContinueWith(async t => { if (t.IsFaulted) { observer.OnError(t.Exception); - e.Dispose(); + await e.DisposeAsync().ConfigureAwait(false); } else if (t.IsCanceled) { - e.Dispose(); + await e.DisposeAsync().ConfigureAwait(false); } else if (t.IsCompleted) { @@ -213,14 +214,14 @@ public IDisposable Subscribe(IObserver observer) else { observer.OnCompleted(); - e.Dispose(); + await e.DisposeAsync().ConfigureAwait(false); } } }, ctd.Token); f(); - return Disposable.Create(ctd, e); + return Disposable.Create(ctd, Disposable.Create(() => { e.DisposeAsync(); /* REVIEW: fire-and-forget? */ })); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/Using.cs index ba38c17a82..63635f9f1f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/Using.cs @@ -44,11 +44,11 @@ public override AsyncIterator Clone() return new UsingAsyncIterator(resourceFactory, enumerableFactory); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } @@ -58,7 +58,7 @@ public override void Dispose() resource = default(TResource); } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -78,7 +78,7 @@ protected override async Task MoveNextCore() return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Interactive.Async/Where.cs index 2255b3b8cd..5e88902160 100644 --- a/Ix.NET/Source/System.Interactive.Async/Where.cs +++ b/Ix.NET/Source/System.Interactive.Async/Where.cs @@ -63,14 +63,14 @@ public override AsyncIterator Clone() return new WhereEnumerableAsyncIterator(source, predicate); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } public override IAsyncEnumerable Select(Func selector) @@ -104,7 +104,7 @@ protected override async Task MoveNextCore() } } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } @@ -134,14 +134,14 @@ public override AsyncIterator Clone() return new WhereEnumerableWithIndexAsyncIterator(source, predicate); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -170,7 +170,7 @@ protected override async Task MoveNextCore() } } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } @@ -202,15 +202,15 @@ public override AsyncIterator Clone() return new WhereSelectEnumerableAsyncIterator(source, predicate, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (enumerator != null) { - enumerator.Dispose(); + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } public override IAsyncEnumerable Select(Func selector) @@ -239,7 +239,7 @@ protected override async Task MoveNextCore() } } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Interactive.Async/Zip.cs index 4219302a2c..97ab741ac2 100644 --- a/Ix.NET/Source/System.Interactive.Async/Zip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Zip.cs @@ -48,20 +48,20 @@ public override AsyncIterator Clone() return new ZipAsyncIterator(first, second, selector); } - public override void Dispose() + public override async Task DisposeAsync() { if (firstEnumerator != null) { - firstEnumerator.Dispose(); + await firstEnumerator.DisposeAsync().ConfigureAwait(false); firstEnumerator = null; } if (secondEnumerator != null) { - secondEnumerator.Dispose(); + await secondEnumerator.DisposeAsync().ConfigureAwait(false); secondEnumerator = null; } - base.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); } protected override async Task MoveNextCore() @@ -89,7 +89,7 @@ await Task.WhenAll(ft, st) return true; } - Dispose(); + await DisposeAsync().ConfigureAwait(false); break; } diff --git a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs index 956451edf4..0fac06763e 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Bugs.cs @@ -114,7 +114,7 @@ public async void CorrectDispose() // We have to call move next because otherwise the internal enumerator is never allocated await e.MoveNextAsync(); - e.Dispose(); + await e.DisposeAsync(); await disposed.Task; @@ -212,9 +212,10 @@ public Enumerator(DisposeCounter disposeCounter) _disposeCounter = disposeCounter; } - public void Dispose() + public Task DisposeAsync() { _disposeCounter.DisposeCount++; + return Task.FromResult(true); } public Task MoveNextAsync() @@ -243,7 +244,7 @@ public static IAsyncEnumerable WithDispose(this IAsyncEnumerable source return AsyncEnumerable.CreateEnumerable(() => { var e = source.GetAsyncEnumerator(); - return AsyncEnumerable.CreateEnumerator(e.MoveNextAsync, () => e.Current, () => { e.Dispose(); a(); }); + return AsyncEnumerable.CreateEnumerator(e.MoveNextAsync, () => e.Current, async () => { await e.DisposeAsync(); a(); }); }); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs index 10470add7b..1c20417870 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Conversions.cs @@ -453,7 +453,7 @@ public void ToObservable_disposes_enumerator_on_completion() () => AsyncEnumerable.CreateEnumerator( () => Task.FromResult(false), () => { throw new InvalidOperationException(); }, - () => { evt.Set(); })); + () => { evt.Set(); return Task.FromResult(true); })); ae .ToObservable() @@ -491,7 +491,7 @@ public void ToObservable_disposes_enumerator_when_subscription_is_disposed() return true; }, () => 1, - () => { evt.Set(); })); + () => { evt.Set(); return Task.FromResult(true); })); subscription = ae .ToObservable() @@ -535,7 +535,7 @@ public void ToObservable_does_not_call_MoveNext_again_when_subscription_is_dispo return true; }, () => 1, - () => { evt.Set(); })); + () => { evt.Set(); return Task.FromResult(true); })); subscription = ae .ToObservable() diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index cbdc41bffe..9c648e2955 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -19,7 +19,7 @@ public partial class AsyncTests public void Create_Null() { AssertThrows(() => AsyncEnumerable.CreateEnumerable(null)); - AssertThrows(() => AsyncEnumerable.CreateEnumerator(null, () => 3, () => {})); + AssertThrows(() => AsyncEnumerable.CreateEnumerator(null, () => 3, () => Task.FromResult(true))); } @@ -27,7 +27,7 @@ public void Create_Null() public void Create_Iterator_Throws() { - var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => { }); + var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => Task.FromResult(true)); var enu = (IAsyncEnumerable)iter; @@ -43,14 +43,14 @@ public void Return() } [Fact] - public void Never() + public async Task Never() { var xs = AsyncEnumerable.Never(); var e = xs.GetAsyncEnumerator(); Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check AssertThrows(() => Nop(e.Current)); - e.Dispose(); + await e.DisposeAsync(); } [Fact] @@ -157,7 +157,7 @@ public void Repeat2() } [Fact] - public void Repeat3() + public async Task Repeat3() { var xs = AsyncEnumerable.Repeat(2); @@ -167,7 +167,7 @@ public void Repeat3() HasNext(e, 2); HasNext(e, 2); HasNext(e, 2); - e.Dispose(); + await e.DisposeAsync(); } [Fact] @@ -213,7 +213,7 @@ public void Generate_Null() } [Fact] - public void Generate1() + public async Task Generate1() { var xs = AsyncEnumerable.Generate(0, x => x < 5, x => x + 1, x => x * x); @@ -224,7 +224,7 @@ public void Generate1() HasNext(e, 9); HasNext(e, 16); NoNext(e); - e.Dispose(); + await e.DisposeAsync(); } [Fact] @@ -296,7 +296,7 @@ public void Using1() } [Fact] - public void Using2() + public async Task Using2() { var i = 0; var d = 0; @@ -315,7 +315,7 @@ public void Using2() var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); - e.Dispose(); + await e.DisposeAsync(); Assert.Equal(1, d); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs index fc237fd093..86dfc17667 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs @@ -377,7 +377,7 @@ public void Finally4() } [Fact] - public void Finally5() + public async Task Finally5() { var b = false; @@ -388,7 +388,7 @@ public void Finally5() Assert.False(b); HasNext(e, 1); - e.Dispose(); + await e.DisposeAsync(); Assert.True(b); } diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index f565e1dd08..29c7e27443 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -2299,7 +2299,7 @@ public void GroupBy15() } [Fact] - public void GroupBy16() + public async Task GroupBy16() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); @@ -2315,7 +2315,7 @@ public void GroupBy16() HasNext(g1e, 'g'); HasNext(g1e, 'j'); NoNext(g1e); - g1e.Dispose(); + await g1e.DisposeAsync(); Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; @@ -2325,7 +2325,7 @@ public void GroupBy16() HasNext(g2e, 'e'); HasNext(g2e, 'h'); NoNext(g2e); - g2e.Dispose(); + await g2e.DisposeAsync(); Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; @@ -2335,27 +2335,27 @@ public void GroupBy16() HasNext(g3e, 'f'); HasNext(g3e, 'i'); NoNext(g3e); - g3e.Dispose(); + await g3e.DisposeAsync(); NoNext(e); - e.Dispose(); + await e.DisposeAsync(); } [Fact] - public void GroupBy17() + public async Task GroupBy17() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); var e = ys.GetAsyncEnumerator(); - e.Dispose(); + await e.DisposeAsync(); Assert.False(e.MoveNextAsync().Result); } [Fact] - public void GroupBy18() + public async Task GroupBy18() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); @@ -2368,13 +2368,13 @@ public void GroupBy18() var g1e = g1.GetAsyncEnumerator(); HasNext(g1e, 'a'); - e.Dispose(); + await e.DisposeAsync(); HasNext(g1e, 'd'); HasNext(g1e, 'g'); HasNext(g1e, 'j'); NoNext(g1e); - g1e.Dispose(); + await g1e.DisposeAsync(); Assert.False(e.MoveNextAsync().Result); } diff --git a/Ix.NET/Source/Tests/AsyncTests.cs b/Ix.NET/Source/Tests/AsyncTests.cs index db86345485..643fa31f01 100644 --- a/Ix.NET/Source/Tests/AsyncTests.cs +++ b/Ix.NET/Source/Tests/AsyncTests.cs @@ -67,8 +67,8 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) Assert.Equal(en1.GetType(), en2.GetType()); - en1.Dispose(); - en2.Dispose(); + await en1.DisposeAsync(); + await en2.DisposeAsync(); var e1t = enumerable.ToList(); var e2t = enumerable.ToList(); From d5040a051a5f5e660b4e65febfc02360ad1f7d7b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 18:22:36 -0700 Subject: [PATCH 017/862] Async variants for Where and Select. --- .../System.Interactive.Async/AsyncIterator.cs | 10 + .../Source/System.Interactive.Async/Select.cs | 220 +++++++++++++++++- .../Source/System.Interactive.Async/Where.cs | 163 ++++++++++++- 3 files changed, 390 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 6e8843a530..ecc0929efd 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -112,11 +112,21 @@ public virtual IAsyncEnumerable Select(Func return new SelectEnumerableAsyncIterator(this, selector); } + public virtual IAsyncEnumerable Select(Func> selector) + { + return new SelectEnumerableAsyncIteratorWithTask(this, selector); + } + public virtual IAsyncEnumerable Where(Func predicate) { return new WhereEnumerableAsyncIterator(this, predicate); } + public virtual IAsyncEnumerable Where(Func> predicate) + { + return new WhereEnumerableAsyncIteratorWithTask(this, predicate); + } + protected abstract Task MoveNextCore(); protected virtual void OnGetEnumerator() diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Interactive.Async/Select.cs index 595a96fe72..bd4b3afc30 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Interactive.Async/Select.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -41,11 +40,46 @@ public static IAsyncEnumerable Select(this IAsyncEnum return new SelectEnumerableWithIndexAsyncIterator(source, selector); } + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + if (source is AsyncIterator iterator) + { + return iterator.Select(selector); + } + + if (source is IList ilist) + { + return new SelectIListIteratorWithTask(ilist, selector); + } + + return new SelectEnumerableAsyncIteratorWithTask(source, selector); + } + + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return new SelectEnumerableWithIndexAsyncIteratorWithTask(source, selector); + } + private static Func CombineSelectors(Func selector1, Func selector2) { return x => selector2(selector1(x)); } + private static Func> CombineSelectors(Func> selector1, Func> selector2) + { + return async x => await selector2(await selector1(x).ConfigureAwait(false)).ConfigureAwait(false); + } + internal sealed class SelectEnumerableAsyncIterator : AsyncIterator { private readonly Func selector; @@ -229,5 +263,189 @@ protected override async Task MoveNextCore() return false; } } + + internal sealed class SelectEnumerableAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> selector; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + + public SelectEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + this.source = source; + this.selector = selector; + } + + public override AsyncIterator Clone() + { + return new SelectEnumerableAsyncIteratorWithTask(source, selector); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + public override IAsyncEnumerable Select(Func> selector) + { + return new SelectEnumerableAsyncIteratorWithTask(source, CombineSelectors(this.selector, selector)); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + current = await selector(enumerator.Current).ConfigureAwait(false); + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } + + internal sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> selector; + private readonly IAsyncEnumerable source; + private IAsyncEnumerator enumerator; + private int index; + + public SelectEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + this.source = source; + this.selector = selector; + } + + public override AsyncIterator Clone() + { + return new SelectEnumerableWithIndexAsyncIteratorWithTask(source, selector); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + checked + { + index++; + } + current = await selector(enumerator.Current, index).ConfigureAwait(false); + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } + + internal sealed class SelectIListIteratorWithTask : AsyncIterator + { + private readonly Func> selector; + private readonly IList source; + private IEnumerator enumerator; + + public SelectIListIteratorWithTask(IList source, Func> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + this.source = source; + this.selector = selector; + } + + public override AsyncIterator Clone() + { + return new SelectIListIteratorWithTask(source, selector); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + enumerator.Dispose(); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + public override IAsyncEnumerable Select(Func> selector) + { + return new SelectIListIteratorWithTask(source, CombineSelectors(this.selector, selector)); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (enumerator.MoveNext()) + { + current = await selector(enumerator.Current).ConfigureAwait(false); + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Interactive.Async/Where.cs index 5e88902160..447781f169 100644 --- a/Ix.NET/Source/System.Interactive.Async/Where.cs +++ b/Ix.NET/Source/System.Interactive.Async/Where.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -37,12 +36,42 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable(source, predicate); } - private static Func CombinePredicates(Func predicate1, Func predicate2) + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + if (source is AsyncIterator iterator) + { + return iterator.Where(predicate); + } + + // TODO: Can we add array/list optimizations here, does it make sense? + return new WhereEnumerableAsyncIteratorWithTask(source, predicate); + } + + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + return new WhereEnumerableWithIndexAsyncIteratorWithTask(source, predicate); + } + + private static Func CombinePredicates(Func predicate1, Func predicate2) { return x => predicate1(x) && predicate2(x); } + private static Func> CombinePredicates(Func> predicate1, Func> predicate2) + { + return async x => await predicate1(x).ConfigureAwait(false) && await predicate2(x).ConfigureAwait(false); + } + internal sealed class WhereEnumerableAsyncIterator : AsyncIterator { private readonly Func predicate; @@ -178,6 +207,136 @@ protected override async Task MoveNextCore() } } + internal sealed class WhereEnumerableAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + private IAsyncEnumerator enumerator; + + public WhereEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(source != null); + Debug.Assert(predicate != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new WhereEnumerableAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); + } + + public override IAsyncEnumerable Where(Func> predicate) + { + return new WhereEnumerableAsyncIteratorWithTask(source, CombinePredicates(this.predicate, predicate)); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + var item = enumerator.Current; + if (await predicate(item).ConfigureAwait(false)) + { + current = item; + return true; + } + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } + + internal sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private int index; + + public WhereEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(source != null); + Debug.Assert(predicate != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new WhereEnumerableWithIndexAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + checked + { + index++; + } + var item = enumerator.Current; + if (await predicate(item, index).ConfigureAwait(false)) + { + current = item; + return true; + } + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } + internal sealed class WhereSelectEnumerableAsyncIterator : AsyncIterator { private readonly Func predicate; From 24ab7ac3e572a75db629a149f02dc8f476088e9b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 18:25:39 -0700 Subject: [PATCH 018/862] Async variants for First, Last, and Single. --- .../Source/System.Interactive.Async/First.cs | 44 ++++++++++++++++++- .../Source/System.Interactive.Async/Last.cs | 44 ++++++++++++++++++- .../Source/System.Interactive.Async/Single.cs | 43 +++++++++++++++++- 3 files changed, 125 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index 36023dacb8..7d4886f087 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -30,6 +28,16 @@ public static Task First(this IAsyncEnumerable source return First(source, predicate, CancellationToken.None); } + public static Task First(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return First(source, predicate, CancellationToken.None); + } + public static Task First(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -49,6 +57,17 @@ public static Task First(this IAsyncEnumerable source .First(cancellationToken); } + public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .First(cancellationToken); + } + public static Task FirstOrDefault(this IAsyncEnumerable source) { if (source == null) @@ -67,6 +86,16 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return FirstOrDefault(source, predicate, CancellationToken.None); + } + public static Task FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -86,6 +115,17 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .FirstOrDefault(cancellationToken); + } + private static async Task First_(IAsyncEnumerable source, CancellationToken cancellationToken) { var list = source as IList; diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index fd3b07778f..e1e8e9a6d6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -30,6 +28,16 @@ public static Task Last(this IAsyncEnumerable source, return Last(source, predicate, CancellationToken.None); } + public static Task Last(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return Last(source, predicate, CancellationToken.None); + } + public static Task Last(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -49,6 +57,17 @@ public static Task Last(this IAsyncEnumerable source, .Last(cancellationToken); } + public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .Last(cancellationToken); + } + public static Task LastOrDefault(this IAsyncEnumerable source) { if (source == null) @@ -67,6 +86,16 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return LastOrDefault(source, predicate, CancellationToken.None); + } + public static Task LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -86,6 +115,17 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .LastOrDefault(cancellationToken); + } + private static async Task Last_(IAsyncEnumerable source, CancellationToken cancellationToken) { var last = default(TSource); diff --git a/Ix.NET/Source/System.Interactive.Async/Single.cs b/Ix.NET/Source/System.Interactive.Async/Single.cs index 6876b1ab21..12fea9709d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Single.cs +++ b/Ix.NET/Source/System.Interactive.Async/Single.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -30,6 +28,15 @@ public static Task Single(this IAsyncEnumerable sourc return Single(source, predicate, CancellationToken.None); } + public static Task Single(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return Single(source, predicate, CancellationToken.None); + } public static Task Single(this IAsyncEnumerable source, CancellationToken cancellationToken) { @@ -50,6 +57,17 @@ public static Task Single(this IAsyncEnumerable sourc .Single(cancellationToken); } + public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .Single(cancellationToken); + } + public static Task SingleOrDefault(this IAsyncEnumerable source) { if (source == null) @@ -68,6 +86,16 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return SingleOrDefault(source, predicate, CancellationToken.None); + } + public static Task SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -87,6 +115,17 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .SingleOrDefault(cancellationToken); + } + private static async Task Single_(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) From abcc4d0e94c608ca0cf01bde8d78c4905a9f3297 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 18:27:41 -0700 Subject: [PATCH 019/862] Async variant of Zip. --- Ix.NET/Source/System.Interactive.Async/Zip.cs | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Interactive.Async/Zip.cs index 97ab741ac2..a9b332a4c7 100644 --- a/Ix.NET/Source/System.Interactive.Async/Zip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Zip.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -23,6 +22,18 @@ public static IAsyncEnumerable Zip(this IAsyn return new ZipAsyncIterator(first, second, selector); } + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return new ZipAsyncIteratorWithTask(first, second, selector); + } + private sealed class ZipAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable first; @@ -96,5 +107,79 @@ await Task.WhenAll(ft, st) return false; } } + + private sealed class ZipAsyncIteratorWithTask : AsyncIterator + { + private readonly IAsyncEnumerable first; + private readonly IAsyncEnumerable second; + private readonly Func> selector; + + private IAsyncEnumerator firstEnumerator; + private IAsyncEnumerator secondEnumerator; + + public ZipAsyncIteratorWithTask(IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + { + Debug.Assert(first != null); + Debug.Assert(second != null); + Debug.Assert(selector != null); + + this.first = first; + this.second = second; + this.selector = selector; + } + + public override AsyncIterator Clone() + { + return new ZipAsyncIteratorWithTask(first, second, selector); + } + + public override async Task DisposeAsync() + { + if (firstEnumerator != null) + { + await firstEnumerator.DisposeAsync().ConfigureAwait(false); + firstEnumerator = null; + } + if (secondEnumerator != null) + { + await secondEnumerator.DisposeAsync().ConfigureAwait(false); + secondEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + firstEnumerator = first.GetAsyncEnumerator(); + secondEnumerator = second.GetAsyncEnumerator(); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + + // We kick these off and join so they can potentially run in parallel + var ft = firstEnumerator.MoveNextAsync(); + var st = secondEnumerator.MoveNextAsync(); + await Task.WhenAll(ft, st) + .ConfigureAwait(false); + + if (ft.Result && st.Result) + { + current = await selector(firstEnumerator.Current, secondEnumerator.Current).ConfigureAwait(false); + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } \ No newline at end of file From b64bd927cc80f2f53a19c23465e31d6509e13a5d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 18:29:26 -0700 Subject: [PATCH 020/862] Fixing some tests. --- Ix.NET/Source/Tests/AsyncTests.Aggregates.cs | 24 ++++++++++---------- Ix.NET/Source/Tests/AsyncTests.Multiple.cs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs index 8d57302668..8fe033025b 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs @@ -384,11 +384,11 @@ public async Task First_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.First(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -461,11 +461,11 @@ public async Task FirstOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -545,11 +545,11 @@ public async Task Last_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -622,11 +622,11 @@ public async Task LastOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -706,11 +706,11 @@ public async Task Single_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -797,11 +797,11 @@ public async Task SingleOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/Tests/AsyncTests.Multiple.cs index f346f14b8b..ad261a1185 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Multiple.cs @@ -217,7 +217,7 @@ public void Zip_Null() { AssertThrows(() => AsyncEnumerable.Zip(null, AsyncEnumerable.Return(42), (x, y) => x + y)); AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), null, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func))); } [Fact] From c89ae4f52e23751f2355c2993e751bd50ca67da4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 18:35:55 -0700 Subject: [PATCH 021/862] Async variants of TakeWhile and SkipWhile. --- .../Source/System.Interactive.Async/Skip.cs | 180 +++++++++++++++++- .../Source/System.Interactive.Async/Take.cs | 155 ++++++++++++++- Ix.NET/Source/Tests/AsyncTests.Single.cs | 8 +- 3 files changed, 337 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Skip.cs b/Ix.NET/Source/System.Interactive.Async/Skip.cs index 83b8a71d76..08d001710d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Skip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Skip.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -71,6 +70,26 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable return new SkipWhileWithIndexAsyncIterator(source, predicate); } + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new SkipWhileAsyncIteratorWithTask(source, predicate); + } + + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + private sealed class SkipAsyncIterator : AsyncIterator { private readonly int count; @@ -366,5 +385,164 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class SkipWhileAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private bool doMoveNext; + private IAsyncEnumerator enumerator; + + public SkipWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new SkipWhileAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + // skip elements as requested + while (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + var element = enumerator.Current; + if (!await predicate(element).ConfigureAwait(false)) + { + doMoveNext = false; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + break; + + case AsyncIteratorState.Iterating: + if (doMoveNext && await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + if (!doMoveNext) + { + current = enumerator.Current; + doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class SkipWhileWithIndexAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private bool doMoveNext; + private IAsyncEnumerator enumerator; + private int index; + + public SkipWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + + // skip elements as requested + while (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + checked + { + index++; + } + + var element = enumerator.Current; + if (!await predicate(element, index).ConfigureAwait(false)) + { + doMoveNext = false; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + break; + + case AsyncIteratorState.Iterating: + if (doMoveNext && await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + if (!doMoveNext) + { + current = enumerator.Current; + doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index 57de7b0281..24f2626078 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -57,6 +56,26 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable return new TakeWhileWithIndexAsyncIterator(source, predicate); } + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new TakeWhileAsyncIteratorWithTask(source, predicate); + } + + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + private sealed class TakeAsyncIterator : AsyncIterator { private readonly int count; @@ -345,5 +364,139 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class TakeWhileAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + + public TakeWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new TakeWhileAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + var item = enumerator.Current; + if (!await predicate(item).ConfigureAwait(false)) + { + break; + } + current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class TakeWhileWithIndexAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private int index; + + public TakeWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) + { + var item = enumerator.Current; + checked + { + index++; + } + + if (!await predicate(item, index).ConfigureAwait(false)) + { + break; + } + current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } } } \ No newline at end of file diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index 29c7e27443..dc87844b11 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -1006,7 +1006,7 @@ public void TakeWhile5() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => { throw ex; }); + var ys = xs.TakeWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -1053,7 +1053,7 @@ public void TakeWhile9() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i) => { throw ex; }); + var ys = xs.TakeWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -1215,7 +1215,7 @@ public void SkipWhile5() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => { throw ex; }); + var ys = xs.SkipWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -1262,7 +1262,7 @@ public void SkipWhile9() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i) => { throw ex; }); + var ys = xs.SkipWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); From f085fba7f30326d196ec66be38eb70df813bee76 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 18:39:37 -0700 Subject: [PATCH 022/862] Async variants of Any and All. --- .../Source/System.Interactive.Async/AnyAll.cs | 82 +++++++++++++++++++ Ix.NET/Source/Tests/AsyncTests.Aggregates.cs | 12 +-- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs index 6670e8028f..8357b3d014 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs @@ -22,6 +22,16 @@ public static Task All(this IAsyncEnumerable source, Fun return All(source, predicate, CancellationToken.None); } + public static Task All(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return All(source, predicate, CancellationToken.None); + } + public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) @@ -32,6 +42,16 @@ public static Task All(this IAsyncEnumerable source, Fun return All_(source, predicate, cancellationToken); } + public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return All_(source, predicate, cancellationToken); + } + public static Task Any(this IAsyncEnumerable source, Func predicate) { if (source == null) @@ -42,6 +62,16 @@ public static Task Any(this IAsyncEnumerable source, Fun return Any(source, predicate, CancellationToken.None); } + public static Task Any(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return Any(source, predicate, CancellationToken.None); + } + public static Task Any(this IAsyncEnumerable source) { if (source == null) @@ -60,6 +90,16 @@ public static Task Any(this IAsyncEnumerable source, Fun return Any_(source, predicate, cancellationToken); } + public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return Any_(source, predicate, cancellationToken); + } + public static async Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -98,6 +138,27 @@ private static async Task All_(IAsyncEnumerable source, return true; } + private static async Task All_(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken) + .ConfigureAwait(false)) + { + if (!await predicate(e.Current).ConfigureAwait(false)) + return false; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return true; + } + private static async Task Any_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -118,5 +179,26 @@ private static async Task Any_(IAsyncEnumerable source, return false; } + + private static async Task Any_(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken) + .ConfigureAwait(false)) + { + if (await predicate(e.Current).ConfigureAwait(false)) + return true; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return false; + } } } \ No newline at end of file diff --git a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs index 8fe033025b..d29338a204 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs @@ -230,10 +230,10 @@ public void LongCount3() public async Task All_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -262,7 +262,7 @@ public void All3() public void All4() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(x => { throw ex; }); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -271,11 +271,11 @@ public async Task Any_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -304,7 +304,7 @@ public void Any3() public void Any4() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(x => { throw ex; }); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } From 07c8d8c8cf780c1793233fb988a46c1364fc6ba0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 18:42:36 -0700 Subject: [PATCH 023/862] Async variants of Count and LongCount. --- .../Source/System.Interactive.Async/Count.cs | 42 +++++++++++++++++++ Ix.NET/Source/Tests/AsyncTests.Aggregates.cs | 12 +++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Count.cs b/Ix.NET/Source/System.Interactive.Async/Count.cs index 3945c41f3b..c277cf5817 100644 --- a/Ix.NET/Source/System.Interactive.Async/Count.cs +++ b/Ix.NET/Source/System.Interactive.Async/Count.cs @@ -41,6 +41,17 @@ public static Task Count(this IAsyncEnumerable source, Fu .Aggregate(0, (c, _) => checked(c + 1), cancellationToken); } + public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + } + public static Task Count(this IAsyncEnumerable source) { if (source == null) @@ -59,6 +70,16 @@ public static Task Count(this IAsyncEnumerable source, Fu return Count(source, predicate, CancellationToken.None); } + public static Task Count(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return Count(source, predicate, CancellationToken.None); + } + public static Task LongCount(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -78,6 +99,17 @@ public static Task LongCount(this IAsyncEnumerable sourc .Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); } + public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate) + .Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + } + public static Task LongCount(this IAsyncEnumerable source) { if (source == null) @@ -95,5 +127,15 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCount(source, predicate, CancellationToken.None); } + + public static Task LongCount(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return LongCount(source, predicate, CancellationToken.None); + } } } \ No newline at end of file diff --git a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs index d29338a204..e24ab42af2 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs @@ -159,11 +159,11 @@ public async Task Count_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -186,7 +186,7 @@ public void Count2() public void Count3() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => { throw ex; }); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -195,11 +195,11 @@ public async Task LongCount_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } [Fact] @@ -222,7 +222,7 @@ public void LongCount2() public void LongCount3() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => { throw ex; }); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } From f1106161c826db6c93076c0072b1a331552c543d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 19:51:39 -0700 Subject: [PATCH 024/862] Generating Sum operators. --- .../{Sum.cs => Sum.Generated.cs} | 213 ++++++++---------- .../System.Interactive.Async/Sum.Generated.tt | 78 +++++++ .../System.Interactive.Async.csproj | 27 +++ 3 files changed, 205 insertions(+), 113 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{Sum.cs => Sum.Generated.cs} (81%) create mode 100644 Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.cs b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs similarity index 81% rename from Ix.NET/Source/System.Interactive.Async/Sum.cs rename to Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs index 496bcd9757..eaaef23d93 100644 --- a/Ix.NET/Source/System.Interactive.Async/Sum.cs +++ b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -12,221 +10,220 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0, (x, y) => x + y, cancellationToken); + return source.Aggregate(0, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0L, (x, y) => x + y, cancellationToken); + return source.Aggregate(0, (x, y) => x + y, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Aggregate(0.0, (x, y) => x + y, cancellationToken); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Aggregate(0f, (x, y) => x + y, cancellationToken); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0m, (x, y) => x + y, cancellationToken); + return source.Aggregate(0L, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return source.Aggregate(0L, (x, y) => x + y, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Aggregate((long?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Aggregate((double?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((float?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return source.Aggregate(0.0f, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((decimal?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return source.Aggregate(0.0f, (x, y) => x + y, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Aggregate(0.0, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Aggregate(0.0, (x, y) => x + y, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Aggregate(0m, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Aggregate(0m, (x, y) => x + y, cancellationToken); } - - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return Sum(source, CancellationToken.None); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return Sum(source, CancellationToken.None); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return Sum(source, CancellationToken.None); + return source.Aggregate((int?)0, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return Sum(source, CancellationToken.None); + return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return Sum(source, CancellationToken.None); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return Sum(source, CancellationToken.None); + return source.Select(selector).Sum(cancellationToken); } public static Task Sum(this IAsyncEnumerable source) @@ -234,143 +231,133 @@ public static Task Sum(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Sum(source, CancellationToken.None); + return source.Aggregate((long?)0L, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return Sum(source, CancellationToken.None); + return source.Aggregate((long?)0L, (x, y) => x + y.GetValueOrDefault(), cancellationToken); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return Sum(source, CancellationToken.None); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return Sum(source, CancellationToken.None); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Aggregate((float?)0.0f, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Aggregate((float?)0.0f, (x, y) => x + y.GetValueOrDefault(), cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Aggregate((double?)0.0, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Aggregate((double?)0.0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Select(selector).Sum(CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Select(selector).Sum(cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Aggregate((decimal?)0m, (x, y) => x + y, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return Sum(source, selector, CancellationToken.None); + return source.Aggregate((decimal?)0m, (x, y) => x + y.GetValueOrDefault(), cancellationToken); } - - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Select(selector).Sum(CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -380,8 +367,8 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Sum(cancellationToken); + return source.Select(selector).Sum(cancellationToken); } + } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt new file mode 100644 index 0000000000..5bd8d88835 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt @@ -0,0 +1,78 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { +<# +var os = new[] +{ + new { type = "int", zero = "0" }, + new { type = "long", zero = "0L" }, + new { type = "float", zero = "0.0f" }, + new { type = "double", zero = "0.0" }, + new { type = "decimal", zero = "0m" }, + new { type = "int?", zero = "(int?)0" }, + new { type = "long?", zero = "(long?)0L" }, + new { type = "float?", zero = "(float?)0.0f" }, + new { type = "double?", zero = "(double?)0.0" }, + new { type = "decimal?", zero = "(decimal?)0m" }, +}; + +foreach (var o in os) +{ + var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; +#> + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(<#=o.zero#>, (x, y) => x + y, CancellationToken.None); + } + + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(<#=o.zero#>, (x, y) => x + y<#=n#>, cancellationToken); + } + + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + +<# +} +#> + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index ced5d50330..95938a7f03 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -11,4 +11,31 @@ + + + True + True + Sum.Generated.tt + + + + + + TextTemplatingFileGenerator + Sum.Generated.cs + + + + + + + + + + True + True + Sum.Generated.tt + + + From 807fdf34d8ffd8b1e6da0f28b313e0cf4bb9918b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 20:10:29 -0700 Subject: [PATCH 025/862] Generating Min and Max. --- Ix.NET/Source/System.Interactive.Async/Max.cs | 387 --------- Ix.NET/Source/System.Interactive.Async/Min.cs | 388 --------- .../MinMax.Generated.cs | 757 ++++++++++++++++++ .../MinMax.Generated.tt | 130 +++ .../System.Interactive.Async.csproj | 14 + 5 files changed, 901 insertions(+), 775 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Interactive.Async/Max.cs index 71f2051fe3..cb4ee91a90 100644 --- a/Ix.NET/Source/System.Interactive.Async/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/Max.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -22,119 +20,6 @@ public static Task Max(this IAsyncEnumerable source, return Max_(source, comparer, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Max, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Max, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Max, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Max, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Max, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(int?), NullableMax, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(long?), NullableMax, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(double?), NullableMax, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(float?), NullableMax, cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(decimal?), NullableMax, cancellationToken); - } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -144,116 +29,6 @@ public static Task Max(this IAsyncEnumerable source, return source.Aggregate((x, y) => comparer.Compare(x, y) >= 0 ? x : y, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Max(cancellationToken); - } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) @@ -265,55 +40,6 @@ public static Task Max(this IAsyncEnumerable .Max(cancellationToken); } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Max(source, CancellationToken.None); - } - public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -322,106 +48,6 @@ public static Task Max(this IAsyncEnumerable source) return Max(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Max(source, selector, CancellationToken.None); - } - public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) @@ -432,7 +58,6 @@ public static Task Max(this IAsyncEnumerable return Max(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, IComparer comparer) { if (source == null) @@ -492,17 +117,5 @@ private static async Task Max_(IAsyncEnumerable sourc return (await MaxBy(source, x => x, comparer, cancellationToken) .ConfigureAwait(false)).First(); } - - private static T? NullableMax(T? x, T? y) - where T : struct, IComparable - { - if (!x.HasValue) - return y; - if (!y.HasValue) - return x; - if (x.Value.CompareTo(y.Value) >= 0) - return x; - return y; - } } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index b3f18dd681..d1305c0df4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -12,16 +10,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) @@ -42,87 +30,6 @@ public static Task Min(this IAsyncEnumerable source, return Min_(source, comparer, cancellationToken); } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Min(source, CancellationToken.None); - } - public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -131,167 +38,6 @@ public static Task Min(this IAsyncEnumerable source) return Min(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Min, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Min, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Min, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Min, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(Math.Min, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(int?), NullableMin, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(long?), NullableMin, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(double?), NullableMin, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(float?), NullableMin, cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(default(decimal?), NullableMin, cancellationToken); - } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) @@ -301,106 +47,6 @@ public static Task Min(this IAsyncEnumerable source, return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - - public static Task Min(this IAsyncEnumerable source, IComparer comparer) { if (source == null) @@ -411,17 +57,6 @@ public static Task Min(this IAsyncEnumerable source, return source.Min(comparer, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Min(cancellationToken); - } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) @@ -433,17 +68,6 @@ public static Task Min(this IAsyncEnumerable .Min(cancellationToken); } - - public static Task Min(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Min(source, selector, CancellationToken.None); - } - public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) @@ -539,17 +163,5 @@ private static async Task Min_(IAsyncEnumerable sourc return (await MinBy(source, x => x, comparer, cancellationToken) .ConfigureAwait(false)).First(); } - - private static T? NullableMin(T? x, T? y) - where T : struct, IComparable - { - if (!x.HasValue) - return y; - if (!y.HasValue) - return x; - if (x.Value.CompareTo(y.Value) <= 0) - return x; - return y; - } } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs new file mode 100644 index 0000000000..3a18630e27 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs @@ -0,0 +1,757 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Max, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(int?), NullableMax, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(int?), NullableMax, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(long?), NullableMax, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(long?), NullableMax, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(float?), NullableMax, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(float?), NullableMax, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(double?), NullableMax, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(double?), NullableMax, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(decimal?), NullableMax, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(decimal?), NullableMax, cancellationToken); + } + + public static Task Max(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(Math.Min, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(int?), NullableMin, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(int?), NullableMin, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(long?), NullableMin, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(long?), NullableMin, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(float?), NullableMin, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(float?), NullableMin, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(double?), NullableMin, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(double?), NullableMin, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(decimal?), NullableMin, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(default(decimal?), NullableMin, cancellationToken); + } + + public static Task Min(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + + private static T? NullableMax(T? x, T? y) + where T : struct, IComparable + { + if (!x.HasValue) + return y; + if (!y.HasValue) + return x; + if (x.Value.CompareTo(y.Value) >= 0) + return x; + return y; + } + + private static T? NullableMin(T? x, T? y) + where T : struct, IComparable + { + if (!x.HasValue) + return y; + if (!y.HasValue) + return x; + if (x.Value.CompareTo(y.Value) <= 0) + return x; + return y; + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt new file mode 100644 index 0000000000..b9b9812eb1 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt @@ -0,0 +1,130 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { +<# +var ts = new[] +{ + "int", + "long", + "float", + "double", + "decimal", + "int?", + "long?", + "float?", + "double?", + "decimal?", +}; + +foreach (var m in new[] { "Max", "Min" }) +{ + foreach (var t in ts) + { + var n = t.EndsWith("?"); +#> + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +<# +if (n) +{ +#> + return source.Aggregate(default(<#=t#>), Nullable<#=m#>, CancellationToken.None); +<# +} +else +{ +#> + return source.Aggregate(Math.<#=m#>, CancellationToken.None); +<# +} +#> + } + + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +<# +if (n) +{ +#> + return source.Aggregate(default(<#=t#>), Nullable<#=m#>, cancellationToken); +<# +} +else +{ +#> + return source.Aggregate(Math.<#=m#>, cancellationToken); +<# +} +#> + } + + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).<#=m#>(CancellationToken.None); + } + + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).<#=m#>(cancellationToken); + } + +<# + } +} +#> + private static T? NullableMax(T? x, T? y) + where T : struct, IComparable + { + if (!x.HasValue) + return y; + if (!y.HasValue) + return x; + if (x.Value.CompareTo(y.Value) >= 0) + return x; + return y; + } + + private static T? NullableMin(T? x, T? y) + where T : struct, IComparable + { + if (!x.HasValue) + return y; + if (!y.HasValue) + return x; + if (x.Value.CompareTo(y.Value) <= 0) + return x; + return y; + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 95938a7f03..faeea51c97 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -12,6 +12,11 @@ + + True + True + MinMax.Generated.tt + True True @@ -20,6 +25,10 @@ + + TextTemplatingFileGenerator + MinMax.Generated.cs + TextTemplatingFileGenerator Sum.Generated.cs @@ -31,6 +40,11 @@ + + True + True + MinMax.Generated.tt + True True From 4f3a90ada145a9ba0acdca30773868c8657d82ee Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 20:23:16 -0700 Subject: [PATCH 026/862] Generating Average. --- .../Average.Generated.cs | 374 ++++++++++++++++++ .../Average.Generated.tt | 78 ++++ .../System.Interactive.Async/Average.cs | 369 ----------------- .../System.Interactive.Async.csproj | 14 + 4 files changed, 466 insertions(+), 369 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/Average.Generated.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/Average.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs b/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs new file mode 100644 index 0000000000..a0de1aeaa9 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs @@ -0,0 +1,374 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task Average(this IAsyncEnumerable source, Func selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt b/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt new file mode 100644 index 0000000000..131df5a92e --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt @@ -0,0 +1,78 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { +<# +var os = new[] +{ + new { type = "int", res = "double" }, + new { type = "long", res = "double" }, + new { type = "float", res = "float" }, + new { type = "double", res = "double" }, + new { type = "decimal", res = "decimal" }, + new { type = "int?", res = "double?" }, + new { type = "long?", res = "double?" }, + new { type = "float?", res = "float?" }, + new { type = "double?", res = "double?" }, + new { type = "decimal?", res = "decimal?" }, +}; + +foreach (var o in os) +{ + var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; +#> + public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, CancellationToken.None); + } + + public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return Average_(source, cancellationToken); + } + + public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + +<# +} +#> + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index 684a6b33d1..94c1083f5d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -12,375 +12,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average(source, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - public static Task Average(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return Average(source, selector, CancellationToken.None); - } - - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return Average_(source, cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Select(selector) - .Average(cancellationToken); - } - private static async Task Average_(this IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index faeea51c97..e00f5d2d33 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -12,6 +12,11 @@ + + True + True + Average.Generated.tt + True True @@ -25,6 +30,10 @@ + + TextTemplatingFileGenerator + Average.Generated.cs + TextTemplatingFileGenerator MinMax.Generated.cs @@ -40,6 +49,11 @@ + + True + True + Average.Generated.tt + True True From 8ec4b1ec2fe406950983da40522156f9cce46811 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 20:24:19 -0700 Subject: [PATCH 027/862] Some cleanup. --- Ix.NET/Source/System.Interactive.Async/Average.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index 94c1083f5d..bf7810854d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -363,4 +361,4 @@ private static async Task Average_(IAsyncEnumerable source, Ca return null; } } -} \ No newline at end of file +} From b7bc6a5a59581793897b185c49f947c686daf3e8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 20:28:02 -0700 Subject: [PATCH 028/862] Async variants of Average, Max, Min, and Sum. --- .../Average.Generated.cs | 200 +++++++++ .../Average.Generated.tt | 20 + .../MinMax.Generated.cs | 400 ++++++++++++++++++ .../MinMax.Generated.tt | 20 + .../System.Interactive.Async/Sum.Generated.cs | 200 +++++++++ .../System.Interactive.Async/Sum.Generated.tt | 20 + 6 files changed, 860 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs b/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs index a0de1aeaa9..c6f38525ef 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs @@ -46,6 +46,26 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -82,6 +102,26 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -118,6 +158,26 @@ public static Task Average(this IAsyncEnumerable source return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -154,6 +214,26 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -190,6 +270,26 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -226,6 +326,26 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -262,6 +382,26 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -298,6 +438,26 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -334,6 +494,26 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + public static Task Average(this IAsyncEnumerable source) { if (source == null) @@ -370,5 +550,25 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } + public static Task Average(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + } } diff --git a/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt b/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt index 131df5a92e..f7118ace8d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt @@ -71,6 +71,26 @@ foreach (var o in os) return source.Select(selector).Average(cancellationToken); } + public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(CancellationToken.None); + } + + public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Average(cancellationToken); + } + <# } #> diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs index 3a18630e27..1293f74c64 100644 --- a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs @@ -46,6 +46,26 @@ public static Task Max(this IAsyncEnumerable source, Func return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -82,6 +102,26 @@ public static Task Max(this IAsyncEnumerable source, Fun return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -118,6 +158,26 @@ public static Task Max(this IAsyncEnumerable source, Fu return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -154,6 +214,26 @@ public static Task Max(this IAsyncEnumerable source, F return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -190,6 +270,26 @@ public static Task Max(this IAsyncEnumerable source, return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -226,6 +326,26 @@ public static Task Max(this IAsyncEnumerable source, return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -262,6 +382,26 @@ public static Task Max(this IAsyncEnumerable source, return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -298,6 +438,26 @@ public static Task Max(this IAsyncEnumerable source, return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -334,6 +494,26 @@ public static Task Max(this IAsyncEnumerable source, return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Max(this IAsyncEnumerable source) { if (source == null) @@ -370,6 +550,26 @@ public static Task Max(this IAsyncEnumerable source, return source.Select(selector).Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Max(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -406,6 +606,26 @@ public static Task Min(this IAsyncEnumerable source, Func return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -442,6 +662,26 @@ public static Task Min(this IAsyncEnumerable source, Fun return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -478,6 +718,26 @@ public static Task Min(this IAsyncEnumerable source, Fu return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -514,6 +774,26 @@ public static Task Min(this IAsyncEnumerable source, F return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -550,6 +830,26 @@ public static Task Min(this IAsyncEnumerable source, return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -586,6 +886,26 @@ public static Task Min(this IAsyncEnumerable source, return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -622,6 +942,26 @@ public static Task Min(this IAsyncEnumerable source, return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -658,6 +998,26 @@ public static Task Min(this IAsyncEnumerable source, return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -694,6 +1054,26 @@ public static Task Min(this IAsyncEnumerable source, return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + public static Task Min(this IAsyncEnumerable source) { if (source == null) @@ -730,6 +1110,26 @@ public static Task Min(this IAsyncEnumerable source, return source.Select(selector).Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Min(cancellationToken); + } + private static T? NullableMax(T? x, T? y) where T : struct, IComparable { diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt index b9b9812eb1..ad96b2f51e 100644 --- a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt @@ -99,6 +99,26 @@ else return source.Select(selector).<#=m#>(cancellationToken); } + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).<#=m#>(CancellationToken.None); + } + + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).<#=m#>(cancellationToken); + } + <# } } diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs index eaaef23d93..b75885811a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs @@ -46,6 +46,26 @@ public static Task Sum(this IAsyncEnumerable source, Func return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -82,6 +102,26 @@ public static Task Sum(this IAsyncEnumerable source, Fun return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -118,6 +158,26 @@ public static Task Sum(this IAsyncEnumerable source, Fu return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -154,6 +214,26 @@ public static Task Sum(this IAsyncEnumerable source, F return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -190,6 +270,26 @@ public static Task Sum(this IAsyncEnumerable source, return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -226,6 +326,26 @@ public static Task Sum(this IAsyncEnumerable source, return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -262,6 +382,26 @@ public static Task Sum(this IAsyncEnumerable source, return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -298,6 +438,26 @@ public static Task Sum(this IAsyncEnumerable source, return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -334,6 +494,26 @@ public static Task Sum(this IAsyncEnumerable source, return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -370,5 +550,25 @@ public static Task Sum(this IAsyncEnumerable source, return source.Select(selector).Sum(cancellationToken); } + public static Task Sum(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + } } diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt index 5bd8d88835..505f0924c8 100644 --- a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt @@ -71,6 +71,26 @@ foreach (var o in os) return source.Select(selector).Sum(cancellationToken); } + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(CancellationToken.None); + } + + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector).Sum(cancellationToken); + } + <# } #> From 81751c57440934b2999df2dba4817cdbdfb12cd0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 20:29:43 -0700 Subject: [PATCH 029/862] Reordering members in Min and Max. --- Ix.NET/Source/System.Interactive.Async/Max.cs | 30 ++++++++-------- Ix.NET/Source/System.Interactive.Async/Min.cs | 34 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Interactive.Async/Max.cs index cb4ee91a90..31cc051f86 100644 --- a/Ix.NET/Source/System.Interactive.Async/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/Max.cs @@ -10,14 +10,12 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Max(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return Max_(source, comparer, cancellationToken); + return Max(source, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -29,23 +27,24 @@ public static Task Max(this IAsyncEnumerable source, return source.Aggregate((x, y) => comparer.Compare(x, y) >= 0 ? x : y, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.Select(selector) - .Max(cancellationToken); + return source.Max(comparer, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return Max(source, CancellationToken.None); + return Max_(source, comparer, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -58,14 +57,15 @@ public static Task Max(this IAsyncEnumerable return Max(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, IComparer comparer) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Max(comparer, CancellationToken.None); + return source.Select(selector) + .Max(cancellationToken); } public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index d1305c0df4..971ba967bc 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -10,51 +10,51 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - return Min(source, selector, CancellationToken.None); + return Min(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return Min_(source, comparer, cancellationToken); + var comparer = Comparer.Default; + return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return Min(source, CancellationToken.None); + return source.Min(comparer, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - var comparer = Comparer.Default; - return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken); + return Min_(source, comparer, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, IComparer comparer) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); - return source.Min(comparer, CancellationToken.None); + return Min(source, selector, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) From 4f3598df20ad4f947bdf75c7a0f10f704e47b22b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 20:30:55 -0700 Subject: [PATCH 030/862] More async variants for Min and Max. --- Ix.NET/Source/System.Interactive.Async/Max.cs | 21 +++++++++++++++++++ Ix.NET/Source/System.Interactive.Async/Min.cs | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Interactive.Async/Max.cs index 31cc051f86..c255e7e7a4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/Max.cs @@ -68,6 +68,27 @@ public static Task Max(this IAsyncEnumerable .Max(cancellationToken); } + public static Task Max(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return Max(source, selector, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector) + .Max(cancellationToken); + } + public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 971ba967bc..1048c2385c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -68,6 +68,27 @@ public static Task Min(this IAsyncEnumerable .Min(cancellationToken); } + public static Task Min(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return Min(source, selector, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Select(selector) + .Min(cancellationToken); + } + public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) From cca77b36348d64f1baa133c865866d9612312272 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 20:49:33 -0700 Subject: [PATCH 031/862] Supporting deep cancellation in ExtremaBy. --- Ix.NET/Source/System.Interactive.Async/Min.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 1048c2385c..52c32c9001 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -133,6 +133,11 @@ public static Task> MinBy(this IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); } + private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + return (await MinBy(source, x => x, comparer, cancellationToken) + .ConfigureAwait(false)).First(); + } private static async Task> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) { @@ -142,7 +147,7 @@ private static async Task> ExtremaBy(IAsyncEnumera try { - if (!await e.MoveNextAsync() + if (!await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); @@ -150,7 +155,7 @@ private static async Task> ExtremaBy(IAsyncEnumera var resKey = keySelector(current); result.Add(current); - while (await e.MoveNextAsync() + while (await e.MoveNextAsync(cancellationToken) .ConfigureAwait(false)) { var cur = e.Current; @@ -178,11 +183,5 @@ private static async Task> ExtremaBy(IAsyncEnumera return result; } - - private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - return (await MinBy(source, x => x, comparer, cancellationToken) - .ConfigureAwait(false)).First(); - } } } \ No newline at end of file From 47756a08d1bad2544baf5faa8f9cba3ad49b3f0f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:27:19 -0700 Subject: [PATCH 032/862] Fixing code generation for Sum. --- .../Source/System.Interactive.Async/Sum.Generated.cs | 10 +++++----- .../Source/System.Interactive.Async/Sum.Generated.tt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs index b75885811a..c65f159344 100644 --- a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs @@ -295,7 +295,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((int?)0, (x, y) => x + y, CancellationToken.None); + return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -351,7 +351,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((long?)0L, (x, y) => x + y, CancellationToken.None); + return source.Aggregate((long?)0L, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -407,7 +407,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((float?)0.0f, (x, y) => x + y, CancellationToken.None); + return source.Aggregate((float?)0.0f, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -463,7 +463,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((double?)0.0, (x, y) => x + y, CancellationToken.None); + return source.Aggregate((double?)0.0, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -519,7 +519,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((decimal?)0m, (x, y) => x + y, CancellationToken.None); + return source.Aggregate((decimal?)0m, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt index 505f0924c8..696afcd483 100644 --- a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt @@ -40,7 +40,7 @@ foreach (var o in os) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(<#=o.zero#>, (x, y) => x + y, CancellationToken.None); + return source.Aggregate(<#=o.zero#>, (x, y) => x + y<#=n#>, CancellationToken.None); } public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) From 8af963fe3236a3ab259eb37484bc5ed39b8ac9ab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:33:34 -0700 Subject: [PATCH 033/862] Some cleanup. --- .../System.Interactive.Async/SequenceEqual.cs | 18 +++++----------- .../System.Interactive.Async/ToObservable.cs | 4 +--- .../Source/System.Interactive.Async/Union.cs | 5 ++--- .../Source/System.Interactive.Async/Using.cs | 6 ++---- .../Source/System.Interactive.Async/Where.cs | 21 +++++++++---------- Ix.NET/Source/System.Interactive.Async/Zip.cs | 10 ++++----- 6 files changed, 25 insertions(+), 39 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs index 865d801ea0..590e690a06 100644 --- a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs +++ b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -60,12 +58,9 @@ public static Task SequenceEqual(this IAsyncEnumerable f private static async Task SequenceEqual_(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { - if (first is ICollection firstCol) + if (first is ICollection firstCol && second is ICollection secondCol && firstCol.Count != secondCol.Count) { - if (second is ICollection secondCol && firstCol.Count != secondCol.Count) - { - return false; - } + return false; } var e1 = first.GetAsyncEnumerator(); @@ -76,18 +71,15 @@ private static async Task SequenceEqual_(IAsyncEnumerable observer) } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Union.cs b/Ix.NET/Source/System.Interactive.Async/Union.cs index d0f777ce9c..5a02fba169 100644 --- a/Ix.NET/Source/System.Interactive.Async/Union.cs +++ b/Ix.NET/Source/System.Interactive.Async/Union.cs @@ -20,8 +20,7 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second) @@ -34,4 +33,4 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable.Default); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/Using.cs index 63635f9f1f..abd1b5f630 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/Using.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -71,8 +70,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -94,4 +92,4 @@ protected override void OnGetEnumerator() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Interactive.Async/Where.cs index 447781f169..13515106af 100644 --- a/Ix.NET/Source/System.Interactive.Async/Where.cs +++ b/Ix.NET/Source/System.Interactive.Async/Where.cs @@ -99,6 +99,7 @@ public override async Task DisposeAsync() await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } + await base.DisposeAsync().ConfigureAwait(false); } @@ -122,8 +123,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; if (predicate(item)) @@ -170,6 +170,7 @@ public override async Task DisposeAsync() await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } + await base.DisposeAsync().ConfigureAwait(false); } @@ -184,8 +185,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { @@ -234,6 +234,7 @@ public override async Task DisposeAsync() await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } + await base.DisposeAsync().ConfigureAwait(false); } @@ -252,8 +253,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; if (await predicate(item).ConfigureAwait(false)) @@ -300,6 +300,7 @@ public override async Task DisposeAsync() await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } + await base.DisposeAsync().ConfigureAwait(false); } @@ -314,8 +315,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { @@ -387,8 +387,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; if (predicate(item)) @@ -406,4 +405,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Interactive.Async/Zip.cs index a9b332a4c7..bc2110c56c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Zip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Zip.cs @@ -66,6 +66,7 @@ public override async Task DisposeAsync() await firstEnumerator.DisposeAsync().ConfigureAwait(false); firstEnumerator = null; } + if (secondEnumerator != null) { await secondEnumerator.DisposeAsync().ConfigureAwait(false); @@ -91,8 +92,7 @@ protected override async Task MoveNextCore() // We kick these off and join so they can potentially run in parallel var ft = firstEnumerator.MoveNextAsync(); var st = secondEnumerator.MoveNextAsync(); - await Task.WhenAll(ft, st) - .ConfigureAwait(false); + await Task.WhenAll(ft, st).ConfigureAwait(false); if (ft.Result && st.Result) { @@ -140,6 +140,7 @@ public override async Task DisposeAsync() await firstEnumerator.DisposeAsync().ConfigureAwait(false); firstEnumerator = null; } + if (secondEnumerator != null) { await secondEnumerator.DisposeAsync().ConfigureAwait(false); @@ -165,8 +166,7 @@ protected override async Task MoveNextCore() // We kick these off and join so they can potentially run in parallel var ft = firstEnumerator.MoveNextAsync(); var st = secondEnumerator.MoveNextAsync(); - await Task.WhenAll(ft, st) - .ConfigureAwait(false); + await Task.WhenAll(ft, st).ConfigureAwait(false); if (ft.Result && st.Result) { @@ -182,4 +182,4 @@ await Task.WhenAll(ft, st) } } } -} \ No newline at end of file +} From 930cfc6cd425f0505703d0bb5a0dd5c24928eced Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:34:09 -0700 Subject: [PATCH 034/862] Some code modernization. --- .../System.Interactive.Async/ToObservable.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs index 00e05d148d..1f4d181ea2 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs @@ -116,10 +116,7 @@ public void OnCompleted() } } - if (tcs != null) - { - tcs.TrySetResult(false); - } + tcs?.TrySetResult(false); } public void OnError(Exception error) @@ -137,10 +134,7 @@ public void OnError(Exception error) } } - if (tcs != null) - { - tcs.TrySetException(error); - } + tcs?.TrySetException(error); } public void OnNext(T value) @@ -162,10 +156,7 @@ public void OnNext(T value) } } - if (tcs != null) - { - tcs.TrySetResult(true); - } + tcs?.TrySetResult(true); } } From b313e4060fc99faa4e0ffee3aaa07452a2774010 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:48:14 -0700 Subject: [PATCH 035/862] Some more cosmetics. --- Ix.NET/Source/System.Interactive.Async/Max.cs | 11 ++--- Ix.NET/Source/System.Interactive.Async/Min.cs | 22 +++------ .../OnErrorResumeNext.cs | 11 ++--- .../System.Interactive.Async/OrderBy.cs | 2 +- .../OrderedAsyncEnumerable.cs | 13 ++--- .../Source/System.Interactive.Async/Range.cs | 8 +--- .../Source/System.Interactive.Async/Repeat.cs | 11 ++--- .../Source/System.Interactive.Async/Retry.cs | 11 ++--- .../System.Interactive.Async/Reverse.cs | 12 ++--- .../Source/System.Interactive.Async/Scan.cs | 6 +-- .../Source/System.Interactive.Async/Select.cs | 12 ++--- .../System.Interactive.Async/SelectMany.cs | 30 ++++-------- .../System.Interactive.Async/SequenceEqual.cs | 5 +- Ix.NET/Source/System.Interactive.Async/Set.cs | 5 +- .../Source/System.Interactive.Async/Single.cs | 30 +++++------- .../Source/System.Interactive.Async/Skip.cs | 48 +++++++++---------- .../System.Interactive.Async/StartsWith.cs | 8 +--- .../System.Interactive.Async/Strings.cs | 1 + .../Source/System.Interactive.Async/Take.cs | 26 +++++----- .../System.Interactive.Async/TaskExt.cs | 1 - .../ToAsyncEnumerable.cs | 9 +++- .../System.Interactive.Async/ToCollection.cs | 32 ++++++++----- 22 files changed, 130 insertions(+), 184 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Interactive.Async/Max.cs index c255e7e7a4..4c46d49a9a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/Max.cs @@ -64,8 +64,7 @@ public static Task Max(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Max(cancellationToken); + return source.Select(selector).Max(cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) @@ -85,8 +84,7 @@ public static Task Max(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Max(cancellationToken); + return source.Select(selector).Max(cancellationToken); } public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) @@ -135,8 +133,7 @@ public static Task> MaxBy(this IAsyncEnumerable Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { - return (await MaxBy(source, x => x, comparer, cancellationToken) - .ConfigureAwait(false)).First(); + return (await MaxBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 52c32c9001..2c2063c1dc 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -64,8 +64,7 @@ public static Task Min(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Min(cancellationToken); + return source.Select(selector).Min(cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) @@ -85,8 +84,7 @@ public static Task Min(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector) - .Min(cancellationToken); + return source.Select(selector).Min(cancellationToken); } public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) @@ -135,8 +133,7 @@ public static Task> MinBy(this IAsyncEnumerable Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { - return (await MinBy(source, x => x, comparer, cancellationToken) - .ConfigureAwait(false)).First(); + return (await MinBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); } private static async Task> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) @@ -147,16 +144,14 @@ private static async Task> ExtremaBy(IAsyncEnumera try { - if (!await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); var current = e.Current; var resKey = keySelector(current); result.Add(current); - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var cur = e.Current; var key = keySelector(cur); @@ -168,10 +163,7 @@ private static async Task> ExtremaBy(IAsyncEnumera } else if (cmp > 0) { - result = new List - { - cur - }; + result = new List { cur }; resKey = key; } } @@ -184,4 +176,4 @@ private static async Task> ExtremaBy(IAsyncEnumera return result; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs index 6be099630a..25da92868d 100644 --- a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs @@ -2,11 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -20,7 +17,7 @@ public static IAsyncEnumerable OnErrorResumeNext(this IAsyncEn if (second == null) throw new ArgumentNullException(nameof(second)); - return OnErrorResumeNext_(new[] {first, second}); + return OnErrorResumeNext_(new[] { first, second }); } public static IAsyncEnumerable OnErrorResumeNext(params IAsyncEnumerable[] sources) @@ -105,8 +102,7 @@ protected override async Task MoveNextCore() try { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -123,7 +119,6 @@ protected override async Task MoveNextCore() } break; // case - } await DisposeAsync().ConfigureAwait(false); @@ -131,4 +126,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs index 61357c9b6f..1ae7982518 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs @@ -96,4 +96,4 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer, true); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs index fda3a1c29d..0fec3175e7 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -64,6 +63,7 @@ public override async Task DisposeAsync() await parentEnumerator.DisposeAsync().ConfigureAwait(false); parentEnumerator = null; } + await base.DisposeAsync().ConfigureAwait(false); } @@ -73,8 +73,7 @@ protected override async Task MoveNextCore() { case AsyncEnumerable.AsyncIteratorState.Allocated: - await Initialize() - .ConfigureAwait(false); + await Initialize().ConfigureAwait(false); enumerator = enumerable.GetEnumerator(); state = AsyncEnumerable.AsyncIteratorState.Iterating; @@ -98,17 +97,15 @@ internal override async Task Initialize() { if (parent == null) { - var buffer = await source.ToList() - .ConfigureAwait(false); + var buffer = await source.ToList().ConfigureAwait(false); enumerable = (!@descending ? buffer.OrderBy(keySelector, comparer) : buffer.OrderByDescending(keySelector, comparer)); } else { parentEnumerator = parent.GetAsyncEnumerator(); - await parent.Initialize() - .ConfigureAwait(false); + await parent.Initialize().ConfigureAwait(false); enumerable = parent.enumerable.CreateOrderedEnumerable(keySelector, comparer, @descending); } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Range.cs b/Ix.NET/Source/System.Interactive.Async/Range.cs index 703b66ff8d..0edf304281 100644 --- a/Ix.NET/Source/System.Interactive.Async/Range.cs +++ b/Ix.NET/Source/System.Interactive.Async/Range.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -16,8 +13,7 @@ public static IAsyncEnumerable Range(int start, int count) if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - return Enumerable.Range(start, count) - .ToAsyncEnumerable(); + return Enumerable.Range(start, count).ToAsyncEnumerable(); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/Repeat.cs index 77fbd051a4..29ff1a7679 100644 --- a/Ix.NET/Source/System.Interactive.Async/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/Repeat.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -16,8 +15,7 @@ public static IAsyncEnumerable Repeat(TResult element, int cou if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - return Enumerable.Repeat(element, count) - .ToAsyncEnumerable(); + return Enumerable.Repeat(element, count).ToAsyncEnumerable(); } public static IAsyncEnumerable Repeat(TResult element) @@ -116,18 +114,17 @@ protected override async Task MoveNextCore() enumerator = source.GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; } goto case AsyncIteratorState.Allocated; - } await DisposeAsync().ConfigureAwait(false); @@ -136,4 +133,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Retry.cs b/Ix.NET/Source/System.Interactive.Async/Retry.cs index 64a4f22be9..1aece27186 100644 --- a/Ix.NET/Source/System.Interactive.Async/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async/Retry.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -16,8 +13,7 @@ public static IAsyncEnumerable Retry(this IAsyncEnumerable Retry(this IAsyncEnumerable source, int retryCount) @@ -27,8 +23,7 @@ public static IAsyncEnumerable Retry(this IAsyncEnumerable Repeat(this IEnumerable source) @@ -45,4 +40,4 @@ private static IEnumerable Repeat(this IEnumerable so yield return item; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Reverse.cs b/Ix.NET/Source/System.Interactive.Async/Reverse.cs index d4b36d9b14..eed713263c 100644 --- a/Ix.NET/Source/System.Interactive.Async/Reverse.cs +++ b/Ix.NET/Source/System.Interactive.Async/Reverse.cs @@ -36,8 +36,7 @@ public ReverseAsyncIterator(IAsyncEnumerable source) public async Task ToArrayAsync(CancellationToken cancellationToken) { - var array = await source.ToArray(cancellationToken) - .ConfigureAwait(false); + var array = await source.ToArray(cancellationToken).ConfigureAwait(false); // Array.Reverse() involves boxing for non-primitive value types, but // checking that has its own cost, so just use this approach for all types. @@ -53,8 +52,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) public async Task> ToListAsync(CancellationToken cancellationToken) { - var list = await source.ToList(cancellationToken) - .ConfigureAwait(false); + var list = await source.ToList(cancellationToken).ConfigureAwait(false); list.Reverse(); return list; @@ -89,14 +87,12 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() { switch (state) { case AsyncIteratorState.Allocated: - items = await source.ToArray() - .ConfigureAwait(false); + items = await source.ToArray().ConfigureAwait(false); index = items.Length - 1; state = AsyncIteratorState.Iterating; @@ -118,4 +114,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index 1b2a064347..a5c13c6677 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -147,8 +146,7 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; if (!hasSeed) @@ -172,4 +170,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Interactive.Async/Select.cs index bd4b3afc30..64c7976514 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Interactive.Async/Select.cs @@ -127,8 +127,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = selector(enumerator.Current); return true; @@ -185,8 +184,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { @@ -311,8 +309,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = await selector(enumerator.Current).ConfigureAwait(false); return true; @@ -369,8 +366,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index 9193f272c3..6ecab3d6ed 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -123,8 +122,7 @@ protected override async Task MoveNextCore() switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { if (resultEnumerator != null) { @@ -140,8 +138,7 @@ protected override async Task MoveNextCore() break; case State_Result: - if (await resultEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { current = resultEnumerator.Current; return true; @@ -222,8 +219,7 @@ protected override async Task MoveNextCore() switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { if (resultEnumerator != null) { @@ -240,8 +236,7 @@ protected override async Task MoveNextCore() break; case State_Result: - if (await resultEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { current = resultSelector(currentSource, resultEnumerator.Current); return true; @@ -324,8 +319,7 @@ protected override async Task MoveNextCore() switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { if (resultEnumerator != null) { @@ -339,8 +333,7 @@ protected override async Task MoveNextCore() index++; } - resultEnumerator = collectionSelector(currentSource, index) - .GetAsyncEnumerator(); + resultEnumerator = collectionSelector(currentSource, index).GetAsyncEnumerator(); mode = State_Result; goto case State_Result; @@ -348,8 +341,7 @@ protected override async Task MoveNextCore() break; case State_Result: - if (await resultEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { current = resultSelector(currentSource, resultEnumerator.Current); return true; @@ -426,8 +418,7 @@ protected override async Task MoveNextCore() switch (mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { if (resultEnumerator != null) { @@ -447,8 +438,7 @@ protected override async Task MoveNextCore() break; case State_Result: - if (await resultEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { current = resultEnumerator.Current; return true; @@ -466,4 +456,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs index 590e690a06..ee5363248f 100644 --- a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs +++ b/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs @@ -55,8 +55,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f return first.SequenceEqual(second, EqualityComparer.Default, cancellationToken); } - private static async Task SequenceEqual_(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, - CancellationToken cancellationToken) + private static async Task SequenceEqual_(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first is ICollection firstCol && second is ICollection secondCol && firstCol.Count != secondCol.Count) { @@ -92,4 +91,4 @@ private static async Task SequenceEqual_(IAsyncEnumerable Single(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Single(cancellationToken); + return source.Where(predicate).Single(cancellationToken); } public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -64,8 +63,7 @@ public static Task Single(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Single(cancellationToken); + return source.Where(predicate).Single(cancellationToken); } public static Task SingleOrDefault(this IAsyncEnumerable source) @@ -111,8 +109,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -122,8 +119,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable Single_(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -135,6 +131,7 @@ private static async Task Single_(IAsyncEnumerable so case 0: throw new InvalidOperationException(Strings.NO_ELEMENTS); case 1: return list[0]; } + throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } @@ -142,17 +139,17 @@ private static async Task Single_(IAsyncEnumerable so try { - if (!await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } + var result = e.Current; - if (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } + return result; } finally @@ -170,6 +167,7 @@ private static async Task SingleOrDefault_(IAsyncEnumerable SingleOrDefault_(IAsyncEnumerable SingleOrDefault_(IAsyncEnumerable MoveNextCore() { switch (state) @@ -132,21 +131,21 @@ protected override async Task MoveNextCore() enumerator = source.GetAsyncEnumerator(); // skip elements as requested - while (currentCount > 0 && await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (currentCount > 0 && await enumerator.MoveNextAsync().ConfigureAwait(false)) { currentCount--; } + if (currentCount <= 0) { state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } + break; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -188,6 +187,7 @@ public override async Task DisposeAsync() await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } + queue = null; // release the memory await base.DisposeAsync().ConfigureAwait(false); @@ -207,11 +207,11 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; queue.Enqueue(item); + if (queue.Count > count) { current = queue.Dequeue(); @@ -268,8 +268,7 @@ protected override async Task MoveNextCore() enumerator = source.GetAsyncEnumerator(); // skip elements as requested - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var element = enumerator.Current; if (!predicate(element)) @@ -279,15 +278,16 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; } } + break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; } + if (!doMoveNext) { current = enumerator.Current; @@ -346,8 +346,7 @@ protected override async Task MoveNextCore() index = -1; // skip elements as requested - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { @@ -362,15 +361,16 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; } } + break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; } + if (!doMoveNext) { current = enumerator.Current; @@ -427,8 +427,7 @@ protected override async Task MoveNextCore() enumerator = source.GetAsyncEnumerator(); // skip elements as requested - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var element = enumerator.Current; if (!await predicate(element).ConfigureAwait(false)) @@ -438,15 +437,16 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; } } + break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; } + if (!doMoveNext) { current = enumerator.Current; @@ -505,8 +505,7 @@ protected override async Task MoveNextCore() index = -1; // skip elements as requested - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { @@ -521,15 +520,16 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; } } + break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; } + if (!doMoveNext) { current = enumerator.Current; @@ -545,4 +545,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/StartsWith.cs b/Ix.NET/Source/System.Interactive.Async/StartsWith.cs index 3a3e8b7d7c..68b9c9962f 100644 --- a/Ix.NET/Source/System.Interactive.Async/StartsWith.cs +++ b/Ix.NET/Source/System.Interactive.Async/StartsWith.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -16,8 +13,7 @@ public static IAsyncEnumerable StartWith(this IAsyncEnumerable if (source == null) throw new ArgumentNullException(nameof(source)); - return values.ToAsyncEnumerable() - .Concat(source); + return values.ToAsyncEnumerable().Concat(source); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Strings.cs b/Ix.NET/Source/System.Interactive.Async/Strings.cs index 1fbcb54807..755114023d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Strings.cs +++ b/Ix.NET/Source/System.Interactive.Async/Strings.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + namespace System.Linq { internal static class Strings diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index 24f2626078..deb2b0684e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -121,8 +121,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (currentCount > 0 && await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (currentCount > 0 && await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; currentCount--; @@ -166,12 +165,12 @@ public override async Task DisposeAsync() await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } + queue = null; // release the memory await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() { switch (state) @@ -190,8 +189,7 @@ protected override async Task MoveNextCore() { if (!isDone) { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { if (count > 0) { @@ -275,14 +273,14 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; if (!predicate(item)) { break; } + current = item; return true; } @@ -340,8 +338,7 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; checked @@ -353,6 +350,7 @@ protected override async Task MoveNextCore() { break; } + current = item; return true; } @@ -409,14 +407,14 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; if (!await predicate(item).ConfigureAwait(false)) { break; } + current = item; return true; } @@ -474,8 +472,7 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; checked @@ -487,6 +484,7 @@ protected override async Task MoveNextCore() { break; } + current = item; return true; } @@ -499,4 +497,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index 88635a565b..c9512dcde0 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Collections.Generic; namespace System.Threading.Tasks { diff --git a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs index e3eefafc03..31ee6a34e6 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs @@ -69,10 +69,11 @@ private static IEnumerable ToEnumerable_(IAsyncEnumerable MoveNextCore() enumerator = source.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; + case AsyncIteratorState.Iterating: if (enumerator.MoveNext()) { current = enumerator.Current; return true; } + await DisposeAsync().ConfigureAwait(false); break; } + return false; } diff --git a/Ix.NET/Source/System.Interactive.Async/ToCollection.cs b/Ix.NET/Source/System.Interactive.Async/ToCollection.cs index 6ae85a5846..a89f2798d6 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToCollection.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToCollection.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -90,11 +88,15 @@ public static Task> ToDictionary(comparer), (d, x) => - { - d.Add(keySelector(x), elementSelector(x)); - return d; - }, cancellationToken); + return source.Aggregate( + new Dictionary(comparer), + (d, x) => + { + d.Add(keySelector(x), elementSelector(x)); + return d; + }, + cancellationToken + ); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) @@ -147,11 +149,15 @@ public static Task> ToList(this IAsyncEnumerable if (source is IIListProvider listProvider) return listProvider.ToListAsync(cancellationToken); - return source.Aggregate(new List(), (list, x) => - { - list.Add(x); - return list; - }, cancellationToken); + return source.Aggregate( + new List(), + (list, x) => + { + list.Add(x); + return list; + }, + cancellationToken + ); } } -} \ No newline at end of file +} From 8a4db0c35a8d891efdd057a6753cd283adbd77eb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:51:14 -0700 Subject: [PATCH 036/862] Async variants of MinBy and MaxBy. --- Ix.NET/Source/System.Interactive.Async/Max.cs | 44 ++++++++++ Ix.NET/Source/System.Interactive.Async/Min.cs | 84 +++++++++++++++++++ 2 files changed, 128 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Interactive.Async/Max.cs index 4c46d49a9a..d7279c102d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/Max.cs @@ -131,6 +131,50 @@ public static Task> MaxBy(this IAsyncEnumerable comparer.Compare(key, minValue), cancellationToken); } + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.MaxBy(keySelector, CancellationToken.None); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.MaxBy(keySelector, comparer, CancellationToken.None); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MaxBy(source, keySelector, Comparer.Default, cancellationToken); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); + } + private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { return (await MaxBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 2c2063c1dc..acafc3501e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -131,6 +131,50 @@ public static Task> MinBy(this IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); } + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.MinBy(keySelector, CancellationToken.None); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.MinBy(keySelector, comparer, CancellationToken.None); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MinBy(source, keySelector, Comparer.Default, cancellationToken); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); + } + private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { return (await MinBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); @@ -175,5 +219,45 @@ private static async Task> ExtremaBy(IAsyncEnumera return result; } + + private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) + { + var result = new List(); + + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + var current = e.Current; + var resKey = await keySelector(current).ConfigureAwait(false); + result.Add(current); + + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var cur = e.Current; + var key = await keySelector(cur).ConfigureAwait(false); + + var cmp = compare(key, resKey); + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return result; + } } } From c695d246f23d7e4296ed24cf9018faa2de1f6678 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:55:36 -0700 Subject: [PATCH 037/862] More code cosmetics. --- .../Source/System.Interactive.Async/First.cs | 20 ++++------ .../IOrderedAsyncEnumerable.cs | 2 +- .../IgnoreElements.cs | 6 +-- .../System.Interactive.Async/Intersect.cs | 12 ++---- .../Source/System.Interactive.Async/Join.cs | 31 ++++++++-------- .../Source/System.Interactive.Async/Last.cs | 18 ++++----- .../Source/System.Interactive.Async/Lookup.cs | 37 +++++++------------ 7 files changed, 49 insertions(+), 77 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index 7d4886f087..1ba9a8b5da 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -53,8 +53,7 @@ public static Task First(this IAsyncEnumerable source if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .First(cancellationToken); + return source.Where(predicate).First(cancellationToken); } public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -64,8 +63,7 @@ public static Task First(this IAsyncEnumerable source if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .First(cancellationToken); + return source.Where(predicate).First(cancellationToken); } public static Task FirstOrDefault(this IAsyncEnumerable source) @@ -111,8 +109,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -122,8 +119,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable First_(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -138,8 +134,7 @@ private static async Task First_(IAsyncEnumerable sou try { - if (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { return e.Current; } @@ -164,8 +159,7 @@ private static async Task FirstOrDefault_(IAsyncEnumerable FirstOrDefault_(IAsyncEnumerable MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { // Do nothing, we're ignoring these elements } @@ -71,4 +69,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Interactive.Async/Intersect.cs index 2ed30f0165..6bd0c44a98 100644 --- a/Ix.NET/Source/System.Interactive.Async/Intersect.cs +++ b/Ix.NET/Source/System.Interactive.Async/Intersect.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -98,15 +97,13 @@ protected override async Task MoveNextCore() { // This is here so we don't need to call Task.WhenAll each time after the set is filled var moveNextTask = firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask, fillSetTask) - .ConfigureAwait(false); + await Task.WhenAll(moveNextTask, fillSetTask).ConfigureAwait(false); setFilled = true; moveNext = moveNextTask.Result; } else { - moveNext = await firstEnumerator.MoveNextAsync() - .ConfigureAwait(false); + moveNext = await firstEnumerator.MoveNextAsync().ConfigureAwait(false); } if (moveNext) @@ -129,8 +126,7 @@ await Task.WhenAll(moveNextTask, fillSetTask) private async Task FillSet() { - var array = await second.ToArray() - .ConfigureAwait(false); + var array = await second.ToArray().ConfigureAwait(false); for (var i = 0; i < array.Length; i++) { set.Add(array[i]); @@ -138,4 +134,4 @@ private async Task FillSet() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index feb3ddb329..1f73e9a1b9 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -42,7 +42,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } internal sealed class JoinAsyncIterator : AsyncIterator @@ -90,17 +90,17 @@ public override async Task DisposeAsync() } // State machine vars - Internal.Lookup lookup; - int count; - TInner[] elements; - int index; - TOuter item; + private Internal.Lookup lookup; + private int count; + private TInner[] elements; + private int index; + private TOuter item; private int mode; - const int State_If = 1; - const int State_DoLoop = 2; - const int State_For = 3; - const int State_While = 4; + private const int State_If = 1; + private const int State_DoLoop = 2; + private const int State_For = 3; + private const int State_While = 4; protected override async Task MoveNextCore() { @@ -116,19 +116,19 @@ protected override async Task MoveNextCore() switch (mode) { case State_If: - if (await outerEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer).ConfigureAwait(false); if (lookup.Count != 0) { mode = State_DoLoop; - goto case State_DoLoop; + goto case State_DoLoop; } } break; + case State_DoLoop: item = outerEnumerator.Current; var g = lookup.GetGrouping(outerKeySelector(item), create: false); @@ -152,6 +152,7 @@ protected override async Task MoveNextCore() { mode = State_While; } + return true; case State_While: @@ -161,12 +162,10 @@ protected override async Task MoveNextCore() goto case State_DoLoop; } - break; } await DisposeAsync().ConfigureAwait(false); - break; } @@ -174,4 +173,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index e1e8e9a6d6..2e9992adf4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -53,8 +53,7 @@ public static Task Last(this IAsyncEnumerable source, if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Last(cancellationToken); + return source.Where(predicate).Last(cancellationToken); } public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -64,8 +63,7 @@ public static Task Last(this IAsyncEnumerable source, if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Last(cancellationToken); + return source.Where(predicate).Last(cancellationToken); } public static Task LastOrDefault(this IAsyncEnumerable source) @@ -122,8 +120,7 @@ public static Task LastOrDefault(this IAsyncEnumerable Last_(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -144,8 +141,7 @@ private static async Task Last_(IAsyncEnumerable sour try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { hasLast = true; last = e.Current; @@ -158,6 +154,7 @@ private static async Task Last_(IAsyncEnumerable sour if (!hasLast) throw new InvalidOperationException(Strings.NO_ELEMENTS); + return last; } @@ -179,8 +176,7 @@ private static async Task LastOrDefault_(IAsyncEnumerable LastOrDefault_(IAsyncEnumerable> ToLookup.CreateAsync(source, keySelector, elementSelector, comparer) - .ConfigureAwait(false); + var lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); return lookup; } @@ -188,7 +184,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) { Debug.Assert(source != null); @@ -201,11 +197,9 @@ public IEnumerable ApplyResultSelector(Func ApplyResultSelector(Func> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -227,8 +221,7 @@ public IEnumerable ApplyResultSelector(Func> CreateForJoinAsync(IAsyncEnum try { - while (await enu.MoveNextAsync() - .ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var key = keySelector(enu.Current); if (key != null) { - lookup.GetGrouping(key, create: true) - .Add(enu.Current); + lookup.GetGrouping(key, create: true).Add(enu.Current); } } } @@ -272,7 +263,7 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum internal Grouping GetGrouping(TKey key, bool create) { var hashCode = InternalGetHashCode(key); - for (var g = _groupings[hashCode%_groupings.Length]; g != null; g = g._hashNext) + for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) { if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) { @@ -287,7 +278,7 @@ internal Grouping GetGrouping(TKey key, bool create) Resize(); } - var index = hashCode%_groupings.Length; + var index = hashCode % _groupings.Length; var g = new Grouping { _key = key, @@ -358,20 +349,19 @@ internal List ToList(Func, TR private void Resize() { - var newSize = checked((Count*2) + 1); + var newSize = checked((Count * 2) + 1); var newGroupings = new Grouping[newSize]; var g = _lastGrouping; do { g = g._next; - var index = g._hashCode%newSize; + var index = g._hashCode % newSize; g._hashNext = newGroupings[index]; newGroupings[index] = g; } while (g != _lastGrouping); _groupings = newGroupings; } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { @@ -418,6 +408,5 @@ Task[]> IIListProvider Date: Wed, 30 Aug 2017 22:55:57 -0700 Subject: [PATCH 038/862] Adding missing copyright header. --- Ix.NET/Source/System.Interactive.Async/IIListProvider.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs b/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs index a8e9e8ef75..d339e64055 100644 --- a/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs +++ b/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs @@ -1,6 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; From da9bdd0cd71ddde0d335ac366b3c4e3ec5e0b926 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:56:11 -0700 Subject: [PATCH 039/862] Mark interface as internal. --- Ix.NET/Source/System.Interactive.Async/IIListProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs b/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs index d339e64055..fcae98851a 100644 --- a/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs +++ b/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs @@ -11,7 +11,7 @@ namespace System.Linq /// /// An iterator that can produce an array or through an optimized path. /// - interface IIListProvider : IAsyncEnumerable + internal interface IIListProvider : IAsyncEnumerable { /// /// Produce an array of the sequence through an optimized path. From c79931601e1ec1f05f5a38d5a2f06a4e77e4e4c9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:57:44 -0700 Subject: [PATCH 040/862] Fixing interface XML doc comments. --- .../System.Interactive.Async/IAsyncEnumerable.cs | 5 ++--- .../System.Interactive.Async/IAsyncEnumerator.cs | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs index b48233057a..2db51bbd38 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs @@ -5,14 +5,13 @@ namespace System.Collections.Generic { /// - /// Asynchronous version of the IEnumerable<T> interface, allowing elements of the - /// enumerable sequence to be retrieved asynchronously. + /// Asynchronous version of the interface, allowing elements of the enumerable sequence to be retrieved asynchronously. /// /// Element type. public interface IAsyncEnumerable { /// - /// Gets an asynchronous enumerator over the sequence. + /// Gets an asynchronous enumerator over the sequence. /// /// Enumerator for asynchronous enumeration over the sequence. IAsyncEnumerator GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index c69e31413d..68ea03f6a6 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -7,23 +7,22 @@ namespace System.Collections.Generic { /// - /// Asynchronous version of the IEnumerator<T> interface, allowing elements to be - /// retrieved asynchronously. + /// Asynchronous version of the interface, allowing elements to be retrieved asynchronously. /// /// Element type. public interface IAsyncEnumerator : IAsyncDisposable { /// - /// Gets the current element in the iteration. + /// Gets the current element in the iteration. /// T Current { get; } /// - /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. + /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. /// /// - /// Task containing the result of the operation: true if the enumerator was successfully advanced - /// to the next element; false if the enumerator has passed the end of the sequence. + /// Task containing the result of the operation: true if the enumerator was successfully advanced + /// to the next element; false if the enumerator has passed the end of the sequence. /// Task MoveNextAsync(); } From 5b9bb8d9cf161f22f47bb7552a37a89e39c0b1e8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 22:58:38 -0700 Subject: [PATCH 041/862] Adding link to the language proposal. --- Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs | 3 +++ Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs | 3 +++ Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs index 823320f08e..e2fa721ac2 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +// See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface +// and the design rationale. (8/30/2017) + using System.Threading.Tasks; namespace System diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs index 2db51bbd38..4cc0d075b8 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +// See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface +// and the design rationale. (8/30/2017) + namespace System.Collections.Generic { /// diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs index 68ea03f6a6..1b1e3bf80f 100644 --- a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +// See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface +// and the design rationale. (8/30/2017) + using System.Threading.Tasks; namespace System.Collections.Generic From 4eb53305bd16c597634e02297d183b60433e900b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:00:19 -0700 Subject: [PATCH 042/862] Some more code cosmetics. --- .../Source/System.Interactive.Async/GroupJoin.cs | 15 +++------------ .../Source/System.Interactive.Async/Grouping.cs | 9 +++------ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs index 8ccf7eaab2..780756208c 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -27,7 +24,6 @@ public static IAsyncEnumerable GroupJoin if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } @@ -47,9 +43,6 @@ public static IAsyncEnumerable GroupJoin return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } - - - private sealed class GroupJoinAsyncEnumerable : IAsyncEnumerable { private readonly IEqualityComparer _comparer; @@ -114,16 +107,14 @@ public GroupJoinAsyncEnumerator( public async Task MoveNextAsync() { // nothing to do - if (!await _outer.MoveNextAsync() - .ConfigureAwait(false)) + if (!await _outer.MoveNextAsync().ConfigureAwait(false)) { return false; } if (_lookup == null) { - _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer) - .ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer).ConfigureAwait(false); } var item = _outer.Current; @@ -137,4 +128,4 @@ public async Task MoveNextAsync() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Interactive.Async/Grouping.cs index 3b2ef3fae8..cf9234a266 100644 --- a/Ix.NET/Source/System.Interactive.Async/Grouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/Grouping.cs @@ -5,7 +5,6 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; @@ -74,8 +73,7 @@ public static IAsyncEnumerable GroupBy resultSelector(g.Key, g)); + return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) @@ -89,8 +87,7 @@ public static IAsyncEnumerable GroupBy.Default) - .Select(g => resultSelector(g.Key, g)); + return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default).Select(g => resultSelector(g.Key, g)); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) @@ -509,4 +506,4 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() return this.ToAsyncEnumerable().GetAsyncEnumerator(); } } -} \ No newline at end of file +} From 93eaba9365eba2eb4bb005105eb2d3b8bd007486 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:01:16 -0700 Subject: [PATCH 043/862] Modernizing some code. --- .../System.Interactive.Async/Grouping.cs | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Interactive.Async/Grouping.cs index cf9234a266..7804045f02 100644 --- a/Ix.NET/Source/System.Interactive.Async/Grouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/Grouping.cs @@ -397,10 +397,7 @@ internal class Grouping : IGrouping, IList _next; - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerator GetEnumerator() { @@ -412,20 +409,11 @@ public IEnumerator GetEnumerator() // DDB195907: implement IGrouping<>.Key implicitly // so that WPF binding works on this property. - public TKey Key - { - get { return _key; } - } + public TKey Key => _key; - int ICollection.Count - { - get { return _count; } - } + int ICollection.Count => _count; - bool ICollection.IsReadOnly - { - get { return true; } - } + bool ICollection.IsReadOnly => true; void ICollection.Add(TElement item) { @@ -452,10 +440,7 @@ bool ICollection.Remove(TElement item) throw new NotSupportedException(Strings.NOT_SUPPORTED); } - int IList.IndexOf(TElement item) - { - return Array.IndexOf(_elements, item, 0, _count); - } + int IList.IndexOf(TElement item) => Array.IndexOf(_elements, item, 0, _count); void IList.Insert(int index, TElement item) { From debb67bdf482640503fe8b31fa42513cc2d749d6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:03:00 -0700 Subject: [PATCH 044/862] More code cosmetics. --- Ix.NET/Source/System.Interactive.Async/Finally.cs | 6 ++---- Ix.NET/Source/System.Interactive.Async/ForEach.cs | 14 ++++---------- Ix.NET/Source/System.Interactive.Async/Generate.cs | 3 +-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/Finally.cs index 3933054c11..0a7591bd25 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/Finally.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -65,8 +64,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -80,4 +78,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/ForEach.cs b/Ix.NET/Source/System.Interactive.Async/ForEach.cs index f9d25af325..767a5cac5a 100644 --- a/Ix.NET/Source/System.Interactive.Async/ForEach.cs +++ b/Ix.NET/Source/System.Interactive.Async/ForEach.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -32,7 +30,6 @@ public static void ForEach(this IAsyncEnumerable source, Actio source.ForEach(action, CancellationToken.None); } - public static void ForEach(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { if (source == null) @@ -40,8 +37,7 @@ public static void ForEach(this IAsyncEnumerable source, Actio if (action == null) throw new ArgumentNullException(nameof(action)); - source.ForEachAsync(action, cancellationToken) - .Wait(cancellationToken); + source.ForEachAsync(action, cancellationToken).Wait(cancellationToken); } public static void ForEach(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) @@ -51,8 +47,7 @@ public static void ForEach(this IAsyncEnumerable source, Actio if (action == null) throw new ArgumentNullException(nameof(action)); - source.ForEachAsync(action, cancellationToken) - .Wait(cancellationToken); + source.ForEachAsync(action, cancellationToken).Wait(cancellationToken); } public static Task ForEachAsync(this IAsyncEnumerable source, Action action) @@ -103,8 +98,7 @@ private static async Task ForEachAsync_(IAsyncEnumerable sourc try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { action(e.Current, checked(index++)); } @@ -115,4 +109,4 @@ private static async Task ForEachAsync_(IAsyncEnumerable sourc } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Generate.cs b/Ix.NET/Source/System.Interactive.Async/Generate.cs index f6918f40e8..50b22260de 100644 --- a/Ix.NET/Source/System.Interactive.Async/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Generate.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -91,4 +90,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} From 91dc1f106a6529b25d9f3c9b328a67e2223214d8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:09:57 -0700 Subject: [PATCH 045/862] Async variants of ForEachAsync. --- .../System.Interactive.Async/ForEach.cs | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/ForEach.cs b/Ix.NET/Source/System.Interactive.Async/ForEach.cs index 767a5cac5a..3081b16f63 100644 --- a/Ix.NET/Source/System.Interactive.Async/ForEach.cs +++ b/Ix.NET/Source/System.Interactive.Async/ForEach.cs @@ -90,6 +90,66 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return ForEachAsync_(source, action, cancellationToken); } + public static Task ForEachAsync(this IAsyncEnumerable source, Func action) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (action == null) + throw new ArgumentNullException(nameof(action)); + + return ForEachAsync(source, action, CancellationToken.None); + } + + public static Task ForEachAsync(this IAsyncEnumerable source, Func action) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (action == null) + throw new ArgumentNullException(nameof(action)); + + return ForEachAsync(source, action, CancellationToken.None); + } + + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (action == null) + throw new ArgumentNullException(nameof(action)); + + return source.ForEachAsync((x, i, ct) => action(x), cancellationToken); + } + + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (action == null) + throw new ArgumentNullException(nameof(action)); + + return source.ForEachAsync((x, i, ct) => action(x, ct), cancellationToken); + } + + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (action == null) + throw new ArgumentNullException(nameof(action)); + + return source.ForEachAsync((x, i, ct) => action(x, i), cancellationToken); + } + + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (action == null) + throw new ArgumentNullException(nameof(action)); + + return ForEachAsync_(source, action, cancellationToken); + } + private static async Task ForEachAsync_(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { var index = 0; @@ -108,5 +168,24 @@ private static async Task ForEachAsync_(IAsyncEnumerable sourc await e.DisposeAsync().ConfigureAwait(false); } } + + private static async Task ForEachAsync_(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + { + var index = 0; + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + await action(e.Current, checked(index++), cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } } From ae718bad3d20452875ef442e51a9c0cab74d3204 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:14:41 -0700 Subject: [PATCH 046/862] More code cosmetics. --- .../System.Interactive.Async/Disposables.cs | 1 + .../System.Interactive.Async/Distinct.cs | 51 ++++++++----------- Ix.NET/Source/System.Interactive.Async/Do.cs | 6 +-- .../System.Interactive.Async/ElementAt.cs | 11 ++-- .../System.Interactive.Async/EmptyArray.cs | 6 +-- .../Source/System.Interactive.Async/Except.cs | 19 +++---- .../ExcludeFromCodeCoverageAttribute.cs | 2 +- .../Source/System.Interactive.Async/Expand.cs | 6 +-- 8 files changed, 41 insertions(+), 61 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Disposables.cs b/Ix.NET/Source/System.Interactive.Async/Disposables.cs index 79dcb144de..2374fc3d62 100644 --- a/Ix.NET/Source/System.Interactive.Async/Disposables.cs +++ b/Ix.NET/Source/System.Interactive.Async/Disposables.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Threading; namespace System.Linq diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index 06aa5e8d9c..af2615ff31 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -118,15 +118,13 @@ public DistinctAsyncIterator(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) { - var s = await FillSet(cancellationToken) - .ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async Task> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSet(cancellationToken) - .ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } @@ -144,8 +142,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell try { - while (await enu.MoveNextAsync() - .ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var item = enu.Current; if (s.Add(keySelector(item))) @@ -185,8 +182,8 @@ protected override async Task MoveNextCore() { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (!await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + + if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); return false; @@ -196,12 +193,12 @@ protected override async Task MoveNextCore() set = new Set(comparer); set.Add(keySelector(element)); current = element; + state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { element = enumerator.Current; if (set.Add(keySelector(element))) @@ -218,7 +215,7 @@ protected override async Task MoveNextCore() return false; } - private async Task> FillSet(CancellationToken cancellationToken) + private async Task> FillSetAsync(CancellationToken cancellationToken) { var s = new Set(comparer); var r = new List(); @@ -227,8 +224,7 @@ private async Task> FillSet(CancellationToken cancellationToken) try { - while (await enu.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var item = enu.Current; if (s.Add(keySelector(item))) @@ -264,22 +260,20 @@ public DistinctAsyncIterator(IAsyncEnumerable source, IEqualityComparer public async Task ToArrayAsync(CancellationToken cancellationToken) { - var s = await FillSet(cancellationToken) - .ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async Task> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSet(cancellationToken) + var s = await FillSetAsync(cancellationToken) .ConfigureAwait(false); return s.ToList(); } public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return onlyIfCheap ? -1 : (await FillSet(cancellationToken) - .ConfigureAwait(false)).Count; + return onlyIfCheap ? -1 : (await FillSetAsync(cancellationToken).ConfigureAwait(false)).Count; } public override AsyncIterator Clone() @@ -305,8 +299,7 @@ protected override async Task MoveNextCore() { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (!await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); return false; @@ -316,12 +309,12 @@ protected override async Task MoveNextCore() set = new Set(comparer); set.Add(element); current = element; + state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { element = enumerator.Current; if (set.Add(element)) @@ -338,7 +331,7 @@ protected override async Task MoveNextCore() return false; } - private async Task> FillSet(CancellationToken cancellationToken) + private async Task> FillSetAsync(CancellationToken cancellationToken) { var s = new Set(comparer); @@ -346,8 +339,7 @@ private async Task> FillSet(CancellationToken cancellationToken) try { - while (await enu.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { s.Add(enu.Current); } @@ -406,8 +398,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; var comparerEquals = false; @@ -416,6 +407,7 @@ protected override async Task MoveNextCore() { comparerEquals = comparer.Equals(currentValue, item); } + if (!hasCurrentValue || !comparerEquals) { hasCurrentValue = true; @@ -477,8 +469,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; var key = keySelector(item); @@ -505,4 +496,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/Do.cs index 777d998a73..938a45d341 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/Do.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -122,8 +121,7 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: try { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; onNext(current); @@ -151,4 +149,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index 7b7ee9d3e9..3b6806c978 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -2,9 +2,7 @@ // // The .NET Foundation licenses this file to you under the Apache 2.0 License. // // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -22,7 +20,6 @@ public static Task ElementAt(this IAsyncEnumerable so return ElementAt_(source, index, cancellationToken); } - public static Task ElementAt(this IAsyncEnumerable source, int index) { if (source == null) @@ -62,8 +59,7 @@ private static async Task ElementAt_(IAsyncEnumerable try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { if (index == 0) { @@ -90,8 +86,7 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { if (index == 0) { @@ -110,4 +105,4 @@ private static async Task ElementAtOrDefault_(IAsyncEnumerable return default(TSource); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/EmptyArray.cs b/Ix.NET/Source/System.Interactive.Async/EmptyArray.cs index 02757b7d97..c529a98b06 100644 --- a/Ix.NET/Source/System.Interactive.Async/EmptyArray.cs +++ b/Ix.NET/Source/System.Interactive.Async/EmptyArray.cs @@ -1,11 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + #if NO_ARRAY_EMPTY -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -14,4 +11,5 @@ internal sealed class EmptyArray public static readonly TElement[] Value = new TElement[0]; } } + #endif diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Interactive.Async/Except.cs index 55366cef71..fe7a6f42a7 100644 --- a/Ix.NET/Source/System.Interactive.Async/Except.cs +++ b/Ix.NET/Source/System.Interactive.Async/Except.cs @@ -83,7 +83,7 @@ protected override async Task MoveNextCore() firstEnumerator = first.GetAsyncEnumerator(); set = new Set(comparer); setFilled = false; - fillSetTask = FillSet(); + fillSetTask = FillSetAsync(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -96,15 +96,14 @@ protected override async Task MoveNextCore() { // This is here so we don't need to call Task.WhenAll each time after the set is filled var moveNextTask = firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask, fillSetTask) - .ConfigureAwait(false); + await Task.WhenAll(moveNextTask, fillSetTask).ConfigureAwait(false); + setFilled = true; moveNext = moveNextTask.Result; } else { - moveNext = await firstEnumerator.MoveNextAsync() - .ConfigureAwait(false); + moveNext = await firstEnumerator.MoveNextAsync().ConfigureAwait(false); } if (moveNext) @@ -116,10 +115,8 @@ await Task.WhenAll(moveNextTask, fillSetTask) return true; } } - } while (moveNext); - await DisposeAsync().ConfigureAwait(false); break; } @@ -127,10 +124,10 @@ await Task.WhenAll(moveNextTask, fillSetTask) return false; } - private async Task FillSet() + private async Task FillSetAsync() { - var array = await second.ToArray() - .ConfigureAwait(false); + var array = await second.ToArray().ConfigureAwait(false); + foreach (var t in array) { set.Add(t); @@ -138,4 +135,4 @@ private async Task FillSet() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/ExcludeFromCodeCoverageAttribute.cs b/Ix.NET/Source/System.Interactive.Async/ExcludeFromCodeCoverageAttribute.cs index a6879b12ca..73e55bab60 100644 --- a/Ix.NET/Source/System.Interactive.Async/ExcludeFromCodeCoverageAttribute.cs +++ b/Ix.NET/Source/System.Interactive.Async/ExcludeFromCodeCoverageAttribute.cs @@ -12,4 +12,4 @@ internal sealed class ExcludeFromCodeCoverageAttribute : Attribute } } -#endif \ No newline at end of file +#endif diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index 5e0d85e67f..16cd9b9c76 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -90,8 +90,7 @@ protected override async Task MoveNextCore() break; // while } - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; var next = selector(item); @@ -99,6 +98,7 @@ protected override async Task MoveNextCore() current = item; return true; } + await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; } @@ -111,4 +111,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} From eceec47d1547a77bad48da386ee940efc9a037e0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:15:45 -0700 Subject: [PATCH 047/862] Some improvements to disposables. --- .../System.Interactive.Async/Disposables.cs | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Disposables.cs b/Ix.NET/Source/System.Interactive.Async/Disposables.cs index 2374fc3d62..ecfeae8ad1 100644 --- a/Ix.NET/Source/System.Interactive.Async/Disposables.cs +++ b/Ix.NET/Source/System.Interactive.Async/Disposables.cs @@ -6,17 +6,11 @@ namespace System.Linq { - class CancellationTokenDisposable : IDisposable + internal sealed class CancellationTokenDisposable : IDisposable { private readonly CancellationTokenSource cts = new CancellationTokenSource(); - public CancellationToken Token - { - get - { - return cts.Token; - } - } + public CancellationToken Token => cts.Token; public void Dispose() { @@ -27,20 +21,14 @@ public void Dispose() } } - static class Disposable + internal static class Disposable { - public static IDisposable Create(IDisposable d1, IDisposable d2) - { - return new BinaryDisposable(d1, d2); - } + public static IDisposable Create(IDisposable d1, IDisposable d2) => new BinaryDisposable(d1, d2); - public static IDisposable Create(Action action) - { - return new AnonymousDisposable(action); - } + public static IDisposable Create(Action action) => new AnonymousDisposable(action); } - class BinaryDisposable : IDisposable + internal sealed class BinaryDisposable : IDisposable { private IDisposable _d1; private IDisposable _d2; @@ -67,7 +55,7 @@ public void Dispose() } } - class AnonymousDisposable : IDisposable + internal sealed class AnonymousDisposable : IDisposable { private Action _action; @@ -76,6 +64,6 @@ public AnonymousDisposable(Action action) _action = action; } - public void Dispose() => _action(); + public void Dispose() => Interlocked.Exchange(ref _action, null)?.Invoke(); } } From 4e6c9fb11ec763503b285a1a3e4a21a6e40c1fe9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:32:02 -0700 Subject: [PATCH 048/862] More code cosmetics. --- .../System.Interactive.Async/Aggregate.cs | 20 +++---- .../Source/System.Interactive.Async/AnyAll.cs | 22 +++---- .../System.Interactive.Async/AppendPrepend.cs | 30 ++++------ .../AsyncEnumerable.cs | 23 ++----- .../AsyncEnumerableHelpers.cs | 11 ++-- .../System.Interactive.Async/AsyncIterator.cs | 9 ++- .../System.Interactive.Async/Average.cs | 60 +++++++------------ .../Source/System.Interactive.Async/Buffer.cs | 9 +-- .../Source/System.Interactive.Async/Cast.cs | 14 ++--- .../Source/System.Interactive.Async/Catch.cs | 13 ++-- .../System.Interactive.Async/Concatenate.cs | 18 +++--- .../System.Interactive.Async/Contains.cs | 10 ++-- .../Source/System.Interactive.Async/Count.cs | 16 ++--- .../Source/System.Interactive.Async/Create.cs | 21 ++----- .../DefaultIfEmpty.cs | 10 ++-- .../Source/System.Interactive.Async/Defer.cs | 9 +-- .../System.Interactive.Async/ElementAt.cs | 6 +- 17 files changed, 105 insertions(+), 196 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index 54cfabb139..dc54e30118 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -1,10 +1,8 @@ -// // Licensed to the .NET Foundation under one or more agreements. -// // The .NET Foundation licenses this file to you under the Apache 2.0 License. -// // See the LICENSE file in the project root for more information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -76,8 +74,7 @@ public static Task Aggregate(this IAsyncEnumerable so return Aggregate_(source, accumulator, cancellationToken); } - private static async Task Aggregate_(IAsyncEnumerable source, TAccumulate seed, - Func accumulator, Func resultSelector, CancellationToken cancellationToken) + private static async Task Aggregate_(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { var acc = seed; @@ -85,8 +82,7 @@ private static async Task Aggregate_(IAs try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { acc = accumulator(acc, e.Current); } @@ -108,8 +104,7 @@ private static async Task Aggregate_(IAsyncEnumerable try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { acc = first ? e.Current : accumulator(acc, e.Current); first = false; @@ -122,7 +117,8 @@ private static async Task Aggregate_(IAsyncEnumerable if (first) throw new InvalidOperationException(Strings.NO_ELEMENTS); + return acc; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs index 8357b3d014..2fe3929308 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/AnyAll.cs @@ -1,10 +1,8 @@ -// // Licensed to the .NET Foundation under one or more agreements. -// // The .NET Foundation licenses this file to you under the Apache 2.0 License. -// // See the LICENSE file in the project root for more information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -123,8 +121,7 @@ private static async Task All_(IAsyncEnumerable source, try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { if (!predicate(e.Current)) return false; @@ -144,8 +141,7 @@ private static async Task All_(IAsyncEnumerable source, try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { if (!await predicate(e.Current).ConfigureAwait(false)) return false; @@ -165,8 +161,7 @@ private static async Task Any_(IAsyncEnumerable source, try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { if (predicate(e.Current)) return true; @@ -186,8 +181,7 @@ private static async Task Any_(IAsyncEnumerable source, try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { if (await predicate(e.Current).ConfigureAwait(false)) return true; @@ -201,4 +195,4 @@ private static async Task Any_(IAsyncEnumerable source, return false; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index a09872393e..061794f176 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -60,10 +58,9 @@ protected void GetSourceEnumerator() public abstract AppendPrepentAsyncIterator Append(TSource item); public abstract AppendPrepentAsyncIterator Prepend(TSource item); - protected async Task LoadFromEnumerator() + protected async Task LoadFromEnumeratorAsync() { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -113,7 +110,6 @@ public override AsyncIterator Clone() return new AppendPrepend1AsyncIterator(source, item, appending); } - protected override async Task MoveNextCore() { switch (state) @@ -133,12 +129,12 @@ protected override async Task MoveNextCore() if (!hasEnumerator) { GetSourceEnumerator(); - hasEnumerator = true; + hasEnumerator = true; } if (enumerator != null) { - if (await LoadFromEnumerator() + if (await LoadFromEnumeratorAsync() .ConfigureAwait(false)) { return true; @@ -208,8 +204,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio try { - while (await en.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { array[index] = en.Current; ++index; @@ -244,8 +239,7 @@ public override async Task> ToListAsync(CancellationToken cancella try { - while (await en.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { list.Add(en.Current); } @@ -362,7 +356,7 @@ protected override async Task MoveNextCore() { case AsyncIteratorState.Allocated: mode = 1; - state = AsyncIteratorState.Iterating; + state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -386,8 +380,7 @@ protected override async Task MoveNextCore() goto case 3; case 3: - if (await LoadFromEnumerator() - .ConfigureAwait(false)) + if (await LoadFromEnumeratorAsync().ConfigureAwait(false)) { return true; } @@ -400,7 +393,7 @@ protected override async Task MoveNextCore() } break; - + case 4: if (appendedEnumerator.MoveNext()) @@ -490,8 +483,7 @@ public override async Task> ToListAsync(CancellationToken cancella try { - while (await en.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { list.Add(en.Current); } @@ -527,4 +519,4 @@ public override async Task GetCountAsync(bool onlyIfCheap, CancellationToke } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs index 68746bccdd..f2de2ea7d4 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -22,10 +20,7 @@ public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEn public static IAsyncEnumerable Empty() { - return CreateEnumerable( - () => CreateEnumerator( - ct => TaskExt.False, null, null) - ); + return CreateEnumerable(() => CreateEnumerator(ct => TaskExt.False, current: null, dispose: null)); } public static Task IsEmpty(this IAsyncEnumerable source) @@ -46,12 +41,7 @@ public static Task IsEmpty(this IAsyncEnumerable source, public static IAsyncEnumerable Never() { - return CreateEnumerable( - () => CreateEnumerator( - tcs => tcs.Task, - null, - null) - ); + return CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); } @@ -73,15 +63,14 @@ public static IAsyncEnumerable Throw(Exception exception) tcs.TrySetException(exception); return tcs.Task; }, - null, - null) + current: null, + dispose: null) ); } private static async Task IsEmpty_(IAsyncEnumerable source, CancellationToken cancellationToken) { - return !await source.Any(cancellationToken) - .ConfigureAwait(false); + return !await source.Any(cancellationToken).ConfigureAwait(false); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs index 854c89d2e0..d387823301 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs @@ -13,8 +13,7 @@ internal static class AsyncEnumerableHelpers { internal static async Task ToArray(IAsyncEnumerable source, CancellationToken cancellationToken) { - var result = await ToArrayWithLength(source, cancellationToken) - .ConfigureAwait(false); + var result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false); Array.Resize(ref result.array, result.length); return result.array; } @@ -47,16 +46,14 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer try { - if (await en.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { const int DefaultCapacity = 4; var arr = new T[DefaultCapacity]; arr[0] = en.Current; var count = 1; - while (await en.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { if (count == arr.Length) { @@ -115,4 +112,4 @@ internal struct ArrayWithLength public int length; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index ecc0929efd..120e967f3b 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - private static readonly Task CompletedTask = Task.FromResult(true); // TODO: Change to Task.CompletedTask when all build targets allow. + private static readonly Task CompletedTask = TaskExt.True; internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator { @@ -49,7 +49,6 @@ public IAsyncEnumerator GetAsyncEnumerator() return enumerator; } - public virtual Task DisposeAsync() { if (cancellationTokenSource != null) @@ -73,6 +72,7 @@ public TSource Current { if (currentIsInvalid) throw new InvalidOperationException("Enumerator is in an invalid state"); + return current; } } @@ -90,8 +90,7 @@ public async Task MoveNextAsync() try { - var result = await MoveNextCore() - .ConfigureAwait(false); + var result = await MoveNextCore().ConfigureAwait(false); currentIsInvalid = !result; // if move next is false, invalid otherwise valid @@ -142,4 +141,4 @@ internal enum AsyncIteratorState Disposed = -1 } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Interactive.Async/Average.cs index bf7810854d..e3a1aea31a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Average.cs +++ b/Ix.NET/Source/System.Interactive.Async/Average.cs @@ -16,8 +16,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca try { - if (!await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } @@ -26,8 +25,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { sum += e.Current; ++count; @@ -48,8 +46,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -58,8 +55,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -88,8 +84,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel try { - if (!await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } @@ -98,8 +93,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { sum += e.Current; ++count; @@ -120,8 +114,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -130,8 +123,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -160,16 +152,14 @@ private static async Task Average_(IAsyncEnumerable source, Canc try { - if (!await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is // ever NaN then the result will always be NaN. Assuming that this case is @@ -192,8 +182,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -202,8 +191,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -232,16 +220,14 @@ private static async Task Average_(IAsyncEnumerable source, Cancel try { - if (!await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } double sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { sum += e.Current; ++count; @@ -261,8 +247,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -271,8 +256,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -301,16 +285,14 @@ private static async Task Average_(IAsyncEnumerable source, Ca try { - if (!await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { sum += e.Current; ++count; @@ -330,16 +312,14 @@ private static async Task Average_(IAsyncEnumerable source, Ca try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) { var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { v = e.Current; if (v.HasValue) diff --git a/Ix.NET/Source/System.Interactive.Async/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/Buffer.cs index 838c5529c7..2fd3bdc841 100644 --- a/Ix.NET/Source/System.Interactive.Async/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Buffer.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -89,8 +88,7 @@ protected override async Task MoveNextCore() { if (!stopped) { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; if (index++ % skip == 0) @@ -103,8 +101,7 @@ protected override async Task MoveNextCore() buffer.Add(item); } - if (buffers.Count > 0 && buffers.Peek() - .Count == count) + if (buffers.Count > 0 && buffers.Peek().Count == count) { current = buffers.Dequeue(); return true; @@ -136,4 +133,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Cast.cs b/Ix.NET/Source/System.Interactive.Async/Cast.cs index 1c85a69552..fae69b9093 100644 --- a/Ix.NET/Source/System.Interactive.Async/Cast.cs +++ b/Ix.NET/Source/System.Interactive.Async/Cast.cs @@ -1,11 +1,8 @@ -// // Licensed to the .NET Foundation under one or more agreements. -// // The .NET Foundation licenses this file to you under the Apache 2.0 License. -// // See the LICENSE file in the project root for more information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -30,8 +27,7 @@ public static IAsyncEnumerable OfType(this IAsyncEnumerable x is TType) - .Cast(); + return source.Where(x => x is TType).Cast(); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/Catch.cs index b35a1bd8ef..906f9dc494 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/Catch.cs @@ -46,7 +46,7 @@ public static IAsyncEnumerable Catch(this IAsyncEnumerable Catch_(this IEnumerable> sources) @@ -105,8 +105,7 @@ protected override async Task MoveNextCore() { try { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -131,8 +130,7 @@ protected override async Task MoveNextCore() } } - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -217,8 +215,7 @@ protected override async Task MoveNextCore() try { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -244,4 +241,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs index 3260e2912e..b08ba4d049 100644 --- a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Concatenate.cs @@ -83,8 +83,8 @@ public override async Task DisposeAsync() private IAsyncEnumerator currentEnumerator; private int mode; - const int State_OuterNext = 1; - const int State_While = 4; + private const int State_OuterNext = 1; + private const int State_While = 4; protected override async Task MoveNextCore() { @@ -117,8 +117,7 @@ protected override async Task MoveNextCore() break; case State_While: - if (await currentEnumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await currentEnumerator.MoveNextAsync().ConfigureAwait(false)) { current = currentEnumerator.Current; return true; @@ -200,8 +199,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken try { - while (await e.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { list.Add(e.Current); } @@ -255,8 +253,7 @@ protected override async Task MoveNextCore() { if (state == AsyncIteratorState.Allocated) { - enumerator = GetAsyncEnumerable(0) - .GetAsyncEnumerator(); + enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator(); state = AsyncIteratorState.Iterating; counter = 2; } @@ -265,8 +262,7 @@ protected override async Task MoveNextCore() { while (true) { - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -367,4 +363,4 @@ internal override IAsyncEnumerable GetAsyncEnumerable(int index) } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Contains.cs b/Ix.NET/Source/System.Interactive.Async/Contains.cs index 23b0a040ed..6a4f1ac895 100644 --- a/Ix.NET/Source/System.Interactive.Async/Contains.cs +++ b/Ix.NET/Source/System.Interactive.Async/Contains.cs @@ -1,10 +1,8 @@ -// // Licensed to the .NET Foundation under one or more agreements. -// // The .NET Foundation licenses this file to you under the Apache 2.0 License. -// // See the LICENSE file in the project root for more information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -48,4 +46,4 @@ public static Task Contains(this IAsyncEnumerable source return source.Contains(value, EqualityComparer.Default, cancellationToken); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Count.cs b/Ix.NET/Source/System.Interactive.Async/Count.cs index c277cf5817..46250566a3 100644 --- a/Ix.NET/Source/System.Interactive.Async/Count.cs +++ b/Ix.NET/Source/System.Interactive.Async/Count.cs @@ -2,9 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -37,8 +35,7 @@ public static Task Count(this IAsyncEnumerable source, Fu if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); } public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -48,8 +45,7 @@ public static Task Count(this IAsyncEnumerable source, Fu if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); } public static Task Count(this IAsyncEnumerable source) @@ -95,8 +91,7 @@ public static Task LongCount(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); } public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -106,8 +101,7 @@ public static Task LongCount(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); } public static Task LongCount(this IAsyncEnumerable source) @@ -138,4 +132,4 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCount(source, predicate, CancellationToken.None); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Create.cs b/Ix.NET/Source/System.Interactive.Async/Create.cs index ebd3ea6459..8da17ad686 100644 --- a/Ix.NET/Source/System.Interactive.Async/Create.cs +++ b/Ix.NET/Source/System.Interactive.Async/Create.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -36,22 +35,18 @@ private static IAsyncEnumerator CreateEnumerator(Func(); - var stop = new Action( - () => - { - tcs.TrySetCanceled(); - }); + var stop = new Action(() => tcs.TrySetCanceled()); - return await moveNext(tcs) - .ConfigureAwait(false); + return await moveNext(tcs).ConfigureAwait(false); }, current, dispose ); + return self; } - private class AnonymousAsyncEnumerable : IAsyncEnumerable + private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable { private readonly Func> getEnumerator; @@ -62,10 +57,7 @@ public AnonymousAsyncEnumerable(Func> getEnumerator) this.getEnumerator = getEnumerator; } - public IAsyncEnumerator GetAsyncEnumerator() - { - return getEnumerator(); - } + public IAsyncEnumerator GetAsyncEnumerator() => getEnumerator(); } private sealed class AnonymousAsyncIterator : AsyncIterator @@ -74,7 +66,6 @@ private sealed class AnonymousAsyncIterator : AsyncIterator private readonly Func dispose; private readonly Func> moveNext; - public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) { Debug.Assert(moveNext != null); @@ -125,4 +116,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs index e1df242281..6ff1131266 100644 --- a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs @@ -65,8 +65,7 @@ protected override async Task MoveNextCore() { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; state = AsyncIteratorState.Iterating; @@ -77,13 +76,12 @@ protected override async Task MoveNextCore() await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - state = AsyncIteratorState.Disposed; + state = AsyncIteratorState.Disposed; } return true; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; return true; @@ -129,4 +127,4 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/Defer.cs b/Ix.NET/Source/System.Interactive.Async/Defer.cs index c2b8021521..5fe39a78c4 100644 --- a/Ix.NET/Source/System.Interactive.Async/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Defer.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -16,9 +13,7 @@ public static IAsyncEnumerable Defer(Func factory() - .GetAsyncEnumerator()); + return CreateEnumerable(() => factory().GetAsyncEnumerator()); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index 3b6806c978..5e39cf291f 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -1,6 +1,6 @@ -// // Licensed to the .NET Foundation under one or more agreements. -// // The .NET Foundation licenses this file to you under the Apache 2.0 License. -// // See the LICENSE file in the project root for more information. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Threading; From 5b41d51364369aa6db5853ccc75a42bf9d740b49 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:40:17 -0700 Subject: [PATCH 049/862] Adding first async variant of SelectMany. --- .../System.Interactive.Async/SelectMany.cs | 106 +++++++++++++++++- Ix.NET/Source/Tests/AsyncTests.Single.cs | 8 +- 2 files changed, 107 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index 6ecab3d6ed..722aee23c1 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -20,7 +20,6 @@ public static IAsyncEnumerable SelectMany(this IAsyncEn return source.SelectMany(_ => other); } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector) { if (source == null) @@ -31,6 +30,16 @@ public static IAsyncEnumerable SelectMany(this IAsync return new SelectManyAsyncIterator(source, selector); } + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return new SelectManyAsyncIteratorWithTask(source, selector); + } + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector) { if (source == null) @@ -129,8 +138,99 @@ protected override async Task MoveNextCore() await resultEnumerator.DisposeAsync().ConfigureAwait(false); } - resultEnumerator = selector(sourceEnumerator.Current) - .GetAsyncEnumerator(); + var inner = selector(sourceEnumerator.Current); + resultEnumerator = inner.GetAsyncEnumerator(); + + mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = resultEnumerator.Current; + return true; + } + + mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class SelectManyAsyncIteratorWithTask : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> selector; + private readonly IAsyncEnumerable source; + + private int mode; + private IAsyncEnumerator resultEnumerator; + private IAsyncEnumerator sourceEnumerator; + + public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + this.source = source; + this.selector = selector; + } + + public override AsyncIterator Clone() + { + return new SelectManyAsyncIteratorWithTask(source, selector); + } + + public override async Task DisposeAsync() + { + if (sourceEnumerator != null) + { + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); + sourceEnumerator = null; + } + + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + resultEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + sourceEnumerator = source.GetAsyncEnumerator(); + mode = State_Source; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (mode) + { + case State_Source: + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + var inner = await selector(sourceEnumerator.Current).ConfigureAwait(false); + resultEnumerator = inner.GetAsyncEnumerator(); mode = State_Result; goto case State_Result; diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index dc87844b11..14d8c68c15 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -268,13 +268,13 @@ public async Task Where9() [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerable.SelectMany(null, x => null)); - AssertThrows(() => AsyncEnumerable.SelectMany(null, (x, i) => null)); + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(null, x => null, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(null, (x, i) => null, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), x => null, default(Func))); From 6a514382f67c1c703db57d0b7cb0ca98b8045119 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:40:35 -0700 Subject: [PATCH 050/862] Renaming a file. --- .../System.Interactive.Async/{StartsWith.cs => StartWith.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{StartsWith.cs => StartWith.cs} (100%) diff --git a/Ix.NET/Source/System.Interactive.Async/StartsWith.cs b/Ix.NET/Source/System.Interactive.Async/StartWith.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/StartsWith.cs rename to Ix.NET/Source/System.Interactive.Async/StartWith.cs From cef656eb14f82d98046511da6e0c7f4252355da9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:47:10 -0700 Subject: [PATCH 051/862] Adding remaining async variants of SelectMany. --- .../System.Interactive.Async/SelectMany.cs | 348 +++++++++++++++++- 1 file changed, 343 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs index 722aee23c1..c760adecfe 100644 --- a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/SelectMany.cs @@ -50,6 +50,16 @@ public static IAsyncEnumerable SelectMany(this IAsync return new SelectManyWithIndexAsyncIterator(source, selector); } + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return new SelectManyWithIndexAsyncIteratorWithTask(source, selector); + } + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) { if (source == null) @@ -62,6 +72,18 @@ public static IAsyncEnumerable SelectMany(source, selector, resultSelector); } + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return new SelectManyAsyncIteratorWithTask(source, selector, resultSelector); + } + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) { if (source == null) @@ -74,6 +96,18 @@ public static IAsyncEnumerable SelectMany(source, selector, resultSelector); } + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return new SelectManyWithIndexAsyncIteratorWithTask(source, selector, resultSelector); + } + private sealed class SelectManyAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -327,8 +361,8 @@ protected override async Task MoveNextCore() } currentSource = sourceEnumerator.Current; - resultEnumerator = collectionSelector(currentSource) - .GetAsyncEnumerator(); + var inner = collectionSelector(currentSource); + resultEnumerator = inner.GetAsyncEnumerator(); mode = State_Result; goto case State_Result; @@ -354,6 +388,104 @@ protected override async Task MoveNextCore() } } + private sealed class SelectManyAsyncIteratorWithTask : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> collectionSelector; + private readonly Func> resultSelector; + private readonly IAsyncEnumerable source; + + private TSource currentSource; + private int mode; + private IAsyncEnumerator resultEnumerator; + private IAsyncEnumerator sourceEnumerator; + + public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + { + Debug.Assert(source != null); + Debug.Assert(collectionSelector != null); + Debug.Assert(resultSelector != null); + + this.source = source; + this.collectionSelector = collectionSelector; + this.resultSelector = resultSelector; + } + + public override AsyncIterator Clone() + { + return new SelectManyAsyncIteratorWithTask(source, collectionSelector, resultSelector); + } + + public override async Task DisposeAsync() + { + if (sourceEnumerator != null) + { + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); + sourceEnumerator = null; + } + + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + resultEnumerator = null; + } + + currentSource = default(TSource); + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + sourceEnumerator = source.GetAsyncEnumerator(); + mode = State_Source; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (mode) + { + case State_Source: + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + currentSource = sourceEnumerator.Current; + var inner = await collectionSelector(currentSource).ConfigureAwait(false); + resultEnumerator = inner.GetAsyncEnumerator(); + + mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = await resultSelector(currentSource, resultEnumerator.Current).ConfigureAwait(false); + return true; + } + + mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + private sealed class SelectManyWithIndexAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -433,7 +565,8 @@ protected override async Task MoveNextCore() index++; } - resultEnumerator = collectionSelector(currentSource, index).GetAsyncEnumerator(); + var inner = collectionSelector(currentSource, index); + resultEnumerator = inner.GetAsyncEnumerator(); mode = State_Result; goto case State_Result; @@ -459,6 +592,112 @@ protected override async Task MoveNextCore() } } + private sealed class SelectManyWithIndexAsyncIteratorWithTask : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> collectionSelector; + private readonly Func> resultSelector; + private readonly IAsyncEnumerable source; + + private TSource currentSource; + private int index; + private int mode; + private IAsyncEnumerator resultEnumerator; + private IAsyncEnumerator sourceEnumerator; + + public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + { + Debug.Assert(source != null); + Debug.Assert(collectionSelector != null); + Debug.Assert(resultSelector != null); + + this.source = source; + this.collectionSelector = collectionSelector; + this.resultSelector = resultSelector; + } + + public override AsyncIterator Clone() + { + return new SelectManyWithIndexAsyncIteratorWithTask(source, collectionSelector, resultSelector); + } + + public override async Task DisposeAsync() + { + if (sourceEnumerator != null) + { + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); + sourceEnumerator = null; + } + + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + resultEnumerator = null; + } + + currentSource = default(TSource); + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + sourceEnumerator = source.GetAsyncEnumerator(); + index = -1; + mode = State_Source; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (mode) + { + case State_Source: + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + currentSource = sourceEnumerator.Current; + + checked + { + index++; + } + + var inner = await collectionSelector(currentSource, index).ConfigureAwait(false); + resultEnumerator = inner.GetAsyncEnumerator(); + + mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = await resultSelector(currentSource, resultEnumerator.Current).ConfigureAwait(false); + return true; + } + + mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + private sealed class SelectManyWithIndexAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -529,8 +768,107 @@ protected override async Task MoveNextCore() { index++; } - resultEnumerator = selector(sourceEnumerator.Current, index) - .GetAsyncEnumerator(); + + var inner = selector(sourceEnumerator.Current, index); + resultEnumerator = inner.GetAsyncEnumerator(); + + mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = resultEnumerator.Current; + return true; + } + + mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class SelectManyWithIndexAsyncIteratorWithTask : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> selector; + private readonly IAsyncEnumerable source; + + private int index; + private int mode; + private IAsyncEnumerator resultEnumerator; + private IAsyncEnumerator sourceEnumerator; + + public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + this.source = source; + this.selector = selector; + } + + public override AsyncIterator Clone() + { + return new SelectManyWithIndexAsyncIteratorWithTask(source, selector); + } + + public override async Task DisposeAsync() + { + if (sourceEnumerator != null) + { + await sourceEnumerator.DisposeAsync().ConfigureAwait(false); + sourceEnumerator = null; + } + + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + resultEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + sourceEnumerator = source.GetAsyncEnumerator(); + index = -1; + mode = State_Source; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (mode) + { + case State_Source: + if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (resultEnumerator != null) + { + await resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + checked + { + index++; + } + + var inner = await selector(sourceEnumerator.Current, index).ConfigureAwait(false); + resultEnumerator = inner.GetAsyncEnumerator(); mode = State_Result; goto case State_Result; From 74803bfbfd33f377eea7c194db1ce8267f1850f2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:50:10 -0700 Subject: [PATCH 052/862] Splitting All and Any. --- Ix.NET/Source/System.Interactive.Async/All.cs | 93 +++++++++++++++++++ .../{AnyAll.cs => Any.cs} | 80 ---------------- 2 files changed, 93 insertions(+), 80 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/All.cs rename Ix.NET/Source/System.Interactive.Async/{AnyAll.cs => Any.cs} (58%) diff --git a/Ix.NET/Source/System.Interactive.Async/All.cs b/Ix.NET/Source/System.Interactive.Async/All.cs new file mode 100644 index 0000000000..bef9eac3ee --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/All.cs @@ -0,0 +1,93 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task All(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return All(source, predicate, CancellationToken.None); + } + + public static Task All(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return All(source, predicate, CancellationToken.None); + } + + public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return All_(source, predicate, cancellationToken); + } + + public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return All_(source, predicate, cancellationToken); + } + + private static async Task All_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + if (!predicate(e.Current)) + return false; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return true; + } + + private static async Task All_(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + if (!await predicate(e.Current).ConfigureAwait(false)) + return false; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return true; + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs b/Ix.NET/Source/System.Interactive.Async/Any.cs similarity index 58% rename from Ix.NET/Source/System.Interactive.Async/AnyAll.cs rename to Ix.NET/Source/System.Interactive.Async/Any.cs index 2fe3929308..067aff0e27 100644 --- a/Ix.NET/Source/System.Interactive.Async/AnyAll.cs +++ b/Ix.NET/Source/System.Interactive.Async/Any.cs @@ -10,46 +10,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task All(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return All(source, predicate, CancellationToken.None); - } - - public static Task All(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return All(source, predicate, CancellationToken.None); - } - - public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return All_(source, predicate, cancellationToken); - } - - public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return All_(source, predicate, cancellationToken); - } - public static Task Any(this IAsyncEnumerable source, Func predicate) { if (source == null) @@ -115,46 +75,6 @@ public static async Task Any(this IAsyncEnumerable sourc } } - private static async Task All_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(); - - try - { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - if (!predicate(e.Current)) - return false; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return true; - } - - private static async Task All_(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(); - - try - { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - if (!await predicate(e.Current).ConfigureAwait(false)) - return false; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return true; - } - private static async Task Any_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); From f2600ee3ba8144bea3656fd86ec50133af8c1f69 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Aug 2017 23:52:59 -0700 Subject: [PATCH 053/862] Reordering Aggregate overloads. --- .../System.Interactive.Async/Aggregate.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index dc54e30118..baaeaddcf3 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -10,68 +10,68 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) + public static Task Aggregate(this IAsyncEnumerable source, Func accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - return Aggregate(source, seed, accumulator, resultSelector, CancellationToken.None); + return Aggregate(source, accumulator, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) + public static Task Aggregate(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate(source, seed, accumulator, CancellationToken.None); + return Aggregate_(source, accumulator, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, Func accumulator) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate(source, accumulator, CancellationToken.None); + return Aggregate(source, seed, accumulator, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - return Aggregate_(source, seed, accumulator, resultSelector, cancellationToken); + return source.Aggregate(seed, accumulator, x => x, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); - return source.Aggregate(seed, accumulator, x => x, cancellationToken); + return Aggregate(source, seed, accumulator, resultSelector, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); - return Aggregate_(source, accumulator, cancellationToken); + return Aggregate_(source, seed, accumulator, resultSelector, cancellationToken); } private static async Task Aggregate_(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) From 01c87be60b528a8ba4e5bd991760b9e45a94e6eb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 09:55:09 -0700 Subject: [PATCH 054/862] Async variants of Aggregate. --- .../System.Interactive.Async/Aggregate.cs | 111 ++++++++++++++++++ .../MinMax.Generated.cs | 80 ++++++------- .../MinMax.Generated.tt | 8 +- Ix.NET/Source/Tests/AsyncTests.Aggregates.cs | 20 ++-- 4 files changed, 165 insertions(+), 54 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs index baaeaddcf3..814dc3dd7b 100644 --- a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs +++ b/Ix.NET/Source/System.Interactive.Async/Aggregate.cs @@ -30,6 +30,26 @@ public static Task Aggregate(this IAsyncEnumerable so return Aggregate_(source, accumulator, cancellationToken); } + public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return Aggregate(source, accumulator, CancellationToken.None); + } + + public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return Aggregate_(source, accumulator, cancellationToken); + } + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) { if (source == null) @@ -50,6 +70,26 @@ public static Task Aggregate(this IAsyncEnume return source.Aggregate(seed, accumulator, x => x, cancellationToken); } + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return Aggregate(source, seed, accumulator, CancellationToken.None); + } + + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return source.Aggregate(seed, accumulator, x => Task.FromResult(x), cancellationToken); + } + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) { if (source == null) @@ -74,6 +114,30 @@ public static Task Aggregate(this IAsync return Aggregate_(source, seed, accumulator, resultSelector, cancellationToken); } + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return Aggregate(source, seed, accumulator, resultSelector, CancellationToken.None); + } + + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return Aggregate_(source, seed, accumulator, resultSelector, cancellationToken); + } + private static async Task Aggregate_(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { var acc = seed; @@ -120,5 +184,52 @@ private static async Task Aggregate_(IAsyncEnumerable return acc; } + + private static async Task Aggregate_(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + { + var acc = seed; + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return await resultSelector(acc).ConfigureAwait(false); + } + + private static async Task Aggregate_(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + { + var first = true; + var acc = default(TSource); + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + acc = first ? e.Current : await accumulator(acc, e.Current).ConfigureAwait(false); + first = false; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + if (first) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + return acc; + } } } diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs index 1293f74c64..4350291874 100644 --- a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs @@ -15,7 +15,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, CancellationToken.None); + return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,7 +23,7 @@ public static Task Max(this IAsyncEnumerable source, CancellationToken if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, cancellationToken); + return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -71,7 +71,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, CancellationToken.None); + return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -79,7 +79,7 @@ public static Task Max(this IAsyncEnumerable source, CancellationTok if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, cancellationToken); + return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -127,7 +127,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, CancellationToken.None); + return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -135,7 +135,7 @@ public static Task Max(this IAsyncEnumerable source, CancellationT if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, cancellationToken); + return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -183,7 +183,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, CancellationToken.None); + return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -191,7 +191,7 @@ public static Task Max(this IAsyncEnumerable source, Cancellatio if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, cancellationToken); + return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -239,7 +239,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, CancellationToken.None); + return source.Aggregate(new Func(Math.Max), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -247,7 +247,7 @@ public static Task Max(this IAsyncEnumerable source, Cancellat if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Max, cancellationToken); + return source.Aggregate(new Func(Math.Max), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -295,7 +295,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), NullableMax, CancellationToken.None); + return source.Aggregate(default(int?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -303,7 +303,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), NullableMax, cancellationToken); + return source.Aggregate(default(int?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -351,7 +351,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), NullableMax, CancellationToken.None); + return source.Aggregate(default(long?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -359,7 +359,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), NullableMax, cancellationToken); + return source.Aggregate(default(long?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -407,7 +407,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), NullableMax, CancellationToken.None); + return source.Aggregate(default(float?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -415,7 +415,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), NullableMax, cancellationToken); + return source.Aggregate(default(float?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -463,7 +463,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), NullableMax, CancellationToken.None); + return source.Aggregate(default(double?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -471,7 +471,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), NullableMax, cancellationToken); + return source.Aggregate(default(double?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -519,7 +519,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), NullableMax, CancellationToken.None); + return source.Aggregate(default(decimal?), new Func(NullableMax), CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -527,7 +527,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), NullableMax, cancellationToken); + return source.Aggregate(default(decimal?), new Func(NullableMax), cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -575,7 +575,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, CancellationToken.None); + return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -583,7 +583,7 @@ public static Task Min(this IAsyncEnumerable source, CancellationToken if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, cancellationToken); + return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -631,7 +631,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, CancellationToken.None); + return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -639,7 +639,7 @@ public static Task Min(this IAsyncEnumerable source, CancellationTok if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, cancellationToken); + return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -687,7 +687,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, CancellationToken.None); + return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -695,7 +695,7 @@ public static Task Min(this IAsyncEnumerable source, CancellationT if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, cancellationToken); + return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -743,7 +743,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, CancellationToken.None); + return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -751,7 +751,7 @@ public static Task Min(this IAsyncEnumerable source, Cancellatio if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, cancellationToken); + return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -799,7 +799,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, CancellationToken.None); + return source.Aggregate(new Func(Math.Min), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -807,7 +807,7 @@ public static Task Min(this IAsyncEnumerable source, Cancellat if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(Math.Min, cancellationToken); + return source.Aggregate(new Func(Math.Min), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -855,7 +855,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), NullableMin, CancellationToken.None); + return source.Aggregate(default(int?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -863,7 +863,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), NullableMin, cancellationToken); + return source.Aggregate(default(int?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -911,7 +911,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), NullableMin, CancellationToken.None); + return source.Aggregate(default(long?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -919,7 +919,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), NullableMin, cancellationToken); + return source.Aggregate(default(long?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -967,7 +967,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), NullableMin, CancellationToken.None); + return source.Aggregate(default(float?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -975,7 +975,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), NullableMin, cancellationToken); + return source.Aggregate(default(float?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -1023,7 +1023,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), NullableMin, CancellationToken.None); + return source.Aggregate(default(double?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -1031,7 +1031,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), NullableMin, cancellationToken); + return source.Aggregate(default(double?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -1079,7 +1079,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), NullableMin, CancellationToken.None); + return source.Aggregate(default(decimal?), new Func(NullableMin), CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -1087,7 +1087,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), NullableMin, cancellationToken); + return source.Aggregate(default(decimal?), new Func(NullableMin), cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt index ad96b2f51e..86e1f60cb1 100644 --- a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt @@ -46,13 +46,13 @@ foreach (var m in new[] { "Max", "Min" }) if (n) { #> - return source.Aggregate(default(<#=t#>), Nullable<#=m#>, CancellationToken.None); + return source.Aggregate(default(<#=t#>), new Func<<#=t#>, <#=t#>, <#=t#>>(Nullable<#=m#>), CancellationToken.None); <# } else { #> - return source.Aggregate(Math.<#=m#>, CancellationToken.None); + return source.Aggregate(new Func<<#=t#>, <#=t#>, <#=t#>>(Math.<#=m#>), CancellationToken.None); <# } #> @@ -67,13 +67,13 @@ else if (n) { #> - return source.Aggregate(default(<#=t#>), Nullable<#=m#>, cancellationToken); + return source.Aggregate(default(<#=t#>), new Func<<#=t#>, <#=t#>, <#=t#>>(Nullable<#=m#>), cancellationToken); <# } else { #> - return source.Aggregate(Math.<#=m#>, cancellationToken); + return source.Aggregate(new Func<<#=t#>, <#=t#>, <#=t#>>(Math.<#=m#>), cancellationToken); <# } #> diff --git a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs index e24ab42af2..67c081a460 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs @@ -23,24 +23,24 @@ public partial class AsyncTests public async Task Aggregate_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, null, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, null, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func), CancellationToken.None)); } [Fact] @@ -73,7 +73,7 @@ public void Aggregate4() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate((x, y) => { throw ex; }); + var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -107,7 +107,7 @@ public void Aggregate8() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => { throw ex; }); + var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } From 0db5681ca0d1eb54e92cda4fd8fa2f04f4b039cc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 09:56:12 -0700 Subject: [PATCH 055/862] Some code cosmetics. --- Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs index 061794f176..92872e2dbb 100644 --- a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs +++ b/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs @@ -447,8 +447,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio try { - while (await en.MoveNextAsync(cancellationToken) - .ConfigureAwait(false)) + while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { array[index] = en.Current; ++index; From 582670448cf41008cd191864877c392b6225fca6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 09:57:48 -0700 Subject: [PATCH 056/862] Splitting IsEmpty into separate file. --- .../AsyncEnumerable.cs | 25 +------------- .../System.Interactive.Async/IsEmpty.cs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/IsEmpty.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs index f2de2ea7d4..63ffe1b63e 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -23,31 +22,14 @@ public static IAsyncEnumerable Empty() return CreateEnumerable(() => CreateEnumerator(ct => TaskExt.False, current: null, dispose: null)); } - public static Task IsEmpty(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.IsEmpty(CancellationToken.None); - } - - public static Task IsEmpty(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return IsEmpty_(source, cancellationToken); - } - public static IAsyncEnumerable Never() { return CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); } - public static IAsyncEnumerable Return(TValue value) { - return new[] {value}.ToAsyncEnumerable(); + return new[] { value }.ToAsyncEnumerable(); } public static IAsyncEnumerable Throw(Exception exception) @@ -67,10 +49,5 @@ public static IAsyncEnumerable Throw(Exception exception) dispose: null) ); } - - private static async Task IsEmpty_(IAsyncEnumerable source, CancellationToken cancellationToken) - { - return !await source.Any(cancellationToken).ConfigureAwait(false); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/IsEmpty.cs new file mode 100644 index 0000000000..14b5f8f5d6 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/IsEmpty.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task IsEmpty(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.IsEmpty(CancellationToken.None); + } + + public static Task IsEmpty(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return IsEmpty_(source, cancellationToken); + } + + private static async Task IsEmpty_(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return !await source.Any(cancellationToken).ConfigureAwait(false); + } + } +} From 1c9258123a0c914e8996f1279dc97374563b8f7d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 09:59:19 -0700 Subject: [PATCH 057/862] Moving CompletedTask to TaskExt. --- Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs | 5 ++--- Ix.NET/Source/System.Interactive.Async/TaskExt.cs | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 120e967f3b..bdec262a64 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -10,8 +10,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - private static readonly Task CompletedTask = TaskExt.True; - internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator { private readonly int threadId; @@ -57,13 +55,14 @@ public virtual Task DisposeAsync() { cancellationTokenSource.Cancel(); } + cancellationTokenSource.Dispose(); } current = default(TSource); state = AsyncIteratorState.Disposed; - return CompletedTask; + return TaskExt.CompletedTask; } public TSource Current diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index c9512dcde0..ff33c9c9a2 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -8,5 +8,6 @@ static class TaskExt { public static readonly Task True = Task.FromResult(true); public static readonly Task False = Task.FromResult(false); + public static readonly Task CompletedTask = True; } } From 91cdd73ba82550a6309285a92cd549f1c91979e9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:03:14 -0700 Subject: [PATCH 058/862] Async variant of Catch. --- .../Source/System.Interactive.Async/Catch.cs | 109 +++++++++++++++++- Ix.NET/Source/Tests/AsyncTests.Exceptions.cs | 4 +- 2 files changed, 107 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/Catch.cs index 906f9dc494..92a3882425 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/Catch.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.ExceptionServices; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -23,6 +22,17 @@ public static IAsyncEnumerable Catch(this IAsyncEn return new CatchAsyncIterator(source, handler); } + public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func>> handler) + where TException : Exception + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (handler == null) + throw new ArgumentNullException(nameof(handler)); + + return new CatchAsyncIteratorWithTask(source, handler); + } + public static IAsyncEnumerable Catch(this IEnumerable> sources) { if (sources == null) @@ -116,8 +126,101 @@ protected override async Task MoveNextCore() // Note: Ideally we'd dipose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - var err = handler(ex) - .GetAsyncEnumerator(); + var inner = handler(ex); + var err = inner.GetAsyncEnumerator(); + + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + + enumerator = err; + isDone = true; + continue; // loop so we hit the catch state + } + } + + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + break; // while + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class CatchAsyncIteratorWithTask : AsyncIterator where TException : Exception + { + private readonly Func>> handler; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private bool isDone; + + public CatchAsyncIteratorWithTask(IAsyncEnumerable source, Func>> handler) + { + Debug.Assert(source != null); + Debug.Assert(handler != null); + + this.source = source; + this.handler = handler; + } + + public override AsyncIterator Clone() + { + return new CatchAsyncIteratorWithTask(source, handler); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + isDone = false; + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (true) + { + if (!isDone) + { + try + { + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + } + catch (TException ex) + { + // Note: Ideally we'd dipose of the previous enumerator before + // invoking the handler, but we use this order to preserve + // current behavior + var inner = await handler(ex).ConfigureAwait(false); + var err = inner.GetAsyncEnumerator(); if (enumerator != null) { diff --git a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs index 86dfc17667..82e477fd96 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Exceptions.cs @@ -5,9 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Xunit; -using System.Threading; using System.Threading.Tasks; namespace Tests @@ -17,7 +15,7 @@ public partial class AsyncTests [Fact] public void Catch_Null() { - AssertThrows(() => AsyncEnumerable.Catch(default(IAsyncEnumerable), x => null)); + AssertThrows(() => AsyncEnumerable.Catch(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerable.Catch(AsyncEnumerable.Return(42), default(Func>))); AssertThrows(() => AsyncEnumerable.Catch(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); From f92678e70baa8c494d854ef8ae46769cbbb29a32 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:20:02 -0700 Subject: [PATCH 059/862] Async variants of Create and Defer. --- .../Source/System.Interactive.Async/Create.cs | 97 +++++++++++++++++++ .../Source/System.Interactive.Async/Defer.cs | 9 ++ 2 files changed, 106 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/Create.cs b/Ix.NET/Source/System.Interactive.Async/Create.cs index 8da17ad686..c0dbaac1af 100644 --- a/Ix.NET/Source/System.Interactive.Async/Create.cs +++ b/Ix.NET/Source/System.Interactive.Async/Create.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -18,6 +19,14 @@ public static IAsyncEnumerable CreateEnumerable(Func> return new AnonymousAsyncEnumerable(getEnumerator); } + public static IAsyncEnumerable CreateEnumerable(Func>> getEnumerator) + { + if (getEnumerator == null) + throw new ArgumentNullException(nameof(getEnumerator)); + + return new AnonymousAsyncEnumerableWithTask(getEnumerator); + } + public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Func dispose) { if (moveNext == null) @@ -60,6 +69,94 @@ public AnonymousAsyncEnumerable(Func> getEnumerator) public IAsyncEnumerator GetAsyncEnumerator() => getEnumerator(); } + private sealed class AnonymousAsyncEnumerableWithTask : IAsyncEnumerable + { + private readonly Func>> getEnumerator; + + public AnonymousAsyncEnumerableWithTask(Func>> getEnumerator) + { + Debug.Assert(getEnumerator != null); + + this.getEnumerator = getEnumerator; + } + + public IAsyncEnumerator GetAsyncEnumerator() => new Enumerator(getEnumerator); + + private sealed class Enumerator : IAsyncEnumerator + { + private Func>> getEnumerator; + private IAsyncEnumerator enumerator; + + public Enumerator(Func>> getEnumerator) + { + Debug.Assert(getEnumerator != null); + + this.getEnumerator = getEnumerator; + } + + public T Current + { + get + { + if (enumerator == null) + throw new InvalidOperationException(); + + return enumerator.Current; + } + } + + public async Task DisposeAsync() + { + var old = Interlocked.Exchange(ref enumerator, DisposedEnumerator.Instance); + + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + } + + public Task MoveNextAsync() + { + if (enumerator == null) + { + return InitAndMoveNextAsync(); + } + + return enumerator.MoveNextAsync(); + } + + private async Task InitAndMoveNextAsync() + { + try + { + enumerator = await getEnumerator().ConfigureAwait(false); + } + catch (Exception ex) + { + enumerator = Throw(ex).GetAsyncEnumerator(); + throw; + } + finally + { + getEnumerator = null; + } + + return await enumerator.MoveNextAsync().ConfigureAwait(false); + } + + private sealed class DisposedEnumerator : IAsyncEnumerator + { + public static readonly DisposedEnumerator Instance = new DisposedEnumerator(); + + public T Current => throw new ObjectDisposedException("this"); + + public Task DisposeAsync() => TaskExt.CompletedTask; + + public Task MoveNextAsync() => throw new ObjectDisposedException("this"); + } + } + } + private sealed class AnonymousAsyncIterator : AsyncIterator { private readonly Func currentFunc; diff --git a/Ix.NET/Source/System.Interactive.Async/Defer.cs b/Ix.NET/Source/System.Interactive.Async/Defer.cs index 5fe39a78c4..ee44b2b721 100644 --- a/Ix.NET/Source/System.Interactive.Async/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/Defer.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading.Tasks; namespace System.Linq { @@ -15,5 +16,13 @@ public static IAsyncEnumerable Defer(Func factory().GetAsyncEnumerator()); } + + public static IAsyncEnumerable Defer(Func>> factory) + { + if (factory == null) + throw new ArgumentNullException(nameof(factory)); + + return CreateEnumerable(async () => (await factory().ConfigureAwait(false)).GetAsyncEnumerator()); + } } } From 5995192416733d4632b36f2a0024d576917e77a0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:31:52 -0700 Subject: [PATCH 060/862] Fixing some tests. --- Ix.NET/Source/Tests/AsyncTests.Creation.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index 9c648e2955..dba69d92ce 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Xunit; using System.Threading.Tasks; using System.Threading; @@ -18,23 +17,20 @@ public partial class AsyncTests [Fact] public void Create_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerable(null)); + AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); AssertThrows(() => AsyncEnumerable.CreateEnumerator(null, () => 3, () => Task.FromResult(true))); - } [Fact] public void Create_Iterator_Throws() { - - var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => Task.FromResult(true)); + var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => Task.FromResult(true)); var enu = (IAsyncEnumerable)iter; AssertThrows(() => enu.GetAsyncEnumerator()); } - [Fact] public void Return() { @@ -56,8 +52,8 @@ public async Task Never() [Fact] public async Task Empty_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.IsEmpty(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.IsEmpty(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.IsEmpty(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.IsEmpty(null, CancellationToken.None)); } [Fact] @@ -181,7 +177,7 @@ public async Task Repeat4() [Fact] public void Defer_Null() { - AssertThrows(() => AsyncEnumerable.Defer(null)); + AssertThrows(() => AsyncEnumerable.Defer(default(Func>))); } [Fact] @@ -338,7 +334,7 @@ public void Using3() Assert.Equal(0, i); AssertThrows(() => xs.GetAsyncEnumerator(), ex_ => ex_ == ex); - + Assert.Equal(1, d); } From e857487e3156d54f944910be8bd7b0145679adcf Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:33:35 -0700 Subject: [PATCH 061/862] Reordering Distinct overloads. --- .../System.Interactive.Async/Distinct.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index af2615ff31..18dee9a61d 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -11,16 +11,22 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Distinct(EqualityComparer.Default); + } + + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new DistinctAsyncIterator(source, keySelector, comparer); + return new DistinctAsyncIterator(source, comparer); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector) @@ -33,22 +39,16 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return source.Distinct(keySelector, EqualityComparer.Default); } - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, IEqualityComparer comparer) + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new DistinctAsyncIterator(source, comparer); - } - - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Distinct(EqualityComparer.Default); + return new DistinctAsyncIterator(source, keySelector, comparer); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source) From 9a752692ddfe24130e291e5910f155ef4dbe7e28 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:38:24 -0700 Subject: [PATCH 062/862] Async variants of Distinct and DistinctUntilChanged. --- .../System.Interactive.Async/Distinct.cs | 298 +++++++++++++++++- Ix.NET/Source/Tests/AsyncTests.Single.cs | 4 +- 2 files changed, 284 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index 18dee9a61d..7f22a3b0d8 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -51,6 +51,28 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return new DistinctAsyncIterator(source, keySelector, comparer); } + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.Distinct(keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); + } + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source) { if (source == null) @@ -91,11 +113,149 @@ public static IAsyncEnumerable DistinctUntilChanged(this return source.DistinctUntilChanged_(keySelector, comparer); } + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.DistinctUntilChanged_(keySelector, comparer); + } + private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); } + private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); + } + + private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider + { + private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private Set set; + + public DistinctAsyncIterator(IAsyncEnumerable source, IEqualityComparer comparer) + { + Debug.Assert(source != null); + + this.source = source; + this.comparer = comparer; + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s.ToArray(); + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken) + .ConfigureAwait(false); + return s.ToList(); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + return onlyIfCheap ? -1 : (await FillSetAsync(cancellationToken).ConfigureAwait(false)).Count; + } + + public override AsyncIterator Clone() + { + return new DistinctAsyncIterator(source, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + set = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + await DisposeAsync().ConfigureAwait(false); + return false; + } + + var element = enumerator.Current; + set = new Set(comparer); + set.Add(element); + current = element; + + state = AsyncIteratorState.Iterating; + return true; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + element = enumerator.Current; + if (set.Add(element)) + { + current = element; + return true; + } + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + + private async Task> FillSetAsync(CancellationToken cancellationToken) + { + var s = new Set(comparer); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + s.Add(enu.Current); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return s; + } + } + private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider { private readonly IEqualityComparer comparer; @@ -242,19 +402,23 @@ private async Task> FillSetAsync(CancellationToken cancellationTok } } - private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider + private sealed class DistinctAsyncIteratorWithTask : AsyncIterator, IIListProvider { - private readonly IEqualityComparer comparer; + private readonly IEqualityComparer comparer; + private readonly Func> keySelector; private readonly IAsyncEnumerable source; private IAsyncEnumerator enumerator; - private Set set; + private Set set; - public DistinctAsyncIterator(IAsyncEnumerable source, IEqualityComparer comparer) + public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(comparer != null); this.source = source; + this.keySelector = keySelector; this.comparer = comparer; } @@ -266,19 +430,44 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) public async Task> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken) - .ConfigureAwait(false); - return s.ToList(); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s; } public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return onlyIfCheap ? -1 : (await FillSetAsync(cancellationToken).ConfigureAwait(false)).Count; + if (onlyIfCheap) + { + return -1; + } + + var count = 0; + var s = new Set(comparer); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var item = enu.Current; + if (s.Add(await keySelector(item).ConfigureAwait(false))) + { + count++; + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return count; } public override AsyncIterator Clone() { - return new DistinctAsyncIterator(source, comparer); + return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); } public override async Task DisposeAsync() @@ -299,6 +488,7 @@ protected override async Task MoveNextCore() { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); + if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); @@ -306,8 +496,8 @@ protected override async Task MoveNextCore() } var element = enumerator.Current; - set = new Set(comparer); - set.Add(element); + set = new Set(comparer); + set.Add(await keySelector(element).ConfigureAwait(false)); current = element; state = AsyncIteratorState.Iterating; @@ -317,7 +507,7 @@ protected override async Task MoveNextCore() while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { element = enumerator.Current; - if (set.Add(element)) + if (set.Add(await keySelector(element).ConfigureAwait(false))) { current = element; return true; @@ -331,9 +521,10 @@ protected override async Task MoveNextCore() return false; } - private async Task> FillSetAsync(CancellationToken cancellationToken) + private async Task> FillSetAsync(CancellationToken cancellationToken) { - var s = new Set(comparer); + var s = new Set(comparer); + var r = new List(); var enu = source.GetAsyncEnumerator(); @@ -341,7 +532,11 @@ private async Task> FillSetAsync(CancellationToken cancellationToke { while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { - s.Add(enu.Current); + var item = enu.Current; + if (s.Add(await keySelector(item).ConfigureAwait(false))) + { + r.Add(item); + } } } finally @@ -349,7 +544,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke await enu.DisposeAsync().ConfigureAwait(false); } - return s; + return r; } } @@ -495,5 +690,76 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class DistinctUntilChangedAsyncIteratorWithTask : AsyncIterator + { + private readonly IEqualityComparer comparer; + private readonly Func> keySelector; + private readonly IAsyncEnumerable source; + private TKey currentKeyValue; + + private IAsyncEnumerator enumerator; + private bool hasCurrentKey; + + public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + } + + public override AsyncIterator Clone() + { + return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + currentKeyValue = default(TKey); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + var key = await keySelector(item).ConfigureAwait(false); + var comparerEquals = false; + + if (hasCurrentKey) + { + comparerEquals = comparer.Equals(currentKeyValue, key); + } + if (!hasCurrentKey || !comparerEquals) + { + hasCurrentKey = true; + currentKeyValue = key; + current = item; + return true; + } + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } } } diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index 14d8c68c15..32207d78ce 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -3260,10 +3260,10 @@ public async Task Scan6() public void DistinctKey_Null() { AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), default(Func))); AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), null, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), x => x, null)); } From 12063f6d823043c91ba5fb75165c4d9dbb6ad769 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:43:04 -0700 Subject: [PATCH 063/862] Async variants of Do. --- Ix.NET/Source/System.Interactive.Async/Do.cs | 138 ++++++++++++++++++- 1 file changed, 135 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/Do.cs index 938a45d341..eefd8cb623 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/Do.cs @@ -58,6 +58,54 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + + return DoHelper(source, onNext, null, null); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + + return DoHelper(source, onNext, null, onCompleted); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + + return DoHelper(source, onNext, onError, null); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + + return DoHelper(source, onNext, onError, onCompleted); + } + public static IAsyncEnumerable Do(this IAsyncEnumerable source, IObserver observer) { if (source == null) @@ -65,7 +113,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable(observer.OnNext), new Action(observer.OnError), new Action(observer.OnCompleted)); } private static IAsyncEnumerable DoHelper(this IAsyncEnumerable source, Action onNext, Action onError, Action onCompleted) @@ -73,6 +121,11 @@ private static IAsyncEnumerable DoHelper(this IAsyncEnumerable return new DoAsyncIterator(source, onNext, onError, onCompleted); } + private static IAsyncEnumerable DoHelper(this IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); + } + private sealed class DoAsyncIterator : AsyncIterator { private readonly Action onCompleted; @@ -133,9 +186,9 @@ protected override async Task MoveNextCore() { throw; } - catch (Exception ex) + catch (Exception ex) when (onError != null) { - onError?.Invoke(ex); + onError(ex); throw; } @@ -148,5 +201,84 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class DoAsyncIteratorWithTask : AsyncIterator + { + private readonly Func onCompleted; + private readonly Func onError; + private readonly Func onNext; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + + public DoAsyncIteratorWithTask(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + Debug.Assert(source != null); + Debug.Assert(onNext != null); + + this.source = source; + this.onNext = onNext; + this.onError = onError; + this.onCompleted = onCompleted; + } + + public override AsyncIterator Clone() + { + return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + try + { + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + await onNext(current).ConfigureAwait(false); + + return true; + } + } + catch (OperationCanceledException) + { + throw; + } + catch (Exception ex) when (onError != null) + { + await onError(ex).ConfigureAwait(false); + throw; + } + + if (onCompleted != null) + { + await onCompleted().ConfigureAwait(false); + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } From 004d8cd7d93c503880a6ce4c448d8d05a9acfcc2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:43:31 -0700 Subject: [PATCH 064/862] Sorting ElementAt overloads. --- .../System.Interactive.Async/ElementAt.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs index 5e39cf291f..33b800522b 100644 --- a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs +++ b/Ix.NET/Source/System.Interactive.Async/ElementAt.cs @@ -10,6 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { + public static Task ElementAt(this IAsyncEnumerable source, int index) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return ElementAt(source, index, CancellationToken.None); + } + public static Task ElementAt(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source == null) @@ -20,12 +28,12 @@ public static Task ElementAt(this IAsyncEnumerable so return ElementAt_(source, index, cancellationToken); } - public static Task ElementAt(this IAsyncEnumerable source, int index) + public static Task ElementAtOrDefault(this IAsyncEnumerable source, int index) { if (source == null) throw new ArgumentNullException(nameof(source)); - return ElementAt(source, index, CancellationToken.None); + return ElementAtOrDefault(source, index, CancellationToken.None); } public static Task ElementAtOrDefault(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) @@ -38,14 +46,6 @@ public static Task ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefault(this IAsyncEnumerable source, int index) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return ElementAtOrDefault(source, index, CancellationToken.None); - } - private static async Task ElementAt_(IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source is IList list) From 34c3e642ea8890b21bb1522b136312f33f6fd566 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:44:22 -0700 Subject: [PATCH 065/862] Some code cosmetics. --- Ix.NET/Source/System.Interactive.Async/Except.cs | 1 - Ix.NET/Source/System.Interactive.Async/Expand.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Interactive.Async/Except.cs index fe7a6f42a7..ab18a21310 100644 --- a/Ix.NET/Source/System.Interactive.Async/Except.cs +++ b/Ix.NET/Source/System.Interactive.Async/Except.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index 16cd9b9c76..4317d9c3d9 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq From a663af486435259acf188c1c9c0b637946ee7b12 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:48:13 -0700 Subject: [PATCH 066/862] Async variant of Expand. --- .../Source/System.Interactive.Async/Expand.cs | 100 ++++++++++++++++++ Ix.NET/Source/Tests/AsyncTests.Single.cs | 8 +- 2 files changed, 104 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/Expand.cs index 4317d9c3d9..9b57ba3f79 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/Expand.cs @@ -20,6 +20,16 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable(source, selector); } + public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return new ExpandAsyncIteratorWithTask(source, selector); + } + private sealed class ExpandAsyncIterator : AsyncIterator { private readonly Func> selector; @@ -109,5 +119,95 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class ExpandAsyncIteratorWithTask : AsyncIterator + { + private readonly Func>> selector; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + + private Queue> queue; + + public ExpandAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + this.source = source; + this.selector = selector; + } + + public override AsyncIterator Clone() + { + return new ExpandAsyncIteratorWithTask(source, selector); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + queue = null; + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + queue = new Queue>(); + queue.Enqueue(source); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (true) + { + if (enumerator == null) + { + if (queue.Count > 0) + { + var src = queue.Dequeue(); + + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + + enumerator = src.GetAsyncEnumerator(); + + continue; // loop + } + + break; // while + } + + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + var next = await selector(item).ConfigureAwait(false); + queue.Enqueue(next); + current = item; + return true; + } + + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } } } diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index 32207d78ce..d005e0eb3e 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -3138,8 +3138,8 @@ public async Task DistinctUntilChanged5() [Fact] public void Expand_Null() { - AssertThrows(() => AsyncEnumerable.Expand(default(IAsyncEnumerable), x => null)); - AssertThrows(() => AsyncEnumerable.Expand(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Expand(AsyncEnumerable.Return(42), default(Func>))); } [Fact] @@ -3162,7 +3162,7 @@ public void Expand1() public void Expand2() { var ex = new Exception("Bang!"); - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => { throw ex; }); + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(new Func>(x => { throw ex; })); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -3171,7 +3171,7 @@ public void Expand2() [Fact] public void Expand3() { - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => null); + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => default(IAsyncEnumerable)); var e = xs.GetAsyncEnumerator(); HasNext(e, 2); From d4d1fe14107ec3bb711f5dc8b940510028e6a6b7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:49:48 -0700 Subject: [PATCH 067/862] Async variant of Finally. --- .../System.Interactive.Async/Finally.cs | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/Finally.cs index 0a7591bd25..dad970388f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/Finally.cs @@ -20,6 +20,16 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable(source, finallyAction); } + public static IAsyncEnumerable Finally(this IAsyncEnumerable source, Func finallyAction) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (finallyAction == null) + throw new ArgumentNullException(nameof(finallyAction)); + + return new FinallyAsyncIteratorWithTask(source, finallyAction); + } + private sealed class FinallyAsyncIterator : AsyncIterator { private readonly Action finallyAction; @@ -77,5 +87,63 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class FinallyAsyncIteratorWithTask : AsyncIterator + { + private readonly Func finallyAction; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + + public FinallyAsyncIteratorWithTask(IAsyncEnumerable source, Func finallyAction) + { + Debug.Assert(source != null); + Debug.Assert(finallyAction != null); + + this.source = source; + this.finallyAction = finallyAction; + } + + public override AsyncIterator Clone() + { + return new FinallyAsyncIteratorWithTask(source, finallyAction); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + + await finallyAction().ConfigureAwait(false); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } From bcf2c05a151a187cff2d7fd3e8c7f96d9550c2e3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:55:41 -0700 Subject: [PATCH 068/862] Async variant of using. --- .../Source/System.Interactive.Async/Using.cs | 77 +++++++++++++++++++ Ix.NET/Source/Tests/AsyncTests.Creation.cs | 8 +- 2 files changed, 81 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/Using.cs index abd1b5f630..dce0c6da56 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/Using.cs @@ -20,6 +20,16 @@ public static IAsyncEnumerable Using(Func(resourceFactory, enumerableFactory); } + public static IAsyncEnumerable Using(Func> resourceFactory, Func>> enumerableFactory) where TResource : IDisposable + { + if (resourceFactory == null) + throw new ArgumentNullException(nameof(resourceFactory)); + if (enumerableFactory == null) + throw new ArgumentNullException(nameof(enumerableFactory)); + + return new UsingAsyncIteratorWithTask(resourceFactory, enumerableFactory); + } + private sealed class UsingAsyncIterator : AsyncIterator where TResource : IDisposable { private readonly Func> enumerableFactory; @@ -91,5 +101,72 @@ protected override void OnGetEnumerator() base.OnGetEnumerator(); } } + + private sealed class UsingAsyncIteratorWithTask : AsyncIterator where TResource : IDisposable + { + private readonly Func>> enumerableFactory; + private readonly Func> resourceFactory; + + private IAsyncEnumerable enumerable; + private IAsyncEnumerator enumerator; + private TResource resource; + + public UsingAsyncIteratorWithTask(Func> resourceFactory, Func>> enumerableFactory) + { + Debug.Assert(resourceFactory != null); + Debug.Assert(enumerableFactory != null); + + this.resourceFactory = resourceFactory; + this.enumerableFactory = enumerableFactory; + } + + public override AsyncIterator Clone() + { + return new UsingAsyncIteratorWithTask(resourceFactory, enumerableFactory); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + if (resource != null) + { + resource.Dispose(); + resource = default(TResource); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + resource = await resourceFactory().ConfigureAwait(false); + enumerable = await enumerableFactory(resource).ConfigureAwait(false); + + enumerator = enumerable.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } diff --git a/Ix.NET/Source/Tests/AsyncTests.Creation.cs b/Ix.NET/Source/Tests/AsyncTests.Creation.cs index dba69d92ce..4dbc2106a0 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Creation.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Xunit; -using System.Threading.Tasks; using System.Threading; +using System.Threading.Tasks; +using Xunit; namespace Tests { @@ -266,8 +266,8 @@ public async Task Generate5() [Fact] public void Using_Null() { - AssertThrows(() => AsyncEnumerable.Using(null, _ => null)); - AssertThrows(() => AsyncEnumerable.Using(() => new MyD(null), null)); + AssertThrows(() => AsyncEnumerable.Using(null, _ => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Using(() => new MyD(null), default(Func>))); } [Fact] From a08c66a558373b90bbc4a872160f27e9d323e1a2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:56:13 -0700 Subject: [PATCH 069/862] Reordering overloads of Union. --- Ix.NET/Source/System.Interactive.Async/Union.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Union.cs b/Ix.NET/Source/System.Interactive.Async/Union.cs index 5a02fba169..ac396f20c3 100644 --- a/Ix.NET/Source/System.Interactive.Async/Union.cs +++ b/Ix.NET/Source/System.Interactive.Async/Union.cs @@ -2,35 +2,32 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return first.Concat(second).Distinct(comparer); + return first.Union(second, EqualityComparer.Default); } - public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second) + public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return first.Union(second, EqualityComparer.Default); + return first.Concat(second).Distinct(comparer); } } } From 59fa82f619a4416f5f99f0003c6985a2c6aa7ae3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:57:02 -0700 Subject: [PATCH 070/862] Sealing some classes. --- Ix.NET/Source/System.Interactive.Async/ToObservable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs index 1f4d181ea2..a2302aca7e 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToObservable.cs @@ -82,7 +82,7 @@ public static IObservable ToObservable(this IAsyncEnumerable(source); } - private class ToAsyncEnumerableObserver : IObserver + private sealed class ToAsyncEnumerableObserver : IObserver { public readonly Queue Values; @@ -160,7 +160,7 @@ public void OnNext(T value) } } - private class ToObservableObservable : IObservable + private sealed class ToObservableObservable : IObservable { private readonly IAsyncEnumerable source; From 8a97fe8fd6299561ed0ea4b88b611af9e547d362 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 10:59:06 -0700 Subject: [PATCH 071/862] Splitting ToArray, ToDictionary, and ToList. --- .../System.Interactive.Async/ToArray.cs | 32 +++++++++++++ .../{ToCollection.cs => ToDictionary.cs} | 46 ------------------- .../Source/System.Interactive.Async/ToList.cs | 40 ++++++++++++++++ 3 files changed, 72 insertions(+), 46 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/ToArray.cs rename Ix.NET/Source/System.Interactive.Async/{ToCollection.cs => ToDictionary.cs} (77%) create mode 100644 Ix.NET/Source/System.Interactive.Async/ToList.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ToArray.cs b/Ix.NET/Source/System.Interactive.Async/ToArray.cs new file mode 100644 index 0000000000..4d4564b340 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/ToArray.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task ToArray(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return ToArray(source, CancellationToken.None); + } + + public static Task ToArray(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + if (source is IIListProvider arrayProvider) + return arrayProvider.ToArrayAsync(cancellationToken); + + return AsyncEnumerableHelpers.ToArray(source, cancellationToken); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/ToCollection.cs b/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs similarity index 77% rename from Ix.NET/Source/System.Interactive.Async/ToCollection.cs rename to Ix.NET/Source/System.Interactive.Async/ToDictionary.cs index a89f2798d6..59ea466de0 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToCollection.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs @@ -10,25 +10,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ToArray(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return ToArray(source, CancellationToken.None); - } - - public static Task ToArray(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - if (source is IIListProvider arrayProvider) - return arrayProvider.ToArrayAsync(cancellationToken); - - return AsyncEnumerableHelpers.ToArray(source, cancellationToken); - } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) @@ -132,32 +113,5 @@ public static Task> ToDictionary(this I return source.ToDictionary(keySelector, x => x, EqualityComparer.Default, cancellationToken); } - - public static Task> ToList(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return ToList(source, CancellationToken.None); - } - - public static Task> ToList(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - if (source is IIListProvider listProvider) - return listProvider.ToListAsync(cancellationToken); - - return source.Aggregate( - new List(), - (list, x) => - { - list.Add(x); - return list; - }, - cancellationToken - ); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/ToList.cs b/Ix.NET/Source/System.Interactive.Async/ToList.cs new file mode 100644 index 0000000000..5277b2fcdf --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/ToList.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task> ToList(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return ToList(source, CancellationToken.None); + } + + public static Task> ToList(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + if (source is IIListProvider listProvider) + return listProvider.ToListAsync(cancellationToken); + + return source.Aggregate( + new List(), + (list, x) => + { + list.Add(x); + return list; + }, + cancellationToken + ); + } + } +} From 45d9601f0d0d369c8ad7903ce2284a76e954ea8c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:01:39 -0700 Subject: [PATCH 072/862] Reordering ToDictionary overloads. --- .../System.Interactive.Async/ToDictionary.cs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs b/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs index 59ea466de0..6e191b7479 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs @@ -10,30 +10,24 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return ToDictionary(source, keySelector, elementSelector, comparer, CancellationToken.None); + return ToDictionary(source, keySelector, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector) + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - return ToDictionary(source, keySelector, elementSelector, CancellationToken.None); + return source.ToDictionary(keySelector, x => x, EqualityComparer.Default, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -48,17 +42,19 @@ public static Task> ToDictionary(this I return ToDictionary(source, keySelector, comparer, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector) + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return ToDictionary(source, keySelector, CancellationToken.None); + return source.ToDictionary(keySelector, x => x, comparer, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -66,18 +62,8 @@ public static Task> ToDictionary(comparer), - (d, x) => - { - d.Add(keySelector(x), elementSelector(x)); - return d; - }, - cancellationToken - ); + return ToDictionary(source, keySelector, elementSelector, CancellationToken.None); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) @@ -92,26 +78,40 @@ public static Task> ToDictionary.Default, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.ToDictionary(keySelector, x => x, comparer, cancellationToken); + return ToDictionary(source, keySelector, elementSelector, comparer, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.ToDictionary(keySelector, x => x, EqualityComparer.Default, cancellationToken); + return source.Aggregate( + new Dictionary(comparer), + (d, x) => + { + d.Add(keySelector(x), elementSelector(x)); + return d; + }, + cancellationToken + ); } } } From 73b6aeffa1ac4fcffb34b4a781e69b63e1712320 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:08:42 -0700 Subject: [PATCH 073/862] Async variants of ToDictionary. --- .../System.Interactive.Async/ToDictionary.cs | 104 ++++++++++++++++++ Ix.NET/Source/Tests/AsyncTests.Aggregates.cs | 55 +++++---- 2 files changed, 131 insertions(+), 28 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs b/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs index 6e191b7479..237709fa15 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs @@ -30,6 +30,26 @@ public static Task> ToDictionary(this I return source.ToDictionary(keySelector, x => x, EqualityComparer.Default, cancellationToken); } + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return ToDictionary(source, keySelector, CancellationToken.None); + } + + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.ToDictionary(keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); + } + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) @@ -54,6 +74,30 @@ public static Task> ToDictionary(this I return source.ToDictionary(keySelector, x => x, comparer, cancellationToken); } + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ToDictionary(source, keySelector, comparer, CancellationToken.None); + } + + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.ToDictionary(keySelector, x => Task.FromResult(x), comparer, cancellationToken); + } + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) @@ -78,6 +122,30 @@ public static Task> ToDictionary.Default, cancellationToken); } + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + + return ToDictionary(source, keySelector, elementSelector, CancellationToken.None); + } + + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + + return source.ToDictionary(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); + } + public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) @@ -113,5 +181,41 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ToDictionary(source, keySelector, elementSelector, comparer, CancellationToken.None); + } + + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Aggregate( + new Dictionary(comparer), + async (d, x) => + { + d.Add(await keySelector(x).ConfigureAwait(false), await elementSelector(x).ConfigureAwait(false)); + return d; + }, + cancellationToken + ); + } } } diff --git a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs index 67c081a460..556b9590f4 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs @@ -1061,7 +1061,7 @@ public void ToArray3() [Fact] public async Task ToArray4() { - var xs = await AsyncEnumerable.Range(5,50).Take(10).ToArray(); + var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArray(); var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; Assert.True(ex.SequenceEqual(xs)); @@ -1074,7 +1074,6 @@ public async Task ToArray5() var xs = new HashSet(res); var arr = await xs.ToAsyncEnumerable().ToArray(); - Assert.True(res.SequenceEqual(arr)); } @@ -1082,37 +1081,37 @@ public async Task ToArray5() [Fact] public async Task ToDictionary_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, null, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(null, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), null, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, null, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); } [Fact] @@ -2149,11 +2148,11 @@ public async Task MaxBy_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func))); - + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); - + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); From f9560f62d43dc9e11c6271ca6c1c878a986c9fd9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:09:09 -0700 Subject: [PATCH 074/862] Marking TaskExt as internal. --- Ix.NET/Source/System.Interactive.Async/TaskExt.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index ff33c9c9a2..0732f58206 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -4,7 +4,7 @@ namespace System.Threading.Tasks { - static class TaskExt + internal static class TaskExt { public static readonly Task True = Task.FromResult(true); public static readonly Task False = Task.FromResult(false); From d7334d99db6ad4e932863cbab441de6ff9395677 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:16:22 -0700 Subject: [PATCH 075/862] Reordering Scan overloads. --- Ix.NET/Source/System.Interactive.Async/Scan.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index a5c13c6677..d73e6e2142 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -10,24 +10,24 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return new ScanAsyncEnumerable(source, seed, accumulator); + return new ScanAsyncEnumerable(source, accumulator); } - public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func accumulator) + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return new ScanAsyncEnumerable(source, accumulator); + return new ScanAsyncEnumerable(source, seed, accumulator); } private sealed class ScanAsyncEnumerable : AsyncIterator From d89efe679584162bcd5db3c6fc6fdaae876c6de9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:16:42 -0700 Subject: [PATCH 076/862] More reodering of Scan code. --- .../Source/System.Interactive.Async/Scan.cs | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index d73e6e2142..aac1ba5c66 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -30,28 +30,28 @@ public static IAsyncEnumerable Scan(this IAsy return new ScanAsyncEnumerable(source, seed, accumulator); } - private sealed class ScanAsyncEnumerable : AsyncIterator + private sealed class ScanAsyncEnumerable : AsyncIterator { - private readonly Func accumulator; - private readonly TAccumulate seed; + private readonly Func accumulator; private readonly IAsyncEnumerable source; - private TAccumulate accumulated; + private TSource accumulated; private IAsyncEnumerator enumerator; - public ScanAsyncEnumerable(IAsyncEnumerable source, TAccumulate seed, Func accumulator) + private bool hasSeed; + + public ScanAsyncEnumerable(IAsyncEnumerable source, Func accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); this.source = source; - this.seed = seed; this.accumulator = accumulator; } - public override AsyncIterator Clone() + public override AsyncIterator Clone() { - return new ScanAsyncEnumerable(source, seed, accumulator); + return new ScanAsyncEnumerable(source, accumulator); } public override async Task DisposeAsync() @@ -60,7 +60,7 @@ public override async Task DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - accumulated = default(TAccumulate); + accumulated = default(TSource); } await base.DisposeAsync().ConfigureAwait(false); @@ -72,23 +72,31 @@ protected override async Task MoveNextCore() { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - accumulated = seed; + hasSeed = false; + accumulated = default(TSource); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; + if (!hasSeed) + { + hasSeed = true; + accumulated = item; + continue; // loop + } + accumulated = accumulator(accumulated, item); current = accumulated; return true; } - break; - + break; // case + } await DisposeAsync().ConfigureAwait(false); @@ -96,28 +104,28 @@ protected override async Task MoveNextCore() } } - private sealed class ScanAsyncEnumerable : AsyncIterator + private sealed class ScanAsyncEnumerable : AsyncIterator { - private readonly Func accumulator; + private readonly Func accumulator; + private readonly TAccumulate seed; private readonly IAsyncEnumerable source; - private TSource accumulated; + private TAccumulate accumulated; private IAsyncEnumerator enumerator; - private bool hasSeed; - - public ScanAsyncEnumerable(IAsyncEnumerable source, Func accumulator) + public ScanAsyncEnumerable(IAsyncEnumerable source, TAccumulate seed, Func accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); this.source = source; + this.seed = seed; this.accumulator = accumulator; } - public override AsyncIterator Clone() + public override AsyncIterator Clone() { - return new ScanAsyncEnumerable(source, accumulator); + return new ScanAsyncEnumerable(source, seed, accumulator); } public override async Task DisposeAsync() @@ -126,7 +134,7 @@ public override async Task DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - accumulated = default(TSource); + accumulated = default(TAccumulate); } await base.DisposeAsync().ConfigureAwait(false); @@ -138,31 +146,23 @@ protected override async Task MoveNextCore() { case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(); - hasSeed = false; - accumulated = default(TSource); + accumulated = seed; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await enumerator.MoveNextAsync() + .ConfigureAwait(false)) { var item = enumerator.Current; - if (!hasSeed) - { - hasSeed = true; - accumulated = item; - continue; // loop - } - accumulated = accumulator(accumulated, item); current = accumulated; return true; } - break; // case - + break; + } await DisposeAsync().ConfigureAwait(false); From 2456f5767b14c6ebc757e980f8d3da118595436c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:31:32 -0700 Subject: [PATCH 077/862] Async variants of Scan. --- .../Source/System.Interactive.Async/Scan.cs | 162 +++++++++++++++++- Ix.NET/Source/Tests/AsyncTests.Single.cs | 8 +- 2 files changed, 164 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/Scan.cs index aac1ba5c66..a4d2dbad56 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/Scan.cs @@ -30,6 +30,26 @@ public static IAsyncEnumerable Scan(this IAsy return new ScanAsyncEnumerable(source, seed, accumulator); } + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return new ScanAsyncEnumerableWithTask(source, accumulator); + } + + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return new ScanAsyncEnumerableWithTask(source, seed, accumulator); + } + private sealed class ScanAsyncEnumerable : AsyncIterator { private readonly Func accumulator; @@ -152,8 +172,7 @@ protected override async Task MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync() - .ConfigureAwait(false)) + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = enumerator.Current; accumulated = accumulator(accumulated, item); @@ -169,5 +188,144 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class ScanAsyncEnumerableWithTask : AsyncIterator + { + private readonly Func> accumulator; + private readonly IAsyncEnumerable source; + + private TSource accumulated; + private IAsyncEnumerator enumerator; + + private bool hasSeed; + + public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, Func> accumulator) + { + Debug.Assert(source != null); + Debug.Assert(accumulator != null); + + this.source = source; + this.accumulator = accumulator; + } + + public override AsyncIterator Clone() + { + return new ScanAsyncEnumerableWithTask(source, accumulator); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + accumulated = default(TSource); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + hasSeed = false; + accumulated = default(TSource); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + if (!hasSeed) + { + hasSeed = true; + accumulated = item; + continue; // loop + } + + accumulated = await accumulator(accumulated, item).ConfigureAwait(false); + current = accumulated; + return true; + } + + break; // case + + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class ScanAsyncEnumerableWithTask : AsyncIterator + { + private readonly Func> accumulator; + private readonly TAccumulate seed; + private readonly IAsyncEnumerable source; + + private TAccumulate accumulated; + private IAsyncEnumerator enumerator; + + public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + { + Debug.Assert(source != null); + Debug.Assert(accumulator != null); + + this.source = source; + this.seed = seed; + this.accumulator = accumulator; + } + + public override AsyncIterator Clone() + { + return new ScanAsyncEnumerableWithTask(source, seed, accumulator); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + accumulated = default(TAccumulate); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + accumulated = seed; + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + accumulated = await accumulator(accumulated, item).ConfigureAwait(false); + current = accumulated; + return true; + } + + break; + + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } } } diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index d005e0eb3e..4ac1bb9994 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -3191,10 +3191,10 @@ public async Task Expand4() public void Scan_Null() { AssertThrows(() => AsyncEnumerable.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Scan(AsyncEnumerable.Return(42), 3, null)); + AssertThrows(() => AsyncEnumerable.Scan(AsyncEnumerable.Return(42), 3, default(Func))); AssertThrows(() => AsyncEnumerable.Scan(default(IAsyncEnumerable), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Scan(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Scan(AsyncEnumerable.Return(42), default(Func))); } [Fact] @@ -3224,7 +3224,7 @@ public void Scan2() public void Scan3() { var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => { throw ex; }); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, new Func((x, y) => { throw ex; })); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -3234,7 +3234,7 @@ public void Scan3() public void Scan4() { var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => { throw ex; }); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(new Func((x, y) => { throw ex; })); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); From 9d29fc916f10ab6e146d16f1e0144ee1d3564144 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:32:54 -0700 Subject: [PATCH 078/862] Rename file to ToLookup. --- Ix.NET/Source/System.Interactive.Async/{Lookup.cs => ToLookup.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{Lookup.cs => ToLookup.cs} (100%) diff --git a/Ix.NET/Source/System.Interactive.Async/Lookup.cs b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Lookup.cs rename to Ix.NET/Source/System.Interactive.Async/ToLookup.cs From e9d302a83e4fb505eb23eaf7d88726c2d36a31ce Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:34:54 -0700 Subject: [PATCH 079/862] Reordering overloads of ToLookup. --- .../System.Interactive.Async/ToLookup.cs | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs index 41b93581db..0cb403f430 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs @@ -12,30 +12,24 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); + return ToLookup(source, keySelector, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector) + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - return ToLookup(source, keySelector, elementSelector, CancellationToken.None); + return source.ToLookup(keySelector, x => x, EqualityComparer.Default, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -50,17 +44,19 @@ public static Task> ToLookup(this IAsyncEn return ToLookup(source, keySelector, comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector) + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return ToLookup(source, keySelector, CancellationToken.None); + return source.ToLookup(keySelector, x => x, comparer, cancellationToken); } - public static async Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -68,12 +64,8 @@ public static async Task> ToLookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); - return lookup; + return ToLookup(source, keySelector, elementSelector, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) @@ -88,26 +80,34 @@ public static Task> ToLookup(th return source.ToLookup(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.ToLookup(keySelector, x => x, comparer, cancellationToken); + return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static async Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.ToLookup(keySelector, x => x, EqualityComparer.Default, cancellationToken); + var lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + + return lookup; } } } From f06a9e02788eda8ff925426f7f68a520f563f56a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:37:17 -0700 Subject: [PATCH 080/862] Minor changes in ToLookup. --- Ix.NET/Source/System.Interactive.Async/ToLookup.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs index 0cb403f430..3d44706cf4 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs @@ -180,7 +180,9 @@ public IEnumerable ApplyResultSelector(Func ApplyResultSelector(Func ToList(Func, TR { g = g._next; g.Trim(); - list.Add(resultSelector(g._key, g._elements.ToAsyncEnumerable())); + + var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); + list.Add(result); } while (g != _lastGrouping); } From 8a24dbf26a5db8d754d94d31f44bf38c3a173f94 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:37:46 -0700 Subject: [PATCH 081/862] Reordering overloads of Intersect. --- Ix.NET/Source/System.Interactive.Async/Intersect.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Interactive.Async/Intersect.cs index 6bd0c44a98..d06f8148c3 100644 --- a/Ix.NET/Source/System.Interactive.Async/Intersect.cs +++ b/Ix.NET/Source/System.Interactive.Async/Intersect.cs @@ -10,27 +10,26 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return new IntersectAsyncIterator(first, second, comparer); + return first.Intersect(second, EqualityComparer.Default); } - - public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second) + public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return first.Intersect(second, EqualityComparer.Default); + return new IntersectAsyncIterator(first, second, comparer); } private sealed class IntersectAsyncIterator : AsyncIterator From 13335566d82cbfe835a136726f6387c8fac1aeed Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:48:18 -0700 Subject: [PATCH 082/862] Async variants of ToLookup. --- .../System.Interactive.Async/ToLookup.cs | 406 +++++++++++++++++- Ix.NET/Source/Tests/AsyncTests.Aggregates.cs | 48 +-- 2 files changed, 429 insertions(+), 25 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs index 3d44706cf4..71b1e59ae9 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs @@ -32,6 +32,26 @@ public static Task> ToLookup(this IAsyncEn return source.ToLookup(keySelector, x => x, EqualityComparer.Default, cancellationToken); } + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return ToLookup(source, keySelector, CancellationToken.None); + } + + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.ToLookup(keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); + } + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) @@ -56,6 +76,30 @@ public static Task> ToLookup(this IAsyncEn return source.ToLookup(keySelector, x => x, comparer, cancellationToken); } + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ToLookup(source, keySelector, comparer, CancellationToken.None); + } + + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.ToLookup(keySelector, x => Task.FromResult(x), comparer, cancellationToken); + } + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) @@ -80,6 +124,30 @@ public static Task> ToLookup(th return source.ToLookup(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + + return ToLookup(source, keySelector, elementSelector, CancellationToken.None); + } + + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + + return source.ToLookup(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); + } + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) @@ -109,6 +177,36 @@ public static async Task> ToLookup> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); + } + + public static async Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + var lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + + return lookup; + } } } @@ -201,7 +299,11 @@ public IEnumerable ApplyResultSelector(Func[]> IIListProvider : ILookup, IIListProvider> + { + private readonly IEqualityComparer _comparer; + private Grouping[] _groupings; + private Grouping _lastGrouping; + + private LookupWithTask(IEqualityComparer comparer) + { + _comparer = comparer ?? EqualityComparer.Default; + _groupings = new Grouping[7]; + } + + public int Count { get; private set; } + + public IEnumerable this[TKey key] + { + get + { + var grouping = GetGrouping(key, create: false); + if (grouping != null) + { + return grouping; + } + +#if NO_ARRAY_EMPTY + return EmptyArray.Value; +#else + return Array.Empty(); +#endif + } + } + + public bool Contains(TKey key) + { + return GetGrouping(key, create: false) != null; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public IEnumerator> GetEnumerator() + { + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + yield return g; + } while (g != _lastGrouping); + } + } + + public IEnumerable ApplyResultSelector(Func, TResult> resultSelector) + { + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + + var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); + yield return result; + } while (g != _lastGrouping); + } + } + + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(elementSelector != null); + + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(enu.Current).ConfigureAwait(false); + var group = lookup.GetGrouping(key, create: true); + + var element = await elementSelector(enu.Current).ConfigureAwait(false); + group.Add(element); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(enu.Current).ConfigureAwait(false); + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = await keySelector(enu.Current).ConfigureAwait(false); + if (key != null) + { + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal Grouping GetGrouping(TKey key, bool create) + { + var hashCode = InternalGetHashCode(key); + for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) + { + if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) + { + return g; + } + } + + if (create) + { + if (Count == _groupings.Length) + { + Resize(); + } + + var index = hashCode % _groupings.Length; + var g = new Grouping + { + _key = key, + _hashCode = hashCode, + _elements = new TElement[1], + _hashNext = _groupings[index] + }; + _groupings[index] = g; + if (_lastGrouping == null) + { + g._next = g; + } + else + { + g._next = _lastGrouping._next; + _lastGrouping._next = g; + } + + _lastGrouping = g; + Count++; + return g; + } + + return null; + } + + internal int InternalGetHashCode(TKey key) + { + // Handle comparer implementations that throw when passed null + return (key == null) ? 0 : _comparer.GetHashCode(key) & 0x7FFFFFFF; + } + + internal async Task ToArray(Func, Task> resultSelector) + { + var array = new TResult[Count]; + var index = 0; + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); + ++index; + } while (g != _lastGrouping); + } + + return array; + } + + internal async Task> ToList(Func, Task> resultSelector) + { + var list = new List(Count); + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + + var result = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); + list.Add(result); + } while (g != _lastGrouping); + } + + return list; + } + + private void Resize() + { + var newSize = checked((Count * 2) + 1); + var newGroupings = new Grouping[newSize]; + var g = _lastGrouping; + do + { + g = g._next; + var index = g._hashCode % newSize; + g._hashNext = newGroupings[index]; + newGroupings[index] = g; + } while (g != _lastGrouping); + + _groupings = newGroupings; + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + return Task.FromResult(Count); + } + + IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator() + { + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(); + } + + Task>> IIListProvider>.ToListAsync(CancellationToken cancellationToken) + { + var list = new List>(Count); + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + list.Add(g); + } + while (g != _lastGrouping); + } + + return Task.FromResult(list); + } + + Task[]> IIListProvider>.ToArrayAsync(CancellationToken cancellationToken) + { + var array = new IAsyncGrouping[Count]; + var index = 0; + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + array[index] = g; + ++index; + } + while (g != _lastGrouping); + } + + return Task.FromResult(array); + } + } } diff --git a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs index 556b9590f4..06b07c3b9e 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Aggregates.cs @@ -1174,37 +1174,37 @@ public void ToDictionary7() [Fact] public async Task ToLookup_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, null, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(null, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), null, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, null, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); } [Fact] From c38d7ee3e5ee51c959f6841f9e6c85dc8d08fa19 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:51:23 -0700 Subject: [PATCH 083/862] Reordering OrderBy and ThenBy overloads. --- .../System.Interactive.Async/OrderBy.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs index 1ae7982518..94bb9b0206 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs @@ -8,48 +8,48 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return new OrderedAsyncEnumerable(source, keySelector, comparer, false, null); + return source.OrderBy(keySelector, Comparer.Default); } - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.OrderBy(keySelector, Comparer.Default); + return new OrderedAsyncEnumerable(source, keySelector, comparer, false, null); } - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return new OrderedAsyncEnumerable(source, keySelector, comparer, true, null); + return source.OrderByDescending(keySelector, Comparer.Default); } - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return source.OrderByDescending(keySelector, Comparer.Default); + return new OrderedAsyncEnumerable(source, keySelector, comparer, true, null); } public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector) From 21cfd1a50d223f750d959fde0fed7971b9702834 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 11:52:03 -0700 Subject: [PATCH 084/862] Use some named parameters. --- Ix.NET/Source/System.Interactive.Async/OrderBy.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs index 94bb9b0206..a6e14a77b1 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs @@ -27,7 +27,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new OrderedAsyncEnumerable(source, keySelector, comparer, false, null); + return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); } public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) @@ -49,7 +49,7 @@ public static IOrderedAsyncEnumerable OrderByDescending( if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new OrderedAsyncEnumerable(source, keySelector, comparer, true, null); + return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); } public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector) @@ -71,7 +71,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.CreateOrderedEnumerable(keySelector, comparer, false); + return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector) @@ -93,7 +93,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.CreateOrderedEnumerable(keySelector, comparer, true); + return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } } } From e280f57f0fdb2bbe8956badedd293244ff09d73b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:07:06 -0700 Subject: [PATCH 085/862] Initial work on async variants for OrderBy. --- .../IOrderedAsyncEnumerable.cs | 2 + .../System.Interactive.Async/OrderBy.cs | 88 ++++++++++++++ .../OrderedAsyncEnumerable.cs | 113 +++++++++++++++++- Ix.NET/Source/Tests/AsyncTests.Single.cs | 48 ++++---- 4 files changed, 226 insertions(+), 25 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs index fc989159fd..20b07ad3c0 100644 --- a/Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs @@ -3,11 +3,13 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading.Tasks; namespace System.Linq { public interface IOrderedAsyncEnumerable : IAsyncEnumerable { IOrderedAsyncEnumerable CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending); + IOrderedAsyncEnumerable CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending); } } diff --git a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs index a6e14a77b1..d78eee1ff1 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderBy.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading.Tasks; namespace System.Linq { @@ -18,6 +19,16 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn return source.OrderBy(keySelector, Comparer.Default); } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.OrderBy(keySelector, Comparer.Default); + } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) @@ -29,6 +40,17 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); + } public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) { @@ -40,6 +62,16 @@ public static IOrderedAsyncEnumerable OrderByDescending( return source.OrderByDescending(keySelector, Comparer.Default); } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.OrderByDescending(keySelector, Comparer.Default); + } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) @@ -52,6 +84,18 @@ public static IOrderedAsyncEnumerable OrderByDescending( return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); + } + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector) { if (source == null) @@ -62,6 +106,16 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.ThenBy(keySelector, Comparer.Default); } + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.ThenBy(keySelector, Comparer.Default); + } + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) @@ -74,6 +128,18 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); + } + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector) { if (source == null) @@ -84,6 +150,16 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.ThenByDescending(keySelector, Comparer.Default); } + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.ThenByDescending(keySelector, Comparer.Default); + } + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) @@ -95,5 +171,17 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } + + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); + } } } diff --git a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs index 0fec3175e7..1044f35833 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs @@ -18,6 +18,11 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere return new OrderedAsyncEnumerable(source, keySelector, comparer, descending, this); } + IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending) + { + return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending, this); + } + internal abstract Task Initialize(); } @@ -49,7 +54,6 @@ public override AsyncEnumerable.AsyncIterator Clone() return new OrderedAsyncEnumerable(source, keySelector, comparer, descending, parent); } - public override async Task DisposeAsync() { if (enumerator != null) @@ -108,4 +112,111 @@ internal override async Task Initialize() } } } + + internal sealed class OrderedAsyncEnumerableWithTask : OrderedAsyncEnumerable + { + private readonly IComparer comparer; + private readonly bool descending; + private readonly Func> keySelector; + private readonly OrderedAsyncEnumerable parent; + + private IEnumerator enumerator; + private IAsyncEnumerator parentEnumerator; + + public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + this.descending = descending; + this.parent = parent; + } + + public override AsyncEnumerable.AsyncIterator Clone() + { + return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending, parent); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + enumerator.Dispose(); + enumerator = null; + } + + if (parentEnumerator != null) + { + await parentEnumerator.DisposeAsync().ConfigureAwait(false); + parentEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncEnumerable.AsyncIteratorState.Allocated: + + await Initialize().ConfigureAwait(false); + + enumerator = enumerable.GetEnumerator(); + state = AsyncEnumerable.AsyncIteratorState.Iterating; + goto case AsyncEnumerable.AsyncIteratorState.Iterating; + + case AsyncEnumerable.AsyncIteratorState.Iterating: + if (enumerator.MoveNext()) + { + current = enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + internal override async Task Initialize() + { + if (parent == null) + { + var buffer = await source.ToList().ConfigureAwait(false); + enumerable = (!@descending ? buffer.OrderByAsync(keySelector, comparer) : buffer.OrderByDescendingAsync(keySelector, comparer)); + } + else + { + parentEnumerator = parent.GetAsyncEnumerator(); + await parent.Initialize().ConfigureAwait(false); + enumerable = parent.enumerable.CreateOrderedEnumerableAsync(keySelector, comparer, @descending); + } + } + } + + internal static class EnumerableSortingExtensions + { + // TODO: Implement async sorting. + + public static IOrderedEnumerable OrderByAsync(this IEnumerable source, Func> keySelector, IComparer comparer) + { + return source.OrderBy(key => keySelector(key).GetAwaiter().GetResult(), comparer); + } + + public static IOrderedEnumerable OrderByDescendingAsync(this IEnumerable source, Func> keySelector, IComparer comparer) + { + return source.OrderByDescending(key => keySelector(key).GetAwaiter().GetResult(), comparer); + } + + public static IOrderedEnumerable CreateOrderedEnumerableAsync(this IOrderedEnumerable source, Func> keySelector, IComparer comparer, bool descending) + { + return source.CreateOrderedEnumerable(key => keySelector(key).GetAwaiter().GetResult(), comparer, descending); + } + } } diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index 4ac1bb9994..5a66688591 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -1668,35 +1668,35 @@ public async Task Reverse9() [Fact] public void OrderBy_Null() { - AssertThrows(() => AsyncEnumerable.OrderBy(null, x => x)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.OrderBy(null, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), null, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), x => x, null)); + AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); - AssertThrows(() => AsyncEnumerable.OrderByDescending(null, x => x)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.OrderByDescending(null, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), null, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), x => x, null)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), x => x, default(IComparer))); var xs = AsyncEnumerable.Return(42).OrderBy(x => x); - AssertThrows(() => AsyncEnumerable.ThenBy(null, x => x)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, null)); + AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); - AssertThrows(() => AsyncEnumerable.ThenBy(null, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, null, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, x => x, null)); + AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, x => x, default(IComparer))); - AssertThrows(() => AsyncEnumerable.ThenByDescending(null, x => x)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, null)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); - AssertThrows(() => AsyncEnumerable.ThenByDescending(null, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, null, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, x => x, null)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, x => x, default(IComparer))); } [Fact] @@ -1716,7 +1716,7 @@ public void OrderBy2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => { throw ex; }); + var ys = xs.OrderBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -1736,7 +1736,7 @@ public void ThenBy2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x).ThenBy(x => { throw ex; }); + var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -1759,7 +1759,7 @@ public void OrderByDescending2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderByDescending(x => { throw ex; }); + var ys = xs.OrderByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -1779,7 +1779,7 @@ public void ThenByDescending2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x).ThenByDescending(x => { throw ex; }); + var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); From 9caf56f4f4cda7e8cd43ef89bc039f62da06b40c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:09:08 -0700 Subject: [PATCH 086/862] Reorder MinBy and MaxBy overloads. --- Ix.NET/Source/System.Interactive.Async/Max.cs | 24 +++++++++---------- Ix.NET/Source/System.Interactive.Async/Min.cs | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Interactive.Async/Max.cs index d7279c102d..646e1800a6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/Max.cs @@ -97,26 +97,26 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return source.MaxBy(keySelector, comparer, CancellationToken.None); + return MaxBy(source, keySelector, Comparer.Default, cancellationToken); } - public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return MaxBy(source, keySelector, Comparer.Default, cancellationToken); + return source.MaxBy(keySelector, comparer, CancellationToken.None); } public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) @@ -141,26 +141,26 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return source.MaxBy(keySelector, comparer, CancellationToken.None); + return MaxBy(source, keySelector, Comparer.Default, cancellationToken); } - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return MaxBy(source, keySelector, Comparer.Default, cancellationToken); + return source.MaxBy(keySelector, comparer, CancellationToken.None); } public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index acafc3501e..0d4c4d558f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -97,26 +97,26 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return source.MinBy(keySelector, comparer, CancellationToken.None); + return MinBy(source, keySelector, Comparer.Default, cancellationToken); } - public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return MinBy(source, keySelector, Comparer.Default, cancellationToken); + return source.MinBy(keySelector, comparer, CancellationToken.None); } public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) @@ -141,26 +141,26 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return source.MinBy(keySelector, comparer, CancellationToken.None); + return MinBy(source, keySelector, Comparer.Default, cancellationToken); } - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return MinBy(source, keySelector, Comparer.Default, cancellationToken); + return source.MinBy(keySelector, comparer, CancellationToken.None); } public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) From 55fad84d0435445e795484dd2ae92e6ad30be4ad Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:12:34 -0700 Subject: [PATCH 087/862] Splitting [Min|Max][By] files. --- Ix.NET/Source/System.Interactive.Async/Max.cs | 93 --------- .../Source/System.Interactive.Async/MaxBy.cs | 106 ++++++++++ Ix.NET/Source/System.Interactive.Async/Min.cs | 173 ---------------- .../Source/System.Interactive.Async/MinBy.cs | 186 ++++++++++++++++++ 4 files changed, 292 insertions(+), 266 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/MaxBy.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/MinBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Interactive.Async/Max.cs index 646e1800a6..eb74f5c315 100644 --- a/Ix.NET/Source/System.Interactive.Async/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/Max.cs @@ -86,98 +86,5 @@ public static Task Max(this IAsyncEnumerable return source.Select(selector).Max(cancellationToken); } - - public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.MaxBy(keySelector, CancellationToken.None); - } - - public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return MaxBy(source, keySelector, Comparer.Default, cancellationToken); - } - - public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.MaxBy(keySelector, comparer, CancellationToken.None); - } - - public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); - } - - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.MaxBy(keySelector, CancellationToken.None); - } - - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return MaxBy(source, keySelector, Comparer.Default, cancellationToken); - } - - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.MaxBy(keySelector, comparer, CancellationToken.None); - } - - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); - } - - private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - return (await MaxBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/MaxBy.cs new file mode 100644 index 0000000000..6546eb37f2 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/MaxBy.cs @@ -0,0 +1,106 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.MaxBy(keySelector, CancellationToken.None); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MaxBy(source, keySelector, Comparer.Default, cancellationToken); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.MaxBy(keySelector, comparer, CancellationToken.None); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.MaxBy(keySelector, CancellationToken.None); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MaxBy(source, keySelector, Comparer.Default, cancellationToken); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.MaxBy(keySelector, comparer, CancellationToken.None); + } + + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); + } + + private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + return (await MaxBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Interactive.Async/Min.cs index 0d4c4d558f..483df6806e 100644 --- a/Ix.NET/Source/System.Interactive.Async/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/Min.cs @@ -86,178 +86,5 @@ public static Task Min(this IAsyncEnumerable return source.Select(selector).Min(cancellationToken); } - - public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.MinBy(keySelector, CancellationToken.None); - } - - public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return MinBy(source, keySelector, Comparer.Default, cancellationToken); - } - - public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.MinBy(keySelector, comparer, CancellationToken.None); - } - - public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); - } - - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.MinBy(keySelector, CancellationToken.None); - } - - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return MinBy(source, keySelector, Comparer.Default, cancellationToken); - } - - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.MinBy(keySelector, comparer, CancellationToken.None); - } - - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); - } - - private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - return (await MinBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); - } - - private static async Task> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) - { - var result = new List(); - - var e = source.GetAsyncEnumerator(); - - try - { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); - - var current = e.Current; - var resKey = keySelector(current); - result.Add(current); - - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - var cur = e.Current; - var key = keySelector(cur); - - var cmp = compare(key, resKey); - if (cmp == 0) - { - result.Add(cur); - } - else if (cmp > 0) - { - result = new List { cur }; - resKey = key; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return result; - } - - private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) - { - var result = new List(); - - var e = source.GetAsyncEnumerator(); - - try - { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); - - var current = e.Current; - var resKey = await keySelector(current).ConfigureAwait(false); - result.Add(current); - - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - var cur = e.Current; - var key = await keySelector(cur).ConfigureAwait(false); - - var cmp = compare(key, resKey); - if (cmp == 0) - { - result.Add(cur); - } - else if (cmp > 0) - { - result = new List { cur }; - resKey = key; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return result; - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/MinBy.cs new file mode 100644 index 0000000000..3b0b9c8e33 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/MinBy.cs @@ -0,0 +1,186 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.MinBy(keySelector, CancellationToken.None); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MinBy(source, keySelector, Comparer.Default, cancellationToken); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.MinBy(keySelector, comparer, CancellationToken.None); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.MinBy(keySelector, CancellationToken.None); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MinBy(source, keySelector, Comparer.Default, cancellationToken); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.MinBy(keySelector, comparer, CancellationToken.None); + } + + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); + } + + private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + return (await MinBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); + } + + private static async Task> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) + { + var result = new List(); + + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + var current = e.Current; + var resKey = keySelector(current); + result.Add(current); + + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var cur = e.Current; + var key = keySelector(cur); + + var cmp = compare(key, resKey); + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return result; + } + + private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) + { + var result = new List(); + + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + var current = e.Current; + var resKey = await keySelector(current).ConfigureAwait(false); + result.Add(current); + + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var cur = e.Current; + var key = await keySelector(cur).ConfigureAwait(false); + + var cmp = compare(key, resKey); + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return result; + } + } +} From 5c8c9fce944521ddd7ed7c5181820eae140b374f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:13:51 -0700 Subject: [PATCH 088/862] Sorting Last overloads. --- .../Source/System.Interactive.Async/Last.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Interactive.Async/Last.cs index 2e9992adf4..b61a2d64eb 100644 --- a/Ix.NET/Source/System.Interactive.Async/Last.cs +++ b/Ix.NET/Source/System.Interactive.Async/Last.cs @@ -18,17 +18,15 @@ public static Task Last(this IAsyncEnumerable source) return Last(source, CancellationToken.None); } - public static Task Last(this IAsyncEnumerable source, Func predicate) + public static Task Last(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return Last(source, predicate, CancellationToken.None); + return Last_(source, cancellationToken); } - public static Task Last(this IAsyncEnumerable source, Func> predicate) + public static Task Last(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -38,22 +36,24 @@ public static Task Last(this IAsyncEnumerable source, return Last(source, predicate, CancellationToken.None); } - public static Task Last(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Last(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return Last_(source, cancellationToken); + return source.Where(predicate).Last(cancellationToken); } - public static Task Last(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task Last(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Last(cancellationToken); + return Last(source, predicate, CancellationToken.None); } public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -74,17 +74,15 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func predicate) + public static Task LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return LastOrDefault(source, predicate, CancellationToken.None); + return LastOrDefault_(source, cancellationToken); } - public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task LastOrDefault(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -94,23 +92,24 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LastOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return LastOrDefault_(source, cancellationToken); + return source.Where(predicate).LastOrDefault(cancellationToken); } - public static Task LastOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate) - .LastOrDefault(cancellationToken); + return LastOrDefault(source, predicate, CancellationToken.None); } public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) From be85d6ae7726125d4efce0948d66eb22b1b9a0c5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:14:38 -0700 Subject: [PATCH 089/862] Reordering Single overloads. --- .../Source/System.Interactive.Async/Single.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Single.cs b/Ix.NET/Source/System.Interactive.Async/Single.cs index a227f3e8df..d38e28a4aa 100644 --- a/Ix.NET/Source/System.Interactive.Async/Single.cs +++ b/Ix.NET/Source/System.Interactive.Async/Single.cs @@ -18,17 +18,15 @@ public static Task Single(this IAsyncEnumerable sourc return Single(source, CancellationToken.None); } - public static Task Single(this IAsyncEnumerable source, Func predicate) + public static Task Single(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return Single(source, predicate, CancellationToken.None); + return Single_(source, cancellationToken); } - public static Task Single(this IAsyncEnumerable source, Func> predicate) + public static Task Single(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -38,22 +36,24 @@ public static Task Single(this IAsyncEnumerable sourc return Single(source, predicate, CancellationToken.None); } - public static Task Single(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Single(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return Single_(source, cancellationToken); + return source.Where(predicate).Single(cancellationToken); } - public static Task Single(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task Single(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Single(cancellationToken); + return Single(source, predicate, CancellationToken.None); } public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -74,17 +74,15 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func predicate) + public static Task SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return SingleOrDefault(source, predicate, CancellationToken.None); + return SingleOrDefault_(source, cancellationToken); } - public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task SingleOrDefault(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -94,22 +92,24 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SingleOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return SingleOrDefault_(source, cancellationToken); + return source.Where(predicate).SingleOrDefault(cancellationToken); } - public static Task SingleOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).SingleOrDefault(cancellationToken); + return SingleOrDefault(source, predicate, CancellationToken.None); } public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) From 4babd9fa33709f865c53e3d2611d71a262fcf9b2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:15:34 -0700 Subject: [PATCH 090/862] Reordering First overloads. --- .../Source/System.Interactive.Async/First.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Interactive.Async/First.cs index 1ba9a8b5da..ae2daed898 100644 --- a/Ix.NET/Source/System.Interactive.Async/First.cs +++ b/Ix.NET/Source/System.Interactive.Async/First.cs @@ -18,17 +18,15 @@ public static Task First(this IAsyncEnumerable source return First(source, CancellationToken.None); } - public static Task First(this IAsyncEnumerable source, Func predicate) + public static Task First(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return First(source, predicate, CancellationToken.None); + return First_(source, cancellationToken); } - public static Task First(this IAsyncEnumerable source, Func> predicate) + public static Task First(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -38,22 +36,24 @@ public static Task First(this IAsyncEnumerable source return First(source, predicate, CancellationToken.None); } - public static Task First(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task First(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return First_(source, cancellationToken); + return source.Where(predicate).First(cancellationToken); } - public static Task First(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task First(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).First(cancellationToken); + return First(source, predicate, CancellationToken.None); } public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -74,17 +74,15 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func predicate) + public static Task FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return FirstOrDefault(source, predicate, CancellationToken.None); + return FirstOrDefault_(source, cancellationToken); } - public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task FirstOrDefault(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -94,22 +92,24 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task FirstOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return FirstOrDefault_(source, cancellationToken); + return source.Where(predicate).FirstOrDefault(cancellationToken); } - public static Task FirstOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).FirstOrDefault(cancellationToken); + return FirstOrDefault(source, predicate, CancellationToken.None); } public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) From 7f433224031dbc18c497d14e8de0a66db9692544 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:18:14 -0700 Subject: [PATCH 091/862] Splitting GroupBy operators into separate file. --- .../System.Interactive.Async/GroupBy.cs | 382 +++++++++++++++++ .../System.Interactive.Async/Grouping.cs | 392 +----------------- 2 files changed, 385 insertions(+), 389 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/GroupBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async/GroupBy.cs b/Ix.NET/Source/System.Interactive.Async/GroupBy.cs new file mode 100644 index 0000000000..533d169e33 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/GroupBy.cs @@ -0,0 +1,382 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); + } + + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + + return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new GroupedAsyncEnumerable(source, keySelector, comparer); + } + + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return new GroupedAsyncEnumerable(source, keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); + } + + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default).Select(g => resultSelector(g.Key, g)); + } + + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); + } + + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); + } + + internal sealed class GroupedResultAsyncEnumerable : AsyncIterator, IIListProvider + { + private readonly IAsyncEnumerable source; + private readonly Func keySelector; + private readonly Func, TResult> resultSelector; + private readonly IEqualityComparer comparer; + + private Internal.Lookup lookup; + private IEnumerator enumerator; + + public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(resultSelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.resultSelector = resultSelector; + this.comparer = comparer; + } + + public override AsyncIterator Clone() + { + return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + enumerator.Dispose(); + enumerator = null; + lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + enumerator = lookup.ApplyResultSelector(resultSelector).GetEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (enumerator.MoveNext()) + { + current = enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return l.ToArray(resultSelector); + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return l.ToList(resultSelector); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> + { + private readonly IAsyncEnumerable source; + private readonly Func keySelector; + private readonly Func elementSelector; + private readonly IEqualityComparer comparer; + + private Internal.Lookup lookup; + private IEnumerator> enumerator; + + public GroupedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(elementSelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.elementSelector = elementSelector; + this.comparer = comparer; + } + + public override AsyncIterator> Clone() + { + return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + enumerator.Dispose(); + enumerator = null; + lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + enumerator = lookup.GetEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (enumerator.MoveNext()) + { + current = (IAsyncGrouping)enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task>> ToListAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToListAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> + { + private readonly IAsyncEnumerable source; + private readonly Func keySelector; + private readonly IEqualityComparer comparer; + + private Internal.Lookup lookup; + private IEnumerator> enumerator; + + public GroupedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + } + + public override AsyncIterator> Clone() + { + return new GroupedAsyncEnumerable(source, keySelector, comparer); + } + public override async Task DisposeAsync() + { + if (enumerator != null) + { + enumerator.Dispose(); + enumerator = null; + lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + enumerator = lookup.GetEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (enumerator.MoveNext()) + { + current = (IAsyncGrouping)enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task>> ToListAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToListAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + + return l.Count; + } + } + + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Interactive.Async/Grouping.cs index 7804045f02..77bdd9b354 100644 --- a/Ix.NET/Source/System.Interactive.Async/Grouping.cs +++ b/Ix.NET/Source/System.Interactive.Async/Grouping.cs @@ -4,383 +4,6 @@ using System.Collections; using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); - } - - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - - return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default); - } - - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return new GroupedAsyncEnumerable(source, keySelector, comparer); - } - - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return new GroupedAsyncEnumerable(source, keySelector, EqualityComparer.Default); - } - - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); - } - - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - - return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default).Select(g => resultSelector(g.Key, g)); - } - - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - } - - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - - return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); - } - - internal sealed class GroupedResultAsyncEnumerable : AsyncIterator, IIListProvider - { - private readonly IAsyncEnumerable source; - private readonly Func keySelector; - private readonly Func, TResult> resultSelector; - private readonly IEqualityComparer comparer; - - private Internal.Lookup lookup; - private IEnumerator enumerator; - - public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(resultSelector != null); - Debug.Assert(comparer != null); - - this.source = source; - this.keySelector = keySelector; - this.resultSelector = resultSelector; - this.comparer = comparer; - } - - public override AsyncIterator Clone() - { - return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - enumerator.Dispose(); - enumerator = null; - lookup = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - enumerator = lookup.ApplyResultSelector(resultSelector).GetEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) - { - current = enumerator.Current; - return true; - } - - await DisposeAsync().ConfigureAwait(false); - break; - } - - return false; - } - - public async Task ToArrayAsync(CancellationToken cancellationToken) - { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return l.ToArray(resultSelector); - } - - public async Task> ToListAsync(CancellationToken cancellationToken) - { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return l.ToList(resultSelector); - } - - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - if (onlyIfCheap) - { - return -1; - } - - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - - return l.Count; - } - } - - internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> - { - private readonly IAsyncEnumerable source; - private readonly Func keySelector; - private readonly Func elementSelector; - private readonly IEqualityComparer comparer; - - private Internal.Lookup lookup; - private IEnumerator> enumerator; - - public GroupedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(elementSelector != null); - Debug.Assert(comparer != null); - - this.source = source; - this.keySelector = keySelector; - this.elementSelector = elementSelector; - this.comparer = comparer; - } - - public override AsyncIterator> Clone() - { - return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - enumerator.Dispose(); - enumerator = null; - lookup = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); - enumerator = lookup.GetEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) - { - current = (IAsyncGrouping)enumerator.Current; - return true; - } - - await DisposeAsync().ConfigureAwait(false); - break; - } - - return false; - } - - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) - { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); - return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); - } - - public async Task>> ToListAsync(CancellationToken cancellationToken) - { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); - return await l.ToListAsync(cancellationToken).ConfigureAwait(false); - } - - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - if (onlyIfCheap) - { - return -1; - } - - var l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); - - return l.Count; - } - } - - internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> - { - private readonly IAsyncEnumerable source; - private readonly Func keySelector; - private readonly IEqualityComparer comparer; - - private Internal.Lookup lookup; - private IEnumerator> enumerator; - - public GroupedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(comparer != null); - - this.source = source; - this.keySelector = keySelector; - this.comparer = comparer; - } - - public override AsyncIterator> Clone() - { - return new GroupedAsyncEnumerable(source, keySelector, comparer); - } - public override async Task DisposeAsync() - { - if (enumerator != null) - { - enumerator.Dispose(); - enumerator = null; - lookup = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - enumerator = lookup.GetEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) - { - current = (IAsyncGrouping)enumerator.Current; - return true; - } - - await DisposeAsync().ConfigureAwait(false); - break; - } - - return false; - } - - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) - { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); - } - - public async Task>> ToListAsync(CancellationToken cancellationToken) - { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return await l.ToListAsync(cancellationToken).ConfigureAwait(false); - } - - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - if (onlyIfCheap) - { - return -1; - } - - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - - return l.Count; - } - } - - } -} // Note: The type here has to be internal as System.Linq has it's own public copy we're not using @@ -425,15 +48,9 @@ void ICollection.Clear() throw new NotSupportedException(Strings.NOT_SUPPORTED); } - bool ICollection.Contains(TElement item) - { - return Array.IndexOf(_elements, item, 0, _count) >= 0; - } + bool ICollection.Contains(TElement item) => Array.IndexOf(_elements, item, 0, _count) >= 0; - void ICollection.CopyTo(TElement[] array, int arrayIndex) - { - Array.Copy(_elements, 0, array, arrayIndex, _count); - } + void ICollection.CopyTo(TElement[] array, int arrayIndex) => Array.Copy(_elements, 0, array, arrayIndex, _count); bool ICollection.Remove(TElement item) { @@ -486,9 +103,6 @@ internal void Trim() } } - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() - { - return this.ToAsyncEnumerable().GetAsyncEnumerator(); - } + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() => this.ToAsyncEnumerable().GetAsyncEnumerator(); } } From 78f3470a54ddf3f6695919a65bdefba07b487aee Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:19:46 -0700 Subject: [PATCH 092/862] Reordering GroupBy overloads. --- .../System.Interactive.Async/GroupBy.cs | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/GroupBy.cs b/Ix.NET/Source/System.Interactive.Async/GroupBy.cs index 533d169e33..ca6b304b9f 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupBy.cs @@ -11,18 +11,26 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return new GroupedAsyncEnumerable(source, keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); + return new GroupedAsyncEnumerable(source, keySelector, comparer); } public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) @@ -37,42 +45,44 @@ public static IAsyncEnumerable> GroupBy.Default); } - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new GroupedAsyncEnumerable(source, keySelector, comparer); + return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); } - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); - return new GroupedAsyncEnumerable(source, keySelector, EqualityComparer.Default); + return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); } - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); + return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) @@ -89,30 +99,20 @@ public static IAsyncEnumerable GroupBy.Default).Select(g => resultSelector(g.Key, g)); } - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - } - - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - - return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); + return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); } internal sealed class GroupedResultAsyncEnumerable : AsyncIterator, IIListProvider From 83ace94afc0fe0457d258469f20c8e1c59f4deae Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:33:37 -0700 Subject: [PATCH 093/862] Async variants of GroupBy. --- .../System.Interactive.Async/GroupBy.cs | 366 ++++++++++++++++++ .../System.Interactive.Async/ToLookup.cs | 16 - Ix.NET/Source/Tests/AsyncTests.Single.cs | 2 +- 3 files changed, 367 insertions(+), 17 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/GroupBy.cs b/Ix.NET/Source/System.Interactive.Async/GroupBy.cs index ca6b304b9f..2e1e271c12 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupBy.cs @@ -33,6 +33,28 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, comparer); } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return new GroupedAsyncEnumerableWithTask(source, keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); + } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) @@ -59,6 +81,32 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, comparer); } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + + return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); + } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) { if (source == null) @@ -85,6 +133,32 @@ public static IAsyncEnumerable GroupBy(this IAs return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); + } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) { if (source == null) @@ -115,6 +189,36 @@ public static IAsyncEnumerable GroupBy resultSelector(g.Key, g)); } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, Task> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default).Select(g => resultSelector(g.Key, g)); + } + + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, Task> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); + } + internal sealed class GroupedResultAsyncEnumerable : AsyncIterator, IIListProvider { private readonly IAsyncEnumerable source; @@ -204,6 +308,95 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } + internal sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IIListProvider + { + private readonly IAsyncEnumerable source; + private readonly Func> keySelector; + private readonly Func, Task> resultSelector; + private readonly IEqualityComparer comparer; + + private Internal.LookupWithTask lookup; + private IAsyncEnumerator enumerator; + + public GroupedResultAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(resultSelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.resultSelector = resultSelector; + this.comparer = comparer; + } + + public override AsyncIterator Clone() + { + return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + enumerator = lookup.Select(async g => await resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArray(resultSelector).ConfigureAwait(false); + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToList(resultSelector).ConfigureAwait(false); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> { private readonly IAsyncEnumerable source; @@ -293,6 +486,95 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } + internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IIListProvider> + { + private readonly IAsyncEnumerable source; + private readonly Func> keySelector; + private readonly Func> elementSelector; + private readonly IEqualityComparer comparer; + + private Internal.LookupWithTask lookup; + private IEnumerator> enumerator; + + public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(elementSelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.elementSelector = elementSelector; + this.comparer = comparer; + } + + public override AsyncIterator> Clone() + { + return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + enumerator.Dispose(); + enumerator = null; + lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + enumerator = lookup.GetEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (enumerator.MoveNext()) + { + current = (IAsyncGrouping)enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task>> ToListAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToListAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> { private readonly IAsyncEnumerable source; @@ -378,5 +660,89 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } + internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IIListProvider> + { + private readonly IAsyncEnumerable source; + private readonly Func> keySelector; + private readonly IEqualityComparer comparer; + + private Internal.LookupWithTask lookup; + private IEnumerator> enumerator; + + public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + } + + public override AsyncIterator> Clone() + { + return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); + } + public override async Task DisposeAsync() + { + if (enumerator != null) + { + enumerator.Dispose(); + enumerator = null; + lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + enumerator = lookup.GetEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (enumerator.MoveNext()) + { + current = (IAsyncGrouping)enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task>> ToListAsync(CancellationToken cancellationToken) + { + IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + return await l.ToListAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + + return l.Count; + } + } } } diff --git a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs index 71b1e59ae9..3c25f7cbf5 100644 --- a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs +++ b/Ix.NET/Source/System.Interactive.Async/ToLookup.cs @@ -571,22 +571,6 @@ public IEnumerator> GetEnumerator() } } - public IEnumerable ApplyResultSelector(Func, TResult> resultSelector) - { - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - g.Trim(); - - var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); - yield return result; - } while (g != _lastGrouping); - } - } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) { Debug.Assert(source != null); diff --git a/Ix.NET/Source/Tests/AsyncTests.Single.cs b/Ix.NET/Source/Tests/AsyncTests.Single.cs index 5a66688591..7ebdccb22b 100644 --- a/Ix.NET/Source/Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/Tests/AsyncTests.Single.cs @@ -2095,7 +2095,7 @@ public void GroupBy7() { var ex = new Exception("Bang!"); var xs = AsyncEnumerable.Return(42); - var ys = xs.GroupBy(x => { throw ex; }); + var ys = xs.GroupBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); From 412f83d8d09b7f2e97bd9823425e361097e025e7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:34:06 -0700 Subject: [PATCH 094/862] Reordering GroupJoin overloads. --- Ix.NET/Source/System.Interactive.Async/GroupJoin.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs index 780756208c..a165454fc9 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs @@ -9,7 +9,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -21,13 +21,11 @@ public static IAsyncEnumerable GroupJoin throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector) + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -39,8 +37,10 @@ public static IAsyncEnumerable GroupJoin throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } private sealed class GroupJoinAsyncEnumerable : IAsyncEnumerable From 2e57c01c137b22330f22a52b70f79bdc9e937370 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:34:27 -0700 Subject: [PATCH 095/862] Reordering Join overloads. --- Ix.NET/Source/System.Interactive.Async/Join.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index 1f73e9a1b9..9204e701f7 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -4,14 +4,13 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -23,13 +22,11 @@ public static IAsyncEnumerable Join(this throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -41,8 +38,10 @@ public static IAsyncEnumerable Join(this throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } internal sealed class JoinAsyncIterator : AsyncIterator From 0e3f3bd005857e9e688e99e6db8fbb0e9883f1f6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:37:04 -0700 Subject: [PATCH 096/862] Async variants of Join. --- .../Source/System.Interactive.Async/Join.cs | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Interactive.Async/Join.cs index 9204e701f7..0100755aca 100644 --- a/Ix.NET/Source/System.Interactive.Async/Join.cs +++ b/Ix.NET/Source/System.Interactive.Async/Join.cs @@ -44,6 +44,40 @@ public static IAsyncEnumerable Join(this return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + } + internal sealed class JoinAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable outer; @@ -171,5 +205,133 @@ protected override async Task MoveNextCore() return false; } } + + internal sealed class JoinAsyncIteratorWithTask : AsyncIterator + { + private readonly IAsyncEnumerable outer; + private readonly IAsyncEnumerable inner; + private readonly Func> outerKeySelector; + private readonly Func> innerKeySelector; + private readonly Func> resultSelector; + private readonly IEqualityComparer comparer; + + private IAsyncEnumerator outerEnumerator; + + public JoinAsyncIteratorWithTask(IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + { + Debug.Assert(outer != null); + Debug.Assert(inner != null); + Debug.Assert(outerKeySelector != null); + Debug.Assert(innerKeySelector != null); + Debug.Assert(resultSelector != null); + Debug.Assert(comparer != null); + + this.outer = outer; + this.inner = inner; + this.outerKeySelector = outerKeySelector; + this.innerKeySelector = innerKeySelector; + this.resultSelector = resultSelector; + this.comparer = comparer; + } + + public override AsyncIterator Clone() + { + return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + } + + public override async Task DisposeAsync() + { + if (outerEnumerator != null) + { + await outerEnumerator.DisposeAsync().ConfigureAwait(false); + outerEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + // State machine vars + private Internal.LookupWithTask lookup; + private int count; + private TInner[] elements; + private int index; + private TOuter item; + private int mode; + + private const int State_If = 1; + private const int State_DoLoop = 2; + private const int State_For = 3; + private const int State_While = 4; + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + outerEnumerator = outer.GetAsyncEnumerator(); + mode = State_If; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (mode) + { + case State_If: + if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer).ConfigureAwait(false); + + if (lookup.Count != 0) + { + mode = State_DoLoop; + goto case State_DoLoop; + } + } + + break; + + case State_DoLoop: + item = outerEnumerator.Current; + var g = lookup.GetGrouping(await outerKeySelector(item).ConfigureAwait(false), create: false); + if (g != null) + { + count = g._count; + elements = g._elements; + index = 0; + mode = State_For; + goto case State_For; + } + + // advance to while + mode = State_While; + goto case State_While; + + case State_For: + current = await resultSelector(item, elements[index]).ConfigureAwait(false); + index++; + if (index == count) + { + mode = State_While; + } + + return true; + + case State_While: + var hasNext = await outerEnumerator.MoveNextAsync().ConfigureAwait(false); + if (hasNext) + { + goto case State_DoLoop; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } From 591f7b755b065620c8bb50b42cfa02c6343b5c37 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:44:02 -0700 Subject: [PATCH 097/862] Async variants of GroupJoin. --- .../System.Interactive.Async/GroupJoin.cs | 131 +++++++++++++++++- 1 file changed, 130 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs index a165454fc9..04cbcf3b82 100644 --- a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs +++ b/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs @@ -43,6 +43,40 @@ public static IAsyncEnumerable GroupJoin return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + } + private sealed class GroupJoinAsyncEnumerable : IAsyncEnumerable { private readonly IEqualityComparer _comparer; @@ -118,7 +152,102 @@ public async Task MoveNextAsync() } var item = _outer.Current; - Current = _resultSelector(item, _lookup[_outerKeySelector(item)].ToAsyncEnumerable()); + + var outerKey = _outerKeySelector(item); + var inner = _lookup[outerKey].ToAsyncEnumerable(); + + Current = _resultSelector(item, inner); + + return true; + } + + public TResult Current { get; private set; } + + public Task DisposeAsync() => _outer.DisposeAsync(); + } + } + + private sealed class GroupJoinAsyncEnumerableWithTask : IAsyncEnumerable + { + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _inner; + private readonly Func> _innerKeySelector; + private readonly IAsyncEnumerable _outer; + private readonly Func> _outerKeySelector; + private readonly Func, Task> _resultSelector; + + public GroupJoinAsyncEnumerableWithTask( + IAsyncEnumerable outer, + IAsyncEnumerable inner, + Func> outerKeySelector, + Func> innerKeySelector, + Func, Task> resultSelector, + IEqualityComparer comparer) + { + _outer = outer; + _inner = inner; + _outerKeySelector = outerKeySelector; + _innerKeySelector = innerKeySelector; + _resultSelector = resultSelector; + _comparer = comparer; + } + + public IAsyncEnumerator GetAsyncEnumerator() + => new GroupJoinAsyncEnumeratorWithTask( + _outer.GetAsyncEnumerator(), + _inner, + _outerKeySelector, + _innerKeySelector, + _resultSelector, + _comparer); + + private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator + { + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _inner; + private readonly Func> _innerKeySelector; + private readonly IAsyncEnumerator _outer; + private readonly Func> _outerKeySelector; + private readonly Func, Task> _resultSelector; + + private Internal.LookupWithTask _lookup; + + public GroupJoinAsyncEnumeratorWithTask( + IAsyncEnumerator outer, + IAsyncEnumerable inner, + Func> outerKeySelector, + Func> innerKeySelector, + Func, Task> resultSelector, + IEqualityComparer comparer) + { + _outer = outer; + _inner = inner; + _outerKeySelector = outerKeySelector; + _innerKeySelector = innerKeySelector; + _resultSelector = resultSelector; + _comparer = comparer; + } + + public async Task MoveNextAsync() + { + // nothing to do + if (!await _outer.MoveNextAsync().ConfigureAwait(false)) + { + return false; + } + + if (_lookup == null) + { + _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer).ConfigureAwait(false); + } + + var item = _outer.Current; + + var outerKey = await _outerKeySelector(item).ConfigureAwait(false); + var inner = _lookup[outerKey].ToAsyncEnumerable(); + + Current = await _resultSelector(item, inner).ConfigureAwait(false); + return true; } From 6b1207779d5a2235139d3f39749189c662da7eaa Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:48:31 -0700 Subject: [PATCH 098/862] Some clean-up of Ix. --- Ix.NET/Source/System.Interactive/Buffer.cs | 5 +---- Ix.NET/Source/System.Interactive/Case.cs | 2 +- Ix.NET/Source/System.Interactive/Catch.cs | 5 +---- Ix.NET/Source/System.Interactive/Concatenate.cs | 5 +---- Ix.NET/Source/System.Interactive/Create.cs | 5 +---- Ix.NET/Source/System.Interactive/Defer.cs | 5 +---- 6 files changed, 6 insertions(+), 21 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/Buffer.cs b/Ix.NET/Source/System.Interactive/Buffer.cs index 0d2ece2335..9d8334fa8e 100644 --- a/Ix.NET/Source/System.Interactive/Buffer.cs +++ b/Ix.NET/Source/System.Interactive/Buffer.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -80,4 +77,4 @@ private static IEnumerable> Buffer_(this IEnumerable : IEnumerable, IDisposable { } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Case.cs b/Ix.NET/Source/System.Interactive/Case.cs index 2366d86c62..be55b6af5c 100644 --- a/Ix.NET/Source/System.Interactive/Case.cs +++ b/Ix.NET/Source/System.Interactive/Case.cs @@ -59,4 +59,4 @@ public static IEnumerable Case(Func selector, }); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Catch.cs b/Ix.NET/Source/System.Interactive/Catch.cs index 5760c7e1a1..df4c671d54 100644 --- a/Ix.NET/Source/System.Interactive/Catch.cs +++ b/Ix.NET/Source/System.Interactive/Catch.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -150,4 +147,4 @@ private static IEnumerable Catch_(this IEnumerable Concat_(this IEnumerable Defer_(Func> e yield return item; } } -} \ No newline at end of file +} From 2ab9acdd65abafd5f50ccfde2f0c803fba4c4472 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:48:41 -0700 Subject: [PATCH 099/862] Sealing a class. --- Ix.NET/Source/System.Interactive/Create.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive/Create.cs b/Ix.NET/Source/System.Interactive/Create.cs index 8f9cd1e828..6b0a9ce240 100644 --- a/Ix.NET/Source/System.Interactive/Create.cs +++ b/Ix.NET/Source/System.Interactive/Create.cs @@ -41,7 +41,7 @@ public static IEnumerable Create(Action> create) yield return x; } - private class AnonymousEnumerable : IEnumerable + private sealed class AnonymousEnumerable : IEnumerable { private readonly Func> _getEnumerator; From 86a39962f02b678f9085105108761704db7d9e38 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:48:54 -0700 Subject: [PATCH 100/862] Modernizing some code. --- Ix.NET/Source/System.Interactive/Create.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/Create.cs b/Ix.NET/Source/System.Interactive/Create.cs index 6b0a9ce240..2b63c07a20 100644 --- a/Ix.NET/Source/System.Interactive/Create.cs +++ b/Ix.NET/Source/System.Interactive/Create.cs @@ -50,15 +50,9 @@ public AnonymousEnumerable(Func> getEnumerator) _getEnumerator = getEnumerator; } - public IEnumerator GetEnumerator() - { - return _getEnumerator(); - } + public IEnumerator GetEnumerator() => _getEnumerator(); - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } } From 6dd9939ccc5607f093d64af52b8f6de149c67021 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:49:12 -0700 Subject: [PATCH 101/862] Adding missing copyright header. --- Ix.NET/Source/System.Interactive/Distinct.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/Distinct.cs b/Ix.NET/Source/System.Interactive/Distinct.cs index 65eb8ad494..ccd2966370 100644 --- a/Ix.NET/Source/System.Interactive/Distinct.cs +++ b/Ix.NET/Source/System.Interactive/Distinct.cs @@ -1,7 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { From 3ff7f0edd4d19908cf0cf89f3d06465b1b00a7e6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:50:55 -0700 Subject: [PATCH 102/862] More cleanup. --- Ix.NET/Source/System.Interactive/Do.cs | 5 +---- Ix.NET/Source/System.Interactive/Empty.cs | 5 +---- Ix.NET/Source/System.Interactive/Expand.cs | 5 +---- Ix.NET/Source/System.Interactive/Finally.cs | 5 +---- Ix.NET/Source/System.Interactive/For.cs | 5 +---- Ix.NET/Source/System.Interactive/ForEach.cs | 5 +---- Ix.NET/Source/System.Interactive/Generate.cs | 5 +---- Ix.NET/Source/System.Interactive/Hide.cs | 5 +---- Ix.NET/Source/System.Interactive/IAwaitable.cs | 6 +----- Ix.NET/Source/System.Interactive/IYielder.cs | 6 +----- Ix.NET/Source/System.Interactive/If.cs | 5 +---- Ix.NET/Source/System.Interactive/IgnoreElements.cs | 5 +---- 12 files changed, 12 insertions(+), 50 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/Do.cs b/Ix.NET/Source/System.Interactive/Do.cs index bcf4ea0945..c3acff9519 100644 --- a/Ix.NET/Source/System.Interactive/Do.cs +++ b/Ix.NET/Source/System.Interactive/Do.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -154,4 +151,4 @@ private static IEnumerable DoHelper(this IEnumerable } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Empty.cs b/Ix.NET/Source/System.Interactive/Empty.cs index 8a4fd0e850..7d2747d2e7 100644 --- a/Ix.NET/Source/System.Interactive/Empty.cs +++ b/Ix.NET/Source/System.Interactive/Empty.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -25,4 +22,4 @@ public static bool IsEmpty(this IEnumerable source) return !source.Any(); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Expand.cs b/Ix.NET/Source/System.Interactive/Expand.cs index 06182254ff..66494ed7fa 100644 --- a/Ix.NET/Source/System.Interactive/Expand.cs +++ b/Ix.NET/Source/System.Interactive/Expand.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -45,4 +42,4 @@ private static IEnumerable Expand_(this IEnumerable s } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Finally.cs b/Ix.NET/Source/System.Interactive/Finally.cs index 46436c8085..797a3a418a 100644 --- a/Ix.NET/Source/System.Interactive/Finally.cs +++ b/Ix.NET/Source/System.Interactive/Finally.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -41,4 +38,4 @@ private static IEnumerable Finally_(this IEnumerable } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/For.cs b/Ix.NET/Source/System.Interactive/For.cs index 6b3e40227a..d0c2798d06 100644 --- a/Ix.NET/Source/System.Interactive/For.cs +++ b/Ix.NET/Source/System.Interactive/For.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -39,4 +36,4 @@ private static IEnumerable> ForCore(IEnum return source.Select(resultSelector); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/ForEach.cs b/Ix.NET/Source/System.Interactive/ForEach.cs index 0434fd365d..39b885b435 100644 --- a/Ix.NET/Source/System.Interactive/ForEach.cs +++ b/Ix.NET/Source/System.Interactive/ForEach.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -46,4 +43,4 @@ public static void ForEach(this IEnumerable source, Action Generate_(TState initialSta yield return resultSelector(i); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Hide.cs b/Ix.NET/Source/System.Interactive/Hide.cs index 69ed7ac508..a27f356889 100644 --- a/Ix.NET/Source/System.Interactive/Hide.cs +++ b/Ix.NET/Source/System.Interactive/Hide.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -35,4 +32,4 @@ private static IEnumerable Hide_(this IEnumerable sou yield return item; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/IAwaitable.cs b/Ix.NET/Source/System.Interactive/IAwaitable.cs index 679255ffe1..4de1464995 100644 --- a/Ix.NET/Source/System.Interactive/IAwaitable.cs +++ b/Ix.NET/Source/System.Interactive/IAwaitable.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; -using System.Threading.Tasks; namespace System.Linq { @@ -20,4 +16,4 @@ public interface IAwaiter : ICriticalNotifyCompletion bool IsCompleted { get; } void GetResult(); } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/IYielder.cs b/Ix.NET/Source/System.Interactive/IYielder.cs index 37891cf45a..cbe38321d3 100644 --- a/Ix.NET/Source/System.Interactive/IYielder.cs +++ b/Ix.NET/Source/System.Interactive/IYielder.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Linq; using System.Security; -using System.Threading.Tasks; namespace System.Linq { @@ -109,4 +105,4 @@ public void Reset() throw new NotSupportedException(); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/If.cs b/Ix.NET/Source/System.Interactive/If.cs index 98c6b3a002..885325c970 100644 --- a/Ix.NET/Source/System.Interactive/If.cs +++ b/Ix.NET/Source/System.Interactive/If.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -49,4 +46,4 @@ public static IEnumerable If(Func condition, IEnumerable return Defer(() => condition() ? thenSource : Enumerable.Empty()); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/IgnoreElements.cs b/Ix.NET/Source/System.Interactive/IgnoreElements.cs index 2bb35d4bfc..62e29d4851 100644 --- a/Ix.NET/Source/System.Interactive/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive/IgnoreElements.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -33,4 +30,4 @@ private static IEnumerable IgnoreElements_(this IEnumerable Date: Thu, 31 Aug 2017 15:51:25 -0700 Subject: [PATCH 103/862] Sealing some class. --- Ix.NET/Source/System.Interactive/IYielder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive/IYielder.cs b/Ix.NET/Source/System.Interactive/IYielder.cs index cbe38321d3..001a4cbc39 100644 --- a/Ix.NET/Source/System.Interactive/IYielder.cs +++ b/Ix.NET/Source/System.Interactive/IYielder.cs @@ -26,7 +26,7 @@ public interface IYielder IAwaitable Return(T value); } - internal class Yielder : IYielder, IAwaitable, IAwaiter + internal sealed class Yielder : IYielder, IAwaitable, IAwaiter { private readonly Action> _create; private Action _continuation; From 2f1ca2ae330062af5213db499a11791a63f60ab3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:51:55 -0700 Subject: [PATCH 104/862] Modernizing some code. --- Ix.NET/Source/System.Interactive/IYielder.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/IYielder.cs b/Ix.NET/Source/System.Interactive/IYielder.cs index 001a4cbc39..027fa06311 100644 --- a/Ix.NET/Source/System.Interactive/IYielder.cs +++ b/Ix.NET/Source/System.Interactive/IYielder.cs @@ -41,15 +41,9 @@ public Yielder(Action> create) public T Current { get; private set; } - public IAwaiter GetAwaiter() - { - return this; - } + public IAwaiter GetAwaiter() => this; - public bool IsCompleted - { - get { return false; } - } + public bool IsCompleted => false; public void GetResult() { @@ -79,10 +73,7 @@ public IAwaitable Break() return this; } - public Yielder GetEnumerator() - { - return this; - } + public Yielder GetEnumerator() => this; public bool MoveNext() { From 9d3b95336e309cb3e9453478dcea5f47a46a1a34 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 15:56:16 -0700 Subject: [PATCH 105/862] Final cleanup of Ix. --- Ix.NET/Source/System.Interactive/Max.cs | 5 +--- Ix.NET/Source/System.Interactive/Memoize.cs | 23 +++++++------------ Ix.NET/Source/System.Interactive/Min.cs | 8 ++----- .../System.Interactive/OnErrorResumeNext.cs | 7 ++---- Ix.NET/Source/System.Interactive/Publish.cs | 5 +--- Ix.NET/Source/System.Interactive/Repeat.cs | 5 +--- Ix.NET/Source/System.Interactive/Retry.cs | 11 +++------ Ix.NET/Source/System.Interactive/Return.cs | 5 +--- Ix.NET/Source/System.Interactive/Scan.cs | 5 +--- .../Source/System.Interactive/SelectMany.cs | 5 +--- Ix.NET/Source/System.Interactive/Share.cs | 10 +++----- Ix.NET/Source/System.Interactive/Skip.cs | 5 +--- .../Source/System.Interactive/StartsWith.cs | 5 +--- Ix.NET/Source/System.Interactive/Take.cs | 5 +--- Ix.NET/Source/System.Interactive/Throw.cs | 5 +--- Ix.NET/Source/System.Interactive/Using.cs | 5 +--- Ix.NET/Source/System.Interactive/While.cs | 5 +--- 17 files changed, 30 insertions(+), 89 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/Max.cs b/Ix.NET/Source/System.Interactive/Max.cs index 4adfa01f93..9a5b7ea9ef 100644 --- a/Ix.NET/Source/System.Interactive/Max.cs +++ b/Ix.NET/Source/System.Interactive/Max.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -105,4 +102,4 @@ private static IList ExtremaBy(IEnumerable sour return result; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Memoize.cs b/Ix.NET/Source/System.Interactive/Memoize.cs index d8a1664513..3683732515 100644 --- a/Ix.NET/Source/System.Interactive/Memoize.cs +++ b/Ix.NET/Source/System.Interactive/Memoize.cs @@ -2,12 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -60,8 +57,7 @@ public static IEnumerable Memoize(this IEnumerable selector(source.Memoize()) - .GetEnumerator()); + return Create(() => selector(source.Memoize()).GetEnumerator()); } /// @@ -113,11 +109,10 @@ public static IEnumerable Memoize(this IEnumerable selector(source.Memoize(readerCount)) - .GetEnumerator()); + return Create(() => selector(source.Memoize(readerCount)).GetEnumerator()); } - private class MemoizedBuffer : IBuffer + private sealed class MemoizedBuffer : IBuffer { private IRefCountList _buffer; private bool _disposed; @@ -245,9 +240,7 @@ private IEnumerator GetEnumerator_() } } - - - interface IRefCountList + internal interface IRefCountList { void Clear(); @@ -263,7 +256,7 @@ T this[int i] void Done(int index); } - class MaxRefCountList : IRefCountList + internal sealed class MaxRefCountList : IRefCountList { private IList _list = new List(); @@ -292,7 +285,7 @@ public void Done(int index) } } - class RefCountList : IRefCountList + internal sealed class RefCountList : IRefCountList { private int _readerCount; private readonly IDictionary _list; @@ -360,10 +353,10 @@ public void Done(int index) _readerCount--; } - class RefCount + private sealed class RefCount { public int Count; public T Value; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Min.cs b/Ix.NET/Source/System.Interactive/Min.cs index e4e82ac6f7..bad016f3a5 100644 --- a/Ix.NET/Source/System.Interactive/Min.cs +++ b/Ix.NET/Source/System.Interactive/Min.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -25,8 +22,7 @@ public static TSource Min(this IEnumerable source, IComparer x, comparer) - .First(); + return MinBy(source, x => x, comparer).First(); } /// @@ -68,4 +64,4 @@ public static IList MinBy(this IEnumerable sour return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue)); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive/OnErrorResumeNext.cs index 4544826def..f063232d7f 100644 --- a/Ix.NET/Source/System.Interactive/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive/OnErrorResumeNext.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -25,7 +22,7 @@ public static IEnumerable OnErrorResumeNext(this IEnumerable @@ -84,4 +81,4 @@ private static IEnumerable OnErrorResumeNext_(IEnumerable GetEnumerator_(int i) } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Repeat.cs b/Ix.NET/Source/System.Interactive/Repeat.cs index 3acdc782db..e007c0fb80 100644 --- a/Ix.NET/Source/System.Interactive/Repeat.cs +++ b/Ix.NET/Source/System.Interactive/Repeat.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -80,4 +77,4 @@ private static IEnumerable Repeat_(IEnumerable source yield return item; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Retry.cs b/Ix.NET/Source/System.Interactive/Retry.cs index 03286ab0bd..548418d92b 100644 --- a/Ix.NET/Source/System.Interactive/Retry.cs +++ b/Ix.NET/Source/System.Interactive/Retry.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -22,8 +19,7 @@ public static IEnumerable Retry(this IEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return new[] {source}.Repeat() - .Catch(); + return new[] { source }.Repeat().Catch(); } /// @@ -41,8 +37,7 @@ public static IEnumerable Retry(this IEnumerable sour if (retryCount < 0) throw new ArgumentOutOfRangeException(nameof(retryCount)); - return new[] {source}.Repeat(retryCount) - .Catch(); + return new[] { source }.Repeat(retryCount).Catch(); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Return.cs b/Ix.NET/Source/System.Interactive/Return.cs index 9cd5895251..b07bd7b8e5 100644 --- a/Ix.NET/Source/System.Interactive/Return.cs +++ b/Ix.NET/Source/System.Interactive/Return.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -22,4 +19,4 @@ public static IEnumerable Return(TResult value) yield return value; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Scan.cs b/Ix.NET/Source/System.Interactive/Scan.cs index ce6d68cafe..39b8c12eaa 100644 --- a/Ix.NET/Source/System.Interactive/Scan.cs +++ b/Ix.NET/Source/System.Interactive/Scan.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -83,4 +80,4 @@ private static IEnumerable Scan_(this IEnumerable sou } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/SelectMany.cs b/Ix.NET/Source/System.Interactive/SelectMany.cs index 1cb81b09d6..61e1fd9099 100644 --- a/Ix.NET/Source/System.Interactive/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive/SelectMany.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -29,4 +26,4 @@ public static IEnumerable SelectMany(this IEnumerable other); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Share.cs b/Ix.NET/Source/System.Interactive/Share.cs index 53ae64ec2c..4dc8345234 100644 --- a/Ix.NET/Source/System.Interactive/Share.cs +++ b/Ix.NET/Source/System.Interactive/Share.cs @@ -2,11 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -56,11 +53,10 @@ public static IEnumerable Share(this IEnumerable selector(source.Share()) - .GetEnumerator()); + return Create(() => selector(source.Share()).GetEnumerator()); } - private class SharedBuffer : IBuffer + private sealed class SharedBuffer : IBuffer { private bool _disposed; private IEnumerator _source; @@ -125,4 +121,4 @@ private IEnumerator GetEnumerator_() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Skip.cs b/Ix.NET/Source/System.Interactive/Skip.cs index 82fe98afb4..0fb3691bca 100644 --- a/Ix.NET/Source/System.Interactive/Skip.cs +++ b/Ix.NET/Source/System.Interactive/Skip.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -43,4 +40,4 @@ private static IEnumerable SkipLast_(this IEnumerable } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/StartsWith.cs b/Ix.NET/Source/System.Interactive/StartsWith.cs index 009bb53328..9d4d6c57c7 100644 --- a/Ix.NET/Source/System.Interactive/StartsWith.cs +++ b/Ix.NET/Source/System.Interactive/StartsWith.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -35,4 +32,4 @@ private static IEnumerable StartWith_(this IEnumerable TakeLast_(this IEnumerable yield return q.Dequeue(); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Throw.cs b/Ix.NET/Source/System.Interactive/Throw.cs index 831a2cb54f..e5da8eb7fb 100644 --- a/Ix.NET/Source/System.Interactive/Throw.cs +++ b/Ix.NET/Source/System.Interactive/Throw.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -33,4 +30,4 @@ private static IEnumerable Throw_(Exception exception) #pragma warning restore 0162 } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/Using.cs b/Ix.NET/Source/System.Interactive/Using.cs index ab68bfc668..86482ab63c 100644 --- a/Ix.NET/Source/System.Interactive/Using.cs +++ b/Ix.NET/Source/System.Interactive/Using.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -37,4 +34,4 @@ private static IEnumerable Using_(Func r yield return item; } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive/While.cs b/Ix.NET/Source/System.Interactive/While.cs index a297ff434e..10128c0187 100644 --- a/Ix.NET/Source/System.Interactive/While.cs +++ b/Ix.NET/Source/System.Interactive/While.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -35,4 +32,4 @@ private static IEnumerable> WhileCore(Func c yield return source; } } -} \ No newline at end of file +} From 5b13cd700c49edfad71e6045e07a3468485b01d5 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Thu, 31 Aug 2017 19:41:24 -0400 Subject: [PATCH 106/862] Add blank solutions for Sys.Linq.Async --- Ix.NET/Source/Directory.build.targets | 2 +- Ix.NET/Source/Ix.NET.sln | 38 +++++++++++++++++++ .../System.Linq.Async.Queryable.csproj | 11 ++++++ .../System.Linq.Async.csproj | 7 ++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj create mode 100644 Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index dda03c72ab..7297c7b6ee 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -8,7 +8,7 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION;PLIB;SIGNED - + $(DefineConstants);NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION;PLIB;SIGNED diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index da520f7e87..be49bf971a 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -32,6 +32,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Tests", "System.Interactive.Tests\System.Interactive.Tests.csproj", "{AFD2E6EC-C5B0-4276-A14A-467D786D0DDA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Tests", "System.Interactive.Async.Tests\System.Interactive.Async.Tests.csproj", "{172BD8C4-5C3E-4928-9D3F-746CF336FFEC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Linq.Async", "System.Linq.Async\System.Linq.Async.csproj", "{9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Linq.Async.Queryable", "System.Linq.Async.Queryable\System.Linq.Async.Queryable.csproj", "{513F9ABD-4FB8-4AC1-89DA-C3300399F34C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -165,6 +168,38 @@ Global {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|x64.Build.0 = Release|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|x86.ActiveCfg = Release|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|x86.Build.0 = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|ARM.ActiveCfg = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|ARM.Build.0 = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x64.ActiveCfg = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x64.Build.0 = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x86.ActiveCfg = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x86.Build.0 = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.Build.0 = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|ARM.ActiveCfg = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|ARM.Build.0 = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x64.ActiveCfg = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x64.Build.0 = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x86.ActiveCfg = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x86.Build.0 = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|ARM.Build.0 = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x64.ActiveCfg = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x64.Build.0 = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x86.ActiveCfg = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x86.Build.0 = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.Build.0 = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|ARM.ActiveCfg = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|ARM.Build.0 = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x64.ActiveCfg = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x64.Build.0 = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x86.ActiveCfg = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -177,4 +212,7 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9B5F6126-CBBA-4C3A-A3BB-26AFE56DABEC} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} + EndGlobalSection EndGlobal diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj new file mode 100644 index 0000000000..145eaea791 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -0,0 +1,11 @@ + + + + net46;netstandard1.4 + + + + + + + diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj new file mode 100644 index 0000000000..7821837d87 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -0,0 +1,7 @@ + + + + net46;netstandard1.4 + + + From 541ca2d9db26e42e71052aa6b5d2908f02c8e88f Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Thu, 31 Aug 2017 19:47:17 -0400 Subject: [PATCH 107/862] bump ver in branch --- Ix.NET/Source/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/version.json b/Ix.NET/Source/version.json index a73186832c..7e5e4780dc 100644 --- a/Ix.NET/Source/version.json +++ b/Ix.NET/Source/version.json @@ -1,5 +1,5 @@ { - "version": "3.2.0-preview.{height}", + "version": "4.0.0-preview.1.build.{height}", "publicReleaseRefSpec": [ "^refs/heads/master$", // we release out of master "^refs/heads/develop$", // we release out of develop From 1c69583ffa5e2946fa3b80490c2e13b5803a12cb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 18:44:46 -0700 Subject: [PATCH 108/862] Moving interfaces to System.Linq.Async. --- .../System.Interactive.Async.Providers.csproj | 2 +- .../System.Interactive.Async.csproj | 6 +++++- .../System/Collections/Generic}/IAsyncEnumerable.cs | 0 .../System/Collections/Generic}/IAsyncEnumerator.cs | 0 .../System}/IAsyncDisposable.cs | 0 .../System/Linq}/IAsyncGrouping.cs | 0 .../System/Linq}/IOrderedAsyncEnumerable.cs | 0 7 files changed, 6 insertions(+), 2 deletions(-) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Collections/Generic}/IAsyncEnumerable.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Collections/Generic}/IAsyncEnumerator.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System}/IAsyncDisposable.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/IAsyncGrouping.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/IOrderedAsyncEnumerable.cs (100%) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index f40ecf0897..74812e9dcf 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Providers Library used to build query providers and express queries over async enumerable sequences. Interactive Extensions - Async Providers Library - net45;netstandard1.0 + net46;netstandard1.4 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index e00f5d2d33..3340e8c0f9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. Interactive Extensions - Async Library - net45;net46;netstandard1.0;netstandard1.3 + net46;netstandard1.4 Ix;Interactive;Extensions;Enumerable;Asynchronous @@ -29,6 +29,10 @@ + + + + TextTemplatingFileGenerator diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/IAsyncEnumerable.cs rename to Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs rename to Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs b/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/IAsyncDisposable.cs rename to Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs diff --git a/Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncGrouping.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/IAsyncGrouping.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncGrouping.cs diff --git a/Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/IOrderedAsyncEnumerable.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs From 01453abc7a0891a1e683996a4ad59f1bf8173007 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 20:45:50 -0700 Subject: [PATCH 109/862] Adding AssemblyInfo.cs files. --- .../Properties/AssemblyInfo.cs | 18 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs create mode 100644 Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..6c2beda1e6 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System; +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; +using System.Security; + +[assembly: NeutralResourcesLanguage("en-US")] + +#if !PLIB +[assembly: ComVisible(false)] +#endif + +[assembly: CLSCompliant(true)] + +#if HAS_APTCA && NO_CODECOVERAGE +[assembly: AllowPartiallyTrustedCallers] +#endif + diff --git a/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..6c2beda1e6 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System; +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; +using System.Security; + +[assembly: NeutralResourcesLanguage("en-US")] + +#if !PLIB +[assembly: ComVisible(false)] +#endif + +[assembly: CLSCompliant(true)] + +#if HAS_APTCA && NO_CODECOVERAGE +[assembly: AllowPartiallyTrustedCallers] +#endif + From d9df0566802c1b4b40e9bf48482df58e5c48ba98 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 20:49:31 -0700 Subject: [PATCH 110/862] Restructuring System.Interactive. --- Ix.NET/Source/System.Interactive/{ => System/Linq}/IAwaitable.cs | 0 Ix.NET/Source/System.Interactive/{ => System/Linq}/IYielder.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Buffer.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Case.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Catch.cs | 0 .../{ => System/Linq/Operators}/Concatenate.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Create.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Defer.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Distinct.cs | 1 - .../Source/System.Interactive/{ => System/Linq/Operators}/Do.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Empty.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Expand.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Finally.cs | 0 .../Source/System.Interactive/{ => System/Linq/Operators}/For.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/ForEach.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Generate.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Hide.cs | 0 .../Source/System.Interactive/{ => System/Linq/Operators}/If.cs | 0 .../{ => System/Linq/Operators}/IgnoreElements.cs | 0 .../Source/System.Interactive/{ => System/Linq/Operators}/Max.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Memoize.cs | 0 .../Source/System.Interactive/{ => System/Linq/Operators}/Min.cs | 0 .../{ => System/Linq/Operators}/OnErrorResumeNext.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Publish.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Repeat.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Retry.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Return.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Scan.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/SelectMany.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Share.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Skip.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/StartsWith.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Take.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Throw.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/Using.cs | 0 .../System.Interactive/{ => System/Linq/Operators}/While.cs | 0 36 files changed, 1 deletion(-) rename Ix.NET/Source/System.Interactive/{ => System/Linq}/IAwaitable.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq}/IYielder.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Buffer.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Case.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Catch.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Concatenate.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Create.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Defer.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Distinct.cs (99%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Do.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Empty.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Expand.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Finally.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/For.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/ForEach.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Generate.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Hide.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/If.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/IgnoreElements.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Max.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Memoize.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Min.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/OnErrorResumeNext.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Publish.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Repeat.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Retry.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Return.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Scan.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/SelectMany.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Share.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Skip.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/StartsWith.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Take.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Throw.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/Using.cs (100%) rename Ix.NET/Source/System.Interactive/{ => System/Linq/Operators}/While.cs (100%) diff --git a/Ix.NET/Source/System.Interactive/IAwaitable.cs b/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/IAwaitable.cs rename to Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs diff --git a/Ix.NET/Source/System.Interactive/IYielder.cs b/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/IYielder.cs rename to Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs diff --git a/Ix.NET/Source/System.Interactive/Buffer.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Buffer.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs diff --git a/Ix.NET/Source/System.Interactive/Case.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Case.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs diff --git a/Ix.NET/Source/System.Interactive/Catch.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Catch.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs diff --git a/Ix.NET/Source/System.Interactive/Concatenate.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concatenate.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Concatenate.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Concatenate.cs diff --git a/Ix.NET/Source/System.Interactive/Create.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Create.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs diff --git a/Ix.NET/Source/System.Interactive/Defer.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Defer.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs diff --git a/Ix.NET/Source/System.Interactive/Distinct.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs similarity index 99% rename from Ix.NET/Source/System.Interactive/Distinct.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs index ccd2966370..c0c3f49098 100644 --- a/Ix.NET/Source/System.Interactive/Distinct.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs @@ -8,7 +8,6 @@ namespace System.Linq { public static partial class EnumerableEx { - /// /// Returns elements with a distinct key value by using the default equality comparer to compare key values. /// diff --git a/Ix.NET/Source/System.Interactive/Do.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Do.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs diff --git a/Ix.NET/Source/System.Interactive/Empty.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Empty.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Empty.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Empty.cs diff --git a/Ix.NET/Source/System.Interactive/Expand.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Expand.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs diff --git a/Ix.NET/Source/System.Interactive/Finally.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Finally.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs diff --git a/Ix.NET/Source/System.Interactive/For.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/For.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs diff --git a/Ix.NET/Source/System.Interactive/ForEach.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/ForEach.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs diff --git a/Ix.NET/Source/System.Interactive/Generate.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Generate.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs diff --git a/Ix.NET/Source/System.Interactive/Hide.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Hide.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs diff --git a/Ix.NET/Source/System.Interactive/If.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/If.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/If.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/If.cs diff --git a/Ix.NET/Source/System.Interactive/IgnoreElements.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/IgnoreElements.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs diff --git a/Ix.NET/Source/System.Interactive/Max.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Max.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs diff --git a/Ix.NET/Source/System.Interactive/Memoize.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Memoize.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs diff --git a/Ix.NET/Source/System.Interactive/Min.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Min.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs diff --git a/Ix.NET/Source/System.Interactive/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/OnErrorResumeNext.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs diff --git a/Ix.NET/Source/System.Interactive/Publish.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Publish.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs diff --git a/Ix.NET/Source/System.Interactive/Repeat.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Repeat.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs diff --git a/Ix.NET/Source/System.Interactive/Retry.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Retry.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Retry.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Retry.cs diff --git a/Ix.NET/Source/System.Interactive/Return.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Return.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Return.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Return.cs diff --git a/Ix.NET/Source/System.Interactive/Scan.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Scan.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs diff --git a/Ix.NET/Source/System.Interactive/SelectMany.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SelectMany.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/SelectMany.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/SelectMany.cs diff --git a/Ix.NET/Source/System.Interactive/Share.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Share.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs diff --git a/Ix.NET/Source/System.Interactive/Skip.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Skip.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Skip.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Skip.cs diff --git a/Ix.NET/Source/System.Interactive/StartsWith.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/StartsWith.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs diff --git a/Ix.NET/Source/System.Interactive/Take.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Take.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Take.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Take.cs diff --git a/Ix.NET/Source/System.Interactive/Throw.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Throw.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs diff --git a/Ix.NET/Source/System.Interactive/Using.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/Using.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs diff --git a/Ix.NET/Source/System.Interactive/While.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/While.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs From d4aa15bcb2875b50ba2b9eae620f185e88ac1afc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 20:50:42 -0700 Subject: [PATCH 111/862] Refactoring some files. --- .../System/Linq/IAwaitable.cs | 8 -- .../System/Linq/IAwaiter.cs | 14 ++++ .../System/Linq/IYielder.cs | 71 ----------------- .../System.Interactive/System/Linq/Yielder.cs | 79 +++++++++++++++++++ 4 files changed, 93 insertions(+), 79 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/Yielder.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs b/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs index 4de1464995..8b061fa0fd 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs @@ -2,18 +2,10 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Runtime.CompilerServices; - namespace System.Linq { public interface IAwaitable { IAwaiter GetAwaiter(); } - - public interface IAwaiter : ICriticalNotifyCompletion - { - bool IsCompleted { get; } - void GetResult(); - } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs b/Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs new file mode 100644 index 0000000000..9b22236d2b --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Runtime.CompilerServices; + +namespace System.Linq +{ + public interface IAwaiter : ICriticalNotifyCompletion + { + bool IsCompleted { get; } + void GetResult(); + } +} diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs b/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs index 027fa06311..d927b78304 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs @@ -25,75 +25,4 @@ public interface IYielder /// Awaitable object for use in an asynchronous method. IAwaitable Return(T value); } - - internal sealed class Yielder : IYielder, IAwaitable, IAwaiter - { - private readonly Action> _create; - private Action _continuation; - private bool _hasValue; - private bool _running; - private bool _stopped; - - public Yielder(Action> create) - { - _create = create; - } - - public T Current { get; private set; } - - public IAwaiter GetAwaiter() => this; - - public bool IsCompleted => false; - - public void GetResult() - { - } - - [SecurityCritical] - public void UnsafeOnCompleted(Action continuation) - { - _continuation = continuation; - } - - public void OnCompleted(Action continuation) - { - _continuation = continuation; - } - - public IAwaitable Return(T value) - { - _hasValue = true; - Current = value; - return this; - } - - public IAwaitable Break() - { - _stopped = true; - return this; - } - - public Yielder GetEnumerator() => this; - - public bool MoveNext() - { - if (!_running) - { - _running = true; - _create(this); - } - else - { - _hasValue = false; - _continuation(); - } - - return !_stopped && _hasValue; - } - - public void Reset() - { - throw new NotSupportedException(); - } - } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Yielder.cs b/Ix.NET/Source/System.Interactive/System/Linq/Yielder.cs new file mode 100644 index 0000000000..1121738638 --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/Yielder.cs @@ -0,0 +1,79 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Security; + +namespace System.Linq +{ + internal sealed class Yielder : IYielder, IAwaitable, IAwaiter + { + private readonly Action> _create; + private Action _continuation; + private bool _hasValue; + private bool _running; + private bool _stopped; + + public Yielder(Action> create) + { + _create = create; + } + + public T Current { get; private set; } + + public IAwaiter GetAwaiter() => this; + + public bool IsCompleted => false; + + public void GetResult() + { + } + + [SecurityCritical] + public void UnsafeOnCompleted(Action continuation) + { + _continuation = continuation; + } + + public void OnCompleted(Action continuation) + { + _continuation = continuation; + } + + public IAwaitable Return(T value) + { + _hasValue = true; + Current = value; + return this; + } + + public IAwaitable Break() + { + _stopped = true; + return this; + } + + public Yielder GetEnumerator() => this; + + public bool MoveNext() + { + if (!_running) + { + _running = true; + _create(this); + } + else + { + _hasValue = false; + _continuation(); + } + + return !_stopped && _hasValue; + } + + public void Reset() + { + throw new NotSupportedException(); + } + } +} From 0bf919fd741df4f98936f46523789652974c9b20 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 20:59:08 -0700 Subject: [PATCH 112/862] Adding AsyncEnumerableEx. --- .../AsyncTests.Creation.cs | 2 +- .../System.Interactive.Async.Tests.csproj | 1 + .../AsyncEnumerable.cs | 5 - .../AsyncEnumerableEx.cs | 93 +++++++++++++++++++ .../System.Linq.Async.csproj | 4 + 5 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/AsyncEnumerableEx.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 4dbc2106a0..00eaddf8a7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -41,7 +41,7 @@ public void Return() [Fact] public async Task Never() { - var xs = AsyncEnumerable.Never(); + var xs = AsyncEnumerableEx.Never(); var e = xs.GetAsyncEnumerator(); Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index 0e2edc6ab7..29ff25901f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -15,6 +15,7 @@ + diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs index 63ffe1b63e..99887ddc78 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs @@ -22,11 +22,6 @@ public static IAsyncEnumerable Empty() return CreateEnumerable(() => CreateEnumerator(ct => TaskExt.False, current: null, dispose: null)); } - public static IAsyncEnumerable Never() - { - return CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); - } - public static IAsyncEnumerable Return(TValue value) { return new[] { value }.ToAsyncEnumerable(); diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableEx.cs b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableEx.cs new file mode 100644 index 0000000000..54a5e22db2 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableEx.cs @@ -0,0 +1,93 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; +using static System.Linq.AsyncEnumerable; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Never() + { + return CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); + } + + private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Func dispose) + { + var self = new AnonymousAsyncIterator( + async () => + { + var tcs = new TaskCompletionSource(); + + var stop = new Action(() => tcs.TrySetCanceled()); + + return await moveNext(tcs).ConfigureAwait(false); + }, + current, + dispose + ); + + return self; + } + + private sealed class AnonymousAsyncIterator : AsyncIterator + { + private readonly Func currentFunc; + private readonly Func dispose; + private readonly Func> moveNext; + + public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) + { + Debug.Assert(moveNext != null); + + this.moveNext = moveNext; + this.currentFunc = currentFunc; + this.dispose = dispose; + + // Explicit call to initialize enumerator mode + GetAsyncEnumerator(); + } + + public override AsyncIterator Clone() + { + throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator."); + } + + public override async Task DisposeAsync() + { + if (dispose != null) + { + await dispose().ConfigureAwait(false); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await moveNext().ConfigureAwait(false)) + { + current = currentFunc(); + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 7821837d87..7e7cb4a945 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -4,4 +4,8 @@ net46;netstandard1.4 + + + + From 63cecd31c3f8136dfa7a043e97f7ef4b04182031 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:03:46 -0700 Subject: [PATCH 113/862] Making AsyncIterator a top-level class. --- .../System.Interactive.Async/AsyncIterator.cs | 183 +++++++++--------- .../OrderedAsyncEnumerable.cs | 22 +-- 2 files changed, 101 insertions(+), 104 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index bdec262a64..0981243e9d 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -8,136 +8,133 @@ namespace System.Linq { - public static partial class AsyncEnumerable + internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator { - internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator + private readonly int threadId; + + private CancellationTokenSource cancellationTokenSource; + private bool currentIsInvalid = true; + + internal TSource current; + internal AsyncIteratorState state = AsyncIteratorState.New; + + protected AsyncIterator() { - private readonly int threadId; + threadId = Environment.CurrentManagedThreadId; + } - private CancellationTokenSource cancellationTokenSource; - private bool currentIsInvalid = true; + public IAsyncEnumerator GetAsyncEnumerator() + { + var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? + this : + Clone(); - internal TSource current; - internal AsyncIteratorState state = AsyncIteratorState.New; + enumerator.state = AsyncIteratorState.Allocated; + enumerator.cancellationTokenSource = new CancellationTokenSource(); - protected AsyncIterator() + try { - threadId = Environment.CurrentManagedThreadId; + enumerator.OnGetEnumerator(); } - - public IAsyncEnumerator GetAsyncEnumerator() + catch { - var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? - this : - Clone(); + enumerator.DisposeAsync(); // REVIEW: fire-and-forget? + throw; + } - enumerator.state = AsyncIteratorState.Allocated; - enumerator.cancellationTokenSource = new CancellationTokenSource(); + return enumerator; + } - try - { - enumerator.OnGetEnumerator(); - } - catch + public virtual Task DisposeAsync() + { + if (cancellationTokenSource != null) + { + if (!cancellationTokenSource.IsCancellationRequested) { - enumerator.DisposeAsync(); // REVIEW: fire-and-forget? - throw; + cancellationTokenSource.Cancel(); } - return enumerator; + cancellationTokenSource.Dispose(); } - public virtual Task DisposeAsync() - { - if (cancellationTokenSource != null) - { - if (!cancellationTokenSource.IsCancellationRequested) - { - cancellationTokenSource.Cancel(); - } + current = default(TSource); + state = AsyncIteratorState.Disposed; - cancellationTokenSource.Dispose(); - } + return TaskExt.CompletedTask; + } - current = default(TSource); - state = AsyncIteratorState.Disposed; + public TSource Current + { + get + { + if (currentIsInvalid) + throw new InvalidOperationException("Enumerator is in an invalid state"); - return TaskExt.CompletedTask; + return current; } + } - public TSource Current - { - get - { - if (currentIsInvalid) - throw new InvalidOperationException("Enumerator is in an invalid state"); + public async Task MoveNextAsync() + { + // Note: MoveNext *must* be implemented as an async method to ensure + // that any exceptions thrown from the MoveNextCore call are handled + // by the try/catch, whether they're sync or async - return current; - } + if (state == AsyncIteratorState.Disposed) + { + return false; } - public async Task MoveNextAsync() + try { - // Note: MoveNext *must* be implemented as an async method to ensure - // that any exceptions thrown from the MoveNextCore call are handled - // by the try/catch, whether they're sync or async - - if (state == AsyncIteratorState.Disposed) - { - return false; - } + var result = await MoveNextCore().ConfigureAwait(false); - try - { - var result = await MoveNextCore().ConfigureAwait(false); - - currentIsInvalid = !result; // if move next is false, invalid otherwise valid + currentIsInvalid = !result; // if move next is false, invalid otherwise valid - return result; - } - catch - { - currentIsInvalid = true; - await DisposeAsync().ConfigureAwait(false); - throw; - } + return result; } - - public abstract AsyncIterator Clone(); - - public virtual IAsyncEnumerable Select(Func selector) + catch { - return new SelectEnumerableAsyncIterator(this, selector); + currentIsInvalid = true; + await DisposeAsync().ConfigureAwait(false); + throw; } + } - public virtual IAsyncEnumerable Select(Func> selector) - { - return new SelectEnumerableAsyncIteratorWithTask(this, selector); - } + public abstract AsyncIterator Clone(); - public virtual IAsyncEnumerable Where(Func predicate) - { - return new WhereEnumerableAsyncIterator(this, predicate); - } + public virtual IAsyncEnumerable Select(Func selector) + { + return new AsyncEnumerable.SelectEnumerableAsyncIterator(this, selector); + } - public virtual IAsyncEnumerable Where(Func> predicate) - { - return new WhereEnumerableAsyncIteratorWithTask(this, predicate); - } + public virtual IAsyncEnumerable Select(Func> selector) + { + return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask(this, selector); + } - protected abstract Task MoveNextCore(); + public virtual IAsyncEnumerable Where(Func predicate) + { + return new AsyncEnumerable.WhereEnumerableAsyncIterator(this, predicate); + } - protected virtual void OnGetEnumerator() - { - } + public virtual IAsyncEnumerable Where(Func> predicate) + { + return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); } - internal enum AsyncIteratorState + protected abstract Task MoveNextCore(); + + protected virtual void OnGetEnumerator() { - New = 0, - Allocated = 1, - Iterating = 2, - Disposed = -1 } } + + internal enum AsyncIteratorState + { + New = 0, + Allocated = 1, + Iterating = 2, + Disposed = -1 + } } diff --git a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs index 1044f35833..5be08e8428 100644 --- a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs @@ -8,7 +8,7 @@ namespace System.Linq { - internal abstract class OrderedAsyncEnumerable : AsyncEnumerable.AsyncIterator, IOrderedAsyncEnumerable + internal abstract class OrderedAsyncEnumerable : AsyncIterator, IOrderedAsyncEnumerable { internal IOrderedEnumerable enumerable; internal IAsyncEnumerable source; @@ -49,7 +49,7 @@ public OrderedAsyncEnumerable(IAsyncEnumerable source, Func Clone() + public override AsyncIterator Clone() { return new OrderedAsyncEnumerable(source, keySelector, comparer, descending, parent); } @@ -75,15 +75,15 @@ protected override async Task MoveNextCore() { switch (state) { - case AsyncEnumerable.AsyncIteratorState.Allocated: + case AsyncIteratorState.Allocated: await Initialize().ConfigureAwait(false); enumerator = enumerable.GetEnumerator(); - state = AsyncEnumerable.AsyncIteratorState.Iterating; - goto case AsyncEnumerable.AsyncIteratorState.Iterating; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; - case AsyncEnumerable.AsyncIteratorState.Iterating: + case AsyncIteratorState.Iterating: if (enumerator.MoveNext()) { current = enumerator.Current; @@ -136,7 +136,7 @@ public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIterator Clone() { return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending, parent); } @@ -162,15 +162,15 @@ protected override async Task MoveNextCore() { switch (state) { - case AsyncEnumerable.AsyncIteratorState.Allocated: + case AsyncIteratorState.Allocated: await Initialize().ConfigureAwait(false); enumerator = enumerable.GetEnumerator(); - state = AsyncEnumerable.AsyncIteratorState.Iterating; - goto case AsyncEnumerable.AsyncIteratorState.Iterating; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; - case AsyncEnumerable.AsyncIteratorState.Iterating: + case AsyncIteratorState.Iterating: if (enumerator.MoveNext()) { current = enumerator.Current; From c0220bef2041b4e4b48d05cf91f916a5fba19054 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:05:40 -0700 Subject: [PATCH 114/862] Moving Never to a separate file. --- .../{ => System/Linq}/AsyncEnumerableEx.cs | 6 ------ .../System/Linq/Operators/Never.cs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq}/AsyncEnumerableEx.cs (92%) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableEx.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs similarity index 92% rename from Ix.NET/Source/System.Interactive.Async/AsyncEnumerableEx.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs index 54a5e22db2..5f037f2c79 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableEx.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs @@ -5,17 +5,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; -using static System.Linq.AsyncEnumerable; namespace System.Linq { public static partial class AsyncEnumerableEx { - public static IAsyncEnumerable Never() - { - return CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); - } - private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Func dispose) { var self = new AnonymousAsyncIterator( diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs new file mode 100644 index 0000000000..d4ea53c51f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using static System.Linq.AsyncEnumerable; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Never() + { + return CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); + } + } +} From 6749f556dc4e2551e1589e833e22c5786fca5f31 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:07:04 -0700 Subject: [PATCH 115/862] Moving Buffer to AsyncEnumerableEx. --- .../AsyncTests.Single.cs | 10 +++++----- .../{ => System/Linq/Operators}/Buffer.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Buffer.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 7ebdccb22b..f9eb9d891c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -2988,12 +2988,12 @@ public void StartWith3() [Fact] public void Buffer_Null() { - AssertThrows(() => AsyncEnumerable.Buffer(default(IAsyncEnumerable), 1)); - AssertThrows(() => AsyncEnumerable.Buffer(default(IAsyncEnumerable), 1, 1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1, 1)); - AssertThrows(() => AsyncEnumerable.Buffer(AsyncEnumerable.Return(42), -1)); - AssertThrows(() => AsyncEnumerable.Buffer(AsyncEnumerable.Return(42), -1, 1)); - AssertThrows(() => AsyncEnumerable.Buffer(AsyncEnumerable.Return(42), 1, -1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1, 1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), 1, -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Buffer.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 2fd3bdc841..20154f4c70 100644 --- a/Ix.NET/Source/System.Interactive.Async/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable> Buffer(this IAsyncEnumerable source, int count) { From 34ff9126d4d6e056113c69e5c3167fccd485e613 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:08:30 -0700 Subject: [PATCH 116/862] Moving Catch to AsyncEnumerableEx. --- .../AsyncTests.Exceptions.cs | 26 +++++++++---------- .../{ => System/Linq/Operators}/Catch.cs | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Catch.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index 82e477fd96..b9daa8a21d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -5,8 +5,8 @@ using System; using System.Collections.Generic; using System.Linq; -using Xunit; using System.Threading.Tasks; +using Xunit; namespace Tests { @@ -15,13 +15,13 @@ public partial class AsyncTests [Fact] public void Catch_Null() { - AssertThrows(() => AsyncEnumerable.Catch(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Catch(AsyncEnumerable.Return(42), default(Func>))); + AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(Func>))); - AssertThrows(() => AsyncEnumerable.Catch(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Catch(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Catch(default(IAsyncEnumerable[]))); - AssertThrows(() => AsyncEnumerable.Catch(default(IEnumerable>))); + AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerableEx.Catch(default(IEnumerable>))); } [Fact] @@ -169,7 +169,7 @@ public void Catch7() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.Catch(xs, ys); + var res = AsyncEnumerableEx.Catch(xs, ys); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -186,7 +186,7 @@ public void Catch8() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.Catch(xs, ys); + var res = AsyncEnumerableEx.Catch(xs, ys); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -206,7 +206,7 @@ public void Catch9() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.Catch(new[] { xs, xs, ys, ys }); + var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -247,7 +247,7 @@ public void Catch11() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var res = AsyncEnumerable.Catch(new[] { xs, xs }); + var res = AsyncEnumerableEx.Catch(new[] { xs, xs }); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -263,7 +263,7 @@ public void Catch11() [Fact] public void Catch12() { - var res = AsyncEnumerable.Catch(Enumerable.Empty>()); + var res = AsyncEnumerableEx.Catch(Enumerable.Empty>()); var e = res.GetAsyncEnumerator(); NoNext(e); @@ -277,7 +277,7 @@ public async Task Catch13() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.Catch(new[] { xs, xs, ys, ys }); + var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); await SequenceIdentity(res); } diff --git a/Ix.NET/Source/System.Interactive.Async/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Catch.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 92a3882425..a617fe0665 100644 --- a/Ix.NET/Source/System.Interactive.Async/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -9,7 +9,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func> handler) where TException : Exception From 303f855af647b963b2e39ec0b49eae4ebe365a22 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:10:20 -0700 Subject: [PATCH 117/862] Moving Defer to AsyncEnumerableEx. --- .../System.Interactive.Async.Tests/AsyncTests.Creation.cs | 4 ++-- .../{ => System/Linq/Operators}/Defer.cs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Defer.cs (91%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 00eaddf8a7..d7e5d45df8 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -177,14 +177,14 @@ public async Task Repeat4() [Fact] public void Defer_Null() { - AssertThrows(() => AsyncEnumerable.Defer(default(Func>))); + AssertThrows(() => AsyncEnumerableEx.Defer(default(Func>))); } [Fact] public void Defer1() { var x = 0; - var xs = AsyncEnumerable.Defer(() => new[] { x }.ToAsyncEnumerable()); + var xs = AsyncEnumerableEx.Defer(() => new[] { x }.ToAsyncEnumerable()); { var e = xs.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs similarity index 91% rename from Ix.NET/Source/System.Interactive.Async/Defer.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index ee44b2b721..b7d5b7667f 100644 --- a/Ix.NET/Source/System.Interactive.Async/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -4,10 +4,11 @@ using System.Collections.Generic; using System.Threading.Tasks; +using static System.Linq.AsyncEnumerable; namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Defer(Func> factory) { From efca86ebe7f5e50b5c29deace7c638eabeebebec Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:11:37 -0700 Subject: [PATCH 118/862] Moving IgnoreElements to AsyncEnumerableEx. --- .../Source/System.Interactive.Async.Tests/AsyncTests.Single.cs | 2 +- .../{ => System/Linq/Operators}/IgnoreElements.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/IgnoreElements.cs (97%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index f9eb9d891c..b5f790e992 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -2889,7 +2889,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() [Fact] public void IgnoreElements_Null() { - AssertThrows(() => AsyncEnumerable.IgnoreElements(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.IgnoreElements(default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs similarity index 97% rename from Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index c820d55c97..d862afd427 100644 --- a/Ix.NET/Source/System.Interactive.Async/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable IgnoreElements(this IAsyncEnumerable source) { From 27a6d083f447d4b2321059bfe518ac80265c5393 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:12:13 -0700 Subject: [PATCH 119/862] Rename Concat. --- .../Source/System.Interactive.Async/{Concatenate.cs => Concat.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{Concatenate.cs => Concat.cs} (100%) diff --git a/Ix.NET/Source/System.Interactive.Async/Concatenate.cs b/Ix.NET/Source/System.Interactive.Async/Concat.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Concatenate.cs rename to Ix.NET/Source/System.Interactive.Async/Concat.cs From 850e27d4873de31295d316b42950c80c09b3d46a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:14:37 -0700 Subject: [PATCH 120/862] Splitting Distinct and DistinctUntilChanged. --- .../System.Interactive.Async/Distinct.cs | 286 ----------------- .../DistinctUntilChanged.cs | 300 ++++++++++++++++++ 2 files changed, 300 insertions(+), 286 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/DistinctUntilChanged.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/Distinct.cs index 7f22a3b0d8..f84ec75e99 100644 --- a/Ix.NET/Source/System.Interactive.Async/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/Distinct.cs @@ -73,78 +73,6 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); } - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.DistinctUntilChanged(EqualityComparer.Default); - } - - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return new DistinctUntilChangedAsyncIterator(source, comparer); - } - - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); - } - - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.DistinctUntilChanged_(keySelector, comparer); - } - - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); - } - - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.DistinctUntilChanged_(keySelector, comparer); - } - - private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); - } - - private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); - } - private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider { private readonly IEqualityComparer comparer; @@ -547,219 +475,5 @@ private async Task> FillSetAsync(CancellationToken cancellationTok return r; } } - - private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator - { - private readonly IEqualityComparer comparer; - private readonly IAsyncEnumerable source; - - private TSource currentValue; - private IAsyncEnumerator enumerator; - private bool hasCurrentValue; - - public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, IEqualityComparer comparer) - { - Debug.Assert(comparer != null); - Debug.Assert(source != null); - - this.source = source; - this.comparer = comparer; - } - - public override AsyncIterator Clone() - { - return new DistinctUntilChangedAsyncIterator(source, comparer); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - currentValue = default(TSource); - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - var comparerEquals = false; - - if (hasCurrentValue) - { - comparerEquals = comparer.Equals(currentValue, item); - } - - if (!hasCurrentValue || !comparerEquals) - { - hasCurrentValue = true; - currentValue = item; - current = item; - return true; - } - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator - { - private readonly IEqualityComparer comparer; - private readonly Func keySelector; - private readonly IAsyncEnumerable source; - private TKey currentKeyValue; - - private IAsyncEnumerator enumerator; - private bool hasCurrentKey; - - public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - this.source = source; - this.keySelector = keySelector; - this.comparer = comparer; - } - - public override AsyncIterator Clone() - { - return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - currentKeyValue = default(TKey); - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - var key = keySelector(item); - var comparerEquals = false; - - if (hasCurrentKey) - { - comparerEquals = comparer.Equals(currentKeyValue, key); - } - if (!hasCurrentKey || !comparerEquals) - { - hasCurrentKey = true; - currentKeyValue = key; - current = item; - return true; - } - } - - break; // case - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class DistinctUntilChangedAsyncIteratorWithTask : AsyncIterator - { - private readonly IEqualityComparer comparer; - private readonly Func> keySelector; - private readonly IAsyncEnumerable source; - private TKey currentKeyValue; - - private IAsyncEnumerator enumerator; - private bool hasCurrentKey; - - public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - this.source = source; - this.keySelector = keySelector; - this.comparer = comparer; - } - - public override AsyncIterator Clone() - { - return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - currentKeyValue = default(TKey); - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - var key = await keySelector(item).ConfigureAwait(false); - var comparerEquals = false; - - if (hasCurrentKey) - { - comparerEquals = comparer.Equals(currentKeyValue, key); - } - if (!hasCurrentKey || !comparerEquals) - { - hasCurrentKey = true; - currentKeyValue = key; - current = item; - return true; - } - } - - break; // case - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/DistinctUntilChanged.cs new file mode 100644 index 0000000000..b914b5cadf --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/DistinctUntilChanged.cs @@ -0,0 +1,300 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.DistinctUntilChanged(EqualityComparer.Default); + } + + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new DistinctUntilChangedAsyncIterator(source, comparer); + } + + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.DistinctUntilChanged_(keySelector, comparer); + } + + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.DistinctUntilChanged_(keySelector, comparer); + } + + private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); + } + + private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); + } + + private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator + { + private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable source; + + private TSource currentValue; + private IAsyncEnumerator enumerator; + private bool hasCurrentValue; + + public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, IEqualityComparer comparer) + { + Debug.Assert(comparer != null); + Debug.Assert(source != null); + + this.source = source; + this.comparer = comparer; + } + + public override AsyncIterator Clone() + { + return new DistinctUntilChangedAsyncIterator(source, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + currentValue = default(TSource); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + var comparerEquals = false; + + if (hasCurrentValue) + { + comparerEquals = comparer.Equals(currentValue, item); + } + + if (!hasCurrentValue || !comparerEquals) + { + hasCurrentValue = true; + currentValue = item; + current = item; + return true; + } + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator + { + private readonly IEqualityComparer comparer; + private readonly Func keySelector; + private readonly IAsyncEnumerable source; + private TKey currentKeyValue; + + private IAsyncEnumerator enumerator; + private bool hasCurrentKey; + + public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + } + + public override AsyncIterator Clone() + { + return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + currentKeyValue = default(TKey); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + var key = keySelector(item); + var comparerEquals = false; + + if (hasCurrentKey) + { + comparerEquals = comparer.Equals(currentKeyValue, key); + } + if (!hasCurrentKey || !comparerEquals) + { + hasCurrentKey = true; + currentKeyValue = key; + current = item; + return true; + } + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class DistinctUntilChangedAsyncIteratorWithTask : AsyncIterator + { + private readonly IEqualityComparer comparer; + private readonly Func> keySelector; + private readonly IAsyncEnumerable source; + private TKey currentKeyValue; + + private IAsyncEnumerator enumerator; + private bool hasCurrentKey; + + public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + } + + public override AsyncIterator Clone() + { + return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + currentKeyValue = default(TKey); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + var key = await keySelector(item).ConfigureAwait(false); + var comparerEquals = false; + + if (hasCurrentKey) + { + comparerEquals = comparer.Equals(currentKeyValue, key); + } + if (!hasCurrentKey || !comparerEquals) + { + hasCurrentKey = true; + currentKeyValue = key; + current = item; + return true; + } + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} From 68fece04094be8a46621145c49fd5e638138d506 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:15:49 -0700 Subject: [PATCH 121/862] Moving DistinctUntilChanged to AsyncEnumerableEx. --- .../AsyncTests.Single.cs | 16 ++++++++-------- .../Linq/Operators}/DistinctUntilChanged.cs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/DistinctUntilChanged.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index b5f790e992..53dfce34fd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -3061,17 +3061,17 @@ public async Task Buffer4() [Fact] public void DistinctUntilChanged_Null() { - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(IEqualityComparer))); - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.DistinctUntilChanged(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/DistinctUntilChanged.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index b914b5cadf..aa8f017da8 100644 --- a/Ix.NET/Source/System.Interactive.Async/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -9,7 +9,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source) { From b160d5b2ab5c3e609c924ab5e4c16fd870fadfe7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:17:11 -0700 Subject: [PATCH 122/862] Moving Do to AsyncEnumerableEx. --- .../AsyncTests.Single.cs | 28 +++++++++---------- .../{ => System/Linq/Operators}/Do.cs | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Do.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 53dfce34fd..76b1943a87 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -572,24 +572,24 @@ public void Cast2() [Fact] public void Do_Null() { - AssertThrows(() => AsyncEnumerable.Do(null, x => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action))); - AssertThrows(() => AsyncEnumerable.Do(null, x => { }, () => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), default(Action), () => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); - AssertThrows(() => AsyncEnumerable.Do(null, x => { }, ex => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), default(Action), ex => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); - AssertThrows(() => AsyncEnumerable.Do(null, x => { }, ex => { }, () => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), default(Action), ex => { }, () => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), x => { }, default(Action), () => { })); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), x => { }, ex => { }, default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action), () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, ex => { }, default(Action))); - AssertThrows(() => AsyncEnumerable.Do(null, new MyObs())); - AssertThrows(() => AsyncEnumerable.Do(AsyncEnumerable.Return(42), default(IObserver))); + AssertThrows(() => AsyncEnumerableEx.Do(null, new MyObs())); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(IObserver))); } class MyObs : IObserver diff --git a/Ix.NET/Source/System.Interactive.Async/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Do.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index eefd8cb623..c69659e388 100644 --- a/Ix.NET/Source/System.Interactive.Async/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext) { From e7a23746364f7e54b426231c6137cce71f8baf82 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:17:44 -0700 Subject: [PATCH 123/862] Renaming some files in Ix. --- .../System/Linq/Operators/{Skip.cs => SkipLast.cs} | 0 .../System/Linq/Operators/{Take.cs => TakeLast.cs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Ix.NET/Source/System.Interactive/System/Linq/Operators/{Skip.cs => SkipLast.cs} (100%) rename Ix.NET/Source/System.Interactive/System/Linq/Operators/{Take.cs => TakeLast.cs} (100%) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/System/Linq/Operators/Skip.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/System/Linq/Operators/Take.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs From 03714aaaee93011fc7062703b174b359f96e0bab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:18:30 -0700 Subject: [PATCH 124/862] Splitting Distinct and DistinctUntilChanged. --- .../System/Linq/Operators/Distinct.cs | 95 ---------------- .../Linq/Operators/DistinctUntilChanged.cs | 106 ++++++++++++++++++ 2 files changed, 106 insertions(+), 95 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs index c0c3f49098..881b4d9702 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs @@ -58,100 +58,5 @@ private static IEnumerable Distinct_(this IEnumerable - /// Returns consecutive distinct elements by using the default equality comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Sequence without adjacent non-distinct elements. - public static IEnumerable DistinctUntilChanged(this IEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.DistinctUntilChanged_(x => x, EqualityComparer.Default); - } - - /// - /// Returns consecutive distinct elements by using the specified equality comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Comparer used to compare values. - /// Sequence without adjacent non-distinct elements. - public static IEnumerable DistinctUntilChanged(this IEnumerable source, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.DistinctUntilChanged_(x => x, comparer); - } - - /// - /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Sequence without adjacent non-distinct elements. - public static IEnumerable DistinctUntilChanged(this IEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); - } - - /// - /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Comparer used to compare key values. - /// Sequence without adjacent non-distinct elements. - public static IEnumerable DistinctUntilChanged(this IEnumerable source, Func keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.DistinctUntilChanged_(keySelector, comparer); - } - - private static IEnumerable DistinctUntilChanged_(this IEnumerable source, Func keySelector, IEqualityComparer comparer) - { - var currentKey = default(TKey); - var hasCurrentKey = false; - - foreach (var item in source) - { - var key = keySelector(item); - - var comparerEquals = false; - if (hasCurrentKey) - { - comparerEquals = comparer.Equals(currentKey, key); - } - - if (!hasCurrentKey || !comparerEquals) - { - hasCurrentKey = true; - currentKey = key; - yield return item; - } - } - } - } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs new file mode 100644 index 0000000000..0ebad8d138 --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs @@ -0,0 +1,106 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class EnumerableEx + { + /// + /// Returns consecutive distinct elements by using the default equality comparer to compare values. + /// + /// Source sequence element type. + /// Source sequence. + /// Sequence without adjacent non-distinct elements. + public static IEnumerable DistinctUntilChanged(this IEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.DistinctUntilChanged_(x => x, EqualityComparer.Default); + } + + /// + /// Returns consecutive distinct elements by using the specified equality comparer to compare values. + /// + /// Source sequence element type. + /// Source sequence. + /// Comparer used to compare values. + /// Sequence without adjacent non-distinct elements. + public static IEnumerable DistinctUntilChanged(this IEnumerable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.DistinctUntilChanged_(x => x, comparer); + } + + /// + /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector. + /// Sequence without adjacent non-distinct elements. + public static IEnumerable DistinctUntilChanged(this IEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); + } + + /// + /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector. + /// Comparer used to compare key values. + /// Sequence without adjacent non-distinct elements. + public static IEnumerable DistinctUntilChanged(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.DistinctUntilChanged_(keySelector, comparer); + } + + private static IEnumerable DistinctUntilChanged_(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + { + var currentKey = default(TKey); + var hasCurrentKey = false; + + foreach (var item in source) + { + var key = keySelector(item); + + var comparerEquals = false; + if (hasCurrentKey) + { + comparerEquals = comparer.Equals(currentKey, key); + } + + if (!hasCurrentKey || !comparerEquals) + { + hasCurrentKey = true; + currentKey = key; + yield return item; + } + } + } + + } +} From 5d8b71d85e7491c86cef03eda1c170b9d39e489e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:19:50 -0700 Subject: [PATCH 125/862] Moving Expand to AsyncEnumerableEx. --- .../System.Interactive.Async.Tests/AsyncTests.Single.cs | 4 ++-- .../{ => System/Linq/Operators}/Expand.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Expand.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 76b1943a87..bbf44590d8 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -3138,8 +3138,8 @@ public async Task DistinctUntilChanged5() [Fact] public void Expand_Null() { - AssertThrows(() => AsyncEnumerable.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Expand(AsyncEnumerable.Return(42), default(Func>))); + AssertThrows(() => AsyncEnumerableEx.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Expand(AsyncEnumerable.Return(42), default(Func>))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Expand.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 9b57ba3f79..5daa5d91cf 100644 --- a/Ix.NET/Source/System.Interactive.Async/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func> selector) { From 0953a1667591872d027ed34394c70793a97d0999 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:20:53 -0700 Subject: [PATCH 126/862] Moving Finally to AsyncEnumerableEx. --- .../System.Interactive.Async.Tests/AsyncTests.Exceptions.cs | 4 ++-- .../{ => System/Linq/Operators}/Finally.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Finally.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index b9daa8a21d..2e71d8daa4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -299,8 +299,8 @@ public async Task Catch14() [Fact] public void Finally_Null() { - AssertThrows(() => AsyncEnumerable.Finally(default(IAsyncEnumerable), () => { })); - AssertThrows(() => AsyncEnumerable.Finally(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerableEx.Finally(default(IAsyncEnumerable), () => { })); + AssertThrows(() => AsyncEnumerableEx.Finally(AsyncEnumerable.Return(42), null)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Finally.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index dad970388f..e9d60f308a 100644 --- a/Ix.NET/Source/System.Interactive.Async/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Finally(this IAsyncEnumerable source, Action finallyAction) { From 1a68655592f6a0db28bf7047f4367dc80a309b16 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:22:22 -0700 Subject: [PATCH 127/862] Moving Generate to AsyncEnumerableEx. --- .../AsyncTests.Creation.cs | 16 ++++++++-------- .../TaskExtTests.cs | 2 +- .../{ => System/Linq/Operators}/Generate.cs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Generate.cs (98%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index d7e5d45df8..22f6bd9706 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -203,15 +203,15 @@ public void Defer1() [Fact] public void Generate_Null() { - AssertThrows(() => AsyncEnumerable.Generate(0, null, x => x, x => x)); - AssertThrows(() => AsyncEnumerable.Generate(0, x => true, null, x => x)); - AssertThrows(() => AsyncEnumerable.Generate(0, x => true, x => x, null)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, null, x => x, x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, null, x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, null)); } [Fact] public async Task Generate1() { - var xs = AsyncEnumerable.Generate(0, x => x < 5, x => x + 1, x => x * x); + var xs = AsyncEnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x); var e = xs.GetAsyncEnumerator(); HasNext(e, 0); @@ -227,7 +227,7 @@ public async Task Generate1() public void Generate2() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Generate(0, x => { throw ex; }, x => x + 1, x => x * x); + var xs = AsyncEnumerableEx.Generate(0, x => { throw ex; }, x => x + 1, x => x * x); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); @@ -237,7 +237,7 @@ public void Generate2() public void Generate3() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Generate(0, x => true, x => x + 1, x => { if (x == 1) throw ex; return x * x; }); + var xs = AsyncEnumerableEx.Generate(0, x => true, x => x + 1, x => { if (x == 1) throw ex; return x * x; }); var e = xs.GetAsyncEnumerator(); HasNext(e, 0); @@ -248,7 +248,7 @@ public void Generate3() public void Generate4() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Generate(0, x => true, x => { throw ex; }, x => x * x); + var xs = AsyncEnumerableEx.Generate(0, x => true, x => { throw ex; }, x => x * x); var e = xs.GetAsyncEnumerator(); HasNext(e, 0); @@ -258,7 +258,7 @@ public void Generate4() [Fact] public async Task Generate5() { - var xs = AsyncEnumerable.Generate(0, x => x < 5, x => x + 1, x => x * x); + var xs = AsyncEnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x); await SequenceIdentity(xs); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs index d81e5447e9..3471192f15 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs @@ -39,7 +39,7 @@ public async Task ExceptionHandling_ShouldThrowUnwrappedException2() { try { - var asyncEnumerable = AsyncEnumerable.Generate(15, (x) => { throw new InvalidOperationException(); }, (x) => { return 20; }, (x) => { return 2; }); + var asyncEnumerable = AsyncEnumerableEx.Generate(15, (x) => { throw new InvalidOperationException(); }, (x) => { return 20; }, (x) => { return 2; }); await asyncEnumerable.ToArray(); } catch (AggregateException) diff --git a/Ix.NET/Source/System.Interactive.Async/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs similarity index 98% rename from Ix.NET/Source/System.Interactive.Async/Generate.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 50b22260de..08d907b8ad 100644 --- a/Ix.NET/Source/System.Interactive.Async/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Generate(TState initialState, Func condition, Func iterate, Func resultSelector) { From e72e59e0583780ee81d82b7464c1bb8bbcb9e72f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:23:33 -0700 Subject: [PATCH 128/862] Moving OnErrorResumeNext to AsyncEnumerableEx. --- .../AsyncTests.Exceptions.cs | 20 +++++++++---------- .../Linq/Operators}/OnErrorResumeNext.cs | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/OnErrorResumeNext.cs (98%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index 2e71d8daa4..d73a0e1780 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -405,10 +405,10 @@ public async Task Finally7() [Fact] public void OnErrorResumeNext_Null() { - AssertThrows(() => AsyncEnumerable.OnErrorResumeNext(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.OnErrorResumeNext(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.OnErrorResumeNext(default(IAsyncEnumerable[]))); - AssertThrows(() => AsyncEnumerable.OnErrorResumeNext(default(IEnumerable>))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IEnumerable>))); } [Fact] @@ -417,7 +417,7 @@ public void OnErrorResumeNext7() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.OnErrorResumeNext(xs, ys); + var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -437,7 +437,7 @@ public void OnErrorResumeNext8() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.OnErrorResumeNext(xs, ys); + var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -457,7 +457,7 @@ public void OnErrorResumeNext9() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.OnErrorResumeNext(new[] { xs, xs, ys, ys }); + var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs, ys, ys }); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -501,7 +501,7 @@ public void OnErrorResumeNext11() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var res = AsyncEnumerable.OnErrorResumeNext(new[] { xs, xs }); + var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs }); var e = res.GetAsyncEnumerator(); HasNext(e, 1); @@ -516,7 +516,7 @@ public void OnErrorResumeNext11() [Fact] public void OnErrorResumeNext12() { - var res = AsyncEnumerable.OnErrorResumeNext(Enumerable.Empty>()); + var res = AsyncEnumerableEx.OnErrorResumeNext(Enumerable.Empty>()); var e = res.GetAsyncEnumerator(); NoNext(e); @@ -528,7 +528,7 @@ public async Task OnErrorResumeNext13() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = AsyncEnumerable.OnErrorResumeNext(xs, ys); + var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); await SequenceIdentity(res); } diff --git a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs similarity index 98% rename from Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index 25da92868d..65720eab88 100644 --- a/Ix.NET/Source/System.Interactive.Async/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable OnErrorResumeNext(this IAsyncEnumerable first, IAsyncEnumerable second) { From 3db1e471d18d0db34d269d827f84d93f4b9acf15 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:25:58 -0700 Subject: [PATCH 129/862] Moving StartWith to AsyncEnumerableEx. --- .../System.Interactive.Async.Tests/AsyncTests.Single.cs | 4 ++-- .../{ => System/Linq/Operators}/StartWith.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/StartWith.cs (92%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index bbf44590d8..81a5710a11 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -2946,8 +2946,8 @@ public async Task IgnoreElements5() [Fact] public void StartWith_Null() { - AssertThrows(() => AsyncEnumerable.StartWith(default(IAsyncEnumerable), new[] { 1 })); - AssertThrows(() => AsyncEnumerable.StartWith(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerableEx.StartWith(default(IAsyncEnumerable), new[] { 1 })); + AssertThrows(() => AsyncEnumerableEx.StartWith(AsyncEnumerable.Return(42), null)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/StartWith.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs similarity index 92% rename from Ix.NET/Source/System.Interactive.Async/StartWith.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs index 68b9c9962f..3d34d559c5 100644 --- a/Ix.NET/Source/System.Interactive.Async/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs @@ -6,7 +6,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable StartWith(this IAsyncEnumerable source, params TSource[] values) { From d14c3ec3205e9f7b5b73bd5de179385abcc60e37 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:29:44 -0700 Subject: [PATCH 130/862] Moving Scan to AsyncEnumerableEx. --- .../System.Interactive.Async.Tests/AsyncTests.Single.cs | 8 ++++---- .../{ => System/Linq/Operators}/Scan.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Scan.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 81a5710a11..f482b86781 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -3190,11 +3190,11 @@ public async Task Expand4() [Fact] public void Scan_Null() { - AssertThrows(() => AsyncEnumerable.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Scan(AsyncEnumerable.Return(42), 3, default(Func))); + AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); + AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), 3, default(Func))); - AssertThrows(() => AsyncEnumerable.Scan(default(IAsyncEnumerable), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Scan(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), (x, y) => x + y)); + AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Scan.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index a4d2dbad56..47b55adade 100644 --- a/Ix.NET/Source/System.Interactive.Async/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func accumulator) { From 155c2d261501ee4488d50b4aab53445c01727de5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:34:36 -0700 Subject: [PATCH 131/862] Splitting Skip and Take operators. --- .../Source/System.Interactive.Async/Skip.cs | 446 ------------------ .../System.Interactive.Async/SkipLast.cs | 101 ++++ .../System.Interactive.Async/SkipWhile.cs | 371 +++++++++++++++ .../Source/System.Interactive.Async/Take.cs | 414 ---------------- .../System.Interactive.Async/TakeLast.cs | 119 +++++ .../System.Interactive.Async/TakeWhile.cs | 321 +++++++++++++ 6 files changed, 912 insertions(+), 860 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/SkipLast.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/SkipWhile.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/TakeLast.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/TakeWhile.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Skip.cs b/Ix.NET/Source/System.Interactive.Async/Skip.cs index 612952aef1..580d71c3a6 100644 --- a/Ix.NET/Source/System.Interactive.Async/Skip.cs +++ b/Ix.NET/Source/System.Interactive.Async/Skip.cs @@ -30,66 +30,6 @@ public static IAsyncEnumerable Skip(this IAsyncEnumerable(source, count); } - public static IAsyncEnumerable SkipLast(this IAsyncEnumerable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - if (count <= 0) - { - // Return source if not actually skipping, but only if it's a type from here, to avoid - // issues if collections are used as keys or otherwise must not be aliased. - if (source is AsyncIterator) - { - return source; - } - - count = 0; - } - - return new SkipLastAsyncIterator(source, count); - } - - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new SkipWhileAsyncIterator(source, predicate); - } - - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new SkipWhileWithIndexAsyncIterator(source, predicate); - } - - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new SkipWhileAsyncIteratorWithTask(source, predicate); - } - - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); - } - private sealed class SkipAsyncIterator : AsyncIterator { private readonly int count; @@ -158,391 +98,5 @@ protected override async Task MoveNextCore() return false; } } - - private sealed class SkipLastAsyncIterator : AsyncIterator - { - private readonly int count; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - private Queue queue; - - public SkipLastAsyncIterator(IAsyncEnumerable source, int count) - { - Debug.Assert(source != null); - - this.source = source; - this.count = count; - } - - public override AsyncIterator Clone() - { - return new SkipLastAsyncIterator(source, count); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - queue = null; // release the memory - - await base.DisposeAsync().ConfigureAwait(false); - } - - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - queue = new Queue(); - - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - - case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - queue.Enqueue(item); - - if (queue.Count > count) - { - current = queue.Dequeue(); - return true; - } - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class SkipWhileAsyncIterator : AsyncIterator - { - private readonly Func predicate; - private readonly IAsyncEnumerable source; - - private bool doMoveNext; - private IAsyncEnumerator enumerator; - - public SkipWhileAsyncIterator(IAsyncEnumerable source, Func predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new SkipWhileAsyncIterator(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var element = enumerator.Current; - if (!predicate(element)) - { - doMoveNext = false; - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - } - } - - break; - - case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = enumerator.Current; - return true; - } - - if (!doMoveNext) - { - current = enumerator.Current; - doMoveNext = true; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class SkipWhileWithIndexAsyncIterator : AsyncIterator - { - private readonly Func predicate; - private readonly IAsyncEnumerable source; - - private bool doMoveNext; - private IAsyncEnumerator enumerator; - private int index; - - public SkipWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new SkipWhileWithIndexAsyncIterator(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - index = -1; - - // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - index++; - } - - var element = enumerator.Current; - if (!predicate(element, index)) - { - doMoveNext = false; - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - } - } - - break; - - case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = enumerator.Current; - return true; - } - - if (!doMoveNext) - { - current = enumerator.Current; - doMoveNext = true; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class SkipWhileAsyncIteratorWithTask : AsyncIterator - { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; - - private bool doMoveNext; - private IAsyncEnumerator enumerator; - - public SkipWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new SkipWhileAsyncIteratorWithTask(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var element = enumerator.Current; - if (!await predicate(element).ConfigureAwait(false)) - { - doMoveNext = false; - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - } - } - - break; - - case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = enumerator.Current; - return true; - } - - if (!doMoveNext) - { - current = enumerator.Current; - doMoveNext = true; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class SkipWhileWithIndexAsyncIteratorWithTask : AsyncIterator - { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; - - private bool doMoveNext; - private IAsyncEnumerator enumerator; - private int index; - - public SkipWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - index = -1; - - // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - index++; - } - - var element = enumerator.Current; - if (!await predicate(element, index).ConfigureAwait(false)) - { - doMoveNext = false; - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - } - } - - break; - - case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = enumerator.Current; - return true; - } - - if (!doMoveNext) - { - current = enumerator.Current; - doMoveNext = true; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/SkipLast.cs b/Ix.NET/Source/System.Interactive.Async/SkipLast.cs new file mode 100644 index 0000000000..46fbbc304f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/SkipLast.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable SkipLast(this IAsyncEnumerable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + if (count <= 0) + { + // Return source if not actually skipping, but only if it's a type from here, to avoid + // issues if collections are used as keys or otherwise must not be aliased. + if (source is AsyncIterator) + { + return source; + } + + count = 0; + } + + return new SkipLastAsyncIterator(source, count); + } + + private sealed class SkipLastAsyncIterator : AsyncIterator + { + private readonly int count; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private Queue queue; + + public SkipLastAsyncIterator(IAsyncEnumerable source, int count) + { + Debug.Assert(source != null); + + this.source = source; + this.count = count; + } + + public override AsyncIterator Clone() + { + return new SkipLastAsyncIterator(source, count); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + queue = null; // release the memory + + await base.DisposeAsync().ConfigureAwait(false); + } + + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + queue = new Queue(); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + queue.Enqueue(item); + + if (queue.Count > count) + { + current = queue.Dequeue(); + return true; + } + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/SkipWhile.cs b/Ix.NET/Source/System.Interactive.Async/SkipWhile.cs new file mode 100644 index 0000000000..81ebae134c --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/SkipWhile.cs @@ -0,0 +1,371 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new SkipWhileAsyncIterator(source, predicate); + } + + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new SkipWhileWithIndexAsyncIterator(source, predicate); + } + + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new SkipWhileAsyncIteratorWithTask(source, predicate); + } + + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + + private sealed class SkipWhileAsyncIterator : AsyncIterator + { + private readonly Func predicate; + private readonly IAsyncEnumerable source; + + private bool doMoveNext; + private IAsyncEnumerator enumerator; + + public SkipWhileAsyncIterator(IAsyncEnumerable source, Func predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new SkipWhileAsyncIterator(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + // skip elements as requested + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var element = enumerator.Current; + if (!predicate(element)) + { + doMoveNext = false; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + + break; + + case AsyncIteratorState.Iterating: + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + if (!doMoveNext) + { + current = enumerator.Current; + doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class SkipWhileWithIndexAsyncIterator : AsyncIterator + { + private readonly Func predicate; + private readonly IAsyncEnumerable source; + + private bool doMoveNext; + private IAsyncEnumerator enumerator; + private int index; + + public SkipWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new SkipWhileWithIndexAsyncIterator(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + + // skip elements as requested + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + index++; + } + + var element = enumerator.Current; + if (!predicate(element, index)) + { + doMoveNext = false; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + + break; + + case AsyncIteratorState.Iterating: + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + if (!doMoveNext) + { + current = enumerator.Current; + doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class SkipWhileAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private bool doMoveNext; + private IAsyncEnumerator enumerator; + + public SkipWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new SkipWhileAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + // skip elements as requested + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var element = enumerator.Current; + if (!await predicate(element).ConfigureAwait(false)) + { + doMoveNext = false; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + + break; + + case AsyncIteratorState.Iterating: + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + if (!doMoveNext) + { + current = enumerator.Current; + doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class SkipWhileWithIndexAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private bool doMoveNext; + private IAsyncEnumerator enumerator; + private int index; + + public SkipWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + + // skip elements as requested + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + index++; + } + + var element = enumerator.Current; + if (!await predicate(element, index).ConfigureAwait(false)) + { + doMoveNext = false; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + + break; + + case AsyncIteratorState.Iterating: + if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + if (!doMoveNext) + { + current = enumerator.Current; + doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Interactive.Async/Take.cs index deb2b0684e..8e53616500 100644 --- a/Ix.NET/Source/System.Interactive.Async/Take.cs +++ b/Ix.NET/Source/System.Interactive.Async/Take.cs @@ -23,59 +23,6 @@ public static IAsyncEnumerable Take(this IAsyncEnumerable(source, count); } - public static IAsyncEnumerable TakeLast(this IAsyncEnumerable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - if (count <= 0) - { - return Empty(); - } - - return new TakeLastAsyncIterator(source, count); - } - - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new TakeWhileAsyncIterator(source, predicate); - } - - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new TakeWhileWithIndexAsyncIterator(source, predicate); - } - - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new TakeWhileAsyncIteratorWithTask(source, predicate); - } - - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); - } - private sealed class TakeAsyncIterator : AsyncIterator { private readonly int count; @@ -135,366 +82,5 @@ protected override async Task MoveNextCore() return false; } } - - private sealed class TakeLastAsyncIterator : AsyncIterator - { - private readonly int count; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - private bool isDone; - private Queue queue; - - public TakeLastAsyncIterator(IAsyncEnumerable source, int count) - { - Debug.Assert(source != null); - - this.source = source; - this.count = count; - } - - public override AsyncIterator Clone() - { - return new TakeLastAsyncIterator(source, count); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - queue = null; // release the memory - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - queue = new Queue(); - isDone = false; - - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - - case AsyncIteratorState.Iterating: - while (true) - { - if (!isDone) - { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - if (count > 0) - { - var item = enumerator.Current; - if (queue.Count >= count) - { - queue.Dequeue(); - } - queue.Enqueue(item); - } - } - else - { - isDone = true; - // Dispose early here as we can - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - continue; // loop until queue is drained - } - - if (queue.Count > 0) - { - current = queue.Dequeue(); - return true; - } - - break; // while - } - - break; // case - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class TakeWhileAsyncIterator : AsyncIterator - { - private readonly Func predicate; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - - public TakeWhileAsyncIterator(IAsyncEnumerable source, Func predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new TakeWhileAsyncIterator(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - - case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - if (!predicate(item)) - { - break; - } - - current = item; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class TakeWhileWithIndexAsyncIterator : AsyncIterator - { - private readonly Func predicate; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - private int index; - - public TakeWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new TakeWhileWithIndexAsyncIterator(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - index = -1; - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - - case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - checked - { - index++; - } - - if (!predicate(item, index)) - { - break; - } - - current = item; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class TakeWhileAsyncIteratorWithTask : AsyncIterator - { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - - public TakeWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new TakeWhileAsyncIteratorWithTask(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - - case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - if (!await predicate(item).ConfigureAwait(false)) - { - break; - } - - current = item; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - private sealed class TakeWhileWithIndexAsyncIteratorWithTask : AsyncIterator - { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - private int index; - - public TakeWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) - { - Debug.Assert(predicate != null); - Debug.Assert(source != null); - - this.source = source; - this.predicate = predicate; - } - - public override AsyncIterator Clone() - { - return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - index = -1; - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - - case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - var item = enumerator.Current; - checked - { - index++; - } - - if (!await predicate(item, index).ConfigureAwait(false)) - { - break; - } - - current = item; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/TakeLast.cs b/Ix.NET/Source/System.Interactive.Async/TakeLast.cs new file mode 100644 index 0000000000..d32713349c --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/TakeLast.cs @@ -0,0 +1,119 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable TakeLast(this IAsyncEnumerable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + if (count <= 0) + { + return Empty(); + } + + return new TakeLastAsyncIterator(source, count); + } + + private sealed class TakeLastAsyncIterator : AsyncIterator + { + private readonly int count; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private bool isDone; + private Queue queue; + + public TakeLastAsyncIterator(IAsyncEnumerable source, int count) + { + Debug.Assert(source != null); + + this.source = source; + this.count = count; + } + + public override AsyncIterator Clone() + { + return new TakeLastAsyncIterator(source, count); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + queue = null; // release the memory + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + queue = new Queue(); + isDone = false; + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + while (true) + { + if (!isDone) + { + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (count > 0) + { + var item = enumerator.Current; + if (queue.Count >= count) + { + queue.Dequeue(); + } + queue.Enqueue(item); + } + } + else + { + isDone = true; + // Dispose early here as we can + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + continue; // loop until queue is drained + } + + if (queue.Count > 0) + { + current = queue.Dequeue(); + return true; + } + + break; // while + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/TakeWhile.cs b/Ix.NET/Source/System.Interactive.Async/TakeWhile.cs new file mode 100644 index 0000000000..510f64d78f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/TakeWhile.cs @@ -0,0 +1,321 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new TakeWhileAsyncIterator(source, predicate); + } + + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new TakeWhileWithIndexAsyncIterator(source, predicate); + } + + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new TakeWhileAsyncIteratorWithTask(source, predicate); + } + + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + + private sealed class TakeWhileAsyncIterator : AsyncIterator + { + private readonly Func predicate; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + + public TakeWhileAsyncIterator(IAsyncEnumerable source, Func predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new TakeWhileAsyncIterator(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + if (!predicate(item)) + { + break; + } + + current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class TakeWhileWithIndexAsyncIterator : AsyncIterator + { + private readonly Func predicate; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private int index; + + public TakeWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new TakeWhileWithIndexAsyncIterator(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + checked + { + index++; + } + + if (!predicate(item, index)) + { + break; + } + + current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class TakeWhileAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + + public TakeWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new TakeWhileAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + if (!await predicate(item).ConfigureAwait(false)) + { + break; + } + + current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + private sealed class TakeWhileWithIndexAsyncIteratorWithTask : AsyncIterator + { + private readonly Func> predicate; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private int index; + + public TakeWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + this.source = source; + this.predicate = predicate; + } + + public override AsyncIterator Clone() + { + return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + index = -1; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = enumerator.Current; + checked + { + index++; + } + + if (!await predicate(item, index).ConfigureAwait(false)) + { + break; + } + + current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} From 0fafaaaefa65dfc4250ff040c2facd31c6edeb25 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:37:37 -0700 Subject: [PATCH 132/862] Moving Using to AsyncEnumerableEx. --- .../AsyncTests.Creation.cs | 16 ++++++++-------- .../{ => System/Linq/Operators}/Using.cs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Using.cs (99%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 22f6bd9706..f0abbd4686 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -266,8 +266,8 @@ public async Task Generate5() [Fact] public void Using_Null() { - AssertThrows(() => AsyncEnumerable.Using(null, _ => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Using(() => new MyD(null), default(Func>))); + AssertThrows(() => AsyncEnumerableEx.Using(null, _ => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Using(() => new MyD(null), default(Func>))); } [Fact] @@ -276,7 +276,7 @@ public void Using1() var i = 0; var d = 0; - var xs = AsyncEnumerable.Using( + var xs = AsyncEnumerableEx.Using( () => { i++; @@ -297,7 +297,7 @@ public async Task Using2() var i = 0; var d = 0; - var xs = AsyncEnumerable.Using( + var xs = AsyncEnumerableEx.Using( () => { i++; @@ -322,7 +322,7 @@ public void Using3() var i = 0; var d = 0; - var xs = AsyncEnumerable.Using( + var xs = AsyncEnumerableEx.Using( () => { i++; @@ -344,7 +344,7 @@ public void Using4() var i = 0; var disposed = new TaskCompletionSource(); - var xs = AsyncEnumerable.Using( + var xs = AsyncEnumerableEx.Using( () => { i++; @@ -371,7 +371,7 @@ public void Using5() var i = 0; var disposed = new TaskCompletionSource(); - var xs = AsyncEnumerable.Using( + var xs = AsyncEnumerableEx.Using( () => { i++; @@ -396,7 +396,7 @@ public async Task Using7() var i = 0; var d = 0; - var xs = AsyncEnumerable.Using( + var xs = AsyncEnumerableEx.Using( () => { i++; diff --git a/Ix.NET/Source/System.Interactive.Async/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Using.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index dce0c6da56..afed1c0462 100644 --- a/Ix.NET/Source/System.Interactive.Async/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Using(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable { From 1a7192b6408968e293da50a19b3165570f262abb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 21:59:31 -0700 Subject: [PATCH 133/862] Moving Standard Query Operators to System.Linq.Async. --- .../AsyncTests.Exceptions.cs | 6 +- .../System.Interactive.Async/AsyncIterator.cs | 20 --- .../System.Interactive.Async.csproj | 51 ------- .../{ => System/Linq/Operators}/Retry.cs | 2 +- .../System.Linq.Async.csproj | 35 ++++- .../ExcludeFromCodeCoverageAttribute.cs | 0 .../System/Linq}/AsyncEnumerable.cs | 0 .../System/Linq}/AsyncEnumerableHelpers.cs | 0 .../System/Linq}/AsyncEnumerator.cs | 0 .../System/Linq/AsyncIterator.cs | 140 ++++++++++++++++++ .../System/Linq}/Disposables.cs | 0 .../System/Linq/EmptyArray.cs | 15 ++ .../System/Linq}/IIListProvider.cs | 0 .../System/Linq/Operators}/Aggregate.cs | 0 .../System/Linq/Operators}/All.cs | 0 .../System/Linq/Operators}/Any.cs | 0 .../System/Linq/Operators}/AppendPrepend.cs | 0 .../Linq/Operators}/Average.Generated.cs | 0 .../Linq/Operators}/Average.Generated.tt | 0 .../System/Linq/Operators}/Average.cs | 0 .../System/Linq/Operators}/Cast.cs | 0 .../System/Linq/Operators}/Concat.cs | 0 .../System/Linq/Operators}/Contains.cs | 0 .../System/Linq/Operators}/Count.cs | 0 .../System/Linq/Operators}/Create.cs | 0 .../System/Linq/Operators}/DefaultIfEmpty.cs | 0 .../System/Linq/Operators}/Distinct.cs | 0 .../System/Linq/Operators}/ElementAt.cs | 0 .../System/Linq/Operators}/Except.cs | 0 .../System/Linq/Operators}/First.cs | 0 .../System/Linq/Operators}/ForEach.cs | 0 .../System/Linq/Operators}/GroupBy.cs | 0 .../System/Linq/Operators}/GroupJoin.cs | 0 .../System/Linq/Operators}/Grouping.cs | 0 .../System/Linq/Operators}/Intersect.cs | 0 .../System/Linq/Operators}/IsEmpty.cs | 0 .../System/Linq/Operators}/Join.cs | 0 .../System/Linq/Operators}/Last.cs | 0 .../System/Linq/Operators}/Max.cs | 0 .../System/Linq/Operators}/MaxBy.cs | 0 .../System/Linq/Operators}/Min.cs | 0 .../System/Linq/Operators}/MinBy.cs | 0 .../Linq/Operators}/MinMax.Generated.cs | 0 .../Linq/Operators}/MinMax.Generated.tt | 0 .../System/Linq/Operators}/OrderBy.cs | 0 .../Linq/Operators}/OrderedAsyncEnumerable.cs | 0 .../System/Linq/Operators}/Range.cs | 0 .../System/Linq/Operators}/Repeat.cs | 0 .../System/Linq/Operators}/Reverse.cs | 0 .../System/Linq/Operators}/Select.cs | 2 +- .../System/Linq/Operators}/SelectMany.cs | 0 .../System/Linq/Operators}/SequenceEqual.cs | 0 .../System/Linq/Operators}/Single.cs | 0 .../System/Linq/Operators}/Skip.cs | 0 .../System/Linq/Operators}/SkipLast.cs | 0 .../System/Linq/Operators}/SkipWhile.cs | 0 .../System/Linq/Operators}/Sum.Generated.cs | 0 .../System/Linq/Operators}/Sum.Generated.tt | 0 .../System/Linq/Operators}/Take.cs | 0 .../System/Linq/Operators}/TakeLast.cs | 0 .../System/Linq/Operators}/TakeWhile.cs | 0 .../System/Linq/Operators}/ToArray.cs | 0 .../Linq/Operators}/ToAsyncEnumerable.cs | 0 .../System/Linq/Operators}/ToDictionary.cs | 0 .../System/Linq/Operators}/ToList.cs | 0 .../System/Linq/Operators}/ToLookup.cs | 0 .../System/Linq/Operators}/ToObservable.cs | 0 .../System/Linq/Operators}/Union.cs | 0 .../System/Linq/Operators}/Where.cs | 0 .../System/Linq/Operators}/Zip.cs | 0 .../System/Linq}/Set.cs | 0 .../System/Linq}/Strings.cs | 0 .../System/Threading/Tasks/TaskExt.cs | 13 ++ 73 files changed, 207 insertions(+), 77 deletions(-) rename Ix.NET/Source/System.Interactive.Async/{ => System/Linq/Operators}/Retry.cs (96%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Diagnostics/CodeAnalysis}/ExcludeFromCodeCoverageAttribute.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/AsyncEnumerable.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/AsyncEnumerableHelpers.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/AsyncEnumerator.cs (100%) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/Disposables.cs (100%) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/EmptyArray.cs rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/IIListProvider.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Aggregate.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/All.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Any.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/AppendPrepend.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Average.Generated.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Average.Generated.tt (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Average.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Cast.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Concat.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Contains.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Count.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Create.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/DefaultIfEmpty.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Distinct.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ElementAt.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Except.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/First.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ForEach.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/GroupBy.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/GroupJoin.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Grouping.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Intersect.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/IsEmpty.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Join.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Last.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Max.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/MaxBy.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Min.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/MinBy.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/MinMax.Generated.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/MinMax.Generated.tt (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/OrderBy.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/OrderedAsyncEnumerable.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Range.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Repeat.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Reverse.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Select.cs (99%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/SelectMany.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/SequenceEqual.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Single.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Skip.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/SkipLast.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/SkipWhile.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Sum.Generated.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Sum.Generated.tt (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Take.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/TakeLast.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/TakeWhile.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ToArray.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ToAsyncEnumerable.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ToDictionary.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ToList.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ToLookup.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/ToObservable.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Union.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Where.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq/Operators}/Zip.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/Set.cs (100%) rename Ix.NET/Source/{System.Interactive.Async => System.Linq.Async/System/Linq}/Strings.cs (100%) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index d73a0e1780..298781cc81 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -536,10 +536,10 @@ public async Task OnErrorResumeNext13() [Fact] public void Retry_Null() { - AssertThrows(() => AsyncEnumerable.Retry(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Retry(default(IAsyncEnumerable), 1)); - AssertThrows(() => AsyncEnumerable.Retry(AsyncEnumerable.Return(42), -1)); + AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable), 1)); + AssertThrows(() => AsyncEnumerableEx.Retry(AsyncEnumerable.Return(42), -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 0981243e9d..2edde69963 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -103,26 +103,6 @@ public async Task MoveNextAsync() public abstract AsyncIterator Clone(); - public virtual IAsyncEnumerable Select(Func selector) - { - return new AsyncEnumerable.SelectEnumerableAsyncIterator(this, selector); - } - - public virtual IAsyncEnumerable Select(Func> selector) - { - return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask(this, selector); - } - - public virtual IAsyncEnumerable Where(Func predicate) - { - return new AsyncEnumerable.WhereEnumerableAsyncIterator(this, predicate); - } - - public virtual IAsyncEnumerable Where(Func> predicate) - { - return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); - } - protected abstract Task MoveNextCore(); protected virtual void OnGetEnumerator() diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 3340e8c0f9..19b580352d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -11,63 +11,12 @@ - - - True - True - Average.Generated.tt - - - True - True - MinMax.Generated.tt - - - True - True - Sum.Generated.tt - - - - - - TextTemplatingFileGenerator - Average.Generated.cs - - - TextTemplatingFileGenerator - MinMax.Generated.cs - - - TextTemplatingFileGenerator - Sum.Generated.cs - - - - - - True - True - Average.Generated.tt - - - True - True - MinMax.Generated.tt - - - True - True - Sum.Generated.tt - - - diff --git a/Ix.NET/Source/System.Interactive.Async/Retry.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs similarity index 96% rename from Ix.NET/Source/System.Interactive.Async/Retry.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs index 1aece27186..e1029ce693 100644 --- a/Ix.NET/Source/System.Interactive.Async/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs @@ -6,7 +6,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Retry(this IAsyncEnumerable source) { diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 7e7cb4a945..2851661d8a 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -5,7 +5,40 @@ - + + Average.Generated.tt + True + True + + + MinMax.Generated.tt + True + True + + + Sum.Generated.tt + True + True + + + + + + Average.Generated.cs + TextTemplatingFileGenerator + + + MinMax.Generated.cs + TextTemplatingFileGenerator + + + Sum.Generated.cs + TextTemplatingFileGenerator + + + + + diff --git a/Ix.NET/Source/System.Interactive.Async/ExcludeFromCodeCoverageAttribute.cs b/Ix.NET/Source/System.Linq.Async/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ExcludeFromCodeCoverageAttribute.cs rename to Ix.NET/Source/System.Linq.Async/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/AsyncEnumerableHelpers.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/AsyncEnumerator.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs new file mode 100644 index 0000000000..0981243e9d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -0,0 +1,140 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator + { + private readonly int threadId; + + private CancellationTokenSource cancellationTokenSource; + private bool currentIsInvalid = true; + + internal TSource current; + internal AsyncIteratorState state = AsyncIteratorState.New; + + protected AsyncIterator() + { + threadId = Environment.CurrentManagedThreadId; + } + + public IAsyncEnumerator GetAsyncEnumerator() + { + var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? + this : + Clone(); + + enumerator.state = AsyncIteratorState.Allocated; + enumerator.cancellationTokenSource = new CancellationTokenSource(); + + try + { + enumerator.OnGetEnumerator(); + } + catch + { + enumerator.DisposeAsync(); // REVIEW: fire-and-forget? + throw; + } + + return enumerator; + } + + public virtual Task DisposeAsync() + { + if (cancellationTokenSource != null) + { + if (!cancellationTokenSource.IsCancellationRequested) + { + cancellationTokenSource.Cancel(); + } + + cancellationTokenSource.Dispose(); + } + + current = default(TSource); + state = AsyncIteratorState.Disposed; + + return TaskExt.CompletedTask; + } + + public TSource Current + { + get + { + if (currentIsInvalid) + throw new InvalidOperationException("Enumerator is in an invalid state"); + + return current; + } + } + + public async Task MoveNextAsync() + { + // Note: MoveNext *must* be implemented as an async method to ensure + // that any exceptions thrown from the MoveNextCore call are handled + // by the try/catch, whether they're sync or async + + if (state == AsyncIteratorState.Disposed) + { + return false; + } + + try + { + var result = await MoveNextCore().ConfigureAwait(false); + + currentIsInvalid = !result; // if move next is false, invalid otherwise valid + + return result; + } + catch + { + currentIsInvalid = true; + await DisposeAsync().ConfigureAwait(false); + throw; + } + } + + public abstract AsyncIterator Clone(); + + public virtual IAsyncEnumerable Select(Func selector) + { + return new AsyncEnumerable.SelectEnumerableAsyncIterator(this, selector); + } + + public virtual IAsyncEnumerable Select(Func> selector) + { + return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask(this, selector); + } + + public virtual IAsyncEnumerable Where(Func predicate) + { + return new AsyncEnumerable.WhereEnumerableAsyncIterator(this, predicate); + } + + public virtual IAsyncEnumerable Where(Func> predicate) + { + return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); + } + + protected abstract Task MoveNextCore(); + + protected virtual void OnGetEnumerator() + { + } + } + + internal enum AsyncIteratorState + { + New = 0, + Allocated = 1, + Iterating = 2, + Disposed = -1 + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/Disposables.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Disposables.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/EmptyArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/EmptyArray.cs new file mode 100644 index 0000000000..c529a98b06 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/EmptyArray.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +#if NO_ARRAY_EMPTY + +namespace System.Linq +{ + internal sealed class EmptyArray + { + public static readonly TElement[] Value = new TElement[0]; + } +} + +#endif diff --git a/Ix.NET/Source/System.Interactive.Async/IIListProvider.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/IIListProvider.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Aggregate.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs diff --git a/Ix.NET/Source/System.Interactive.Async/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/All.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Any.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/AppendPrepend.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Average.Generated.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Average.Generated.tt rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Average.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Cast.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Concat.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Contains.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Count.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Create.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs diff --git a/Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/DefaultIfEmpty.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Distinct.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ElementAt.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Except.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs diff --git a/Ix.NET/Source/System.Interactive.Async/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/First.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ForEach.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs diff --git a/Ix.NET/Source/System.Interactive.Async/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/GroupBy.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/GroupJoin.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Grouping.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Grouping.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Intersect.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs diff --git a/Ix.NET/Source/System.Interactive.Async/IsEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/IsEmpty.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/IsEmpty.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/IsEmpty.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Join.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Last.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Max.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs diff --git a/Ix.NET/Source/System.Interactive.Async/MaxBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/MaxBy.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Min.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs diff --git a/Ix.NET/Source/System.Interactive.Async/MinBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/MinBy.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/MinMax.Generated.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs diff --git a/Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/MinMax.Generated.tt rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/OrderBy.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/OrderedAsyncEnumerable.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Range.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Repeat.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Reverse.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs similarity index 99% rename from Ix.NET/Source/System.Interactive.Async/Select.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 64c7976514..5f256376af 100644 --- a/Ix.NET/Source/System.Interactive.Async/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -444,4 +444,4 @@ protected override async Task MoveNextCore() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/SelectMany.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs diff --git a/Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/SequenceEqual.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Single.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Skip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Skip.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs diff --git a/Ix.NET/Source/System.Interactive.Async/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/SkipLast.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs diff --git a/Ix.NET/Source/System.Interactive.Async/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/SkipWhile.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Sum.Generated.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Sum.Generated.tt rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async/Take.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Take.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs diff --git a/Ix.NET/Source/System.Interactive.Async/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/TakeLast.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs diff --git a/Ix.NET/Source/System.Interactive.Async/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/TakeWhile.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ToArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ToArray.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ToAsyncEnumerable.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ToDictionary.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ToList.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ToLookup.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs diff --git a/Ix.NET/Source/System.Interactive.Async/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/ToObservable.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Union.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Where.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Zip.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Set.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs diff --git a/Ix.NET/Source/System.Interactive.Async/Strings.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Strings.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async/Strings.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/Strings.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs new file mode 100644 index 0000000000..0732f58206 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +namespace System.Threading.Tasks +{ + internal static class TaskExt + { + public static readonly Task True = Task.FromResult(true); + public static readonly Task False = Task.FromResult(false); + public static readonly Task CompletedTask = True; + } +} From 7ce71f89b91646c5de11568fa658823ed9788583 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:01:06 -0700 Subject: [PATCH 134/862] Moving Empty to its own file. --- .../System/Linq/AsyncEnumerable.cs | 5 ----- .../System/Linq/Operators/Empty.cs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 99887ddc78..90af7a4ad8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -17,11 +17,6 @@ public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEn return source.Select(x => x); } - public static IAsyncEnumerable Empty() - { - return CreateEnumerable(() => CreateEnumerator(ct => TaskExt.False, current: null, dispose: null)); - } - public static IAsyncEnumerable Return(TValue value) { return new[] { value }.ToAsyncEnumerable(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs new file mode 100644 index 0000000000..5bf1c12ed2 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable Empty() + { + return CreateEnumerable(() => CreateEnumerator(ct => TaskExt.False, current: null, dispose: null)); + } + } +} From ab72a652835b92c15ac9c52f3a24d57923f10bd8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:01:54 -0700 Subject: [PATCH 135/862] Fixing typo. --- .../System/Linq/Operators/AppendPrepend.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 92872e2dbb..c67ea31ade 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -16,7 +16,7 @@ public static IAsyncEnumerable Append(this IAsyncEnumerable appendable) + if (source is AppendPrependAsyncIterator appendable) { return appendable.Append(element); } @@ -29,7 +29,7 @@ public static IAsyncEnumerable Prepend(this IAsyncEnumerable appendable) + if (source is AppendPrependAsyncIterator appendable) { return appendable.Prepend(element); } @@ -37,12 +37,12 @@ public static IAsyncEnumerable Prepend(this IAsyncEnumerable(source, element, false); } - private abstract class AppendPrepentAsyncIterator : AsyncIterator, IIListProvider + private abstract class AppendPrependAsyncIterator : AsyncIterator, IIListProvider { protected readonly IAsyncEnumerable source; protected IAsyncEnumerator enumerator; - protected AppendPrepentAsyncIterator(IAsyncEnumerable source) + protected AppendPrependAsyncIterator(IAsyncEnumerable source) { Debug.Assert(source != null); @@ -55,8 +55,8 @@ protected void GetSourceEnumerator() enumerator = source.GetAsyncEnumerator(); } - public abstract AppendPrepentAsyncIterator Append(TSource item); - public abstract AppendPrepentAsyncIterator Prepend(TSource item); + public abstract AppendPrependAsyncIterator Append(TSource item); + public abstract AppendPrependAsyncIterator Prepend(TSource item); protected async Task LoadFromEnumeratorAsync() { @@ -91,7 +91,7 @@ public override async Task DisposeAsync() public abstract Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken); } - private sealed class AppendPrepend1AsyncIterator : AppendPrepentAsyncIterator + private sealed class AppendPrepend1AsyncIterator : AppendPrependAsyncIterator { private readonly TSource item; private readonly bool appending; @@ -154,7 +154,7 @@ protected override async Task MoveNextCore() return false; } - public override AppendPrepentAsyncIterator Append(TSource element) + public override AppendPrependAsyncIterator Append(TSource element) { if (appending) { @@ -164,7 +164,7 @@ public override AppendPrepentAsyncIterator Append(TSource element) return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(item), new SingleLinkedNode(element)); } - public override AppendPrepentAsyncIterator Prepend(TSource element) + public override AppendPrependAsyncIterator Prepend(TSource element) { if (appending) { @@ -315,7 +315,7 @@ public IEnumerator GetEnumerator() } } - private sealed class AppendPrependNAsyncIterator : AppendPrepentAsyncIterator + private sealed class AppendPrependNAsyncIterator : AppendPrependAsyncIterator { private readonly SingleLinkedNode prepended; private readonly SingleLinkedNode appended; @@ -411,12 +411,12 @@ protected override async Task MoveNextCore() return false; } - public override AppendPrepentAsyncIterator Append(TSource item) + public override AppendPrependAsyncIterator Append(TSource item) { return new AppendPrependNAsyncIterator(source, prepended, appended != null ? appended.Add(item) : new SingleLinkedNode(item)); } - public override AppendPrepentAsyncIterator Prepend(TSource item) + public override AppendPrependAsyncIterator Prepend(TSource item) { return new AppendPrependNAsyncIterator(source, prepended != null ? prepended.Add(item) : new SingleLinkedNode(item), appended); } From 8c1ca84f1c79ecae347a49e61bd9411dfb130b6a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:02:26 -0700 Subject: [PATCH 136/862] Moving OfType to its own file. --- .../System/Linq/Operators/Cast.cs | 8 -------- .../System/Linq/Operators/OfType.cs | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index fae69b9093..7c576f4645 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -21,13 +21,5 @@ public static IAsyncEnumerable Cast(this IAsyncEnumerable (TResult)x); } - - public static IAsyncEnumerable OfType(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Where(x => x is TType).Cast(); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs new file mode 100644 index 0000000000..65420ec677 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable OfType(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Where(x => x is TType).Cast(); + } + } +} From 5d1be7f7a578caeddc320f0504941e587f9fcf57 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:14:02 -0700 Subject: [PATCH 137/862] More efficient Min and Max. --- .../System/Linq/Operators/Max.cs | 29 +++++++++++++++++++ .../System/Linq/Operators/MaxBy.cs | 5 ---- .../System/Linq/Operators/Min.cs | 29 +++++++++++++++++++ .../System/Linq/Operators/MinBy.cs | 5 ---- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index eb74f5c315..bc6d3366fd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -86,5 +86,34 @@ public static Task Max(this IAsyncEnumerable return source.Select(selector).Max(cancellationToken); } + + private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + var max = e.Current; + + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var cur = e.Current; + + if (comparer.Compare(cur, max) > 0) + { + max = cur; + } + } + + return max; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs index 6546eb37f2..5fa5cf4d3e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs @@ -97,10 +97,5 @@ public static Task> MaxBy(this IAsyncEnumerable comparer.Compare(key, minValue), cancellationToken); } - - private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - return (await MaxBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 483df6806e..ccc9b973cf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -86,5 +86,34 @@ public static Task Min(this IAsyncEnumerable return source.Select(selector).Min(cancellationToken); } + + private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + var min = e.Current; + + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var cur = e.Current; + + if (comparer.Compare(cur, min) < 0) + { + min = cur; + } + } + + return min; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs index 3b0b9c8e33..ed572e0405 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs @@ -98,11 +98,6 @@ public static Task> MinBy(this IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); } - private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - return (await MinBy(source, x => x, comparer, cancellationToken).ConfigureAwait(false)).First(); - } - private static async Task> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) { var result = new List(); From 5f644c677241f28ced36eadc9595d70c52953949 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:17:44 -0700 Subject: [PATCH 138/862] Moving MinBy and MaxBy to AsyncEnumerableEx. --- .../AsyncTests.Aggregates.cs | 40 +++++++++---------- .../System/Linq/Operators/MaxBy.cs | 2 +- .../System/Linq/Operators/MinBy.cs | 2 +- .../System/Linq/Strings.cs | 13 ++++++ 4 files changed, 35 insertions(+), 22 deletions(-) rename Ix.NET/Source/{System.Linq.Async => System.Interactive.Async}/System/Linq/Operators/MaxBy.cs (98%) rename Ix.NET/Source/{System.Linq.Async => System.Interactive.Async}/System/Linq/Operators/MinBy.cs (99%) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 06b07c3b9e..51f1255c32 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -2084,19 +2084,19 @@ public void Sum10() [Fact] public async Task MinBy_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); } [Fact] @@ -2146,19 +2146,19 @@ public void MinBy5() [Fact] public async Task MaxBy_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs similarity index 98% rename from Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index 5fa5cf4d3e..61a40095a8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs similarity index 99% rename from Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index ed572e0405..39b83bcb6d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs new file mode 100644 index 0000000000..755114023d --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +namespace System.Linq +{ + internal static class Strings + { + public static string NO_ELEMENTS = "Source sequence doesn't contain any elements."; + public static string MORE_THAN_ONE_ELEMENT = "Source sequence contains more than one element."; + public static string NOT_SUPPORTED = "Specified method is not supported."; + } +} From f0d897e6c24e95315160ced38f784662dd9044d2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:18:51 -0700 Subject: [PATCH 139/862] Reorder Repeat overloads. --- .../System/Linq/Operators/Repeat.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 29ff1a7679..af40b94206 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -10,6 +10,11 @@ namespace System.Linq { public static partial class AsyncEnumerable { + public static IAsyncEnumerable Repeat(TResult element) + { + return new RepeatElementAsyncIterator(element); + } + public static IAsyncEnumerable Repeat(TResult element, int count) { if (count < 0) @@ -18,9 +23,12 @@ public static IAsyncEnumerable Repeat(TResult element, int cou return Enumerable.Repeat(element, count).ToAsyncEnumerable(); } - public static IAsyncEnumerable Repeat(TResult element) + public static IAsyncEnumerable Repeat(this IAsyncEnumerable source) { - return new RepeatElementAsyncIterator(element); + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return new RepeatSequenceAsyncIterator(source, -1); } public static IAsyncEnumerable Repeat(this IAsyncEnumerable source, int count) @@ -33,14 +41,6 @@ public static IAsyncEnumerable Repeat(this IAsyncEnumerable(source, count); } - public static IAsyncEnumerable Repeat(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return new RepeatSequenceAsyncIterator(source, -1); - } - private sealed class RepeatElementAsyncIterator : AsyncIterator { private readonly TResult element; From ecc947f6c01bb02496d3021c7c209ff34c458854 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:19:53 -0700 Subject: [PATCH 140/862] Some cosmetics. --- .../Source/System.Linq.Async/System/Linq/Operators/Distinct.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index f84ec75e99..6b12b860cb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -97,8 +97,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) public async Task> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken) - .ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToList(); } From ce06267ac5e655452b8c6ed7038525ae312f945c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:23:48 -0700 Subject: [PATCH 141/862] Moving non-standard Distinct overloads to AsyncEnumerableEx. --- .../AsyncTests.Single.cs | 12 +- .../ExcludeFromCodeCoverageAttribute.cs | 15 + .../System/Linq/Operators/Distinct.cs | 350 ++++++++++++++++++ .../System/Linq/Set.cs | 152 ++++++++ .../System/Linq/IIListProvider.cs | 2 +- .../System/Linq/Operators/Distinct.cs | 336 ----------------- 6 files changed, 524 insertions(+), 343 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index f482b86781..eb12664a4a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -1450,7 +1450,7 @@ public void Distinct_Null() AssertThrows(() => AsyncEnumerable.Distinct(null)); AssertThrows(() => AsyncEnumerable.Distinct(null, new Eq())); AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), null)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), (Func)null)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), (Func)null)); } [Fact] @@ -3259,12 +3259,12 @@ public async Task Scan6() [Fact] public void DistinctKey_Null() { - AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), x => x, null)); + AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), x => x, null)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs b/Ix.NET/Source/System.Interactive.Async/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs new file mode 100644 index 0000000000..73e55bab60 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +#if NO_CODE_COVERAGE_ATTRIBUTE + +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event, Inherited = false)] + internal sealed class ExcludeFromCodeCoverageAttribute : Attribute + { + } +} + +#endif diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs new file mode 100644 index 0000000000..cd115b935a --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -0,0 +1,350 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.Distinct(keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new DistinctAsyncIterator(source, keySelector, comparer); + } + + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.Distinct(keySelector, EqualityComparer.Default); + } + + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); + } + + private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider + { + private readonly IEqualityComparer comparer; + private readonly Func keySelector; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private Set set; + + public DistinctAsyncIterator(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s.ToArray(); + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s; + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var count = 0; + var s = new Set(comparer); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var item = enu.Current; + if (s.Add(keySelector(item))) + { + count++; + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return count; + } + + public override AsyncIterator Clone() + { + return new DistinctAsyncIterator(source, keySelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + set = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + await DisposeAsync().ConfigureAwait(false); + return false; + } + + var element = enumerator.Current; + set = new Set(comparer); + set.Add(keySelector(element)); + current = element; + + state = AsyncIteratorState.Iterating; + return true; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + element = enumerator.Current; + if (set.Add(keySelector(element))) + { + current = element; + return true; + } + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + + private async Task> FillSetAsync(CancellationToken cancellationToken) + { + var s = new Set(comparer); + var r = new List(); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var item = enu.Current; + if (s.Add(keySelector(item))) + { + r.Add(item); + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return r; + } + } + + private sealed class DistinctAsyncIteratorWithTask : AsyncIterator, IIListProvider + { + private readonly IEqualityComparer comparer; + private readonly Func> keySelector; + private readonly IAsyncEnumerable source; + + private IAsyncEnumerator enumerator; + private Set set; + + public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(comparer != null); + + this.source = source; + this.keySelector = keySelector; + this.comparer = comparer; + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s.ToArray(); + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s; + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var count = 0; + var s = new Set(comparer); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var item = enu.Current; + if (s.Add(await keySelector(item).ConfigureAwait(false))) + { + count++; + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return count; + } + + public override AsyncIterator Clone() + { + return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + set = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + await DisposeAsync().ConfigureAwait(false); + return false; + } + + var element = enumerator.Current; + set = new Set(comparer); + set.Add(await keySelector(element).ConfigureAwait(false)); + current = element; + + state = AsyncIteratorState.Iterating; + return true; + + case AsyncIteratorState.Iterating: + while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + element = enumerator.Current; + if (set.Add(await keySelector(element).ConfigureAwait(false))) + { + current = element; + return true; + } + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + + private async Task> FillSetAsync(CancellationToken cancellationToken) + { + var s = new Set(comparer); + var r = new List(); + + var enu = source.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var item = enu.Current; + if (s.Add(await keySelector(item).ConfigureAwait(false))) + { + r.Add(item); + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return r; + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs new file mode 100644 index 0000000000..0c28569f4a --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs @@ -0,0 +1,152 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; + +// from https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/System.Linq/src/System/Linq/Set.cs +namespace System.Linq +{ + [ExcludeFromCodeCoverage] + internal sealed class Set + { + private readonly IEqualityComparer _comparer; + private int[] _buckets; +#if DEBUG + private bool _haveRemoved; +#endif + private Slot[] _slots; + + public Set(IEqualityComparer comparer) + { + _comparer = comparer ?? EqualityComparer.Default; + _buckets = new int[7]; + _slots = new Slot[7]; + } + + internal int Count { get; private set; } + + // If value is not in set, add it and return true; otherwise return false + public bool Add(TElement value) + { +#if DEBUG + Debug.Assert(!_haveRemoved, "This class is optimised for never calling Add after Remove. If your changes need to do so, undo that optimization."); +#endif + var hashCode = InternalGetHashCode(value); + for (var i = _buckets[hashCode%_buckets.Length] - 1; i >= 0; i = _slots[i]._next) + { + if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) + { + return false; + } + } + + if (Count == _slots.Length) + { + Resize(); + } + + var index = Count; + Count++; + var bucket = hashCode%_buckets.Length; + _slots[index]._hashCode = hashCode; + _slots[index]._value = value; + _slots[index]._next = _buckets[bucket] - 1; + _buckets[bucket] = index + 1; + return true; + } + + // If value is in set, remove it and return true; otherwise return false + public bool Remove(TElement value) + { +#if DEBUG + _haveRemoved = true; +#endif + var hashCode = InternalGetHashCode(value); + var bucket = hashCode%_buckets.Length; + var last = -1; + for (var i = _buckets[bucket] - 1; i >= 0; last = i, i = _slots[i]._next) + { + if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) + { + if (last < 0) + { + _buckets[bucket] = _slots[i]._next + 1; + } + else + { + _slots[last]._next = _slots[i]._next; + } + + _slots[i]._hashCode = -1; + _slots[i]._value = default(TElement); + _slots[i]._next = -1; + return true; + } + } + + return false; + } + + internal int InternalGetHashCode(TElement value) + { + // Handle comparer implementations that throw when passed null + return (value == null) ? 0 : _comparer.GetHashCode(value) & 0x7FFFFFFF; + } + + internal TElement[] ToArray() + { +#if DEBUG + Debug.Assert(!_haveRemoved, "Optimised ToArray cannot be called if Remove has been called."); +#endif + var array = new TElement[Count]; + for (var i = 0; i != array.Length; ++i) + { + array[i] = _slots[i]._value; + } + + return array; + } + + internal List ToList() + { +#if DEBUG + Debug.Assert(!_haveRemoved, "Optimised ToList cannot be called if Remove has been called."); +#endif + var count = Count; + var list = new List(count); + for (var i = 0; i != count; ++i) + { + list.Add(_slots[i]._value); + } + + return list; + } + + private void Resize() + { + var newSize = checked((Count*2) + 1); + var newBuckets = new int[newSize]; + var newSlots = new Slot[newSize]; + Array.Copy(_slots, 0, newSlots, 0, Count); + for (var i = 0; i < Count; i++) + { + var bucket = newSlots[i]._hashCode%newSize; + newSlots[i]._next = newBuckets[bucket] - 1; + newBuckets[bucket] = i + 1; + } + + _buckets = newBuckets; + _slots = newSlots; + } + + internal struct Slot + { + internal int _hashCode; + internal int _next; + internal TElement _value; + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs index fcae98851a..d396d353cc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs @@ -11,7 +11,7 @@ namespace System.Linq /// /// An iterator that can produce an array or through an optimized path. /// - internal interface IIListProvider : IAsyncEnumerable + public interface IIListProvider : IAsyncEnumerable { /// /// Produce an array of the sequence through an optimized path. diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 6b12b860cb..36650d444b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -29,50 +29,6 @@ public static IAsyncEnumerable Distinct(this IAsyncEnumerable< return new DistinctAsyncIterator(source, comparer); } - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.Distinct(keySelector, EqualityComparer.Default); - } - - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return new DistinctAsyncIterator(source, keySelector, comparer); - } - - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.Distinct(keySelector, EqualityComparer.Default); - } - - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); - } - private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider { private readonly IEqualityComparer comparer; @@ -182,297 +138,5 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return s; } } - - private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider - { - private readonly IEqualityComparer comparer; - private readonly Func keySelector; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - private Set set; - - public DistinctAsyncIterator(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(comparer != null); - - this.source = source; - this.keySelector = keySelector; - this.comparer = comparer; - } - - public async Task ToArrayAsync(CancellationToken cancellationToken) - { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); - return s.ToArray(); - } - - public async Task> ToListAsync(CancellationToken cancellationToken) - { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); - return s; - } - - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - if (onlyIfCheap) - { - return -1; - } - - var count = 0; - var s = new Set(comparer); - - var enu = source.GetAsyncEnumerator(); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - if (s.Add(keySelector(item))) - { - count++; - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return count; - } - - public override AsyncIterator Clone() - { - return new DistinctAsyncIterator(source, keySelector, comparer); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - set = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - await DisposeAsync().ConfigureAwait(false); - return false; - } - - var element = enumerator.Current; - set = new Set(comparer); - set.Add(keySelector(element)); - current = element; - - state = AsyncIteratorState.Iterating; - return true; - - case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - element = enumerator.Current; - if (set.Add(keySelector(element))) - { - current = element; - return true; - } - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - - private async Task> FillSetAsync(CancellationToken cancellationToken) - { - var s = new Set(comparer); - var r = new List(); - - var enu = source.GetAsyncEnumerator(); - - try - { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - var item = enu.Current; - if (s.Add(keySelector(item))) - { - r.Add(item); - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return r; - } - } - - private sealed class DistinctAsyncIteratorWithTask : AsyncIterator, IIListProvider - { - private readonly IEqualityComparer comparer; - private readonly Func> keySelector; - private readonly IAsyncEnumerable source; - - private IAsyncEnumerator enumerator; - private Set set; - - public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(comparer != null); - - this.source = source; - this.keySelector = keySelector; - this.comparer = comparer; - } - - public async Task ToArrayAsync(CancellationToken cancellationToken) - { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); - return s.ToArray(); - } - - public async Task> ToListAsync(CancellationToken cancellationToken) - { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); - return s; - } - - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - if (onlyIfCheap) - { - return -1; - } - - var count = 0; - var s = new Set(comparer); - - var enu = source.GetAsyncEnumerator(); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - if (s.Add(await keySelector(item).ConfigureAwait(false))) - { - count++; - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return count; - } - - public override AsyncIterator Clone() - { - return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - set = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - await DisposeAsync().ConfigureAwait(false); - return false; - } - - var element = enumerator.Current; - set = new Set(comparer); - set.Add(await keySelector(element).ConfigureAwait(false)); - current = element; - - state = AsyncIteratorState.Iterating; - return true; - - case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - element = enumerator.Current; - if (set.Add(await keySelector(element).ConfigureAwait(false))) - { - current = element; - return true; - } - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - - private async Task> FillSetAsync(CancellationToken cancellationToken) - { - var s = new Set(comparer); - var r = new List(); - - var enu = source.GetAsyncEnumerator(); - - try - { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - var item = enu.Current; - if (s.Add(await keySelector(item).ConfigureAwait(false))) - { - r.Add(item); - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return r; - } - } } } From c08f34be5f7d095c6dc3550015201a9445a1050a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:28:23 -0700 Subject: [PATCH 142/862] Moving non-standard SelectMany overload to AsyncEnumerableEx. --- .../AsyncTests.Multiple.cs | 4 ++-- .../System/Linq/Operators/SelectMany.cs | 21 +++++++++++++++++++ .../System/Linq/Operators/SelectMany.cs | 10 --------- 3 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index ad261a1185..d15e901209 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -962,8 +962,8 @@ public void Join12() [Fact] public void SelectManyMultiple_Null() { - AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.SelectMany(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerableEx.SelectMany(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs new file mode 100644 index 0000000000..01cb137f6f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, IAsyncEnumerable other) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (other == null) + throw new ArgumentNullException(nameof(other)); + + return source.SelectMany(_ => other); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index c760adecfe..3c09d78317 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -10,16 +10,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, IAsyncEnumerable other) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (other == null) - throw new ArgumentNullException(nameof(other)); - - return source.SelectMany(_ => other); - } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector) { if (source == null) From 9db579d8de44ea5bab823a15651e0ab05f96a8d7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:29:00 -0700 Subject: [PATCH 143/862] Renaming a file. --- .../System/Linq/Operators/{Concatenate.cs => Concat.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Ix.NET/Source/System.Interactive/System/Linq/Operators/{Concatenate.cs => Concat.cs} (100%) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concatenate.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/System/Linq/Operators/Concatenate.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs From 2fdef918431588481b9277d0cee8fb1e2c592d15 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:29:30 -0700 Subject: [PATCH 144/862] Some code cosmetics. --- Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs index 9a5b7ea9ef..9d8c4a6bc1 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs @@ -22,8 +22,7 @@ public static TSource Max(this IEnumerable source, IComparer x, comparer) - .First(); + return MaxBy(source, x => x, comparer).First(); } /// From ba2c0093831d0df3129b2125b635e71ee6961536 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:31:07 -0700 Subject: [PATCH 145/862] Some refactoring of Ix. --- .../System/Linq/Operators/Max.cs | 76 ---------------- .../System/Linq/Operators/MaxBy.cs | 87 +++++++++++++++++++ .../System/Linq/Operators/Min.cs | 39 --------- .../System/Linq/Operators/MinBy.cs | 50 +++++++++++ 4 files changed, 137 insertions(+), 115 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs index 9d8c4a6bc1..ba796b5785 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs @@ -24,81 +24,5 @@ public static TSource Max(this IEnumerable source, IComparer x, comparer).First(); } - - /// - /// Returns the elements with the maximum key value by using the default comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// List with the elements that share the same maximum key value. - public static IList MaxBy(this IEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return MaxBy(source, keySelector, Comparer.Default); - } - - /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// Comparer used to determine the maximum key value. - /// List with the elements that share the same maximum key value. - public static IList MaxBy(this IEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue)); - } - - private static IList ExtremaBy(IEnumerable source, Func keySelector, Func compare) - { - var result = new List(); - - using (var e = source.GetEnumerator()) - { - if (!e.MoveNext()) - throw new InvalidOperationException("Source sequence doesn't contain any elements."); - - var current = e.Current; - var resKey = keySelector(current); - result.Add(current); - - while (e.MoveNext()) - { - var cur = e.Current; - var key = keySelector(cur); - - var cmp = compare(key, resKey); - if (cmp == 0) - { - result.Add(cur); - } - else if (cmp > 0) - { - result = new List - { - cur - }; - resKey = key; - } - } - } - - return result; - } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs new file mode 100644 index 0000000000..d1dc988852 --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs @@ -0,0 +1,87 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class EnumerableEx + { + /// + /// Returns the elements with the maximum key value by using the default comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// List with the elements that share the same maximum key value. + public static IList MaxBy(this IEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MaxBy(source, keySelector, Comparer.Default); + } + + /// + /// Returns the elements with the minimum key value by using the specified comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// Comparer used to determine the maximum key value. + /// List with the elements that share the same maximum key value. + public static IList MaxBy(this IEnumerable source, Func keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue)); + } + + private static IList ExtremaBy(IEnumerable source, Func keySelector, Func compare) + { + var result = new List(); + + using (var e = source.GetEnumerator()) + { + if (!e.MoveNext()) + throw new InvalidOperationException("Source sequence doesn't contain any elements."); + + var current = e.Current; + var resKey = keySelector(current); + result.Add(current); + + while (e.MoveNext()) + { + var cur = e.Current; + var key = keySelector(cur); + + var cmp = compare(key, resKey); + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List + { + cur + }; + resKey = key; + } + } + } + + return result; + } + } +} diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs index bad016f3a5..4904538a70 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs @@ -24,44 +24,5 @@ public static TSource Min(this IEnumerable source, IComparer x, comparer).First(); } - - /// - /// Returns the elements with the minimum key value by using the default comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// List with the elements that share the same minimum key value. - public static IList MinBy(this IEnumerable source, Func keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return MinBy(source, keySelector, Comparer.Default); - } - - /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// Comparer used to determine the minimum key value. - /// List with the elements that share the same minimum key value. - public static IList MinBy(this IEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue)); - } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs new file mode 100644 index 0000000000..8406f74284 --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class EnumerableEx + { + /// + /// Returns the elements with the minimum key value by using the default comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// List with the elements that share the same minimum key value. + public static IList MinBy(this IEnumerable source, Func keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return MinBy(source, keySelector, Comparer.Default); + } + + /// + /// Returns the elements with the minimum key value by using the specified comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// Comparer used to determine the minimum key value. + /// List with the elements that share the same minimum key value. + public static IList MinBy(this IEnumerable source, Func keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue)); + } + } +} From 206c7f2f1fb9be0d757587d6f083d30da4b031dd Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 22:32:44 -0700 Subject: [PATCH 146/862] Splitting Count and LongCount. --- .../System/Linq/Operators/Count.cs | 56 --------------- .../System/Linq/Operators/LongCount.cs | 69 +++++++++++++++++++ 2 files changed, 69 insertions(+), 56 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 46250566a3..bc72bcdd8a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -75,61 +75,5 @@ public static Task Count(this IAsyncEnumerable source, Fu return Count(source, predicate, CancellationToken.None); } - - public static Task LongCount(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); - } - - public static Task LongCount(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); - } - - public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); - } - - public static Task LongCount(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return LongCount(source, CancellationToken.None); - } - - public static Task LongCount(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return LongCount(source, predicate, CancellationToken.None); - } - - public static Task LongCount(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return LongCount(source, predicate, CancellationToken.None); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs new file mode 100644 index 0000000000..37339f46df --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task LongCount(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + } + + public static Task LongCount(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + } + + public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + } + + public static Task LongCount(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return LongCount(source, CancellationToken.None); + } + + public static Task LongCount(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return LongCount(source, predicate, CancellationToken.None); + } + + public static Task LongCount(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return LongCount(source, predicate, CancellationToken.None); + } + } +} From ba34394ae1f1b4466e155fd2d520be15d63de4c7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 23:18:34 -0700 Subject: [PATCH 147/862] Moving IAsyncQueryable interfaces. --- .../System.Interactive.Async.Providers.csproj | 1 + .../System.Linq.Async.Queryable.csproj | 4 ++++ .../System/Linq}/IAsyncQueryProvider.cs | 0 .../System/Linq}/IAsyncQueryable.cs | 0 .../System/Linq}/IOrderedAsyncQueryable.cs | 0 5 files changed, 5 insertions(+) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/IAsyncQueryProvider.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/IAsyncQueryable.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/IOrderedAsyncQueryable.cs (100%) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index 74812e9dcf..729daab5db 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -13,6 +13,7 @@ + diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index 145eaea791..8366e54376 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -8,4 +8,8 @@ + + + + diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/IAsyncQueryProvider.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers/IAsyncQueryProvider.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/IAsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers/IAsyncQueryable.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/IOrderedAsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IOrderedAsyncQueryable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers/IOrderedAsyncQueryable.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IOrderedAsyncQueryable.cs From 3635f00c327fcd5bc644ab9fd56d47ca0d768f38 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 23:18:57 -0700 Subject: [PATCH 148/862] Some code cosmetics. --- .../System/Linq/IAsyncQueryProvider.cs | 3 ++- .../System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs | 3 ++- .../System/Linq/IOrderedAsyncQueryable.cs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs index 15369b5b6c..4274919428 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; @@ -29,4 +30,4 @@ public interface IAsyncQueryProvider /// Task representing the result of evaluating the specified expression tree. Task ExecuteAsync(Expression expression, CancellationToken token); } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs index 8d6a7c476b..7553b612a6 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryable.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Collections.Generic; using System.Linq.Expressions; @@ -34,4 +35,4 @@ public interface IAsyncQueryable public interface IAsyncQueryable : IAsyncEnumerable, IAsyncQueryable { } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IOrderedAsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IOrderedAsyncQueryable.cs index 84056f03c3..0800ec2ad0 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IOrderedAsyncQueryable.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IOrderedAsyncQueryable.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + namespace System.Linq { /// @@ -17,4 +18,4 @@ public interface IOrderedAsyncQueryable : IAsyncQueryable public interface IOrderedAsyncQueryable : IAsyncQueryable, IOrderedAsyncQueryable { } -} \ No newline at end of file +} From 45f69bdc3636d5f1f5c2f89ddb90a67df71fc4b5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 23:19:40 -0700 Subject: [PATCH 149/862] Untabify tt file. --- .../AsyncQueryable.Generated.cs | 8460 +++++++++++------ .../AsyncQueryable.Generated.tt | 370 +- 2 files changed, 5736 insertions(+), 3094 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs index ef29b053d9..86c15d71f0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs @@ -6,4603 +6,7245 @@ namespace System.Linq { - public static partial class AsyncQueryable - { - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); + public static partial class AsyncQueryable + { + public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif - } + } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); + public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif - } + } - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); + public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #endif - } + } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #endif - } + } - public static Task All(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task All(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Any(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #endif - } + } - public static Task Any(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #endif - } + } - public static Task Any(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Any(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Append(this IAsyncQueryable source, TSource element) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task All(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Append(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task All(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task All(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task All(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Any(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Any(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Any(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Any(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Any(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Any(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Append(this IAsyncQueryable source, TSource element) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Append(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count, int skip) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int), default(int))), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Cast(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Cast(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) - { - if (source == null) - throw new ArgumentNullException("source"); - if (handler == null) - throw new ArgumentNullException("handler"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(Expression>>))), source.Expression, handler)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Concat(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Concat(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Contains(this IAsyncQueryable source, TSource value) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Average(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Average(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Count(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Count(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Count(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source, TSource defaultValue) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Distinct(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) - { - if (source == null) - throw new ArgumentNullException("source"); - if (onNext == null) - throw new ArgumentNullException("onNext"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (observer == null) - throw new ArgumentNullException("observer"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) - { - if (source == null) - throw new ArgumentNullException("source"); - if (onNext == null) - throw new ArgumentNullException("onNext"); - if (onCompleted == null) - throw new ArgumentNullException("onCompleted"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) - { - if (source == null) - throw new ArgumentNullException("source"); - if (onNext == null) - throw new ArgumentNullException("onNext"); - if (onError == null) - throw new ArgumentNullException("onError"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Action onCompleted) - { - if (source == null) - throw new ArgumentNullException("source"); - if (onNext == null) - throw new ArgumentNullException("onNext"); - if (onError == null) - throw new ArgumentNullException("onError"); - if (onCompleted == null) - throw new ArgumentNullException("onCompleted"); + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Action))), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task ElementAt(this IAsyncQueryable source, int index) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task ElementAt(this IAsyncQueryable source, int index, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); #endif - } + } - public static Task ElementAtOrDefault(this IAsyncQueryable source, int index) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count, int skip) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int), default(int))), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); #endif - } + } - public static Task ElementAtOrDefault(this IAsyncQueryable source, int index, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Cast(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Cast(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); #endif - } + } - public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif - } + } - public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) + { + if (source == null) + throw new ArgumentNullException("source"); + if (handler == null) + throw new ArgumentNullException("handler"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(Expression>>))), source.Expression, handler)); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); #endif - } + } - public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) + { + if (source == null) + throw new ArgumentNullException("source"); + if (handler == null) + throw new ArgumentNullException("handler"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Expand(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); #endif - } + } - public static IAsyncQueryable Finally(this IAsyncQueryable source, Action finallyAction) - { - if (source == null) - throw new ArgumentNullException("source"); - if (finallyAction == null) - throw new ArgumentNullException("finallyAction"); + public static IAsyncQueryable Concat(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Finally(default(IAsyncQueryable), default(Action))), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Concat(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif - } + } - public static Task First(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Contains(this IAsyncQueryable source, TSource value) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); #endif - } + } - public static Task First(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif - } + } - public static Task First(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task First(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task FirstOrDefault(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Count(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task FirstOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Count(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Count(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Count(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + public static Task Count(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif - } + } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source, TSource defaultValue) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); #endif - } + } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable Distinct(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif - } + } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif - } + } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif - } + } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) - { - if (outer == null) - throw new ArgumentNullException("outer"); - if (inner == null) - throw new ArgumentNullException("inner"); - if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); - if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException("outer"); - if (inner == null) - throw new ArgumentNullException("inner"); - if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); - if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static IAsyncQueryable IgnoreElements(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.IgnoreElements(default(IAsyncQueryable))), source.Expression)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif - } + } - public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif - } + } - public static Task IsEmpty(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif - } + } - public static Task IsEmpty(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) - { - if (outer == null) - throw new ArgumentNullException("outer"); - if (inner == null) - throw new ArgumentNullException("inner"); - if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); - if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException("outer"); - if (inner == null) - throw new ArgumentNullException("inner"); - if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); - if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (observer == null) + throw new ArgumentNullException("observer"); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); #endif - } + } - public static Task Last(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); #endif - } + } - public static Task Last(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); #endif - } + } - public static Task Last(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); + if (onCompleted == null) + throw new ArgumentNullException("onCompleted"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); #endif - } + } - public static Task Last(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); + if (onError == null) + throw new ArgumentNullException("onError"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); #endif - } + } - public static Task LastOrDefault(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); + if (onCompleted == null) + throw new ArgumentNullException("onCompleted"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); #endif - } + } - public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); + if (onError == null) + throw new ArgumentNullException("onError"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); #endif - } + } - public static Task LastOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); + if (onError == null) + throw new ArgumentNullException("onError"); + if (onCompleted == null) + throw new ArgumentNullException("onCompleted"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); #endif - } + } - public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Action onCompleted) + { + if (source == null) + throw new ArgumentNullException("source"); + if (onNext == null) + throw new ArgumentNullException("onNext"); + if (onError == null) + throw new ArgumentNullException("onError"); + if (onCompleted == null) + throw new ArgumentNullException("onCompleted"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Action))), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); #endif - } + } - public static Task LongCount(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task ElementAt(this IAsyncQueryable source, int index) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #endif - } + } - public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task ElementAt(this IAsyncQueryable source, int index, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task LongCount(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task ElementAtOrDefault(this IAsyncQueryable source, int index) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #endif - } + } - public static Task LongCount(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task ElementAtOrDefault(this IAsyncQueryable source, int index, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Expand(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Finally(this IAsyncQueryable source, Action finallyAction) + { + if (source == null) + throw new ArgumentNullException("source"); + if (finallyAction == null) + throw new ArgumentNullException("finallyAction"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Finally(default(IAsyncQueryable), default(Action))), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable Finally(this IAsyncQueryable source, Expression> finallyAction) + { + if (source == null) + throw new ArgumentNullException("source"); + if (finallyAction == null) + throw new ArgumentNullException("finallyAction"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Finally(default(IAsyncQueryable), default(Expression>))), source.Expression, finallyAction)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, finallyAction)); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task First(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task First(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task First(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task First(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task First(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task First(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task FirstOrDefault(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task FirstOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable IgnoreElements(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.IgnoreElements(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task IsEmpty(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task IsEmpty(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif - } + } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException("outer"); + if (inner == null) + throw new ArgumentNullException("inner"); + if (outerKeySelector == null) + throw new ArgumentNullException("outerKeySelector"); + if (innerKeySelector == null) + throw new ArgumentNullException("innerKeySelector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif - } + } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Last(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Last(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Last(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Last(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Last(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Last(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LastOrDefault(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LastOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LongCount(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task LongCount(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task LongCount(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task LongCount(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable OfType(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TType)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable OnErrorResumeNext(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OnErrorResumeNext(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Repeat(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Repeat(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Retry(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Retry(this IAsyncQueryable source, int retryCount) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(retryCount, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Reverse(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException("source"); - if (accumulator == null) - throw new ArgumentNullException("accumulator"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, IAsyncEnumerable other) - { - if (source == null) - throw new ArgumentNullException("source"); - if (other == null) - throw new ArgumentNullException("other"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(IAsyncEnumerable))), source.Expression, GetSourceExpression(other))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); - if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second)), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Single(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Single(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Single(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SingleOrDefault(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SingleOrDefault(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SingleOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task SingleOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Skip(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Skip(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable SkipLast(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif - } + } - public static IAsyncQueryable StartWith(this IAsyncQueryable source, params TSource[] values) - { - if (source == null) - throw new ArgumentNullException("source"); - if (values == null) - throw new ArgumentNullException("values"); + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.StartWith(default(IAsyncQueryable), default(TSource[]))), source.Expression, Expression.Constant(values, typeof(TSource[])))); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[])))); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Take(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Take(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable TakeLast(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif - } + } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif - } + } - public static Task ToArray(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task ToArray(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToList(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToList(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException("source"); - if (keySelector == null) - throw new ArgumentNullException("keySelector"); - if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); + public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (comparer == null) + throw new ArgumentNullException("comparer"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); - if (comparer == null) - throw new ArgumentNullException("comparer"); + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif - } + } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException("source"); - if (predicate == null) - throw new ArgumentNullException("predicate"); + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif - } + } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) - { - if (first == null) - throw new ArgumentNullException("first"); - if (second == null) - throw new ArgumentNullException("second"); - if (selector == null) - throw new ArgumentNullException("selector"); + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif - } + } - } + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static IAsyncQueryable OfType(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TType)), source.Expression)); +#endif + } + + public static IAsyncQueryable OnErrorResumeNext(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OnErrorResumeNext(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); +#endif + } + + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); +#endif + } + + public static IAsyncQueryable Repeat(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); +#endif + } + + public static IAsyncQueryable Repeat(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); +#endif + } + + public static IAsyncQueryable Retry(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); +#endif + } + + public static IAsyncQueryable Retry(this IAsyncQueryable source, int retryCount) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(retryCount, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int)))); +#endif + } + + public static IAsyncQueryable Reverse(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException("source"); + if (accumulator == null) + throw new ArgumentNullException("accumulator"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#endif + } + + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, IAsyncEnumerable other) + { + if (source == null) + throw new ArgumentNullException("source"); + if (other == null) + throw new ArgumentNullException("other"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(IAsyncEnumerable))), source.Expression, GetSourceExpression(other))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other))); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + if (resultSelector == null) + throw new ArgumentNullException("resultSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); +#endif + } + + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + +#if CRIPPLED_REFLECTION + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second)), CancellationToken.None); +#else + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)), CancellationToken.None); +#endif + } + + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + +#if CRIPPLED_REFLECTION + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Single(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + + public static Task Single(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Single(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); +#endif + } + + public static Task Single(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); +#endif + } + + public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task SingleOrDefault(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + + public static Task SingleOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task SingleOrDefault(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); +#endif + } + + public static Task SingleOrDefault(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); +#endif + } + + public static Task SingleOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task SingleOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static IAsyncQueryable Skip(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Skip(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); +#endif + } + + public static IAsyncQueryable SkipLast(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); +#endif + } + + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable StartWith(this IAsyncQueryable source, params TSource[] values) + { + if (source == null) + throw new ArgumentNullException("source"); + if (values == null) + throw new ArgumentNullException("values"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.StartWith(default(IAsyncQueryable), default(TSource[]))), source.Expression, Expression.Constant(values, typeof(TSource[])))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[])))); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static IAsyncQueryable Take(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Take(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); +#endif + } + + public static IAsyncQueryable TakeLast(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); +#endif + } + + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + + public static Task ToArray(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + + public static Task ToArray(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToList(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + + public static Task> ToList(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException("source"); + if (keySelector == null) + throw new ArgumentNullException("keySelector"); + if (elementSelector == null) + throw new ArgumentNullException("elementSelector"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); +#endif + } + + public static IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + if (comparer == null) + throw new ArgumentNullException("comparer"); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException("source"); + if (predicate == null) + throw new ArgumentNullException("predicate"); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); +#endif + } + + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) + { + if (first == null) + throw new ArgumentNullException("first"); + if (second == null) + throw new ArgumentNullException("second"); + if (selector == null) + throw new ArgumentNullException("selector"); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); +#endif + } + + } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt index f2b9a08a6b..a1cace1998 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt @@ -17,77 +17,77 @@ var name = t.Name; if (t.IsGenericType) { - var genDef = t.GetGenericTypeDefinition(); - name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); + var genDef = t.GetGenericTypeDefinition(); + name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); - var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; + var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; - if (b) - { - if (name == "Func" || name == "Action") - { - name = "Expression<" + name + genArgs + ">"; - } - else if (name == "IAsyncEnumerable" && i == 0) - { - name = "IAsyncQueryable" + genArgs; - } - else if (name == "IOrderedAsyncEnumerable" && i == 0) - { - name = "IOrderedAsyncQueryable" + genArgs; - } - else - { - name += genArgs; - } - } - else - { - if (name == "Nullable") - { - name = genArgs.Substring(1, genArgs.Length - 2) + "?"; - } - else - { - name += genArgs; - } - } + if (b) + { + if (name == "Func" || name == "Action") + { + name = "Expression<" + name + genArgs + ">"; + } + else if (name == "IAsyncEnumerable" && i == 0) + { + name = "IAsyncQueryable" + genArgs; + } + else if (name == "IOrderedAsyncEnumerable" && i == 0) + { + name = "IOrderedAsyncQueryable" + genArgs; + } + else + { + name += genArgs; + } + } + else + { + if (name == "Nullable") + { + name = genArgs.Substring(1, genArgs.Length - 2) + "?"; + } + else + { + name += genArgs; + } + } } else if (t.IsArray) { - var elem = toQuotedImpl(t.GetElementType(), i, b); - name = elem + "[]"; + var elem = toQuotedImpl(t.GetElementType(), i, b); + name = elem + "[]"; } else { - if (t == typeof(int)) - { - name = "int"; - } - else if (t == typeof(long)) - { - name = "long"; - } - else if (t == typeof(float)) - { - name = "float"; - } - else if (t == typeof(double)) - { - name = "double"; - } - else if (t == typeof(decimal)) - { - name = "decimal"; - } - else if (t == typeof(bool)) - { - name = "bool"; - } - else if (t == typeof(object)) - { - name = "object"; - } + if (t == typeof(int)) + { + name = "int"; + } + else if (t == typeof(long)) + { + name = "long"; + } + else if (t == typeof(float)) + { + name = "float"; + } + else if (t == typeof(double)) + { + name = "double"; + } + else if (t == typeof(decimal)) + { + name = "decimal"; + } + else if (t == typeof(bool)) + { + name = "bool"; + } + else if (t == typeof(object)) + { + name = "object"; + } } return name; @@ -103,156 +103,156 @@ using System.Threading.Tasks; namespace System.Linq { - public static partial class AsyncQueryable - { + public static partial class AsyncQueryable + { <# // NOTE: Just including extension methods foreach (var m in typeof(AsyncEnumerable).GetMethods() - .Where(m => m.IsStatic) - .Where(m => !exclude.Contains(m.Name)) - .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - .Where(m => - { - var p0 = m.GetParameters()[0].ParameterType; - if (p0.IsGenericType) - { - var p0d = p0.GetGenericTypeDefinition(); - return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); - } + .Where(m => m.IsStatic) + .Where(m => !exclude.Contains(m.Name)) + .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + .Where(m => + { + var p0 = m.GetParameters()[0].ParameterType; + if (p0.IsGenericType) + { + var p0d = p0.GetGenericTypeDefinition(); + return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); + } - return false; - }) - .OrderBy(m => m.Name) - .ThenBy(m => m.GetParameters().Length)) + return false; + }) + .OrderBy(m => m.Name) + .ThenBy(m => m.GetParameters().Length)) { - var genArgs = m.GetGenericArguments(); + var genArgs = m.GetGenericArguments(); - var ret = toQuoted(m.ReturnType, 0); - var name = m.Name; + var ret = toQuoted(m.ReturnType, 0); + var name = m.Name; - if (genArgs.Length > 0) - { - name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; - } + if (genArgs.Length > 0) + { + name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; + } - var isParams = false; - var parCount = m.GetParameters().Length; + var isParams = false; + var parCount = m.GetParameters().Length; - if (parCount != 0) - { - if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) - { - isParams = true; - } - } + if (parCount != 0) + { + if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) + { + isParams = true; + } + } - var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); - var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); + var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); - if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - { - pars = "this " + pars; - } + if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + { + pars = "this " + pars; + } - var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; + var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; - if (m.IsGenericMethod) - { - mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; - } + if (m.IsGenericMethod) + { + mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; + } - var provider = m.GetParameters()[0].Name + ".Provider"; - var factory = ""; - var rem = ""; - var cast = ""; - var quotedArgs = new List(); + var provider = m.GetParameters()[0].Name + ".Provider"; + var factory = ""; + var rem = ""; + var cast = ""; + var quotedArgs = new List(); - if (m.ReturnType.IsGenericType) - { - var td = m.ReturnType.GetGenericTypeDefinition(); + if (m.ReturnType.IsGenericType) + { + var td = m.ReturnType.GetGenericTypeDefinition(); - if (td == typeof(Task<>)) - { - factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + if (td == typeof(Task<>)) + { + factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - var last = m.GetParameters().Last(); - if (last.ParameterType == typeof(CancellationToken)) - { - rem = ", " + last.Name; - } - else - { - rem = ", CancellationToken.None"; - } - } - else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) - { - factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + var last = m.GetParameters().Last(); + if (last.ParameterType == typeof(CancellationToken)) + { + rem = ", " + last.Name; + } + else + { + rem = ", CancellationToken.None"; + } + } + else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) + { + factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - if (td == typeof(IOrderedAsyncEnumerable<>)) - { - cast = "(" + toQuoted(m.ReturnType, 0) + ")"; - } - } - } + if (td == typeof(IOrderedAsyncEnumerable<>)) + { + cast = "(" + toQuoted(m.ReturnType, 0) + ")"; + } + } + } - var n = 0; - foreach (var p in m.GetParameters()) - { - var pt = p.ParameterType; + var n = 0; + foreach (var p in m.GetParameters()) + { + var pt = p.ParameterType; - var add = false; + var add = false; - if (pt.IsGenericType) - { - var ptd = pt.GetGenericTypeDefinition(); + if (pt.IsGenericType) + { + var ptd = pt.GetGenericTypeDefinition(); - if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) - { - if (n == 0) - { - quotedArgs.Add(p.Name + ".Expression"); - } - else - { - quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); - } - add = true; - } - else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) - { - quotedArgs.Add(p.Name); - add = true; - } - } - - if (!add) - { - quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); - } + if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) + { + if (n == 0) + { + quotedArgs.Add(p.Name + ".Expression"); + } + else + { + quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); + } + add = true; + } + else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) + { + quotedArgs.Add(p.Name); + add = true; + } + } + + if (!add) + { + quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); + } - n++; - } + n++; + } - var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; + var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; - var infoofmtd = "InfoOf(() => AsyncQueryable." + name + "(" + quotedPars + "))"; - var infoofexpr = "Expression.Call(" + infoofmtd + ", " + string.Join(", ", quotedArgs) + ")"; + var infoofmtd = "InfoOf(() => AsyncQueryable." + name + "(" + quotedPars + "))"; + var infoofexpr = "Expression.Call(" + infoofmtd + ", " + string.Join(", ", quotedArgs) + ")"; #> - public static <#=ret#> <#=name#>(<#=pars#>) - { + public static <#=ret#> <#=name#>(<#=pars#>) + { <# var any = false; foreach (var p in m.GetParameters()) { - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) - { - any = true; + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + { + any = true; #> - if (<#=p.Name#> == null) - throw new ArgumentNullException("<#=p.Name#>"); + if (<#=p.Name#> == null) + throw new ArgumentNullException("<#=p.Name#>"); <# - } + } } #> <# @@ -264,14 +264,14 @@ if (any) } #> #if CRIPPLED_REFLECTION - return <#=cast#><#=provider#>.<#=factory#>(<#=infoofexpr#><#=rem#>); + return <#=cast#><#=provider#>.<#=factory#>(<#=infoofexpr#><#=rem#>); #else - return <#=cast#><#=provider#>.<#=factory#>(<#=expr#><#=rem#>); + return <#=cast#><#=provider#>.<#=factory#>(<#=expr#><#=rem#>); #endif - } + } <# } #> - } + } } \ No newline at end of file From dde0191568b317bebe23be1c633d3bcc252f877e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 23:20:09 -0700 Subject: [PATCH 150/862] Change codegen to use nameof. --- .../AsyncQueryable.Generated.cs | 2058 ++++++++--------- .../AsyncQueryable.Generated.tt | 2 +- 2 files changed, 1030 insertions(+), 1030 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs index 86c15d71f0..6698c80282 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs @@ -11,9 +11,9 @@ public static partial class AsyncQueryable public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); @@ -25,9 +25,9 @@ public static Task Aggregate(this IAsyncQueryable sou public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); @@ -39,9 +39,9 @@ public static Task Aggregate(this IAsyncQueryable sou public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -53,9 +53,9 @@ public static Task Aggregate(this IAsyncQueryable sou public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -67,9 +67,9 @@ public static Task Aggregate(this IAsyncQueryable sou public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); @@ -81,9 +81,9 @@ public static Task Aggregate(this IAsyncQuery public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); @@ -95,9 +95,9 @@ public static Task Aggregate(this IAsyncQuery public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -109,9 +109,9 @@ public static Task Aggregate(this IAsyncQuery public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -123,11 +123,11 @@ public static Task Aggregate(this IAsyncQuery public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); @@ -139,11 +139,11 @@ public static Task Aggregate(this IAsync public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); @@ -155,11 +155,11 @@ public static Task Aggregate(this IAsync public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -171,11 +171,11 @@ public static Task Aggregate(this IAsync public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -187,9 +187,9 @@ public static Task Aggregate(this IAsync public static Task All(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -201,9 +201,9 @@ public static Task All(this IAsyncQueryable source, Expr public static Task All(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -215,9 +215,9 @@ public static Task All(this IAsyncQueryable source, Expr public static Task All(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -229,9 +229,9 @@ public static Task All(this IAsyncQueryable source, Expr public static Task All(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -243,7 +243,7 @@ public static Task All(this IAsyncQueryable source, Expr public static Task Any(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -255,9 +255,9 @@ public static Task Any(this IAsyncQueryable source) public static Task Any(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -269,9 +269,9 @@ public static Task Any(this IAsyncQueryable source, Expr public static Task Any(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -283,7 +283,7 @@ public static Task Any(this IAsyncQueryable source, Expr public static Task Any(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -295,9 +295,9 @@ public static Task Any(this IAsyncQueryable source, Canc public static Task Any(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -309,9 +309,9 @@ public static Task Any(this IAsyncQueryable source, Expr public static Task Any(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -323,7 +323,7 @@ public static Task Any(this IAsyncQueryable source, Expr public static IAsyncQueryable Append(this IAsyncQueryable source, TSource element) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Append(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); @@ -335,7 +335,7 @@ public static IAsyncQueryable Append(this IAsyncQueryable Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -347,7 +347,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -359,7 +359,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -371,7 +371,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -383,7 +383,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -395,7 +395,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -407,7 +407,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -419,7 +419,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -431,7 +431,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -443,7 +443,7 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -455,9 +455,9 @@ public static Task Average(this IAsyncQueryable source) public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -469,7 +469,7 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -481,9 +481,9 @@ public static Task Average(this IAsyncQueryable source, Cancellati public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -495,9 +495,9 @@ public static Task Average(this IAsyncQueryable source, public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -509,7 +509,7 @@ public static Task Average(this IAsyncQueryable source, public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -521,9 +521,9 @@ public static Task Average(this IAsyncQueryable source, Cancella public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -535,9 +535,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -549,7 +549,7 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -561,9 +561,9 @@ public static Task Average(this IAsyncQueryable source, Cancel public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -575,9 +575,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -589,7 +589,7 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -601,9 +601,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -615,9 +615,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -629,7 +629,7 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -641,9 +641,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -655,9 +655,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -669,7 +669,7 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -681,9 +681,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -695,9 +695,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -709,7 +709,7 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -721,9 +721,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -735,9 +735,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -749,7 +749,7 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -761,9 +761,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -775,9 +775,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -789,7 +789,7 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -801,9 +801,9 @@ public static Task Average(this IAsyncQueryable source, Cancellatio public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -815,9 +815,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -829,7 +829,7 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -841,9 +841,9 @@ public static Task Average(this IAsyncQueryable source, Cancellati public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -855,9 +855,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -869,9 +869,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -883,9 +883,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -897,9 +897,9 @@ public static Task Average(this IAsyncQueryable source, public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -911,9 +911,9 @@ public static Task Average(this IAsyncQueryable source, public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -925,9 +925,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -939,9 +939,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -953,9 +953,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -967,9 +967,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -981,9 +981,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -995,9 +995,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1009,9 +1009,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1023,9 +1023,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1037,9 +1037,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1051,9 +1051,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1065,9 +1065,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1079,9 +1079,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1093,9 +1093,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1107,9 +1107,9 @@ public static Task Average(this IAsyncQueryable sourc public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1121,9 +1121,9 @@ public static Task Average(this IAsyncQueryable source public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1135,7 +1135,7 @@ public static Task Average(this IAsyncQueryable source public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); @@ -1147,7 +1147,7 @@ public static IAsyncQueryable> Buffer(this IAsyncQueryab public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count, int skip) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int), default(int))), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); @@ -1159,7 +1159,7 @@ public static IAsyncQueryable> Buffer(this IAsyncQueryab public static IAsyncQueryable Cast(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Cast(default(IAsyncQueryable))), source.Expression)); @@ -1171,9 +1171,9 @@ public static IAsyncQueryable Cast(this IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); @@ -1185,9 +1185,9 @@ public static IAsyncQueryable Catch(this IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (handler == null) - throw new ArgumentNullException("handler"); + throw new ArgumentNullException(nameof(handler)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(Expression>>))), source.Expression, handler)); @@ -1199,9 +1199,9 @@ public static IAsyncQueryable Catch(this IAsyncQue public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (handler == null) - throw new ArgumentNullException("handler"); + throw new ArgumentNullException(nameof(handler)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); @@ -1213,9 +1213,9 @@ public static IAsyncQueryable Catch(this IAsyncQue public static IAsyncQueryable Concat(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Concat(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); @@ -1227,7 +1227,7 @@ public static IAsyncQueryable Concat(this IAsyncQueryable Contains(this IAsyncQueryable source, TSource value) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); @@ -1239,9 +1239,9 @@ public static Task Contains(this IAsyncQueryable source, public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -1253,7 +1253,7 @@ public static Task Contains(this IAsyncQueryable source, public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1265,9 +1265,9 @@ public static Task Contains(this IAsyncQueryable source, public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1279,7 +1279,7 @@ public static Task Contains(this IAsyncQueryable source, public static Task Count(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -1291,7 +1291,7 @@ public static Task Count(this IAsyncQueryable source) public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1303,9 +1303,9 @@ public static Task Count(this IAsyncQueryable source, Can public static Task Count(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -1317,9 +1317,9 @@ public static Task Count(this IAsyncQueryable source, Exp public static Task Count(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -1331,9 +1331,9 @@ public static Task Count(this IAsyncQueryable source, Exp public static Task Count(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1345,9 +1345,9 @@ public static Task Count(this IAsyncQueryable source, Exp public static Task Count(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1359,7 +1359,7 @@ public static Task Count(this IAsyncQueryable source, Exp public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable))), source.Expression)); @@ -1371,7 +1371,7 @@ public static IAsyncQueryable DefaultIfEmpty(this IAsyncQuerya public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source, TSource defaultValue) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); @@ -1383,7 +1383,7 @@ public static IAsyncQueryable DefaultIfEmpty(this IAsyncQuerya public static IAsyncQueryable Distinct(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable))), source.Expression)); @@ -1395,9 +1395,9 @@ public static IAsyncQueryable Distinct(this IAsyncQueryable Distinct(this IAsyncQueryable source, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1409,9 +1409,9 @@ public static IAsyncQueryable Distinct(this IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); @@ -1423,9 +1423,9 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); @@ -1437,11 +1437,11 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1453,11 +1453,11 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1469,7 +1469,7 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable))), source.Expression)); @@ -1481,9 +1481,9 @@ public static IAsyncQueryable DistinctUntilChanged(this IAsync public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1495,9 +1495,9 @@ public static IAsyncQueryable DistinctUntilChanged(this IAsync public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); @@ -1509,9 +1509,9 @@ public static IAsyncQueryable DistinctUntilChanged(this public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); @@ -1523,11 +1523,11 @@ public static IAsyncQueryable DistinctUntilChanged(this public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1539,11 +1539,11 @@ public static IAsyncQueryable DistinctUntilChanged(this public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1555,9 +1555,9 @@ public static IAsyncQueryable DistinctUntilChanged(this public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (observer == null) - throw new ArgumentNullException("observer"); + throw new ArgumentNullException(nameof(observer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); @@ -1569,9 +1569,9 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); @@ -1583,9 +1583,9 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); @@ -1597,11 +1597,11 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); if (onCompleted == null) - throw new ArgumentNullException("onCompleted"); + throw new ArgumentNullException(nameof(onCompleted)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); @@ -1613,11 +1613,11 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); if (onError == null) - throw new ArgumentNullException("onError"); + throw new ArgumentNullException(nameof(onError)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); @@ -1629,11 +1629,11 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); if (onCompleted == null) - throw new ArgumentNullException("onCompleted"); + throw new ArgumentNullException(nameof(onCompleted)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); @@ -1645,11 +1645,11 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); if (onError == null) - throw new ArgumentNullException("onError"); + throw new ArgumentNullException(nameof(onError)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); @@ -1661,13 +1661,13 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); if (onError == null) - throw new ArgumentNullException("onError"); + throw new ArgumentNullException(nameof(onError)); if (onCompleted == null) - throw new ArgumentNullException("onCompleted"); + throw new ArgumentNullException(nameof(onCompleted)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); @@ -1679,13 +1679,13 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Action onCompleted) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (onNext == null) - throw new ArgumentNullException("onNext"); + throw new ArgumentNullException(nameof(onNext)); if (onError == null) - throw new ArgumentNullException("onError"); + throw new ArgumentNullException(nameof(onError)); if (onCompleted == null) - throw new ArgumentNullException("onCompleted"); + throw new ArgumentNullException(nameof(onCompleted)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Action))), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); @@ -1697,7 +1697,7 @@ public static IAsyncQueryable Do(this IAsyncQueryable public static Task ElementAt(this IAsyncQueryable source, int index) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); @@ -1709,7 +1709,7 @@ public static Task ElementAt(this IAsyncQueryable sou public static Task ElementAt(this IAsyncQueryable source, int index, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1721,7 +1721,7 @@ public static Task ElementAt(this IAsyncQueryable sou public static Task ElementAtOrDefault(this IAsyncQueryable source, int index) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); @@ -1733,7 +1733,7 @@ public static Task ElementAtOrDefault(this IAsyncQueryable ElementAtOrDefault(this IAsyncQueryable source, int index, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1745,9 +1745,9 @@ public static Task ElementAtOrDefault(this IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); @@ -1759,11 +1759,11 @@ public static IAsyncQueryable Except(this IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1775,9 +1775,9 @@ public static IAsyncQueryable Except(this IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Expand(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); @@ -1789,9 +1789,9 @@ public static IAsyncQueryable Expand(this IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); @@ -1803,9 +1803,9 @@ public static IAsyncQueryable Expand(this IAsyncQueryable Finally(this IAsyncQueryable source, Action finallyAction) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (finallyAction == null) - throw new ArgumentNullException("finallyAction"); + throw new ArgumentNullException(nameof(finallyAction)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Finally(default(IAsyncQueryable), default(Action))), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); @@ -1817,9 +1817,9 @@ public static IAsyncQueryable Finally(this IAsyncQueryable Finally(this IAsyncQueryable source, Expression> finallyAction) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (finallyAction == null) - throw new ArgumentNullException("finallyAction"); + throw new ArgumentNullException(nameof(finallyAction)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Finally(default(IAsyncQueryable), default(Expression>))), source.Expression, finallyAction)); @@ -1831,7 +1831,7 @@ public static IAsyncQueryable Finally(this IAsyncQueryable First(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -1843,7 +1843,7 @@ public static Task First(this IAsyncQueryable source) public static Task First(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1855,9 +1855,9 @@ public static Task First(this IAsyncQueryable source, public static Task First(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -1869,9 +1869,9 @@ public static Task First(this IAsyncQueryable source, public static Task First(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -1883,9 +1883,9 @@ public static Task First(this IAsyncQueryable source, public static Task First(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1897,9 +1897,9 @@ public static Task First(this IAsyncQueryable source, public static Task First(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1911,7 +1911,7 @@ public static Task First(this IAsyncQueryable source, public static Task FirstOrDefault(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -1923,7 +1923,7 @@ public static Task FirstOrDefault(this IAsyncQueryable FirstOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1935,9 +1935,9 @@ public static Task FirstOrDefault(this IAsyncQueryable FirstOrDefault(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -1949,9 +1949,9 @@ public static Task FirstOrDefault(this IAsyncQueryable FirstOrDefault(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -1963,9 +1963,9 @@ public static Task FirstOrDefault(this IAsyncQueryable FirstOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1977,9 +1977,9 @@ public static Task FirstOrDefault(this IAsyncQueryable FirstOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1991,9 +1991,9 @@ public static Task FirstOrDefault(this IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); @@ -2005,9 +2005,9 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); @@ -2019,11 +2019,11 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2035,11 +2035,11 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); @@ -2051,11 +2051,11 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); @@ -2067,11 +2067,11 @@ public static IAsyncQueryable> GroupBy GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); @@ -2083,11 +2083,11 @@ public static IAsyncQueryable GroupBy(this IAsy public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); @@ -2099,11 +2099,11 @@ public static IAsyncQueryable GroupBy(this IAsy public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2115,13 +2115,13 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2133,13 +2133,13 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2151,13 +2151,13 @@ public static IAsyncQueryable> GroupBy GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2169,13 +2169,13 @@ public static IAsyncQueryable GroupBy(this IAsy public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2187,13 +2187,13 @@ public static IAsyncQueryable GroupBy(this IAsy public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); @@ -2205,13 +2205,13 @@ public static IAsyncQueryable GroupBy public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, elementSelector, resultSelector)); @@ -2223,15 +2223,15 @@ public static IAsyncQueryable GroupBy public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2243,15 +2243,15 @@ public static IAsyncQueryable GroupBy public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2263,15 +2263,15 @@ public static IAsyncQueryable GroupBy public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); @@ -2283,15 +2283,15 @@ public static IAsyncQueryable GroupJoin( public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); @@ -2303,17 +2303,17 @@ public static IAsyncQueryable GroupJoin( public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2325,17 +2325,17 @@ public static IAsyncQueryable GroupJoin( public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2347,7 +2347,7 @@ public static IAsyncQueryable GroupJoin( public static IAsyncQueryable IgnoreElements(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.IgnoreElements(default(IAsyncQueryable))), source.Expression)); @@ -2359,9 +2359,9 @@ public static IAsyncQueryable IgnoreElements(this IAsyncQuerya public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); @@ -2373,11 +2373,11 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2389,7 +2389,7 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable IsEmpty(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2401,7 +2401,7 @@ public static Task IsEmpty(this IAsyncQueryable source) public static Task IsEmpty(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2413,15 +2413,15 @@ public static Task IsEmpty(this IAsyncQueryable source, public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); @@ -2433,15 +2433,15 @@ public static IAsyncQueryable Join(this public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); @@ -2453,17 +2453,17 @@ public static IAsyncQueryable Join(this public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2475,17 +2475,17 @@ public static IAsyncQueryable Join(this public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException("outer"); + throw new ArgumentNullException(nameof(outer)); if (inner == null) - throw new ArgumentNullException("inner"); + throw new ArgumentNullException(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException("outerKeySelector"); + throw new ArgumentNullException(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException("innerKeySelector"); + throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2497,7 +2497,7 @@ public static IAsyncQueryable Join(this public static Task Last(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2509,7 +2509,7 @@ public static Task Last(this IAsyncQueryable source) public static Task Last(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2521,9 +2521,9 @@ public static Task Last(this IAsyncQueryable source, public static Task Last(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -2535,9 +2535,9 @@ public static Task Last(this IAsyncQueryable source, public static Task Last(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -2549,9 +2549,9 @@ public static Task Last(this IAsyncQueryable source, public static Task Last(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2563,9 +2563,9 @@ public static Task Last(this IAsyncQueryable source, public static Task Last(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2577,7 +2577,7 @@ public static Task Last(this IAsyncQueryable source, public static Task LastOrDefault(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2589,7 +2589,7 @@ public static Task LastOrDefault(this IAsyncQueryable public static Task LastOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2601,9 +2601,9 @@ public static Task LastOrDefault(this IAsyncQueryable public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -2615,9 +2615,9 @@ public static Task LastOrDefault(this IAsyncQueryable public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -2629,9 +2629,9 @@ public static Task LastOrDefault(this IAsyncQueryable public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2643,9 +2643,9 @@ public static Task LastOrDefault(this IAsyncQueryable public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2657,7 +2657,7 @@ public static Task LastOrDefault(this IAsyncQueryable public static Task LongCount(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2669,7 +2669,7 @@ public static Task LongCount(this IAsyncQueryable source public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2681,9 +2681,9 @@ public static Task LongCount(this IAsyncQueryable source public static Task LongCount(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -2695,9 +2695,9 @@ public static Task LongCount(this IAsyncQueryable source public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -2709,9 +2709,9 @@ public static Task LongCount(this IAsyncQueryable source public static Task LongCount(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2723,9 +2723,9 @@ public static Task LongCount(this IAsyncQueryable source public static Task LongCount(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2737,7 +2737,7 @@ public static Task LongCount(this IAsyncQueryable source public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2749,7 +2749,7 @@ public static Task LongCount(this IAsyncQueryable source public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2761,7 +2761,7 @@ public static Task LongCount(this IAsyncQueryable source public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2773,7 +2773,7 @@ public static Task LongCount(this IAsyncQueryable source public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2785,7 +2785,7 @@ public static Task LongCount(this IAsyncQueryable source public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2797,7 +2797,7 @@ public static Task LongCount(this IAsyncQueryable source public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2809,7 +2809,7 @@ public static Task Max(this IAsyncQueryable source) public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2821,7 +2821,7 @@ public static Task Max(this IAsyncQueryable source) public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2833,7 +2833,7 @@ public static Task Max(this IAsyncQueryable source) public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2845,7 +2845,7 @@ public static Task Max(this IAsyncQueryable source) public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2857,7 +2857,7 @@ public static Task Max(this IAsyncQueryable source) public static Task Max(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -2869,9 +2869,9 @@ public static Task Max(this IAsyncQueryable source) public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -2883,7 +2883,7 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2895,9 +2895,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -2909,9 +2909,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -2923,7 +2923,7 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2935,9 +2935,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -2949,9 +2949,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -2963,7 +2963,7 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -2975,9 +2975,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -2989,9 +2989,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3003,7 +3003,7 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3015,9 +3015,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3029,9 +3029,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3043,7 +3043,7 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3055,9 +3055,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3069,9 +3069,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3083,7 +3083,7 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3095,9 +3095,9 @@ public static Task Max(this IAsyncQueryable source, CancellationToken public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3109,9 +3109,9 @@ public static Task Max(this IAsyncQueryable source, Expre public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3123,7 +3123,7 @@ public static Task Max(this IAsyncQueryable source, Expre public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3135,9 +3135,9 @@ public static Task Max(this IAsyncQueryable source, CancellationToke public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3149,9 +3149,9 @@ public static Task Max(this IAsyncQueryable source, Expr public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3163,7 +3163,7 @@ public static Task Max(this IAsyncQueryable source, Expr public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3175,9 +3175,9 @@ public static Task Max(this IAsyncQueryable source, CancellationTo public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3189,9 +3189,9 @@ public static Task Max(this IAsyncQueryable source, Exp public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3203,7 +3203,7 @@ public static Task Max(this IAsyncQueryable source, Exp public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3215,9 +3215,9 @@ public static Task Max(this IAsyncQueryable source, Cancellation public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3229,9 +3229,9 @@ public static Task Max(this IAsyncQueryable source, Ex public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3243,7 +3243,7 @@ public static Task Max(this IAsyncQueryable source, Ex public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3255,9 +3255,9 @@ public static Task Max(this IAsyncQueryable source, Cancellati public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3269,7 +3269,7 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3281,9 +3281,9 @@ public static Task Max(this IAsyncQueryable source, C public static Task Max(this IAsyncQueryable source, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -3295,9 +3295,9 @@ public static Task Max(this IAsyncQueryable source, I public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3309,9 +3309,9 @@ public static Task Max(this IAsyncQueryable public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3323,9 +3323,9 @@ public static Task Max(this IAsyncQueryable public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3337,9 +3337,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3351,9 +3351,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3365,9 +3365,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3379,9 +3379,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3393,9 +3393,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3407,9 +3407,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3421,9 +3421,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3435,9 +3435,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3449,9 +3449,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3463,9 +3463,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3477,9 +3477,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3491,9 +3491,9 @@ public static Task Max(this IAsyncQueryable source, Expre public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3505,9 +3505,9 @@ public static Task Max(this IAsyncQueryable source, Expre public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3519,9 +3519,9 @@ public static Task Max(this IAsyncQueryable source, Expr public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3533,9 +3533,9 @@ public static Task Max(this IAsyncQueryable source, Expr public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3547,9 +3547,9 @@ public static Task Max(this IAsyncQueryable source, Exp public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3561,9 +3561,9 @@ public static Task Max(this IAsyncQueryable source, Exp public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3575,9 +3575,9 @@ public static Task Max(this IAsyncQueryable source, Ex public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3589,9 +3589,9 @@ public static Task Max(this IAsyncQueryable source, Ex public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3603,9 +3603,9 @@ public static Task Max(this IAsyncQueryable source, E public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3617,9 +3617,9 @@ public static Task Max(this IAsyncQueryable source, I public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3631,9 +3631,9 @@ public static Task Max(this IAsyncQueryable public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3645,9 +3645,9 @@ public static Task Max(this IAsyncQueryable public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); @@ -3659,9 +3659,9 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); @@ -3673,9 +3673,9 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3687,11 +3687,11 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -3703,9 +3703,9 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3717,11 +3717,11 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -3733,11 +3733,11 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3749,11 +3749,11 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3765,7 +3765,7 @@ public static Task> MaxBy(this IAsyncQueryable Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3777,7 +3777,7 @@ public static Task> MaxBy(this IAsyncQueryable Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3789,7 +3789,7 @@ public static Task> MaxBy(this IAsyncQueryable Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3801,7 +3801,7 @@ public static Task> MaxBy(this IAsyncQueryable Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3813,7 +3813,7 @@ public static Task> MaxBy(this IAsyncQueryable Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3825,7 +3825,7 @@ public static Task> MaxBy(this IAsyncQueryable Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3837,7 +3837,7 @@ public static Task Min(this IAsyncQueryable source) public static Task Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3849,7 +3849,7 @@ public static Task Min(this IAsyncQueryable source) public static Task Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3861,7 +3861,7 @@ public static Task Min(this IAsyncQueryable source) public static Task Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3873,7 +3873,7 @@ public static Task Min(this IAsyncQueryable source) public static Task Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3885,7 +3885,7 @@ public static Task Min(this IAsyncQueryable source) public static Task Min(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -3897,9 +3897,9 @@ public static Task Min(this IAsyncQueryable source) public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3911,7 +3911,7 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3923,9 +3923,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3937,9 +3937,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3951,7 +3951,7 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -3963,9 +3963,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -3977,9 +3977,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -3991,7 +3991,7 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4003,9 +4003,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4017,9 +4017,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4031,7 +4031,7 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4043,9 +4043,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4057,9 +4057,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4071,7 +4071,7 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4083,9 +4083,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4097,9 +4097,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4111,7 +4111,7 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4123,9 +4123,9 @@ public static Task Min(this IAsyncQueryable source, CancellationToken public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4137,9 +4137,9 @@ public static Task Min(this IAsyncQueryable source, Expre public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4151,7 +4151,7 @@ public static Task Min(this IAsyncQueryable source, Expre public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4163,9 +4163,9 @@ public static Task Min(this IAsyncQueryable source, CancellationToke public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4177,9 +4177,9 @@ public static Task Min(this IAsyncQueryable source, Expr public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4191,7 +4191,7 @@ public static Task Min(this IAsyncQueryable source, Expr public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4203,9 +4203,9 @@ public static Task Min(this IAsyncQueryable source, CancellationTo public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4217,9 +4217,9 @@ public static Task Min(this IAsyncQueryable source, Exp public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4231,7 +4231,7 @@ public static Task Min(this IAsyncQueryable source, Exp public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4243,9 +4243,9 @@ public static Task Min(this IAsyncQueryable source, Cancellation public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4257,9 +4257,9 @@ public static Task Min(this IAsyncQueryable source, Ex public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4271,7 +4271,7 @@ public static Task Min(this IAsyncQueryable source, Ex public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4283,9 +4283,9 @@ public static Task Min(this IAsyncQueryable source, Cancellati public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4297,7 +4297,7 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4309,9 +4309,9 @@ public static Task Min(this IAsyncQueryable source, C public static Task Min(this IAsyncQueryable source, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -4323,9 +4323,9 @@ public static Task Min(this IAsyncQueryable source, I public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -4337,9 +4337,9 @@ public static Task Min(this IAsyncQueryable public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -4351,9 +4351,9 @@ public static Task Min(this IAsyncQueryable public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4365,9 +4365,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4379,9 +4379,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4393,9 +4393,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4407,9 +4407,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4421,9 +4421,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4435,9 +4435,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4449,9 +4449,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4463,9 +4463,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4477,9 +4477,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4491,9 +4491,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4505,9 +4505,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4519,9 +4519,9 @@ public static Task Min(this IAsyncQueryable source, E public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4533,9 +4533,9 @@ public static Task Min(this IAsyncQueryable source, Expre public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4547,9 +4547,9 @@ public static Task Min(this IAsyncQueryable source, Expre public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4561,9 +4561,9 @@ public static Task Min(this IAsyncQueryable source, Expr public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4575,9 +4575,9 @@ public static Task Min(this IAsyncQueryable source, Expr public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4589,9 +4589,9 @@ public static Task Min(this IAsyncQueryable source, Exp public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4603,9 +4603,9 @@ public static Task Min(this IAsyncQueryable source, Exp public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4617,9 +4617,9 @@ public static Task Min(this IAsyncQueryable source, Ex public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4631,9 +4631,9 @@ public static Task Min(this IAsyncQueryable source, Ex public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4645,9 +4645,9 @@ public static Task Min(this IAsyncQueryable source, I public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4659,9 +4659,9 @@ public static Task Min(this IAsyncQueryable public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4673,9 +4673,9 @@ public static Task Min(this IAsyncQueryable public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); @@ -4687,9 +4687,9 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); @@ -4701,9 +4701,9 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4715,11 +4715,11 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -4731,9 +4731,9 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4745,11 +4745,11 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -4761,11 +4761,11 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4777,11 +4777,11 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -4793,7 +4793,7 @@ public static Task> MinBy(this IAsyncQueryable OfType(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); @@ -4805,9 +4805,9 @@ public static IAsyncQueryable OfType(this IAsyncQueryable public static IAsyncQueryable OnErrorResumeNext(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OnErrorResumeNext(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); @@ -4819,9 +4819,9 @@ public static IAsyncQueryable OnErrorResumeNext(this IAsyncQue public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); @@ -4833,9 +4833,9 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); @@ -4847,11 +4847,11 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -4863,11 +4863,11 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -4879,9 +4879,9 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); @@ -4893,9 +4893,9 @@ public static IOrderedAsyncQueryable OrderByDescending(t public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); @@ -4907,11 +4907,11 @@ public static IOrderedAsyncQueryable OrderByDescending(t public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -4923,11 +4923,11 @@ public static IOrderedAsyncQueryable OrderByDescending(t public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -4939,7 +4939,7 @@ public static IOrderedAsyncQueryable OrderByDescending(t public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); @@ -4951,7 +4951,7 @@ public static IAsyncQueryable Prepend(this IAsyncQueryable Repeat(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable))), source.Expression)); @@ -4963,7 +4963,7 @@ public static IAsyncQueryable Repeat(this IAsyncQueryable Repeat(this IAsyncQueryable source, int count) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); @@ -4975,7 +4975,7 @@ public static IAsyncQueryable Repeat(this IAsyncQueryable Retry(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable))), source.Expression)); @@ -4987,7 +4987,7 @@ public static IAsyncQueryable Retry(this IAsyncQueryable Retry(this IAsyncQueryable source, int retryCount) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(retryCount, typeof(int)))); @@ -4999,7 +4999,7 @@ public static IAsyncQueryable Retry(this IAsyncQueryable Reverse(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); @@ -5011,9 +5011,9 @@ public static IAsyncQueryable Reverse(this IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); @@ -5025,9 +5025,9 @@ public static IAsyncQueryable Scan(this IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); @@ -5039,9 +5039,9 @@ public static IAsyncQueryable Scan(this IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); @@ -5053,9 +5053,9 @@ public static IAsyncQueryable Scan(this IAsyn public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (accumulator == null) - throw new ArgumentNullException("accumulator"); + throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); @@ -5067,9 +5067,9 @@ public static IAsyncQueryable Scan(this IAsyn public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); @@ -5081,9 +5081,9 @@ public static IAsyncQueryable Select(this IAsyncQuery public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); @@ -5095,9 +5095,9 @@ public static IAsyncQueryable Select(this IAsyncQuery public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); @@ -5109,9 +5109,9 @@ public static IAsyncQueryable Select(this IAsyncQuery public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); @@ -5123,9 +5123,9 @@ public static IAsyncQueryable Select(this IAsyncQuery public static IAsyncQueryable SelectMany(this IAsyncQueryable source, IAsyncEnumerable other) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (other == null) - throw new ArgumentNullException("other"); + throw new ArgumentNullException(nameof(other)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(IAsyncEnumerable))), source.Expression, GetSourceExpression(other))); @@ -5137,9 +5137,9 @@ public static IAsyncQueryable SelectMany(this IAsyncQue public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); @@ -5151,9 +5151,9 @@ public static IAsyncQueryable SelectMany(this IAsyncQ public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); @@ -5165,9 +5165,9 @@ public static IAsyncQueryable SelectMany(this IAsyncQ public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); @@ -5179,9 +5179,9 @@ public static IAsyncQueryable SelectMany(this IAsyncQ public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); @@ -5193,11 +5193,11 @@ public static IAsyncQueryable SelectMany(this IAsyncQ public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); @@ -5209,11 +5209,11 @@ public static IAsyncQueryable SelectMany public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); @@ -5225,11 +5225,11 @@ public static IAsyncQueryable SelectMany public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); @@ -5241,11 +5241,11 @@ public static IAsyncQueryable SelectMany public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException("resultSelector"); + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); @@ -5257,9 +5257,9 @@ public static IAsyncQueryable SelectMany public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second)), CancellationToken.None); @@ -5271,11 +5271,11 @@ public static Task SequenceEqual(this IAsyncQueryable fi public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -5287,9 +5287,9 @@ public static Task SequenceEqual(this IAsyncQueryable fi public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5301,11 +5301,11 @@ public static Task SequenceEqual(this IAsyncQueryable fi public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5317,7 +5317,7 @@ public static Task SequenceEqual(this IAsyncQueryable fi public static Task Single(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5329,7 +5329,7 @@ public static Task Single(this IAsyncQueryable source public static Task Single(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5341,9 +5341,9 @@ public static Task Single(this IAsyncQueryable source public static Task Single(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -5355,9 +5355,9 @@ public static Task Single(this IAsyncQueryable source public static Task Single(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -5369,9 +5369,9 @@ public static Task Single(this IAsyncQueryable source public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5383,9 +5383,9 @@ public static Task Single(this IAsyncQueryable source public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5397,7 +5397,7 @@ public static Task Single(this IAsyncQueryable source public static Task SingleOrDefault(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5409,7 +5409,7 @@ public static Task SingleOrDefault(this IAsyncQueryable SingleOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5421,9 +5421,9 @@ public static Task SingleOrDefault(this IAsyncQueryable SingleOrDefault(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); @@ -5435,9 +5435,9 @@ public static Task SingleOrDefault(this IAsyncQueryable SingleOrDefault(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); @@ -5449,9 +5449,9 @@ public static Task SingleOrDefault(this IAsyncQueryable SingleOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5463,9 +5463,9 @@ public static Task SingleOrDefault(this IAsyncQueryable SingleOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5477,7 +5477,7 @@ public static Task SingleOrDefault(this IAsyncQueryable Skip(this IAsyncQueryable source, int count) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Skip(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); @@ -5489,7 +5489,7 @@ public static IAsyncQueryable Skip(this IAsyncQueryable SkipLast(this IAsyncQueryable source, int count) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); @@ -5501,9 +5501,9 @@ public static IAsyncQueryable SkipLast(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); @@ -5515,9 +5515,9 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); @@ -5529,9 +5529,9 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); @@ -5543,9 +5543,9 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); @@ -5557,9 +5557,9 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable StartWith(this IAsyncQueryable source, params TSource[] values) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (values == null) - throw new ArgumentNullException("values"); + throw new ArgumentNullException(nameof(values)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.StartWith(default(IAsyncQueryable), default(TSource[]))), source.Expression, Expression.Constant(values, typeof(TSource[])))); @@ -5571,7 +5571,7 @@ public static IAsyncQueryable StartWith(this IAsyncQueryable Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5583,7 +5583,7 @@ public static IAsyncQueryable StartWith(this IAsyncQueryable Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5595,7 +5595,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5607,7 +5607,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5619,7 +5619,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5631,7 +5631,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5643,7 +5643,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5655,7 +5655,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5667,7 +5667,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5679,7 +5679,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -5691,7 +5691,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5703,9 +5703,9 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5717,9 +5717,9 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -5731,7 +5731,7 @@ public static Task Sum(this IAsyncQueryable source) public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5743,9 +5743,9 @@ public static Task Sum(this IAsyncQueryable source, CancellationToken public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5757,9 +5757,9 @@ public static Task Sum(this IAsyncQueryable source, Expre public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -5771,7 +5771,7 @@ public static Task Sum(this IAsyncQueryable source, Expre public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5783,9 +5783,9 @@ public static Task Sum(this IAsyncQueryable source, CancellationToke public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5797,9 +5797,9 @@ public static Task Sum(this IAsyncQueryable source, Expr public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -5811,7 +5811,7 @@ public static Task Sum(this IAsyncQueryable source, Expr public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5823,9 +5823,9 @@ public static Task Sum(this IAsyncQueryable source, CancellationTo public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5837,9 +5837,9 @@ public static Task Sum(this IAsyncQueryable source, Exp public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -5851,7 +5851,7 @@ public static Task Sum(this IAsyncQueryable source, Exp public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5863,9 +5863,9 @@ public static Task Sum(this IAsyncQueryable source, Cancellation public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5877,9 +5877,9 @@ public static Task Sum(this IAsyncQueryable source, Ex public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -5891,7 +5891,7 @@ public static Task Sum(this IAsyncQueryable source, Ex public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5903,9 +5903,9 @@ public static Task Sum(this IAsyncQueryable source, Cancellati public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5917,9 +5917,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -5931,7 +5931,7 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5943,9 +5943,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5957,9 +5957,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -5971,7 +5971,7 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -5983,9 +5983,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -5997,9 +5997,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -6011,7 +6011,7 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6023,9 +6023,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -6037,9 +6037,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -6051,7 +6051,7 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6063,9 +6063,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); @@ -6077,9 +6077,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); @@ -6091,9 +6091,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6105,9 +6105,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6119,9 +6119,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6133,9 +6133,9 @@ public static Task Sum(this IAsyncQueryable source, Expre public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6147,9 +6147,9 @@ public static Task Sum(this IAsyncQueryable source, Expre public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6161,9 +6161,9 @@ public static Task Sum(this IAsyncQueryable source, Expr public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6175,9 +6175,9 @@ public static Task Sum(this IAsyncQueryable source, Expr public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6189,9 +6189,9 @@ public static Task Sum(this IAsyncQueryable source, Exp public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6203,9 +6203,9 @@ public static Task Sum(this IAsyncQueryable source, Exp public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6217,9 +6217,9 @@ public static Task Sum(this IAsyncQueryable source, Ex public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6231,9 +6231,9 @@ public static Task Sum(this IAsyncQueryable source, Ex public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6245,9 +6245,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6259,9 +6259,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6273,9 +6273,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6287,9 +6287,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6301,9 +6301,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6315,9 +6315,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6329,9 +6329,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6343,9 +6343,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6357,9 +6357,9 @@ public static Task Sum(this IAsyncQueryable source, E public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6371,7 +6371,7 @@ public static Task Sum(this IAsyncQueryable source, E public static IAsyncQueryable Take(this IAsyncQueryable source, int count) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Take(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); @@ -6383,7 +6383,7 @@ public static IAsyncQueryable Take(this IAsyncQueryable TakeLast(this IAsyncQueryable source, int count) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); @@ -6395,9 +6395,9 @@ public static IAsyncQueryable TakeLast(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); @@ -6409,9 +6409,9 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); @@ -6423,9 +6423,9 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); @@ -6437,9 +6437,9 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); @@ -6451,9 +6451,9 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); @@ -6465,9 +6465,9 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); @@ -6479,11 +6479,11 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6495,11 +6495,11 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6511,9 +6511,9 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); @@ -6525,9 +6525,9 @@ public static IOrderedAsyncQueryable ThenByDescending(th public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); @@ -6539,11 +6539,11 @@ public static IOrderedAsyncQueryable ThenByDescending(th public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6555,11 +6555,11 @@ public static IOrderedAsyncQueryable ThenByDescending(th public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6571,7 +6571,7 @@ public static IOrderedAsyncQueryable ThenByDescending(th public static Task ToArray(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -6583,7 +6583,7 @@ public static Task ToArray(this IAsyncQueryable sou public static Task ToArray(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6595,9 +6595,9 @@ public static Task ToArray(this IAsyncQueryable sou public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); @@ -6609,9 +6609,9 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); @@ -6623,9 +6623,9 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6637,9 +6637,9 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6651,11 +6651,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -6667,11 +6667,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -6683,11 +6683,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); @@ -6699,11 +6699,11 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); @@ -6715,11 +6715,11 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6731,11 +6731,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6747,11 +6747,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6763,11 +6763,11 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6779,13 +6779,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -6797,13 +6797,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -6815,13 +6815,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6833,13 +6833,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6851,7 +6851,7 @@ public static Task> ToDictionary> ToList(this IAsyncQueryable source) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable))), source.Expression), CancellationToken.None); @@ -6863,7 +6863,7 @@ public static Task> ToList(this IAsyncQueryable public static Task> ToList(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6875,9 +6875,9 @@ public static Task> ToList(this IAsyncQueryable public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); @@ -6889,9 +6889,9 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); @@ -6903,9 +6903,9 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6917,9 +6917,9 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6931,11 +6931,11 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -6947,11 +6947,11 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -6963,11 +6963,11 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); @@ -6979,11 +6979,11 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); @@ -6995,11 +6995,11 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7011,11 +7011,11 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7027,11 +7027,11 @@ public static Task> ToLookup(this IAsyncQu public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7043,11 +7043,11 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7059,13 +7059,13 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7077,13 +7077,13 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7095,13 +7095,13 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7113,13 +7113,13 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (keySelector == null) - throw new ArgumentNullException("keySelector"); + throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException("elementSelector"); + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7131,9 +7131,9 @@ public static Task> ToLookup(th public static IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); @@ -7145,11 +7145,11 @@ public static IAsyncQueryable Union(this IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); if (comparer == null) - throw new ArgumentNullException("comparer"); + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -7161,9 +7161,9 @@ public static IAsyncQueryable Union(this IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); @@ -7175,9 +7175,9 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); @@ -7189,9 +7189,9 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); @@ -7203,9 +7203,9 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (predicate == null) - throw new ArgumentNullException("predicate"); + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); @@ -7217,11 +7217,11 @@ public static IAsyncQueryable Where(this IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); @@ -7233,11 +7233,11 @@ public static IAsyncQueryable Zip(this IAsync public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) { if (first == null) - throw new ArgumentNullException("first"); + throw new ArgumentNullException(nameof(first)); if (second == null) - throw new ArgumentNullException("second"); + throw new ArgumentNullException(nameof(second)); if (selector == null) - throw new ArgumentNullException("selector"); + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt index a1cace1998..08ab8254b8 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt @@ -250,7 +250,7 @@ foreach (var p in m.GetParameters()) any = true; #> if (<#=p.Name#> == null) - throw new ArgumentNullException("<#=p.Name#>"); + throw new ArgumentNullException(nameof(<#=p.Name#>)); <# } } From a3010b7976e783ebc7e7ecefb5be43da5f9009ae Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 23:20:42 -0700 Subject: [PATCH 151/862] Adding missing copyright header. --- .../AsyncQueryable.Generated.cs | 6 +++++- .../AsyncQueryable.Generated.tt | 6 +++++- .../System.Interactive.Async.Providers/AsyncQueryable.cs | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs index 6698c80282..d6954d637d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs @@ -1,4 +1,8 @@ -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Threading; diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt index 08ab8254b8..5fbe407323 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt @@ -1,4 +1,8 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> <#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net45\System.Interactive.Async.dll" #> <#@ import namespace="System.Linq" #> diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs index 7e2a6fe4cb..a44be82fdf 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; From 918d90755adc082763ec0da09a78689f273ccc10 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 23:22:58 -0700 Subject: [PATCH 152/862] Some more code cosmetics. --- .../AsyncEnumerableExecutor.cs | 1 + .../AsyncEnumerableQuery.cs | 1 + .../AsyncEnumerableRewriter.cs | 1 + .../Source/System.Interactive.Async.Providers/Reflection.cs | 5 +++++ 4 files changed, 8 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableExecutor.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableExecutor.cs index e3bf8613fc..6d9231ad97 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableExecutor.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableExecutor.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs index d58722353d..53662fafae 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Collections.Generic; using System.Linq.Expressions; using System.Threading; diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs index 8adc327003..5389d10e34 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs b/Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs index 2de51092e5..70b0599d3d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs @@ -1,7 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + #if CRIPPLED_REFLECTION + using System.Linq; using System.Reflection; @@ -83,7 +85,9 @@ private static bool IsVisible(MethodInfo method, BindingFlags flags) } } } + #else + namespace System { static class TypeExtensions @@ -109,4 +113,5 @@ public static Type GetBaseType(this Type t) } } } + #endif From a70c81c7ce96f42ed0c5714e8dbd767b6e13fdee Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Aug 2017 23:37:55 -0700 Subject: [PATCH 153/862] Refactoring AsyncQueryable surface. --- .../System.Interactive.Async.Providers.csproj | 4 +- .../System/Linq/AsyncQueryableEx.Generated.cs | 800 ++ .../System/Linq/AsyncQueryableEx.Generated.tt | 282 + .../System/Linq/AsyncQueryableEx.cs | 31 + .../AsyncQueryableExTests.Generated.cs | 608 ++ .../AsyncQueryableExTests.Generated.tt | 475 + .../AsyncQueryableTests.Generated.cs | 8062 ++++++++++------- .../AsyncQueryableTests.Generated.tt | 732 +- .../System.Interactive.Async.Tests.csproj | 22 +- .../System.Linq.Async.Queryable/Reflection.cs | 117 + .../System.Linq.Async.Queryable.csproj | 15 + .../System/Linq}/AsyncEnumerableExecutor.cs | 0 .../System/Linq}/AsyncEnumerableQuery.cs | 0 .../System/Linq}/AsyncEnumerableRewriter.cs | 0 .../System/Linq}/AsyncQueryable.Generated.cs | 2008 ++-- .../System/Linq}/AsyncQueryable.Generated.tt | 2 +- .../System/Linq}/AsyncQueryable.cs | 0 17 files changed, 8010 insertions(+), 5148 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs create mode 100644 Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt create mode 100644 Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/AsyncEnumerableExecutor.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/AsyncEnumerableQuery.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/AsyncEnumerableRewriter.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/AsyncQueryable.Generated.cs (89%) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/AsyncQueryable.Generated.tt (98%) rename Ix.NET/Source/{System.Interactive.Async.Providers => System.Linq.Async.Queryable/System/Linq}/AsyncQueryable.cs (100%) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index 729daab5db..c4822ce77a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -21,8 +21,8 @@ - - + + diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs new file mode 100644 index 0000000000..e462ea3295 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -0,0 +1,800 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncQueryableEx + { + public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryableEx.Buffer(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); +#endif + } + + public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count, int skip) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryableEx.Buffer(default(IAsyncQueryable), default(int), default(int))), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); +#endif + } + + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (handler == null) + throw new ArgumentNullException(nameof(handler)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>))), source.Expression, handler)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); +#endif + } + + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (handler == null) + throw new ArgumentNullException(nameof(handler)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); +#endif + } + + public static IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); +#endif + } + + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); +#endif + } + + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (observer == null) + throw new ArgumentNullException(nameof(observer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Action onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Action))), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); +#endif + } + + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable Finally(this IAsyncQueryable source, Action finallyAction) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (finallyAction == null) + throw new ArgumentNullException(nameof(finallyAction)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Finally(default(IAsyncQueryable), default(Action))), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); +#endif + } + + public static IAsyncQueryable Finally(this IAsyncQueryable source, Expression> finallyAction) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (finallyAction == null) + throw new ArgumentNullException(nameof(finallyAction)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Finally(default(IAsyncQueryable), default(Expression>))), source.Expression, finallyAction)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, finallyAction)); +#endif + } + + public static IAsyncQueryable IgnoreElements(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.IgnoreElements(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static IAsyncQueryable OnErrorResumeNext(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.OnErrorResumeNext(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); +#endif + } + + public static IAsyncQueryable Retry(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Retry(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); +#endif + } + + public static IAsyncQueryable Retry(this IAsyncQueryable source, int retryCount) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Retry(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(retryCount, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int)))); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#endif + } + + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#endif + } + + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, IAsyncEnumerable other) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (other == null) + throw new ArgumentNullException(nameof(other)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.SelectMany(default(IAsyncQueryable), default(IAsyncEnumerable))), source.Expression, GetSourceExpression(other))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other))); +#endif + } + + public static IAsyncQueryable StartWith(this IAsyncQueryable source, params TSource[] values) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (values == null) + throw new ArgumentNullException(nameof(values)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.StartWith(default(IAsyncQueryable), default(TSource[]))), source.Expression, Expression.Constant(values, typeof(TSource[])))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[])))); +#endif + } + + } +} \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt new file mode 100644 index 0000000000..e853b1f311 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -0,0 +1,282 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> +<#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net46\System.Interactive.Async.dll" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Threading" #> +<#@ import namespace="System.Threading.Tasks" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# +var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable" }; + +var toQuotedImpl = default(Func); +toQuotedImpl = (t, i, b) => +{ +var name = t.Name; + +if (t.IsGenericType) +{ + var genDef = t.GetGenericTypeDefinition(); + name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); + + var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; + + if (b) + { + if (name == "Func" || name == "Action") + { + name = "Expression<" + name + genArgs + ">"; + } + else if (name == "IAsyncEnumerable" && i == 0) + { + name = "IAsyncQueryable" + genArgs; + } + else if (name == "IOrderedAsyncEnumerable" && i == 0) + { + name = "IOrderedAsyncQueryable" + genArgs; + } + else + { + name += genArgs; + } + } + else + { + if (name == "Nullable") + { + name = genArgs.Substring(1, genArgs.Length - 2) + "?"; + } + else + { + name += genArgs; + } + } +} +else if (t.IsArray) +{ + var elem = toQuotedImpl(t.GetElementType(), i, b); + name = elem + "[]"; +} +else +{ + if (t == typeof(int)) + { + name = "int"; + } + else if (t == typeof(long)) + { + name = "long"; + } + else if (t == typeof(float)) + { + name = "float"; + } + else if (t == typeof(double)) + { + name = "double"; + } + else if (t == typeof(decimal)) + { + name = "decimal"; + } + else if (t == typeof(bool)) + { + name = "bool"; + } + else if (t == typeof(object)) + { + name = "object"; + } +} + +return name; +}; + +var toQuoted = new Func((t, i) => toQuotedImpl(t, i, true)); +#> +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncQueryableEx + { +<# +// NOTE: Just including extension methods +foreach (var m in typeof(AsyncEnumerableEx).GetMethods() + .Where(m => m.IsStatic) + .Where(m => !exclude.Contains(m.Name)) + .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + .Where(m => + { + var p0 = m.GetParameters()[0].ParameterType; + if (p0.IsGenericType) + { + var p0d = p0.GetGenericTypeDefinition(); + return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); + } + + return false; + }) + .OrderBy(m => m.Name) + .ThenBy(m => m.GetParameters().Length)) +{ + var genArgs = m.GetGenericArguments(); + + var ret = toQuoted(m.ReturnType, 0); + var name = m.Name; + + if (genArgs.Length > 0) + { + name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; + } + + var isParams = false; + var parCount = m.GetParameters().Length; + + if (parCount != 0) + { + if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) + { + isParams = true; + } + } + + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); + var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); + + if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + { + pars = "this " + pars; + } + + var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; + + if (m.IsGenericMethod) + { + mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; + } + + var provider = m.GetParameters()[0].Name + ".Provider"; + var factory = ""; + var rem = ""; + var cast = ""; + var quotedArgs = new List(); + + if (m.ReturnType.IsGenericType) + { + var td = m.ReturnType.GetGenericTypeDefinition(); + + if (td == typeof(Task<>)) + { + factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + var last = m.GetParameters().Last(); + if (last.ParameterType == typeof(CancellationToken)) + { + rem = ", " + last.Name; + } + else + { + rem = ", CancellationToken.None"; + } + } + else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) + { + factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + if (td == typeof(IOrderedAsyncEnumerable<>)) + { + cast = "(" + toQuoted(m.ReturnType, 0) + ")"; + } + } + } + + var n = 0; + foreach (var p in m.GetParameters()) + { + var pt = p.ParameterType; + + var add = false; + + if (pt.IsGenericType) + { + var ptd = pt.GetGenericTypeDefinition(); + + if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) + { + if (n == 0) + { + quotedArgs.Add(p.Name + ".Expression"); + } + else + { + quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); + } + add = true; + } + else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) + { + quotedArgs.Add(p.Name); + add = true; + } + } + + if (!add) + { + quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); + } + + n++; + } + + var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; + + var infoofmtd = "InfoOf(() => AsyncQueryableEx." + name + "(" + quotedPars + "))"; + var infoofexpr = "Expression.Call(" + infoofmtd + ", " + string.Join(", ", quotedArgs) + ")"; +#> + public static <#=ret#> <#=name#>(<#=pars#>) + { +<# +var any = false; +foreach (var p in m.GetParameters()) +{ + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + { + any = true; +#> + if (<#=p.Name#> == null) + throw new ArgumentNullException(nameof(<#=p.Name#>)); +<# + } +} +#> +<# +if (any) +{ +#> + +<# +} +#> +#if CRIPPLED_REFLECTION + return <#=cast#><#=provider#>.<#=factory#>(<#=infoofexpr#><#=rem#>); +#else + return <#=cast#><#=provider#>.<#=factory#>(<#=expr#><#=rem#>); +#endif + } + +<# +} +#> + } +} \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs new file mode 100644 index 0000000000..964654d825 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; + +namespace System.Linq +{ + /// + /// Provides a set of extension methods for asynchronous enumerable sequences represented using expression trees. + /// + public static partial class AsyncQueryableEx + { + private static Expression GetSourceExpression(IAsyncEnumerable source) + { + if (source is IAsyncQueryable queryable) + { + return queryable.Expression; + } + + return Expression.Constant(source, typeof(IAsyncEnumerable)); + } + + internal static MethodInfo InfoOf(Expression> f) + { + return ((MethodCallExpression)f.Body).Method; + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs new file mode 100644 index 0000000000..6f1bdc3f47 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs @@ -0,0 +1,608 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class AsyncQueryableTests + { + [Fact] + public void Buffer1() + { + AssertEx.Throws(() => AsyncQueryableEx.Buffer(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.Buffer(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Buffer2() + { + AssertEx.Throws(() => AsyncQueryableEx.Buffer(default(IAsyncQueryable), 1, 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.Buffer(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Catch1() + { + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "handler"); + + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Catch2() + { + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "handler"); + + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => default(Task>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Catch3() + { + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Distinct1() + { + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Distinct2() + { + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Distinct3() + { + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Distinct4() + { + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DistinctUntilChanged1() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DistinctUntilChanged2() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DistinctUntilChanged3() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DistinctUntilChanged4() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DistinctUntilChanged5() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DistinctUntilChanged6() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do1() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do2() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do3() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), new NopObserver()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IObserver)), ane => ane.ParamName == "observer"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new NopObserver()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do4() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), () => { }), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Action)), ane => ane.ParamName == "onCompleted"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), () => { }); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do5() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Expression>)), ane => ane.ParamName == "onError"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do6() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), () => default(Task)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>)), ane => ane.ParamName == "onCompleted"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), () => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do7() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), (Exception arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => default(Task)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>)), ane => ane.ParamName == "onError"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (Exception arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do8() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Expression>), () => { }), ane => ane.ParamName == "onError"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine(), default(Action)), ane => ane.ParamName == "onCompleted"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine(), () => { }); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do9() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), (Exception arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>), () => default(Task)), ane => ane.ParamName == "onError"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (Exception arg0) => default(Task), default(Expression>)), ane => ane.ParamName == "onCompleted"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (Exception arg0) => default(Task), () => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Expand1() + { + AssertEx.Throws(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); + res = res.Take(5); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Expand2() + { + AssertEx.Throws(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); + res = res.Take(5); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Finally1() + { + AssertEx.Throws(() => AsyncQueryableEx.Finally(default(IAsyncQueryable), () => { }), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Finally(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Action)), ane => ane.ParamName == "finallyAction"); + + var res = AsyncQueryableEx.Finally(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), () => { }); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Finally2() + { + AssertEx.Throws(() => AsyncQueryableEx.Finally(default(IAsyncQueryable), () => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Finally(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "finallyAction"); + + var res = AsyncQueryableEx.Finally(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), () => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void IgnoreElements1() + { + AssertEx.Throws(() => AsyncQueryableEx.IgnoreElements(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.IgnoreElements(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void MaxBy1() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy2() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy3() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy4() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy5() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy6() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy7() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy8() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy1() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy2() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy3() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy4() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy5() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy6() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy7() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinBy8() + { + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void OnErrorResumeNext1() + { + AssertEx.Throws(() => AsyncQueryableEx.OnErrorResumeNext(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryableEx.OnErrorResumeNext(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryableEx.OnErrorResumeNext(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Retry1() + { + AssertEx.Throws(() => AsyncQueryableEx.Retry(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.Retry(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Retry2() + { + AssertEx.Throws(() => AsyncQueryableEx.Retry(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.Retry(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Scan1() + { + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Scan2() + { + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Scan3() + { + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Scan4() + { + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany1() + { + AssertEx.Throws(() => AsyncQueryableEx.SelectMany(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "other"); + + var res = AsyncQueryableEx.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void StartWith1() + { + AssertEx.Throws(() => AsyncQueryableEx.StartWith(default(IAsyncQueryable), new int[] { default(int) }), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.StartWith(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(int[])), ane => ane.ParamName == "values"); + + var res = AsyncQueryableEx.StartWith(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + } +} \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt new file mode 100644 index 0000000000..bcb2add8d7 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt @@ -0,0 +1,475 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> +<#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net46\System.Interactive.Async.dll" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Threading" #> +<#@ import namespace="System.Threading.Tasks" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# +var failing = new[] { "TakeLast" }; +var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable" }; + +var toQuotedImpl = default(Func); +toQuotedImpl = (t, i, b) => +{ +var name = t.Name; + +if (t.IsGenericType) +{ + var genDef = t.GetGenericTypeDefinition(); + name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); + + var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; + + if (b) + { + if (name == "Func" || name == "Action") + { + name = "Expression<" + name + genArgs + ">"; + } + else if (name == "IAsyncEnumerable" && i == 0) + { + name = "IAsyncQueryable" + genArgs; + } + else if (name == "IOrderedAsyncEnumerable" && i == 0) + { + name = "IOrderedAsyncQueryable" + genArgs; + } + else + { + name += genArgs; + } + } + else + { + if (name == "Nullable") + { + name = genArgs.Substring(1, genArgs.Length - 2) + "?"; + } + else + { + name += genArgs; + } + } +} +else if (t.IsArray) +{ + var elem = toQuotedImpl(t.GetElementType(), i, b); + name = elem + "[]"; +} +else +{ + if (t == typeof(int)) + { + name = "int"; + } + else if (t == typeof(long)) + { + name = "long"; + } + else if (t == typeof(float)) + { + name = "float"; + } + else if (t == typeof(double)) + { + name = "double"; + } + else if (t == typeof(decimal)) + { + name = "decimal"; + } + else if (t == typeof(bool)) + { + name = "bool"; + } + else if (t == typeof(object)) + { + name = "object"; + } +} + +return name; +}; + +var toQuoted = new Func((t, i) => toQuotedImpl(t, i, true)); + +var index = new Dictionary(); +#> +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class AsyncQueryableTests + { +<# +// NOTE: Just including extension methods +foreach (var m in typeof(AsyncEnumerableEx).GetMethods() + .Where(m => m.IsStatic) + .Where(m => !exclude.Contains(m.Name)) + .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + .Where(m => + { + var p0 = m.GetParameters()[0].ParameterType; + if (p0.IsGenericType) + { + var p0d = p0.GetGenericTypeDefinition(); + return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); + } + + return false; + }) + .OrderBy(m => m.Name) + .ThenBy(m => m.GetParameters().Length)) +{ + var genArgs = m.GetGenericArguments(); + + var ret = toQuoted(m.ReturnType, 0); + var name = m.Name; + + if (genArgs.Length > 0) + { + name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; + } + + var isParams = false; + var parCount = m.GetParameters().Length; + + if (parCount != 0) + { + if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) + { + isParams = true; + } + } + + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); + + if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + { + pars = "this " + pars; + } + + var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; + + if (m.IsGenericMethod) + { + mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; + } + + var provider = m.GetParameters()[0].Name + ".Provider"; + var factory = ""; + var rem = ""; + var cast = ""; + var quotedArgs = new List(); + + if (m.ReturnType.IsGenericType) + { + var td = m.ReturnType.GetGenericTypeDefinition(); + + if (td == typeof(Task<>)) + { + factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + var last = m.GetParameters().Last(); + if (last.ParameterType == typeof(CancellationToken)) + { + rem = ", " + last.Name; + } + else + { + rem = ", CancellationToken.None"; + } + } + else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) + { + factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + if (td == typeof(IOrderedAsyncEnumerable<>)) + { + cast = "(" + toQuoted(m.ReturnType, 0) + ")"; + } + } + } + + var n = 0; + foreach (var p in m.GetParameters()) + { + var pt = p.ParameterType; + + var add = false; + + if (pt.IsGenericType) + { + var ptd = pt.GetGenericTypeDefinition(); + + if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) + { + if (n == 0) + { + quotedArgs.Add(p.Name + ".Expression"); + } + else + { + quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); + } + add = true; + } + else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) + { + quotedArgs.Add(p.Name); + add = true; + } + } + + if (!add) + { + quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); + } + + n++; + } + + var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; + + var testName = m.Name; + + var num = 0; + if (!index.TryGetValue(testName, out num)) + { + index[testName] = 0; + } + + index[testName] = num + 1; + + testName += (num + 1); +#> + [Fact] + public void <#=testName#>() + { +<# +var indexes = new List(); +var j = 0; +foreach (var p in m.GetParameters()) +{ + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + { + indexes.Add(j); + } + + j++; +} + +var tm = m; + +if (tm.IsGenericMethodDefinition) +{ + tm = m.MakeGenericMethod(m.GetGenericArguments().Select(a => + { + var cs = a.GetGenericParameterConstraints(); + if (cs.Length > 0) + { + var bc = cs.FirstOrDefault(c => c.IsClass); + if (bc != null) + { + return bc; + } + } + + return typeof(int); + }).ToArray()); +} + +var opName = tm.Name; + +if (tm.IsGenericMethod) +{ + opName += "<" + string.Join(", ", tm.GetGenericArguments().Select(a => toQuotedImpl(a, -1, false))) + ">"; +} + +var getVal = default(Func); +getVal = (tp, pos) => +{ + if (tp.IsGenericType) + { + var tpd = tp.GetGenericTypeDefinition(); + + if (tpd == typeof(IAsyncEnumerable<>)) + { + var tpa = tp.GetGenericArguments()[0]; + var et = toQuotedImpl(tpa, -1, false); + var res = "new " + et + "[] { default(" + et + ") }.ToAsyncEnumerable()"; + + if (pos == 0) + { + res += ".AsAsyncQueryable()"; + } + + return res; + } + else if (tpd == typeof(IOrderedAsyncEnumerable<>)) + { + var tpa = tp.GetGenericArguments()[0]; + var res = "new " + toQuotedImpl(tpa, -1, false) + "[0].ToAsyncEnumerable()"; + + if (pos == 0) + { + res += ".AsAsyncQueryable()"; + } + + return res + ".OrderBy(x => x)"; + } + else if (tpd.Name.StartsWith("Func")) + { + var inv = tp.GetMethod("Invoke"); + + var largs = string.Join(", ", inv.GetParameters().Select((lp, lpi) => toQuoted(lp.ParameterType, -1) + " arg" + lpi).ToArray()); + + var lret = "default(" + toQuoted(inv.ReturnType, -1) + ")"; + + if (inv.ReturnType.IsGenericType) + { + if (inv.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>)) + { + var tpa = inv.ReturnType.GetGenericArguments()[0]; + var et = toQuotedImpl(tpa, -1, false); + lret = "new " + et + "[] { default(" + et + ") }.ToAsyncEnumerable()"; + } + } + else if (inv.ReturnType == typeof(bool)) + { + lret = "true"; + } + + return "(" + largs + ") => " + lret; + } + else if (tpd.Name.StartsWith("Action")) + { + var inv = tp.GetMethod("Invoke"); + + var largs = string.Join(", ", inv.GetParameters().Select((lp, lpi) => toQuoted(lp.ParameterType, -1) + " arg" + lpi).ToArray()); + var lret = "Console.WriteLine()"; + + return "(" + largs + ") => " + lret; + } + else if (tpd == typeof(IEqualityComparer<>)) + { + var tpa = tp.GetGenericArguments()[0]; + + return "EqualityComparer<" + toQuotedImpl(tpa, -1, false) + ">.Default"; + } + else if (tpd == typeof(IComparer<>)) + { + var tpa = tp.GetGenericArguments()[0]; + + return "Comparer<" + toQuotedImpl(tpa, -1, false) + ">.Default"; + } + else if (tpd == typeof(IObserver<>)) + { + var tpa = tp.GetGenericArguments()[0]; + + return "new NopObserver<" + toQuotedImpl(tpa, -1, false) + ">()"; + } + } + else if (tp == typeof(CancellationToken)) + { + return "CancellationToken.None"; + } + else if (tp == typeof(Action)) + { + return "() => { }"; + } + else if (tp.IsArray) + { + var tpa = tp.GetElementType(); + var et = toQuotedImpl(tpa, -1, false); + + return "new " + et + "[] { default(" + et + ") }"; + } + else if (tp == typeof(int)) + { + return "1"; + } + + return "default(" + toQuoted(tp, pos) + ")"; +}; + +var vals = tm.GetParameters().Select((p, i) => getVal(p.ParameterType, i)).ToArray(); +var nulls = tm.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")").ToArray(); + +var len = vals.Length; + +if (indexes.Count != 0) +{ + foreach (var idx in indexes) + { + var args = string.Join(", ", Enumerable.Range(0, len).Select(k => k == idx ? nulls[k] : vals[k]).ToArray()); + var nullArg = tm.GetParameters()[idx].Name; +#> + AssertEx.Throws(() => AsyncQueryableEx.<#=opName#>(<#=args#>), ane => ane.ParamName == "<#=nullArg#>"); +<# + } +#> + +<# +} + +{ + var args = string.Join(", ", vals); +#> + var res = AsyncQueryableEx.<#=opName#>(<#=args#>); +<# + var tmRet = tm.ReturnType; + + if (tmRet.IsGenericType) + { + tmRet = tmRet.GetGenericTypeDefinition(); + } + + if (tm.Name == "Repeat" || tm.Name == "Expand") + { +#> + res = res.Take(5); +<# + } + + if (!failing.Contains(tm.Name)) + { + if (tmRet == typeof(Task<>)) + { +#> + AssertEx.SucceedOrFailProper(() => res.Wait()); +<# + } + else if (tmRet == typeof(IAsyncEnumerable<>)) + { +#> + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); +<# + } + } + else + { +#> + // TODO: investigate test hang +<# + } +} +#> + } + +<# +} +#> + } +} \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs index bdab59093f..e07eced05d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs @@ -3,3390 +3,4688 @@ using System.Linq; using System.Linq.Expressions; using System.Threading; +using System.Threading.Tasks; using Xunit; namespace Tests { - - public class AsyncQueryableTests - { - [Fact] - public void Aggregate1() - { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Aggregate2() - { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Aggregate3() - { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Aggregate4() - { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Aggregate5() - { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Aggregate6() - { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void All1() - { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void All2() - { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Any1() - { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Any2() - { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Any3() - { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Any4() - { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Append1() - { - AssertEx.Throws(() => AsyncQueryable.Append(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Append(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Average1() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average2() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average3() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average4() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average5() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average6() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average7() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average8() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average9() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average10() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average11() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average12() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average13() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average14() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average15() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average16() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average17() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average18() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average19() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average20() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average21() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average22() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average23() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average24() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average25() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average26() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average27() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average28() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average29() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average30() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average31() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average32() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average33() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average34() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average35() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average36() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average37() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average38() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average39() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average40() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Buffer1() - { - AssertEx.Throws(() => AsyncQueryable.Buffer(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Buffer(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Buffer2() - { - AssertEx.Throws(() => AsyncQueryable.Buffer(default(IAsyncQueryable), 1, 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Buffer(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Cast1() - { - AssertEx.Throws(() => AsyncQueryable.Cast(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Cast(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Catch1() - { - AssertEx.Throws(() => AsyncQueryable.Catch(default(IAsyncQueryable), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "handler"); - - var res = AsyncQueryable.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Catch2() - { - AssertEx.Throws(() => AsyncQueryable.Catch(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Concat1() - { - AssertEx.Throws(() => AsyncQueryable.Concat(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Contains1() - { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Contains2() - { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Contains3() - { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Contains4() - { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Count1() - { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Count2() - { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Count3() - { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Count4() - { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void DefaultIfEmpty1() - { - AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void DefaultIfEmpty2() - { - AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Distinct1() - { - AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Distinct2() - { - AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Distinct3() - { - AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Distinct4() - { - AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void DistinctUntilChanged1() - { - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void DistinctUntilChanged2() - { - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void DistinctUntilChanged3() - { - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void DistinctUntilChanged4() - { - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Do1() - { - AssertEx.Throws(() => AsyncQueryable.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); - - var res = AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Do2() - { - AssertEx.Throws(() => AsyncQueryable.Do(default(IAsyncQueryable), new NopObserver()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IObserver)), ane => ane.ParamName == "observer"); - - var res = AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new NopObserver()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Do3() - { - AssertEx.Throws(() => AsyncQueryable.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), () => { }), ane => ane.ParamName == "onNext"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Action)), ane => ane.ParamName == "onCompleted"); - - var res = AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), () => { }); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Do4() - { - AssertEx.Throws(() => AsyncQueryable.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "onNext"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Expression>)), ane => ane.ParamName == "onError"); - - var res = AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Do5() - { - AssertEx.Throws(() => AsyncQueryable.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "onNext"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Expression>), () => { }), ane => ane.ParamName == "onError"); - AssertEx.Throws(() => AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine(), default(Action)), ane => ane.ParamName == "onCompleted"); - - var res = AsyncQueryable.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine(), () => { }); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void ElementAt1() - { - AssertEx.Throws(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ElementAt(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ElementAt2() - { - AssertEx.Throws(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ElementAt(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ElementAtOrDefault1() - { - AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ElementAtOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ElementAtOrDefault2() - { - AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ElementAtOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Except1() - { - AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Except2() - { - AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Expand1() - { - AssertEx.Throws(() => AsyncQueryable.Expand(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); - res = res.Take(5); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Finally1() - { - AssertEx.Throws(() => AsyncQueryable.Finally(default(IAsyncQueryable), () => { }), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Finally(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Action)), ane => ane.ParamName == "finallyAction"); - - var res = AsyncQueryable.Finally(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), () => { }); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void First1() - { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void First2() - { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void First3() - { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void First4() - { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefault1() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefault2() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefault3() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefault4() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void GroupBy1() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy2() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy3() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy4() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy5() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy6() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy7() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy8() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin1() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin2() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void IgnoreElements1() - { - AssertEx.Throws(() => AsyncQueryable.IgnoreElements(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.IgnoreElements(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Intersect1() - { - AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Intersect2() - { - AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void IsEmpty1() - { - AssertEx.Throws(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void IsEmpty2() - { - AssertEx.Throws(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Join1() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Join2() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Last1() - { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Last2() - { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Last3() - { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Last4() - { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefault1() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefault2() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefault3() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefault4() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCount1() - { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCount2() - { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCount3() - { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCount4() - { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max1() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max2() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max3() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max4() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max5() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max6() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max7() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max8() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max9() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max10() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max11() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max12() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max13() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max14() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max15() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max16() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max17() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max18() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max19() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max20() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max21() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max22() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max23() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max24() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max25() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max26() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max27() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max28() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max29() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max30() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max31() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max32() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max33() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max34() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max35() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max36() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max37() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max38() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max39() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max40() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max41() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max42() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max43() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max44() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max45() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max46() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxBy1() - { - AssertEx.Throws(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxBy2() - { - AssertEx.Throws(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxBy3() - { - AssertEx.Throws(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxBy4() - { - AssertEx.Throws(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min1() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min2() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min3() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min4() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min5() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min6() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min7() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min8() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min9() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min10() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min11() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min12() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min13() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min14() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min15() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min16() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min17() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min18() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min19() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min20() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min21() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min22() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min23() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min24() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min25() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min26() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min27() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min28() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min29() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min30() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min31() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min32() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min33() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min34() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min35() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min36() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min37() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min38() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min39() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min40() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min41() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min42() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min43() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min44() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min45() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min46() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinBy1() - { - AssertEx.Throws(() => AsyncQueryable.MinBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinBy2() - { - AssertEx.Throws(() => AsyncQueryable.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinBy3() - { - AssertEx.Throws(() => AsyncQueryable.MinBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinBy4() - { - AssertEx.Throws(() => AsyncQueryable.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void OfType1() - { - AssertEx.Throws(() => AsyncQueryable.OfType(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.OfType(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void OnErrorResumeNext1() - { - AssertEx.Throws(() => AsyncQueryable.OnErrorResumeNext(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.OnErrorResumeNext(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.OnErrorResumeNext(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void OrderBy1() - { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - } - - [Fact] - public void OrderBy2() - { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); - } - - [Fact] - public void OrderByDescending1() - { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - } - - [Fact] - public void OrderByDescending2() - { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); - } - - [Fact] - public void Prepend1() - { - AssertEx.Throws(() => AsyncQueryable.Prepend(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Prepend(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Repeat1() - { - AssertEx.Throws(() => AsyncQueryable.Repeat(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - res = res.Take(5); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Repeat2() - { - AssertEx.Throws(() => AsyncQueryable.Repeat(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - res = res.Take(5); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Retry1() - { - AssertEx.Throws(() => AsyncQueryable.Retry(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Retry(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Retry2() - { - AssertEx.Throws(() => AsyncQueryable.Retry(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Retry(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Reverse1() - { - AssertEx.Throws(() => AsyncQueryable.Reverse(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Reverse(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Scan1() - { - AssertEx.Throws(() => AsyncQueryable.Scan(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Scan2() - { - AssertEx.Throws(() => AsyncQueryable.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Select1() - { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Select2() - { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SelectMany1() - { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "other"); - - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SelectMany2() - { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SelectMany3() - { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SelectMany4() - { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SelectMany5() - { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SequenceEqual1() - { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SequenceEqual2() - { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SequenceEqual3() - { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SequenceEqual4() - { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Single1() - { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Single2() - { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Single3() - { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Single4() - { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SingleOrDefault1() - { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SingleOrDefault2() - { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SingleOrDefault3() - { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SingleOrDefault4() - { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Skip1() - { - AssertEx.Throws(() => AsyncQueryable.Skip(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Skip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SkipLast1() - { - AssertEx.Throws(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.SkipLast(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SkipWhile1() - { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void SkipWhile2() - { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void StartWith1() - { - AssertEx.Throws(() => AsyncQueryable.StartWith(default(IAsyncQueryable), new int[] { default(int) }), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.StartWith(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(int[])), ane => ane.ParamName == "values"); - - var res = AsyncQueryable.StartWith(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Sum1() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum2() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum3() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum4() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum5() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum6() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum7() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum8() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum9() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum10() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum11() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum12() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum13() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum14() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum15() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum16() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum17() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum18() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum19() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum20() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum21() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum22() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum23() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum24() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum25() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum26() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum27() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum28() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum29() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum30() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum31() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum32() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum33() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum34() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum35() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum36() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum37() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum38() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum39() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum40() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Take1() - { - AssertEx.Throws(() => AsyncQueryable.Take(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Take(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void TakeLast1() - { - AssertEx.Throws(() => AsyncQueryable.TakeLast(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.TakeLast(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - // TODO: investigate test hang - } - - [Fact] - public void TakeWhile1() - { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void TakeWhile2() - { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void ThenBy1() - { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); - } - - [Fact] - public void ThenBy2() - { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); - } - - [Fact] - public void ThenByDescending1() - { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); - } - - [Fact] - public void ThenByDescending2() - { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); - } - - [Fact] - public void ToArray1() - { - AssertEx.Throws(() => AsyncQueryable.ToArray(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToArray(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToArray2() - { - AssertEx.Throws(() => AsyncQueryable.ToArray(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToArray(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary1() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary2() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary3() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary4() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary5() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary6() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary7() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary8() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToList1() - { - AssertEx.Throws(() => AsyncQueryable.ToList(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToList(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToList2() - { - AssertEx.Throws(() => AsyncQueryable.ToList(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToList(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup1() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup2() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup3() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup4() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup5() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup6() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup7() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookup8() - { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Union1() - { - AssertEx.Throws(() => AsyncQueryable.Union(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Union2() - { - AssertEx.Throws(() => AsyncQueryable.Union(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Where1() - { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Where2() - { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Zip1() - { - AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - } + public class AsyncQueryableExTests + { + [Fact] + public void Aggregate1() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate2() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate3() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate4() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate5() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate6() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate7() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate8() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate9() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate10() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate11() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Aggregate12() + { + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void All1() + { + AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void All2() + { + AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void All3() + { + AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void All4() + { + AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Any1() + { + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Any2() + { + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Any3() + { + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Any4() + { + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Any5() + { + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Any6() + { + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Append1() + { + AssertEx.Throws(() => AsyncQueryable.Append(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Append(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Average1() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average2() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average3() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average4() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average5() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average6() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average7() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average8() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average9() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average10() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average11() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average12() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average13() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average14() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average15() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average16() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average17() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average18() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average19() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average20() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average21() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average22() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average23() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average24() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average25() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average26() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average27() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average28() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average29() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average30() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average31() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average32() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average33() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average34() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average35() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average36() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average37() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average38() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average39() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average40() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average41() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average42() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average43() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average44() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average45() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average46() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average47() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average48() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average49() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average50() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average51() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average52() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average53() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average54() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average55() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average56() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average57() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average58() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average59() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average60() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Cast1() + { + AssertEx.Throws(() => AsyncQueryable.Cast(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Cast(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Concat1() + { + AssertEx.Throws(() => AsyncQueryable.Concat(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Contains1() + { + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Contains2() + { + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Contains3() + { + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Contains4() + { + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Count1() + { + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Count2() + { + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Count3() + { + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Count4() + { + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Count5() + { + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Count6() + { + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void DefaultIfEmpty1() + { + AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DefaultIfEmpty2() + { + AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Distinct1() + { + AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Distinct2() + { + AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void ElementAt1() + { + AssertEx.Throws(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ElementAt(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ElementAt2() + { + AssertEx.Throws(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ElementAt(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ElementAtOrDefault1() + { + AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ElementAtOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ElementAtOrDefault2() + { + AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ElementAtOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Except1() + { + AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Except2() + { + AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void First1() + { + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void First2() + { + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void First3() + { + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void First4() + { + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void First5() + { + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void First6() + { + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void FirstOrDefault1() + { + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void FirstOrDefault2() + { + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void FirstOrDefault3() + { + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void FirstOrDefault4() + { + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void FirstOrDefault5() + { + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void FirstOrDefault6() + { + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void GroupBy1() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy2() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy3() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy4() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy5() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy6() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy7() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy8() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy9() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy10() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy11() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy12() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy13() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy14() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy15() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy16() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupJoin1() + { + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupJoin2() + { + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupJoin3() + { + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupJoin4() + { + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Intersect1() + { + AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Intersect2() + { + AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void IsEmpty1() + { + AssertEx.Throws(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void IsEmpty2() + { + AssertEx.Throws(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Join1() + { + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Join2() + { + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Join3() + { + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Join4() + { + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Last1() + { + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Last2() + { + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Last3() + { + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Last4() + { + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Last5() + { + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Last6() + { + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LastOrDefault1() + { + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LastOrDefault2() + { + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LastOrDefault3() + { + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LastOrDefault4() + { + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LastOrDefault5() + { + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LastOrDefault6() + { + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LongCount1() + { + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LongCount2() + { + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LongCount3() + { + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LongCount4() + { + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LongCount5() + { + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void LongCount6() + { + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max1() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max2() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max3() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max4() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max5() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max6() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max7() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max8() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max9() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max10() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max11() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max12() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max13() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max14() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max15() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max16() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max17() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max18() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max19() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max20() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max21() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max22() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max23() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max24() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max25() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max26() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max27() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max28() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max29() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max30() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max31() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max32() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max33() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max34() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max35() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max36() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max37() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max38() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max39() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max40() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max41() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max42() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max43() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max44() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max45() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max46() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max47() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max48() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max49() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max50() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max51() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max52() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max53() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max54() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max55() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max56() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max57() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max58() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max59() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max60() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max61() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max62() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max63() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max64() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max65() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max66() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max67() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max68() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min1() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min2() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min3() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min4() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min5() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min6() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min7() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min8() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min9() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min10() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min11() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min12() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min13() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min14() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min15() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min16() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min17() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min18() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min19() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min20() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min21() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min22() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min23() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min24() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min25() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min26() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min27() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min28() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min29() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min30() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min31() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min32() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min33() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min34() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min35() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min36() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min37() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min38() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min39() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min40() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min41() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min42() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min43() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min44() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min45() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min46() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min47() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min48() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min49() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min50() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min51() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min52() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min53() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min54() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min55() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min56() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min57() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min58() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min59() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min60() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min61() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min62() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min63() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min64() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min65() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min66() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min67() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min68() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void OfType1() + { + AssertEx.Throws(() => AsyncQueryable.OfType(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.OfType(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void OrderBy1() + { + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + } + + [Fact] + public void OrderBy2() + { + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + } + + [Fact] + public void OrderBy3() + { + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + } + + [Fact] + public void OrderBy4() + { + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + } + + [Fact] + public void OrderByDescending1() + { + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + } + + [Fact] + public void OrderByDescending2() + { + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + } + + [Fact] + public void OrderByDescending3() + { + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + } + + [Fact] + public void OrderByDescending4() + { + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + } + + [Fact] + public void Prepend1() + { + AssertEx.Throws(() => AsyncQueryable.Prepend(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Prepend(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Repeat1() + { + AssertEx.Throws(() => AsyncQueryable.Repeat(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + res = res.Take(5); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Repeat2() + { + AssertEx.Throws(() => AsyncQueryable.Repeat(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + res = res.Take(5); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Reverse1() + { + AssertEx.Throws(() => AsyncQueryable.Reverse(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Reverse(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Select1() + { + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Select2() + { + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Select3() + { + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Select4() + { + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany1() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany2() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany3() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany4() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany5() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany6() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany7() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany8() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SequenceEqual1() + { + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SequenceEqual2() + { + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SequenceEqual3() + { + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); + + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SequenceEqual4() + { + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Single1() + { + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Single2() + { + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Single3() + { + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Single4() + { + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Single5() + { + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Single6() + { + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SingleOrDefault1() + { + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SingleOrDefault2() + { + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SingleOrDefault3() + { + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SingleOrDefault4() + { + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SingleOrDefault5() + { + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SingleOrDefault6() + { + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Skip1() + { + AssertEx.Throws(() => AsyncQueryable.Skip(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Skip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SkipLast1() + { + AssertEx.Throws(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.SkipLast(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SkipWhile1() + { + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SkipWhile2() + { + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SkipWhile3() + { + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SkipWhile4() + { + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Sum1() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum2() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum3() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum4() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum5() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum6() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum7() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum8() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum9() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum10() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum11() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum12() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum13() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum14() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum15() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum16() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum17() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum18() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum19() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum20() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum21() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum22() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum23() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum24() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum25() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum26() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum27() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum28() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum29() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum30() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum31() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum32() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum33() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum34() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum35() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum36() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum37() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum38() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum39() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum40() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum41() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum42() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum43() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum44() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum45() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum46() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum47() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum48() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum49() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum50() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum51() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum52() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum53() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum54() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum55() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum56() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum57() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum58() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum59() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum60() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Take1() + { + AssertEx.Throws(() => AsyncQueryable.Take(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Take(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void TakeLast1() + { + AssertEx.Throws(() => AsyncQueryable.TakeLast(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.TakeLast(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + // TODO: investigate test hang + } + + [Fact] + public void TakeWhile1() + { + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void TakeWhile2() + { + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void TakeWhile3() + { + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void TakeWhile4() + { + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void ThenBy1() + { + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); + } + + [Fact] + public void ThenBy2() + { + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task)); + } + + [Fact] + public void ThenBy3() + { + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); + } + + [Fact] + public void ThenBy4() + { + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), Comparer.Default); + } + + [Fact] + public void ThenByDescending1() + { + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); + } + + [Fact] + public void ThenByDescending2() + { + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task)); + } + + [Fact] + public void ThenByDescending3() + { + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); + } + + [Fact] + public void ThenByDescending4() + { + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), Comparer.Default); + } + + [Fact] + public void ToArray1() + { + AssertEx.Throws(() => AsyncQueryable.ToArray(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ToArray(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToArray2() + { + AssertEx.Throws(() => AsyncQueryable.ToArray(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ToArray(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary1() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary2() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary3() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary4() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary5() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary6() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary7() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary8() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary9() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary10() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary11() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary12() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary13() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary14() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary15() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary16() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToList1() + { + AssertEx.Throws(() => AsyncQueryable.ToList(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ToList(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToList2() + { + AssertEx.Throws(() => AsyncQueryable.ToList(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ToList(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup1() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup2() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup3() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup4() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup5() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup6() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup7() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup8() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup9() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup10() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup11() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup12() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup13() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup14() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup15() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookup16() + { + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Union1() + { + AssertEx.Throws(() => AsyncQueryable.Union(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Union2() + { + AssertEx.Throws(() => AsyncQueryable.Union(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Where1() + { + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Where2() + { + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Where3() + { + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Where4() + { + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Zip1() + { + AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Zip2() + { + AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt index ba706e3991..183f359d60 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt @@ -1,6 +1,6 @@ <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> -<#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net45\System.Interactive.Async.dll" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Threading" #> @@ -18,77 +18,77 @@ var name = t.Name; if (t.IsGenericType) { - var genDef = t.GetGenericTypeDefinition(); - name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); - - var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; - - if (b) - { - if (name == "Func" || name == "Action") - { - name = "Expression<" + name + genArgs + ">"; - } - else if (name == "IAsyncEnumerable" && i == 0) - { - name = "IAsyncQueryable" + genArgs; - } - else if (name == "IOrderedAsyncEnumerable" && i == 0) - { - name = "IOrderedAsyncQueryable" + genArgs; - } - else - { - name += genArgs; - } - } - else - { - if (name == "Nullable") - { - name = genArgs.Substring(1, genArgs.Length - 2) + "?"; - } - else - { - name += genArgs; - } - } + var genDef = t.GetGenericTypeDefinition(); + name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); + + var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; + + if (b) + { + if (name == "Func" || name == "Action") + { + name = "Expression<" + name + genArgs + ">"; + } + else if (name == "IAsyncEnumerable" && i == 0) + { + name = "IAsyncQueryable" + genArgs; + } + else if (name == "IOrderedAsyncEnumerable" && i == 0) + { + name = "IOrderedAsyncQueryable" + genArgs; + } + else + { + name += genArgs; + } + } + else + { + if (name == "Nullable") + { + name = genArgs.Substring(1, genArgs.Length - 2) + "?"; + } + else + { + name += genArgs; + } + } } else if (t.IsArray) { - var elem = toQuotedImpl(t.GetElementType(), i, b); - name = elem + "[]"; + var elem = toQuotedImpl(t.GetElementType(), i, b); + name = elem + "[]"; } else { - if (t == typeof(int)) - { - name = "int"; - } - else if (t == typeof(long)) - { - name = "long"; - } - else if (t == typeof(float)) - { - name = "float"; - } - else if (t == typeof(double)) - { - name = "double"; - } - else if (t == typeof(decimal)) - { - name = "decimal"; - } - else if (t == typeof(bool)) - { - name = "bool"; - } - else if (t == typeof(object)) - { - name = "object"; - } + if (t == typeof(int)) + { + name = "int"; + } + else if (t == typeof(long)) + { + name = "long"; + } + else if (t == typeof(float)) + { + name = "float"; + } + else if (t == typeof(double)) + { + name = "double"; + } + else if (t == typeof(decimal)) + { + name = "decimal"; + } + else if (t == typeof(bool)) + { + name = "bool"; + } + else if (t == typeof(object)) + { + name = "object"; + } } return name; @@ -103,303 +103,303 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading; +using System.Threading.Tasks; using Xunit; namespace Tests { - - public class AsyncQueryableTests - { + public class AsyncQueryableExTests + { <# // NOTE: Just including extension methods foreach (var m in typeof(AsyncEnumerable).GetMethods() - .Where(m => m.IsStatic) - .Where(m => !exclude.Contains(m.Name)) - .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - .Where(m => - { - var p0 = m.GetParameters()[0].ParameterType; - if (p0.IsGenericType) - { - var p0d = p0.GetGenericTypeDefinition(); - return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); - } - - return false; - }) - .OrderBy(m => m.Name) - .ThenBy(m => m.GetParameters().Length)) + .Where(m => m.IsStatic) + .Where(m => !exclude.Contains(m.Name)) + .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + .Where(m => + { + var p0 = m.GetParameters()[0].ParameterType; + if (p0.IsGenericType) + { + var p0d = p0.GetGenericTypeDefinition(); + return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); + } + + return false; + }) + .OrderBy(m => m.Name) + .ThenBy(m => m.GetParameters().Length)) { - var genArgs = m.GetGenericArguments(); - - var ret = toQuoted(m.ReturnType, 0); - var name = m.Name; - - if (genArgs.Length > 0) - { - name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; - } - - var isParams = false; - var parCount = m.GetParameters().Length; - - if (parCount != 0) - { - if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) - { - isParams = true; - } - } - - var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); - - if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - { - pars = "this " + pars; - } - - var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; - - if (m.IsGenericMethod) - { - mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; - } - - var provider = m.GetParameters()[0].Name + ".Provider"; - var factory = ""; - var rem = ""; - var cast = ""; - var quotedArgs = new List(); - - if (m.ReturnType.IsGenericType) - { - var td = m.ReturnType.GetGenericTypeDefinition(); - - if (td == typeof(Task<>)) - { - factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - - var last = m.GetParameters().Last(); - if (last.ParameterType == typeof(CancellationToken)) - { - rem = ", " + last.Name; - } - else - { - rem = ", CancellationToken.None"; - } - } - else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) - { - factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - - if (td == typeof(IOrderedAsyncEnumerable<>)) - { - cast = "(" + toQuoted(m.ReturnType, 0) + ")"; - } - } - } - - var n = 0; - foreach (var p in m.GetParameters()) - { - var pt = p.ParameterType; - - var add = false; - - if (pt.IsGenericType) - { - var ptd = pt.GetGenericTypeDefinition(); - - if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) - { - if (n == 0) - { - quotedArgs.Add(p.Name + ".Expression"); - } - else - { - quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); - } - add = true; - } - else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) - { - quotedArgs.Add(p.Name); - add = true; - } - } - - if (!add) - { - quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); - } - - n++; - } - - var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; - - var testName = m.Name; - - var num = 0; - if (!index.TryGetValue(testName, out num)) - { - index[testName] = 0; - } - - index[testName] = num + 1; - - testName += (num + 1); + var genArgs = m.GetGenericArguments(); + + var ret = toQuoted(m.ReturnType, 0); + var name = m.Name; + + if (genArgs.Length > 0) + { + name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; + } + + var isParams = false; + var parCount = m.GetParameters().Length; + + if (parCount != 0) + { + if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) + { + isParams = true; + } + } + + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); + + if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + { + pars = "this " + pars; + } + + var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; + + if (m.IsGenericMethod) + { + mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; + } + + var provider = m.GetParameters()[0].Name + ".Provider"; + var factory = ""; + var rem = ""; + var cast = ""; + var quotedArgs = new List(); + + if (m.ReturnType.IsGenericType) + { + var td = m.ReturnType.GetGenericTypeDefinition(); + + if (td == typeof(Task<>)) + { + factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + var last = m.GetParameters().Last(); + if (last.ParameterType == typeof(CancellationToken)) + { + rem = ", " + last.Name; + } + else + { + rem = ", CancellationToken.None"; + } + } + else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) + { + factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + if (td == typeof(IOrderedAsyncEnumerable<>)) + { + cast = "(" + toQuoted(m.ReturnType, 0) + ")"; + } + } + } + + var n = 0; + foreach (var p in m.GetParameters()) + { + var pt = p.ParameterType; + + var add = false; + + if (pt.IsGenericType) + { + var ptd = pt.GetGenericTypeDefinition(); + + if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) + { + if (n == 0) + { + quotedArgs.Add(p.Name + ".Expression"); + } + else + { + quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); + } + add = true; + } + else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) + { + quotedArgs.Add(p.Name); + add = true; + } + } + + if (!add) + { + quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); + } + + n++; + } + + var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; + + var testName = m.Name; + + var num = 0; + if (!index.TryGetValue(testName, out num)) + { + index[testName] = 0; + } + + index[testName] = num + 1; + + testName += (num + 1); #> - [Fact] - public void <#=testName#>() - { + [Fact] + public void <#=testName#>() + { <# var indexes = new List(); var j = 0; foreach (var p in m.GetParameters()) { - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) - { - indexes.Add(j); - } + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + { + indexes.Add(j); + } - j++; + j++; } var tm = m; if (tm.IsGenericMethodDefinition) { - tm = m.MakeGenericMethod(m.GetGenericArguments().Select(a => - { - var cs = a.GetGenericParameterConstraints(); - if (cs.Length > 0) - { - var bc = cs.FirstOrDefault(c => c.IsClass); - if (bc != null) - { - return bc; - } - } - - return typeof(int); - }).ToArray()); + tm = m.MakeGenericMethod(m.GetGenericArguments().Select(a => + { + var cs = a.GetGenericParameterConstraints(); + if (cs.Length > 0) + { + var bc = cs.FirstOrDefault(c => c.IsClass); + if (bc != null) + { + return bc; + } + } + + return typeof(int); + }).ToArray()); } var opName = tm.Name; if (tm.IsGenericMethod) { - opName += "<" + string.Join(", ", tm.GetGenericArguments().Select(a => toQuotedImpl(a, -1, false))) + ">"; + opName += "<" + string.Join(", ", tm.GetGenericArguments().Select(a => toQuotedImpl(a, -1, false))) + ">"; } var getVal = default(Func); getVal = (tp, pos) => { - if (tp.IsGenericType) - { - var tpd = tp.GetGenericTypeDefinition(); - - if (tpd == typeof(IAsyncEnumerable<>)) - { - var tpa = tp.GetGenericArguments()[0]; - var et = toQuotedImpl(tpa, -1, false); - var res = "new " + et + "[] { default(" + et + ") }.ToAsyncEnumerable()"; - - if (pos == 0) - { - res += ".AsAsyncQueryable()"; - } - - return res; - } - else if (tpd == typeof(IOrderedAsyncEnumerable<>)) - { - var tpa = tp.GetGenericArguments()[0]; - var res = "new " + toQuotedImpl(tpa, -1, false) + "[0].ToAsyncEnumerable()"; - - if (pos == 0) - { - res += ".AsAsyncQueryable()"; - } - - return res + ".OrderBy(x => x)"; - } - else if (tpd.Name.StartsWith("Func")) - { - var inv = tp.GetMethod("Invoke"); - - var largs = string.Join(", ", inv.GetParameters().Select((lp, lpi) => toQuoted(lp.ParameterType, -1) + " arg" + lpi).ToArray()); - - var lret = "default(" + toQuoted(inv.ReturnType, -1) + ")"; - - if (inv.ReturnType.IsGenericType) - { - if (inv.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>)) - { - var tpa = inv.ReturnType.GetGenericArguments()[0]; - var et = toQuotedImpl(tpa, -1, false); - lret = "new " + et + "[] { default(" + et + ") }.ToAsyncEnumerable()"; - } - } - else if (inv.ReturnType == typeof(bool)) - { - lret = "true"; - } - - return "(" + largs + ") => " + lret; - } - else if (tpd.Name.StartsWith("Action")) - { - var inv = tp.GetMethod("Invoke"); - - var largs = string.Join(", ", inv.GetParameters().Select((lp, lpi) => toQuoted(lp.ParameterType, -1) + " arg" + lpi).ToArray()); - var lret = "Console.WriteLine()"; - - return "(" + largs + ") => " + lret; - } - else if (tpd == typeof(IEqualityComparer<>)) - { - var tpa = tp.GetGenericArguments()[0]; - - return "EqualityComparer<" + toQuotedImpl(tpa, -1, false) + ">.Default"; - } - else if (tpd == typeof(IComparer<>)) - { - var tpa = tp.GetGenericArguments()[0]; - - return "Comparer<" + toQuotedImpl(tpa, -1, false) + ">.Default"; - } - else if (tpd == typeof(IObserver<>)) - { - var tpa = tp.GetGenericArguments()[0]; - - return "new NopObserver<" + toQuotedImpl(tpa, -1, false) + ">()"; - } - } - else if (tp == typeof(CancellationToken)) - { - return "CancellationToken.None"; - } - else if (tp == typeof(Action)) - { - return "() => { }"; - } - else if (tp.IsArray) - { - var tpa = tp.GetElementType(); - var et = toQuotedImpl(tpa, -1, false); - - return "new " + et + "[] { default(" + et + ") }"; - } - else if (tp == typeof(int)) - { - return "1"; - } - - return "default(" + toQuoted(tp, pos) + ")"; + if (tp.IsGenericType) + { + var tpd = tp.GetGenericTypeDefinition(); + + if (tpd == typeof(IAsyncEnumerable<>)) + { + var tpa = tp.GetGenericArguments()[0]; + var et = toQuotedImpl(tpa, -1, false); + var res = "new " + et + "[] { default(" + et + ") }.ToAsyncEnumerable()"; + + if (pos == 0) + { + res += ".AsAsyncQueryable()"; + } + + return res; + } + else if (tpd == typeof(IOrderedAsyncEnumerable<>)) + { + var tpa = tp.GetGenericArguments()[0]; + var res = "new " + toQuotedImpl(tpa, -1, false) + "[0].ToAsyncEnumerable()"; + + if (pos == 0) + { + res += ".AsAsyncQueryable()"; + } + + return res + ".OrderBy(x => x)"; + } + else if (tpd.Name.StartsWith("Func")) + { + var inv = tp.GetMethod("Invoke"); + + var largs = string.Join(", ", inv.GetParameters().Select((lp, lpi) => toQuoted(lp.ParameterType, -1) + " arg" + lpi).ToArray()); + + var lret = "default(" + toQuoted(inv.ReturnType, -1) + ")"; + + if (inv.ReturnType.IsGenericType) + { + if (inv.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>)) + { + var tpa = inv.ReturnType.GetGenericArguments()[0]; + var et = toQuotedImpl(tpa, -1, false); + lret = "new " + et + "[] { default(" + et + ") }.ToAsyncEnumerable()"; + } + } + else if (inv.ReturnType == typeof(bool)) + { + lret = "true"; + } + + return "(" + largs + ") => " + lret; + } + else if (tpd.Name.StartsWith("Action")) + { + var inv = tp.GetMethod("Invoke"); + + var largs = string.Join(", ", inv.GetParameters().Select((lp, lpi) => toQuoted(lp.ParameterType, -1) + " arg" + lpi).ToArray()); + var lret = "Console.WriteLine()"; + + return "(" + largs + ") => " + lret; + } + else if (tpd == typeof(IEqualityComparer<>)) + { + var tpa = tp.GetGenericArguments()[0]; + + return "EqualityComparer<" + toQuotedImpl(tpa, -1, false) + ">.Default"; + } + else if (tpd == typeof(IComparer<>)) + { + var tpa = tp.GetGenericArguments()[0]; + + return "Comparer<" + toQuotedImpl(tpa, -1, false) + ">.Default"; + } + else if (tpd == typeof(IObserver<>)) + { + var tpa = tp.GetGenericArguments()[0]; + + return "new NopObserver<" + toQuotedImpl(tpa, -1, false) + ">()"; + } + } + else if (tp == typeof(CancellationToken)) + { + return "CancellationToken.None"; + } + else if (tp == typeof(Action)) + { + return "() => { }"; + } + else if (tp.IsArray) + { + var tpa = tp.GetElementType(); + var et = toQuotedImpl(tpa, -1, false); + + return "new " + et + "[] { default(" + et + ") }"; + } + else if (tp == typeof(int)) + { + return "1"; + } + + return "default(" + toQuoted(tp, pos) + ")"; }; var vals = tm.GetParameters().Select((p, i) => getVal(p.ParameterType, i)).ToArray(); @@ -409,66 +409,66 @@ var len = vals.Length; if (indexes.Count != 0) { - foreach (var idx in indexes) - { - var args = string.Join(", ", Enumerable.Range(0, len).Select(k => k == idx ? nulls[k] : vals[k]).ToArray()); - var nullArg = tm.GetParameters()[idx].Name; + foreach (var idx in indexes) + { + var args = string.Join(", ", Enumerable.Range(0, len).Select(k => k == idx ? nulls[k] : vals[k]).ToArray()); + var nullArg = tm.GetParameters()[idx].Name; #> - AssertEx.Throws(() => AsyncQueryable.<#=opName#>(<#=args#>), ane => ane.ParamName == "<#=nullArg#>"); + AssertEx.Throws(() => AsyncQueryable.<#=opName#>(<#=args#>), ane => ane.ParamName == "<#=nullArg#>"); <# - } + } #> <# } { - var args = string.Join(", ", vals); + var args = string.Join(", ", vals); #> - var res = AsyncQueryable.<#=opName#>(<#=args#>); + var res = AsyncQueryable.<#=opName#>(<#=args#>); <# - var tmRet = tm.ReturnType; + var tmRet = tm.ReturnType; - if (tmRet.IsGenericType) - { - tmRet = tmRet.GetGenericTypeDefinition(); - } + if (tmRet.IsGenericType) + { + tmRet = tmRet.GetGenericTypeDefinition(); + } - if (tm.Name == "Repeat" || tm.Name == "Expand") - { + if (tm.Name == "Repeat" || tm.Name == "Expand") + { #> - res = res.Take(5); + res = res.Take(5); <# - } + } - if (!failing.Contains(tm.Name)) - { - if (tmRet == typeof(Task<>)) - { + if (!failing.Contains(tm.Name)) + { + if (tmRet == typeof(Task<>)) + { #> - AssertEx.SucceedOrFailProper(() => res.Wait()); + AssertEx.SucceedOrFailProper(() => res.Wait()); <# - } - else if (tmRet == typeof(IAsyncEnumerable<>)) - { + } + else if (tmRet == typeof(IAsyncEnumerable<>)) + { #> - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); <# - } - } - else - { + } + } + else + { #> - // TODO: investigate test hang + // TODO: investigate test hang <# - } + } } #> - } + } <# } #> - } + } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index 29ff25901f..8021058693 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -29,8 +29,28 @@ + + AsyncQueryableExTests.Generated.cs + TextTemplatingFileGenerator + - + + + + + + + + + True + True + AsyncQueryableExTests.Generated.tt + + + True + True + AsyncQueryableTests.Generated.tt + diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs b/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs new file mode 100644 index 0000000000..70b0599d3d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs @@ -0,0 +1,117 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +#if CRIPPLED_REFLECTION + +using System.Linq; +using System.Reflection; + +namespace System.Reflection +{ + [Flags] + internal enum BindingFlags + { + Instance = 4, + Static = 8, + Public = 16, + NonPublic = 32, + } +} + +namespace System +{ + static class TypeExtensions + { + public static bool IsNestedPrivate(this Type t) + { + return t.GetTypeInfo().IsNestedPrivate; + } + + public static bool IsInterface(this Type t) + { + return t.GetTypeInfo().IsInterface; + } + + public static bool IsGenericType(this Type t) + { + return t.GetTypeInfo().IsGenericType; + } + + public static Type GetBaseType(this Type t) + { + return t.GetTypeInfo().BaseType; + } + + public static Type[] GetGenericArguments(this Type t) + { + // TODO: check what's the right way to support this + return t.GetTypeInfo().GenericTypeParameters.ToArray(); + } + + public static Type[] GetInterfaces(this Type t) + { + return t.GetTypeInfo().ImplementedInterfaces.ToArray(); + } + + public static bool IsAssignableFrom(this Type t1, Type t2) + { + return t1.GetTypeInfo().IsAssignableFrom(t2.GetTypeInfo()); + } + + public static MethodInfo[] GetMethods(this Type t, BindingFlags flags) + { + return t.GetTypeInfo().DeclaredMethods.Where(m => IsVisible(m, flags)).ToArray(); + } + + private static bool IsVisible(MethodInfo method, BindingFlags flags) + { + if ((flags & BindingFlags.Public) != 0 != method.IsPublic) + { + return false; + } + + if ((flags & BindingFlags.NonPublic) == 0 && !method.IsPublic) + { + return false; + } + + if ((flags & BindingFlags.Static) != 0 != method.IsStatic) + { + return false; + } + + return true; + } + } +} + +#else + +namespace System +{ + static class TypeExtensions + { + public static bool IsNestedPrivate(this Type t) + { + return t.IsNestedPrivate; + } + + public static bool IsInterface(this Type t) + { + return t.IsInterface; + } + + public static bool IsGenericType(this Type t) + { + return t.IsGenericType; + } + + public static Type GetBaseType(this Type t) + { + return t.BaseType; + } + } +} + +#endif diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index 8366e54376..a969da16db 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -12,4 +12,19 @@ + + + AsyncQueryable.Generated.tt + True + True + + + + + + AsyncQueryable.Generated.cs + TextTemplatingFileGenerator + + + diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableExecutor.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableExecutor.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableExecutor.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableExecutor.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableQuery.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers/AsyncEnumerableRewriter.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs similarity index 89% rename from Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index d6954d637d..602b6f713a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -456,20 +456,6 @@ public static Task Average(this IAsyncQueryable source) #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -856,7 +842,7 @@ public static Task Average(this IAsyncQueryable source #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -864,9 +850,9 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -1136,27 +1122,17 @@ public static Task Average(this IAsyncQueryable source #endif } - public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif - } - - public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count, int skip) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.Buffer(default(IAsyncQueryable), default(int), default(int))), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -1172,48 +1148,6 @@ public static IAsyncQueryable Cast(this IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif - } - - public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (handler == null) - throw new ArgumentNullException(nameof(handler)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(Expression>>))), source.Expression, handler)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); -#endif - } - - public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (handler == null) - throw new ArgumentNullException(nameof(handler)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); -#endif - } - public static IAsyncQueryable Concat(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -1240,29 +1174,29 @@ public static Task Contains(this IAsyncQueryable source, #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) + public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) + public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } @@ -1410,665 +1344,337 @@ public static IAsyncQueryable Distinct(this IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) + public static Task ElementAt(this IAsyncQueryable source, int index) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) + public static Task ElementAt(this IAsyncQueryable source, int index, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task ElementAtOrDefault(this IAsyncQueryable source, int index) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task ElementAtOrDefault(this IAsyncQueryable source, int index, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source) + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable))), source.Expression)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, IEqualityComparer comparer) + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) + public static Task First(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) + public static Task First(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task First(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task First(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) + public static Task First(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (observer == null) - throw new ArgumentNullException(nameof(observer)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + public static Task First(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + public static Task FirstOrDefault(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + public static Task FirstOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) + public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) + public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Action onCompleted) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Action))), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task ElementAt(this IAsyncQueryable source, int index) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task ElementAt(this IAsyncQueryable source, int index, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task ElementAtOrDefault(this IAsyncQueryable source, int index) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task ElementAtOrDefault(this IAsyncQueryable source, int index, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Expand(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); -#endif - } - - public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); -#endif - } - - public static IAsyncQueryable Finally(this IAsyncQueryable source, Action finallyAction) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (finallyAction == null) - throw new ArgumentNullException(nameof(finallyAction)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Finally(default(IAsyncQueryable), default(Action))), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); -#endif - } - - public static IAsyncQueryable Finally(this IAsyncQueryable source, Expression> finallyAction) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (finallyAction == null) - throw new ArgumentNullException(nameof(finallyAction)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Finally(default(IAsyncQueryable), default(Expression>))), source.Expression, finallyAction)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, finallyAction)); -#endif - } - - public static Task First(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task First(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task First(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task First(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task First(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task First(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstOrDefault(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task FirstOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2100,22 +1706,6 @@ public static IAsyncQueryable GroupBy(this IAsy #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) @@ -2348,18 +1938,6 @@ public static IAsyncQueryable GroupJoin( #endif } - public static IAsyncQueryable IgnoreElements(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.IgnoreElements(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif - } - public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -2670,33 +2248,33 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task LongCount(this IAsyncQueryable source, Expression> predicate) + public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) + public static Task LongCount(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2704,7 +2282,7 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -2738,30 +2316,6 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - public static Task Max(this IAsyncQueryable source) { if (source == null) @@ -2798,6 +2352,18 @@ public static Task LongCount(this IAsyncQueryable source #endif } + public static Task Max(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + public static Task Max(this IAsyncQueryable source) { if (source == null) @@ -2858,69 +2424,27 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -3084,6 +2608,60 @@ public static Task Max(this IAsyncQueryable source, E #endif } + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Max(this IAsyncQueryable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -3270,47 +2848,7 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Max(this IAsyncQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3318,27 +2856,25 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3346,13 +2882,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3360,9 +2896,9 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -3478,6 +3014,48 @@ public static Task Max(this IAsyncQueryable source, E #endif } + public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) @@ -3604,21 +3182,7 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3626,13 +3190,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3640,141 +3204,23 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3886,69 +3332,27 @@ public static Task Min(this IAsyncQueryable source) #endif } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task Min(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } @@ -4284,7 +3688,21 @@ public static Task Min(this IAsyncQueryable source, Cancellati #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4292,39 +3710,39 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, IComparer comparer) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4332,41 +3750,39 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4374,13 +3790,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4388,9 +3804,9 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } @@ -4632,21 +4048,7 @@ public static Task Min(this IAsyncQueryable source, Ex #endif } - public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4654,13 +4056,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4668,129 +4070,65 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -4806,20 +4144,6 @@ public static IAsyncQueryable OfType(this IAsyncQueryable #endif } - public static IAsyncQueryable OnErrorResumeNext(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OnErrorResumeNext(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif - } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -4876,195 +4200,115 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif - } - - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif - } - - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif - } - - public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); -#endif - } - - public static IAsyncQueryable Repeat(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IAsyncQueryable Repeat(this IAsyncQueryable source, int count) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable Retry(this IAsyncQueryable source) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable))), source.Expression)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable Retry(this IAsyncQueryable source, int retryCount) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Retry(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(retryCount, typeof(int)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IAsyncQueryable Reverse(this IAsyncQueryable source) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) + public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); #endif } - public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) + public static IAsyncQueryable Repeat(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif } - public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) + public static IAsyncQueryable Repeat(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); #endif } - public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + public static IAsyncQueryable Reverse(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif } @@ -5124,20 +4368,6 @@ public static IAsyncQueryable Select(this IAsyncQuery #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, IAsyncEnumerable other) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (other == null) - throw new ArgumentNullException(nameof(other)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(IAsyncEnumerable))), source.Expression, GetSourceExpression(other))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other))); -#endif - } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -5502,7 +4732,7 @@ public static IAsyncQueryable SkipLast(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5510,13 +4740,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5524,13 +4754,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5538,13 +4768,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5552,86 +4782,12 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable StartWith(this IAsyncQueryable source, params TSource[] values) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (values == null) - throw new ArgumentNullException(nameof(values)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.StartWith(default(IAsyncQueryable), default(TSource[]))), source.Expression, Expression.Constant(values, typeof(TSource[])))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[])))); -#endif - } - - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - public static Task Sum(this IAsyncQueryable source) { if (source == null) @@ -5692,163 +4848,63 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -6092,7 +5148,19 @@ public static Task Sum(this IAsyncQueryable source, E #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6100,13 +5168,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6114,13 +5182,25 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6128,13 +5208,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6142,13 +5222,25 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6156,13 +5248,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6170,13 +5262,25 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6184,13 +5288,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6198,9 +5302,9 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -6372,6 +5476,118 @@ public static Task Sum(this IAsyncQueryable source, E #endif } + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static IAsyncQueryable Take(this IAsyncQueryable source, int count) { if (source == null) @@ -6624,20 +5840,6 @@ public static Task> ToDictionary(this I #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) @@ -6716,6 +5918,20 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt similarity index 98% rename from Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index 5fbe407323..517f910fb3 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -4,7 +4,7 @@ <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> -<#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net45\System.Interactive.Async.dll" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Threading" #> diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers/AsyncQueryable.cs rename to Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs From da30f71a27716e4c87bd0604473f3f7c4117ca8e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 09:45:24 -0700 Subject: [PATCH 154/862] Adding LocalQueryMethodImplementationTypeAttribute support. --- .../System/Linq/AsyncQueryableEx.cs | 1 + .../System/Linq/AsyncEnumerableRewriter.cs | 7 +++- ...lQueryMethodImplementationTypeAttribute.cs | 32 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/LocalQueryMethodImplementationTypeAttribute.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs index 964654d825..ba1b2bbac0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs @@ -11,6 +11,7 @@ namespace System.Linq /// /// Provides a set of extension methods for asynchronous enumerable sequences represented using expression trees. /// + [LocalQueryMethodImplementationType(typeof(AsyncEnumerableEx))] public static partial class AsyncQueryableEx { private static Expression GetSourceExpression(IAsyncEnumerable source) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs index 5389d10e34..1c90f2500b 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs @@ -422,10 +422,15 @@ private static MethodInfo FindEnumerableMethod(string name, ReadOnlyCollection args, Type[] typeArgs, BindingFlags flags) { + // + // Support the enumerable methods to be defined on another type. + // + var targetType = type.GetTypeInfo().GetCustomAttribute()?.TargetType ?? type; + // // Get all the candidates based on name and fail if none are found. // - var methods = type.GetMethods(flags).Where(m => m.Name == name).ToArray(); + var methods = targetType.GetMethods(flags).Where(m => m.Name == name).ToArray(); if (methods.Length == 0) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find method with name '{0}' on type '{1}'.", name, type)); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/LocalQueryMethodImplementationTypeAttribute.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/LocalQueryMethodImplementationTypeAttribute.cs new file mode 100644 index 0000000000..10ae639912 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/LocalQueryMethodImplementationTypeAttribute.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; + +namespace System.Linq +{ + /// + /// Attribute applied to static classes providing expression tree forms of query methods, + /// mapping those to the corresponding methods for local query execution on the specified + /// target class type. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public sealed class LocalQueryMethodImplementationTypeAttribute : Attribute + { + /// + /// Creates a new mapping to the specified local execution query method implementation type. + /// + /// Type with query methods for local execution. + public LocalQueryMethodImplementationTypeAttribute(Type targetType) + { + TargetType = targetType; + } + + /// + /// Gets the type with the implementation of local query methods. + /// + public Type TargetType { get; } + } +} From 24dc59a42d6b99e2b00cfe7cd0712ae5cd099d89 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 09:47:27 -0700 Subject: [PATCH 155/862] Small cleanup of build files. --- Ix.NET/Source/Directory.build.props | 15 +++++++-------- Ix.NET/Source/Directory.build.targets | 7 +++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index 797512798b..5018df5f5e 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -1,5 +1,4 @@ - - + $(AssemblyName) ($(TargetFramework)) Copyright (c) .NET Foundation and Contributors. @@ -9,22 +8,22 @@ http://go.microsoft.com/fwlink/?LinkId=261274 http://go.microsoft.com/fwlink/?LinkId=261273 https://raw.githubusercontent.com/Reactive-Extensions/Rx.NET/master/Ix.NET/Source/license.txt - true + true true $(MSBuildThisFileDirectory)ReactiveX.snk $(NoWarn);1701;1702;CS1591 en-US $(MSBuildProjectName.Contains('Test')) - + - + - + 2.0.37-beta - + @@ -38,4 +37,4 @@ BeforeTargets="_GenerateRestoreProjectSpec" DependsOnTargets="GetBuildVersion" Condition=" '$(NerdbankGitVersioningTasksPath)' != '' " /> - \ No newline at end of file + diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 7297c7b6ee..69ac12e612 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -1,9 +1,9 @@ - + embedded - + $(DefineConstants);NO_ARRAY_EMPTY;NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION;PLIB;SIGNED @@ -17,5 +17,4 @@ $(DefineConstants);HAS_APTCA;DESKTOPCLR;DESKTOPCLR46;SIGNED - - \ No newline at end of file + From bbc5793f1f1251cec7bd3eabb8fe521e29efe17f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 09:55:30 -0700 Subject: [PATCH 156/862] Restructuring the solution. --- Ix.NET/Source/Ix.NET.sln | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index be49bf971a..77ced2fced 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26823.1 +VisualStudioVersion = 15.0.26730.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B733D97A-F1ED-4FC3-BF8E-9AC47A89DE96}" ProjectSection(SolutionItems) = preProject @@ -32,9 +32,12 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Tests", "System.Interactive.Tests\System.Interactive.Tests.csproj", "{AFD2E6EC-C5B0-4276-A14A-467D786D0DDA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Tests", "System.Interactive.Async.Tests\System.Interactive.Async.Tests.csproj", "{172BD8C4-5C3E-4928-9D3F-746CF336FFEC}" -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Linq.Async", "System.Linq.Async\System.Linq.Async.csproj", "{9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Linq.Async.Queryable", "System.Linq.Async.Queryable\System.Linq.Async.Queryable.csproj", "{513F9ABD-4FB8-4AC1-89DA-C3300399F34C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async", "System.Linq.Async\System.Linq.Async.csproj", "{9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable", "System.Linq.Async.Queryable\System.Linq.Async.Queryable.csproj", "{513F9ABD-4FB8-4AC1-89DA-C3300399F34C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{80EFE3A1-1414-42EA-949B-1B5370A1B2EA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -205,12 +208,15 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {FF97CD0F-8108-4B66-8A34-42190B459180} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {CA7B7136-13EE-4F01-BC22-722875EE8569} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} {ED118703-9773-4193-BC2A-966C29BC1A46} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {AFD2E6EC-C5B0-4276-A14A-467D786D0DDA} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {172BD8C4-5C3E-4928-9D3F-746CF336FFEC} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9B5F6126-CBBA-4C3A-A3BB-26AFE56DABEC} + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} From 68bc36205f0e8617fde704d9aa2351476b4a5a3f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 10:24:29 -0700 Subject: [PATCH 157/862] Adding Playground console application. --- Ix.NET/Source/Ix.NET.sln | 21 +++ Ix.NET/Source/Playground/DemoAttribute.cs | 21 +++ Ix.NET/Source/Playground/Playground.csproj | 17 ++ Ix.NET/Source/Playground/Program.cs | 185 +++++++++++++++++++++ 4 files changed, 244 insertions(+) create mode 100644 Ix.NET/Source/Playground/DemoAttribute.cs create mode 100644 Ix.NET/Source/Playground/Playground.csproj create mode 100644 Ix.NET/Source/Playground/Program.cs diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index 77ced2fced..3800bfa241 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -39,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{80EFE3A1-1414-42EA-949B-1B5370A1B2EA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dev", "dev", "{61683064-A120-44A7-A174-E19154F6D84F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playground", "Playground\Playground.csproj", "{CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -203,6 +207,22 @@ Global {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x64.Build.0 = Release|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x86.ActiveCfg = Release|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x86.Build.0 = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|ARM.ActiveCfg = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|ARM.Build.0 = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x64.ActiveCfg = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x64.Build.0 = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x86.ActiveCfg = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x86.Build.0 = Debug|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|Any CPU.Build.0 = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|ARM.ActiveCfg = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|ARM.Build.0 = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x64.ActiveCfg = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x64.Build.0 = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x86.ActiveCfg = Release|Any CPU + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -217,6 +237,7 @@ Global {172BD8C4-5C3E-4928-9D3F-746CF336FFEC} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} {513F9ABD-4FB8-4AC1-89DA-C3300399F34C} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0} = {61683064-A120-44A7-A174-E19154F6D84F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} diff --git a/Ix.NET/Source/Playground/DemoAttribute.cs b/Ix.NET/Source/Playground/DemoAttribute.cs new file mode 100644 index 0000000000..357ae8bb4d --- /dev/null +++ b/Ix.NET/Source/Playground/DemoAttribute.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Playground +{ + [AttributeUsage(AttributeTargets.Method)] + internal sealed class DemoAttribute : Attribute + { + public DemoAttribute(int index, string title) + { + Index = index; + Title = title; + } + + public int Index { get; } + public string Title { get; } + } +} diff --git a/Ix.NET/Source/Playground/Playground.csproj b/Ix.NET/Source/Playground/Playground.csproj new file mode 100644 index 0000000000..de2d4a0ca9 --- /dev/null +++ b/Ix.NET/Source/Playground/Playground.csproj @@ -0,0 +1,17 @@ + + + + Exe + netcoreapp2.0 + + + + + + + + + + + + diff --git a/Ix.NET/Source/Playground/Program.cs b/Ix.NET/Source/Playground/Program.cs new file mode 100644 index 0000000000..385984f6e4 --- /dev/null +++ b/Ix.NET/Source/Playground/Program.cs @@ -0,0 +1,185 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; + +namespace Playground +{ + class Program + { + static void Main() + { + RunDemos(); + } + + [Demo(0, "Random experimentation")] + static async Task Experiment() + { + // Add test code here + + await Task.Yield(); + } + + [Demo(1, "LINQ to Objects for IEnumerable")] + static void Linq() + { + var xs = new List { 1, 2, 3 }; + var ys = xs.Where(x => x % 2 == 0); + + foreach (var y in ys) + { + Console.WriteLine(y); + } + } + + [Demo(2, "LINQ to Objects for IEnumerable - Interactive Extensions")] + static void Ix() + { + var xs = new List { 1, 2, 3 }; + var ys = xs.Distinct(x => x % 2); + + foreach (var y in ys) + { + Console.WriteLine(y); + } + } + + [Demo(3, "LINQ to Objects for IAsyncEnumerable")] + static async Task AsyncLinq() + { + var xs = new List { 1, 2, 3 }; + var ys = xs.ToAsyncEnumerable().Where(x => x % 2 == 0); + +#if CSHARP8 + foreach await (var y in ys) + { + Console.WriteLine(y); + } +#else + var e = ys.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync()) + { + var y = e.Current; + + Console.WriteLine(y); + } + } + finally + { + await e.DisposeAsync(); + } +#endif + } + + [Demo(4, "LINQ to Objects for IAsyncEnumerable - Interactive Extensions")] + static async Task AsyncIx() + { + var xs = new List { 1, 2, 3 }; + var ys = xs.ToAsyncEnumerable().Distinct(x => x % 2); + +#if CSHARP8 + foreach await (var y in ys) + { + Console.WriteLine(y); + } +#else + await ys.ForEachAsync(y => + { + Console.WriteLine(y); + }); +#endif + } + + static void RunDemos() + { + var methods = (from method in typeof(Program).GetTypeInfo().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) + let demo = method.GetCustomAttribute() + let parameters = method.GetParameters() + let returnType = method.ReturnType + where demo != null && parameters.Length == 0 && (returnType == typeof(void) || returnType == typeof(Task)) + orderby demo.Index + select new { Demo = demo, Invoke = GetInvoker(method) }) + .ToArray(); + + var invokers = methods.ToDictionary(m => m.Demo.Index, m => m.Invoke); + + while (true) + { + foreach (var method in methods) + { + Console.WriteLine($"{method.Demo.Index}. {method.Demo.Title}"); + } + + Console.WriteLine(); + + var retry = true; + + while (retry) + { + Console.Write("Enter demo [C: Clear, X: Exit]: "); + var input = Console.ReadLine().Trim().ToUpper(); + + switch (input) + { + case "C": + retry = false; + Console.Clear(); + break; + case "X": + return; + default: + if (!int.TryParse(input, out var i) || !invokers.TryGetValue(i, out var invoke)) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Invalid input."); + Console.ResetColor(); + } + else + { + retry = false; + + Console.ForegroundColor = ConsoleColor.Cyan; + + try + { + invoke(); + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(ex.Message); + } + finally + { + Console.ResetColor(); + } + } + + break; + } + } + } + + Action GetInvoker(MethodInfo method) + { + if (method.ReturnType == typeof(void)) + { + return (Action)method.CreateDelegate(typeof(Action)); + } + else + { + var invoke = (Func)method.CreateDelegate(typeof(Func)); + return () => invoke().GetAwaiter().GetResult(); + } + } + } + } +} From 764931734f20e62e72a5e717186b689e14c10dda Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 10:30:23 -0700 Subject: [PATCH 158/862] Downgrading Playground to .NET Core 1.x. --- Ix.NET/Source/Playground/Playground.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/Playground/Playground.csproj b/Ix.NET/Source/Playground/Playground.csproj index de2d4a0ca9..57c9f373de 100644 --- a/Ix.NET/Source/Playground/Playground.csproj +++ b/Ix.NET/Source/Playground/Playground.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.0 + netcoreapp1.1 From d6530afbe57a4e622bd6107f28b430b45a24527e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 10:59:56 -0700 Subject: [PATCH 159/862] Extending the demo project. --- Ix.NET/Source/Playground/Program.cs | 81 +++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/Playground/Program.cs b/Ix.NET/Source/Playground/Program.cs index 385984f6e4..e3bf7c26f2 100644 --- a/Ix.NET/Source/Playground/Program.cs +++ b/Ix.NET/Source/Playground/Program.cs @@ -25,7 +25,7 @@ static async Task Experiment() await Task.Yield(); } - [Demo(1, "LINQ to Objects for IEnumerable")] + [Demo(11, "LINQ to Objects for IEnumerable")] static void Linq() { var xs = new List { 1, 2, 3 }; @@ -37,7 +37,19 @@ static void Linq() } } - [Demo(2, "LINQ to Objects for IEnumerable - Interactive Extensions")] + [Demo(12, "LINQ to Objects for IQueryable")] + static void LinqQueryable() + { + var xs = new List { 1, 2, 3 }.AsQueryable(); + var ys = xs.Where(x => x % 2 == 0); + + foreach (var y in ys) + { + Console.WriteLine(y); + } + } + + [Demo(21, "LINQ to Objects for IEnumerable - Interactive Extensions")] static void Ix() { var xs = new List { 1, 2, 3 }; @@ -49,7 +61,19 @@ static void Ix() } } - [Demo(3, "LINQ to Objects for IAsyncEnumerable")] + [Demo(22, "LINQ to Objects for IQueryable - Interactive Extensions")] + static void IxQueryable() + { + var xs = new List { 1, 2, 3 }.AsQueryable(); + var ys = xs.Distinct(x => x % 2); + + foreach (var y in ys) + { + Console.WriteLine(y); + } + } + + [Demo(31, "LINQ to Objects for IAsyncEnumerable")] static async Task AsyncLinq() { var xs = new List { 1, 2, 3 }; @@ -79,12 +103,61 @@ static async Task AsyncLinq() #endif } - [Demo(4, "LINQ to Objects for IAsyncEnumerable - Interactive Extensions")] + [Demo(32, "LINQ to Objects for IAsyncQueryable")] + static async Task AsyncLinqQueryable() + { + var xs = new List { 1, 2, 3 }.AsQueryable(); + var ys = xs.ToAsyncEnumerable().Where(x => x % 2 == 0); + +#if CSHARP8 + foreach await (var y in ys) + { + Console.WriteLine(y); + } +#else + var e = ys.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync()) + { + var y = e.Current; + + Console.WriteLine(y); + } + } + finally + { + await e.DisposeAsync(); + } +#endif + } + + [Demo(41, "LINQ to Objects for IAsyncEnumerable - Interactive Extensions")] static async Task AsyncIx() { var xs = new List { 1, 2, 3 }; var ys = xs.ToAsyncEnumerable().Distinct(x => x % 2); +#if CSHARP8 + foreach await (var y in ys) + { + Console.WriteLine(y); + } +#else + await ys.ForEachAsync(y => + { + Console.WriteLine(y); + }); +#endif + } + + [Demo(42, "LINQ to Objects for IAsyncQueryable - Interactive Extensions")] + static async Task AsyncIxQueryable() + { + var xs = new List { 1, 2, 3 }.AsQueryable(); + var ys = xs.ToAsyncEnumerable().Distinct(x => x % 2); + #if CSHARP8 foreach await (var y in ys) { From 6df10564ce084e3c7f9587b52b8ba57d5455b094 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:06:21 -0700 Subject: [PATCH 160/862] Adding ApiCompare tool. --- Ix.NET/Source/ApiCompare/ApiCompare.csproj | 17 + Ix.NET/Source/ApiCompare/Program.cs | 657 +++++++++++++++++++++ Ix.NET/Source/Ix.NET.sln | 19 + 3 files changed, 693 insertions(+) create mode 100644 Ix.NET/Source/ApiCompare/ApiCompare.csproj create mode 100644 Ix.NET/Source/ApiCompare/Program.cs diff --git a/Ix.NET/Source/ApiCompare/ApiCompare.csproj b/Ix.NET/Source/ApiCompare/ApiCompare.csproj new file mode 100644 index 0000000000..57c9f373de --- /dev/null +++ b/Ix.NET/Source/ApiCompare/ApiCompare.csproj @@ -0,0 +1,17 @@ + + + + Exe + netcoreapp1.1 + + + + + + + + + + + + diff --git a/Ix.NET/Source/ApiCompare/Program.cs b/Ix.NET/Source/ApiCompare/Program.cs new file mode 100644 index 0000000000..abc66e180d --- /dev/null +++ b/Ix.NET/Source/ApiCompare/Program.cs @@ -0,0 +1,657 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; + +namespace ApiCompare +{ + class Program + { + private static readonly Type asyncInterfaceType = typeof(IAsyncEnumerable<>); + private static readonly Type syncInterfaceType = typeof(IEnumerable<>); + + private static readonly Type asyncOrderedInterfaceType = typeof(IOrderedAsyncEnumerable<>); + private static readonly Type syncOrderedInterfaceType = typeof(IOrderedEnumerable<>); + + private static readonly TypeSubstitutor subst = new TypeSubstitutor(new Dictionary + { + { asyncInterfaceType, syncInterfaceType }, + { asyncOrderedInterfaceType, syncOrderedInterfaceType }, + { typeof(IAsyncGrouping<,>), typeof(IGrouping<,>) }, + }); + + static void Main() + { + var asyncOperatorsType = typeof(AsyncEnumerable); + var syncOperatorsType = typeof(Enumerable); + + Compare(syncOperatorsType, asyncOperatorsType); + } + + static void Compare(Type syncOperatorsType, Type asyncOperatorsType) + { + var syncOperators = GetQueryOperators(new[] { syncInterfaceType, syncOrderedInterfaceType}, syncOperatorsType); + var asyncOperators = GetQueryOperators(new[] { asyncInterfaceType, asyncOrderedInterfaceType }, asyncOperatorsType); + + CompareFactories(syncOperators.Factories, asyncOperators.Factories); + CompareQueryOperators(syncOperators.QueryOperators, asyncOperators.QueryOperators); + CompareAggregates(syncOperators.Aggregates, asyncOperators.Aggregates); + } + + static void CompareFactories(ILookup syncFactories, ILookup asyncFactories) + { + CompareSets(syncFactories, asyncFactories, CompareFactoryOverloads); + } + + static void CompareFactoryOverloads(string name, IEnumerable syncMethods, IEnumerable asyncMethods) + { + var sync = GetSignatures(syncMethods).ToArray(); + var async = GetRewrittenSignatures(asyncMethods).ToArray(); + + // + // Ensure that async is a superset of sync. + // + + var notInAsync = sync.Except(async); + + if (notInAsync.Any()) + { + foreach (var signature in notInAsync) + { + Console.WriteLine("MISSING " + ToString(signature.Method)); + } + } + + // + // Check for excess overloads. + // + + var notInSync = async.Except(sync); + + if (notInSync.Any()) + { + foreach (var signature in notInSync) + { + Console.WriteLine("EXCESS " + ToString(signature.Method)); + } + } + } + + static void CompareQueryOperators(ILookup syncOperators, ILookup asyncOperators) + { + CompareSets(syncOperators, asyncOperators, CompareQueryOperatorsOverloads); + } + + static void CompareQueryOperatorsOverloads(string name, IEnumerable syncMethods, IEnumerable asyncMethods) + { + var sync = GetSignatures(syncMethods).ToArray(); + var async = GetRewrittenSignatures(asyncMethods).ToArray(); + + // + // Ensure that async is a superset of sync. + // + + var notInAsync = sync.Except(async); + + if (notInAsync.Any()) + { + foreach (var signature in notInAsync) + { + Console.WriteLine("MISSING " + ToString(signature.Method)); + } + } + + // + // Find Task-based overloads. + // + + var taskBasedSignatures = new List(); + + foreach (var signature in sync) + { + if (signature.ParameterTypes.Any(IsFuncOrActionType)) + { + taskBasedSignatures.Add(GetAsyncVariant(signature)); + } + } + + if (taskBasedSignatures.Count > 0) + { + var notInAsyncTaskBased = taskBasedSignatures.Except(async); + + if (notInAsyncTaskBased.Any()) + { + foreach (var signature in notInAsyncTaskBased) + { + Console.WriteLine("MISSING " + name + " :: " + signature); + } + } + } + + // + // Excess overloads that are neither carbon copies of sync nor Task-based variants of sync. + // + + var notInSync = async.Except(sync.Union(taskBasedSignatures)); + + if (notInSync.Any()) + { + foreach (var signature in notInSync) + { + Console.WriteLine("EXCESS " + ToString(signature.Method)); + } + } + } + + static void CompareAggregates(ILookup syncAggregates, ILookup asyncAggregates) + { + CompareSets(syncAggregates, asyncAggregates, CompareAggregateOverloads); + } + + static void CompareAggregateOverloads(string name, IEnumerable syncMethods, IEnumerable asyncMethods) + { + var sync = GetSignatures(syncMethods).Select(GetAsyncAggregateSignature).ToArray(); + var async = GetRewrittenSignatures(asyncMethods).ToArray(); + + // + // Ensure that async is a superset of sync. + // + + var notInAsync = sync.Except(async); + + if (notInAsync.Any()) + { + foreach (var signature in notInAsync) + { + Console.WriteLine("MISSING " + ToString(signature.Method)); + } + } + + // + // Find Task-based overloads. + // + + var taskBasedSignatures = new List(); + + foreach (var signature in sync) + { + if (signature.ParameterTypes.Any(IsFuncOrActionType)) + { + taskBasedSignatures.Add(GetAsyncVariant(signature)); + } + } + + if (taskBasedSignatures.Count > 0) + { + var notInAsyncTaskBased = taskBasedSignatures.Except(async); + + if (notInAsyncTaskBased.Any()) + { + foreach (var signature in notInAsyncTaskBased) + { + Console.WriteLine("MISSING " + name + " :: " + signature); + } + } + } + + // + // Check for overloads with CancellationToken. + // + + var withCancellationToken = new List(); + + foreach (var signature in sync) + { + withCancellationToken.Add(AppendCancellationToken(signature)); + } + + foreach (var signature in taskBasedSignatures) + { + withCancellationToken.Add(AppendCancellationToken(signature)); + } + + var notInAsyncWithCancellationToken = withCancellationToken.Except(async); + + if (notInAsyncWithCancellationToken.Any()) + { + foreach (var signature in notInAsyncWithCancellationToken) + { + Console.WriteLine("MISSING " + name + " :: " + signature); + } + } + + // + // Excess overloads that are neither carbon copies of sync nor Task-based variants of sync. + // + + var notInSync = async.Except(sync.Union(taskBasedSignatures).Union(withCancellationToken)); + + if (notInSync.Any()) + { + foreach (var signature in notInSync) + { + Console.WriteLine("EXCESS " + ToString(signature.Method)); + } + } + } + + private static bool IsFuncOrActionType(Type type) + { + if (type.IsConstructedGenericType) + { + var defName = type.GetGenericTypeDefinition().Name; + return defName.StartsWith("Func`") || defName.StartsWith("Action`"); + } + + if (type == typeof(Action)) + { + return true; + } + + return false; + } + + private static Signature GetAsyncVariant(Signature signature) + { + return new Signature + { + ParameterTypes = signature.ParameterTypes.Select(GetAsyncVariant).ToArray(), + ReturnType = signature.ReturnType + }; + } + + private static Signature AppendCancellationToken(Signature signature) + { + return new Signature + { + ParameterTypes = signature.ParameterTypes.Concat(new[] { typeof(CancellationToken) }).ToArray(), + ReturnType = signature.ReturnType + }; + } + + private static Type GetAsyncVariant(Type type) + { + if (IsFuncOrActionType(type)) + { + if (type == typeof(Action)) + { + return typeof(Func); + } + else + { + var args = type.GetGenericArguments(); + + var defName = type.GetGenericTypeDefinition().Name; + if (defName.StartsWith("Func`")) + { + var ret = typeof(Task<>).MakeGenericType(args.Last()); + + return Expression.GetFuncType(args.SkipLast(1).Append(ret).ToArray()); + } + else + { + return Expression.GetFuncType(args.Append(typeof(Task)).ToArray()); + } + } + } + + return type; + } + + static void CompareSets(ILookup sync, ILookup async, Action, IEnumerable> compareCore) + { + var syncNames = sync.Select(g => g.Key).ToArray(); + var asyncNames = async.Select(g => g.Key).ToArray(); + + // + // Analyze that async is a superset of sync. + // + + var notInAsync = syncNames.Except(asyncNames); + + foreach (var n in notInAsync) + { + foreach (var o in sync[n]) + { + Console.WriteLine("MISSING " + ToString(o)); + } + } + + // + // Need to find the same overloads. + // + + var inBoth = syncNames.Intersect(asyncNames); + + foreach (var n in inBoth) + { + var s = sync[n]; + var a = async[n]; + + compareCore(n, s, a); + } + + // + // Report excessive API surface. + // + + var onlyInAsync = asyncNames.Except(syncNames); + + foreach (var n in onlyInAsync) + { + foreach (var o in async[n]) + { + Console.WriteLine("EXCESS " + ToString(o)); + } + } + } + + static Operators GetQueryOperators(Type[] interfaceTypes, Type operatorsType) + { + // + // Get all the static methods. + // + + var methods = operatorsType.GetMethods(BindingFlags.Public | BindingFlags.Static); + + // + // Get extension methods. These can be either operators or aggregates. + // + + var extensionMethods = methods.Where(m => m.IsDefined(typeof(ExtensionAttribute))).ToArray(); + + // + // Static methods that aren't extension methods can be factories. + // + + var factories = methods.Except(extensionMethods).Where(m => m.ReturnType.IsConstructedGenericType && interfaceTypes.Contains(m.ReturnType.GetGenericTypeDefinition())).ToArray(); + + // + // Extension methods that return the interface type are operators. + // + + var queryOperators = extensionMethods.Where(m => m.ReturnType.IsConstructedGenericType && interfaceTypes.Contains(m.ReturnType.GetGenericTypeDefinition())).ToArray(); + + // + // Extension methods that return another type are aggregates. + // + + var aggregates = extensionMethods.Except(queryOperators).ToArray(); + + // + // Return operators. + // + + return new Operators + { + Factories = factories.ToLookup(m => m.Name, m => m), + QueryOperators = queryOperators.ToLookup(m => m.Name, m => m), + Aggregates = aggregates.ToLookup(m => m.Name, m => m), + }; + } + + static IEnumerable GetSignatures(IEnumerable methods) + { + return methods.Select(m => GetSignature(m)); + } + + static IEnumerable GetRewrittenSignatures(IEnumerable methods) + { + return GetSignatures(methods).Select(s => RewriteSignature(s)); + } + + static Signature GetSignature(MethodInfo method) + { + if (method.IsGenericMethodDefinition) + { + var newArgs = method.GetGenericArguments().Select((t, i) => Wildcards[i]).ToArray(); + method = method.MakeGenericMethod(newArgs); + } + + return new Signature + { + Method = method, + ReturnType = method.ReturnType, + ParameterTypes = method.GetParameters().Select(p => p.ParameterType).ToArray() + }; + } + + static Signature RewriteSignature(Signature signature) + { + return new Signature + { + Method = signature.Method, + ReturnType = subst.Visit(signature.ReturnType), + ParameterTypes = subst.Visit(signature.ParameterTypes) + }; + } + + static Signature GetAsyncAggregateSignature(Signature signature) + { + var retType = signature.ReturnType == typeof(void) ? typeof(Task) : typeof(Task<>).MakeGenericType(signature.ReturnType); + + return new Signature + { + Method = signature.Method, + ReturnType = retType, + ParameterTypes = signature.ParameterTypes + }; + } + + static string ToString(MethodInfo method) + { + if (method == null) + { + return "UNKNOWN"; + } + + if (method.IsGenericMethod && !method.IsGenericMethodDefinition) + { + method = method.GetGenericMethodDefinition(); + } + + return method.ToString(); + } + + class Operators + { + public ILookup Factories; + public ILookup QueryOperators; + public ILookup Aggregates; + } + + class Signature : IEquatable + { + public MethodInfo Method; + public Type ReturnType; + public Type[] ParameterTypes; + + public static bool operator ==(Signature s1, Signature s2) + { + if ((object)s1 == null && (object)s2 == null) + { + return true; + } + + if ((object)s1 == null || (object)s2 == null) + { + return false; + } + + return s1.Equals(s2); + } + + public static bool operator !=(Signature s1, Signature s2) + { + return !(s1 == s2); + } + + public bool Equals(Signature s) + { + return (object)s != null && ReturnType.Equals(s.ReturnType) && ParameterTypes.SequenceEqual(s.ParameterTypes); + } + + public override bool Equals(object obj) + { + if (obj is Signature s) + { + return Equals(s); + } + + return false; + } + + public override int GetHashCode() + { + return ParameterTypes.Concat(new[] { ReturnType }).Aggregate(0, (a, t) => a * 17 + t.GetHashCode()); + } + + public override string ToString() + { + return "(" + string.Join(", ", ParameterTypes.Select(t => t.ToCSharp())) + ") -> " + ReturnType.ToCSharp(); + } + } + + class TypeVisitor + { + public virtual Type Visit(Type type) + { + if (type.IsArray) + { + if (type.GetElementType().MakeArrayType() == type) + { + return VisitArray(type); + } + else + { + return VisitMultidimensionalArray(type); + } + } + else if (type.GetTypeInfo().IsGenericTypeDefinition) + { + return VisitGenericTypeDefinition(type); + } + else if (type.IsConstructedGenericType) + { + return VisitGeneric(type); + } + else if (type.IsByRef) + { + return VisitByRef(type); + } + else if (type.IsPointer) + { + return VisitPointer(type); + } + else + { + return VisitSimple(type); + } + } + + protected virtual Type VisitArray(Type type) + { + return Visit(type.GetElementType()).MakeArrayType(); + } + + protected virtual Type VisitMultidimensionalArray(Type type) + { + return Visit(type.GetElementType()).MakeArrayType(type.GetArrayRank()); + } + + protected virtual Type VisitGenericTypeDefinition(Type type) + { + return type; + } + + protected virtual Type VisitGeneric(Type type) + { + return Visit(type.GetGenericTypeDefinition()).MakeGenericType(Visit(type.GenericTypeArguments)); + } + + protected virtual Type VisitByRef(Type type) + { + return Visit(type.GetElementType()).MakeByRefType(); + } + + protected virtual Type VisitPointer(Type type) + { + return Visit(type.GetElementType()).MakePointerType(); + } + + protected virtual Type VisitSimple(Type type) + { + return type; + } + + public Type[] Visit(Type[] types) + { + return types.Select(Visit).ToArray(); + } + } + + class TypeSubstitutor : TypeVisitor + { + private readonly Dictionary map; + + public TypeSubstitutor(Dictionary map) + { + this.map = map; + } + + public override Type Visit(Type type) + { + if (map.TryGetValue(type, out var subst)) + { + return subst; + } + + return base.Visit(type); + } + } + + private static readonly Type[] Wildcards = new[] { typeof(T1), typeof(T2), typeof(T3), typeof(T4) }; + + class T1 { } + class T2 { } + class T3 { } + class T4 { } + } + + static class TypeExtensions + { + public static string ToCSharp(this Type type) + { + if (type.IsArray) + { + if (type.GetElementType().MakeArrayType() == type) + { + return type.GetElementType().ToCSharp() + "[]"; + } + else + { + return type.GetElementType().ToCSharp() + "[" + new string(',', type.GetArrayRank() - 1) + "]"; + } + } + else if (type.IsConstructedGenericType) + { + var def = type.GetGenericTypeDefinition(); + var defName = def.Name.Substring(0, def.Name.IndexOf('`')); + + return defName + "<" + string.Join(", ", type.GetGenericArguments().Select(ToCSharp)) + ">"; + } + else + { + return type.Name; + } + } + } +} diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index 3800bfa241..0c11677c64 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -43,6 +43,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dev", "dev", "{61683064-A12 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playground", "Playground\Playground.csproj", "{CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiCompare", "ApiCompare\ApiCompare.csproj", "{792093F9-83E4-4630-9652-4328FDAED15F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -223,6 +225,22 @@ Global {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x64.Build.0 = Release|Any CPU {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x86.ActiveCfg = Release|Any CPU {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x86.Build.0 = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|ARM.Build.0 = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x64.ActiveCfg = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x64.Build.0 = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x86.ActiveCfg = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x86.Build.0 = Debug|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|Any CPU.Build.0 = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|ARM.ActiveCfg = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|ARM.Build.0 = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x64.ActiveCfg = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x64.Build.0 = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x86.ActiveCfg = Release|Any CPU + {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -238,6 +256,7 @@ Global {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} {513F9ABD-4FB8-4AC1-89DA-C3300399F34C} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0} = {61683064-A120-44A7-A174-E19154F6D84F} + {792093F9-83E4-4630-9652-4328FDAED15F} = {61683064-A120-44A7-A174-E19154F6D84F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} From f060df26e809b28540dcdcd27b2e2c8a1617407f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:13:31 -0700 Subject: [PATCH 161/862] Adding some exclusions to the API comparison tool. --- Ix.NET/Source/ApiCompare/Program.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/ApiCompare/Program.cs b/Ix.NET/Source/ApiCompare/Program.cs index abc66e180d..744625e144 100644 --- a/Ix.NET/Source/ApiCompare/Program.cs +++ b/Ix.NET/Source/ApiCompare/Program.cs @@ -21,6 +21,18 @@ class Program private static readonly Type asyncOrderedInterfaceType = typeof(IOrderedAsyncEnumerable<>); private static readonly Type syncOrderedInterfaceType = typeof(IOrderedEnumerable<>); + private static readonly string[] exceptions = new[] + { + "SkipLast", // In .NET Core 2.0 + "TakeLast", // In .NET Core 2.0 + + "Cast", // Non-generic methods + "OfType", // Non-generic methods + + "AsEnumerable", // Trivially renamed + "AsAsyncEnumerable" // Trivially renamed + }; + private static readonly TypeSubstitutor subst = new TypeSubstitutor(new Dictionary { { asyncInterfaceType, syncInterfaceType }, @@ -38,8 +50,8 @@ static void Main() static void Compare(Type syncOperatorsType, Type asyncOperatorsType) { - var syncOperators = GetQueryOperators(new[] { syncInterfaceType, syncOrderedInterfaceType}, syncOperatorsType); - var asyncOperators = GetQueryOperators(new[] { asyncInterfaceType, asyncOrderedInterfaceType }, asyncOperatorsType); + var syncOperators = GetQueryOperators(new[] { syncInterfaceType, syncOrderedInterfaceType}, syncOperatorsType, exceptions); + var asyncOperators = GetQueryOperators(new[] { asyncInterfaceType, asyncOrderedInterfaceType }, asyncOperatorsType, exceptions); CompareFactories(syncOperators.Factories, asyncOperators.Factories); CompareQueryOperators(syncOperators.QueryOperators, asyncOperators.QueryOperators); @@ -354,13 +366,13 @@ static void CompareSets(ILookup sync, ILookup !exclude.Contains(m.Name)); // // Get extension methods. These can be either operators or aggregates. From 2f49565521c58cc34e60f0940e8a261bdf2ab086 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:15:28 -0700 Subject: [PATCH 162/862] Renaming a file. --- .../System/Linq/Operators/{Empty.cs => IsEmpty.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Ix.NET/Source/System.Interactive/System/Linq/Operators/{Empty.cs => IsEmpty.cs} (100%) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IsEmpty.cs similarity index 100% rename from Ix.NET/Source/System.Interactive/System/Linq/Operators/Empty.cs rename to Ix.NET/Source/System.Interactive/System/Linq/Operators/IsEmpty.cs From 06d3a16ddac847e6b8f363ba42b0af6757f818fc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:16:45 -0700 Subject: [PATCH 163/862] Move IsEmpty to AsyncEnumerableEx. --- .../System.Interactive.Async.Tests/AsyncTests.Creation.cs | 4 ++-- .../System/Linq/Operators/IsEmpty.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename Ix.NET/Source/{System.Linq.Async => System.Interactive.Async}/System/Linq/Operators/IsEmpty.cs (95%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index f0abbd4686..fd3bd3366f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -52,8 +52,8 @@ public async Task Never() [Fact] public async Task Empty_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.IsEmpty(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.IsEmpty(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs similarity index 95% rename from Ix.NET/Source/System.Linq.Async/System/Linq/Operators/IsEmpty.cs rename to Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index 14b5f8f5d6..7ae5379a3b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -8,7 +8,7 @@ namespace System.Linq { - public static partial class AsyncEnumerable + public static partial class AsyncEnumerableEx { public static Task IsEmpty(this IAsyncEnumerable source) { From 4b5bef4fd54b5f394702cf3e7004a2e22b219e9c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:19:27 -0700 Subject: [PATCH 164/862] Regenerated AsyncQueryable[Ex]. --- .../System/Linq/AsyncQueryableEx.Generated.cs | 48 +- .../AsyncQueryableExTests.Generated.cs | 58 +- .../AsyncQueryableTests.Generated.cs | 646 +++++++++--------- .../System/Linq/AsyncQueryable.Generated.cs | 388 +++++------ 4 files changed, 570 insertions(+), 570 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index e462ea3295..70a6b84f7f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -434,6 +434,30 @@ public static IAsyncQueryable IgnoreElements(this IAsyncQuerya #endif } + public static Task IsEmpty(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + + public static Task IsEmpty(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -554,7 +578,7 @@ public static Task> MaxBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -562,13 +586,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -576,13 +600,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -590,13 +614,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -606,13 +630,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -620,13 +644,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -636,7 +660,7 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs index 6f1bdc3f47..75cdce96f1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs @@ -339,6 +339,24 @@ public void IgnoreElements1() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void IsEmpty1() + { + AssertEx.Throws(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void IsEmpty2() + { + AssertEx.Throws(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void MaxBy1() { @@ -426,62 +444,62 @@ public void MaxBy8() [Fact] public void MinBy1() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinBy2() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinBy3() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinBy4() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinBy5() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinBy6() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs index e07eced05d..065b3d61ec 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs @@ -1436,24 +1436,6 @@ public void Intersect2() AssertEx.SucceedOrFailProper(() => task.Wait()); } - [Fact] - public void IsEmpty1() - { - AssertEx.Throws(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void IsEmpty2() - { - AssertEx.Throws(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - [Fact] public void Join1() { @@ -1640,29 +1622,29 @@ public void LongCount1() [Fact] public void LongCount2() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void LongCount3() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void LongCount4() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1715,15 +1697,6 @@ public void Max3() [Fact] public void Max4() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max5() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1732,7 +1705,7 @@ public void Max5() } [Fact] - public void Max6() + public void Max5() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1741,7 +1714,7 @@ public void Max6() } [Fact] - public void Max7() + public void Max6() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1750,7 +1723,7 @@ public void Max7() } [Fact] - public void Max8() + public void Max7() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1759,7 +1732,7 @@ public void Max8() } [Fact] - public void Max9() + public void Max8() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1768,7 +1741,7 @@ public void Max9() } [Fact] - public void Max10() + public void Max9() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1777,7 +1750,7 @@ public void Max10() } [Fact] - public void Max11() + public void Max10() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1786,26 +1759,16 @@ public void Max11() } [Fact] - public void Max12() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max13() + public void Max11() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max14() + public void Max12() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1815,7 +1778,7 @@ public void Max14() } [Fact] - public void Max15() + public void Max13() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1824,7 +1787,7 @@ public void Max15() } [Fact] - public void Max16() + public void Max14() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1834,7 +1797,7 @@ public void Max16() } [Fact] - public void Max17() + public void Max15() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1844,7 +1807,7 @@ public void Max17() } [Fact] - public void Max18() + public void Max16() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1853,7 +1816,7 @@ public void Max18() } [Fact] - public void Max19() + public void Max17() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1863,7 +1826,7 @@ public void Max19() } [Fact] - public void Max20() + public void Max18() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1873,7 +1836,7 @@ public void Max20() } [Fact] - public void Max21() + public void Max19() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1882,7 +1845,7 @@ public void Max21() } [Fact] - public void Max22() + public void Max20() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1892,7 +1855,7 @@ public void Max22() } [Fact] - public void Max23() + public void Max21() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1902,16 +1865,7 @@ public void Max23() } [Fact] - public void Max24() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max25() + public void Max22() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); @@ -1921,7 +1875,7 @@ public void Max25() } [Fact] - public void Max26() + public void Max23() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1931,7 +1885,7 @@ public void Max26() } [Fact] - public void Max27() + public void Max24() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1941,7 +1895,7 @@ public void Max27() } [Fact] - public void Max28() + public void Max25() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1950,7 +1904,7 @@ public void Max28() } [Fact] - public void Max29() + public void Max26() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1960,7 +1914,7 @@ public void Max29() } [Fact] - public void Max30() + public void Max27() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1970,7 +1924,7 @@ public void Max30() } [Fact] - public void Max31() + public void Max28() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1979,7 +1933,7 @@ public void Max31() } [Fact] - public void Max32() + public void Max29() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1989,7 +1943,7 @@ public void Max32() } [Fact] - public void Max33() + public void Max30() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1999,7 +1953,7 @@ public void Max33() } [Fact] - public void Max34() + public void Max31() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2008,7 +1962,7 @@ public void Max34() } [Fact] - public void Max35() + public void Max32() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2018,7 +1972,7 @@ public void Max35() } [Fact] - public void Max36() + public void Max33() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2028,7 +1982,7 @@ public void Max36() } [Fact] - public void Max37() + public void Max34() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2037,7 +1991,7 @@ public void Max37() } [Fact] - public void Max38() + public void Max35() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2047,7 +2001,7 @@ public void Max38() } [Fact] - public void Max39() + public void Max36() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2057,7 +2011,7 @@ public void Max39() } [Fact] - public void Max40() + public void Max37() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2066,7 +2020,7 @@ public void Max40() } [Fact] - public void Max41() + public void Max38() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2076,7 +2030,7 @@ public void Max41() } [Fact] - public void Max42() + public void Max39() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2086,7 +2040,7 @@ public void Max42() } [Fact] - public void Max43() + public void Max40() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2095,7 +2049,7 @@ public void Max43() } [Fact] - public void Max44() + public void Max41() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2105,7 +2059,7 @@ public void Max44() } [Fact] - public void Max45() + public void Max42() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2115,17 +2069,35 @@ public void Max45() } [Fact] - public void Max46() + public void Max43() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max47() + public void Max44() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max45() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max46() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2135,7 +2107,7 @@ public void Max47() } [Fact] - public void Max48() + public void Max47() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2145,7 +2117,7 @@ public void Max48() } [Fact] - public void Max49() + public void Max48() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2155,7 +2127,7 @@ public void Max49() } [Fact] - public void Max50() + public void Max49() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2165,7 +2137,7 @@ public void Max50() } [Fact] - public void Max51() + public void Max50() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2175,7 +2147,7 @@ public void Max51() } [Fact] - public void Max52() + public void Max51() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2185,7 +2157,7 @@ public void Max52() } [Fact] - public void Max53() + public void Max52() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2195,7 +2167,7 @@ public void Max53() } [Fact] - public void Max54() + public void Max53() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); @@ -2205,7 +2177,7 @@ public void Max54() } [Fact] - public void Max55() + public void Max54() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2215,7 +2187,7 @@ public void Max55() } [Fact] - public void Max56() + public void Max55() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2225,7 +2197,7 @@ public void Max56() } [Fact] - public void Max57() + public void Max56() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2235,7 +2207,7 @@ public void Max57() } [Fact] - public void Max58() + public void Max57() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2245,7 +2217,7 @@ public void Max58() } [Fact] - public void Max59() + public void Max58() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2255,7 +2227,7 @@ public void Max59() } [Fact] - public void Max60() + public void Max59() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2265,7 +2237,7 @@ public void Max60() } [Fact] - public void Max61() + public void Max60() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2275,7 +2247,7 @@ public void Max61() } [Fact] - public void Max62() + public void Max61() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2285,7 +2257,7 @@ public void Max62() } [Fact] - public void Max63() + public void Max62() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2295,7 +2267,7 @@ public void Max63() } [Fact] - public void Max64() + public void Max63() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2305,7 +2277,7 @@ public void Max64() } [Fact] - public void Max65() + public void Max64() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2315,7 +2287,7 @@ public void Max65() } [Fact] - public void Max66() + public void Max65() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2325,7 +2297,7 @@ public void Max66() } [Fact] - public void Max67() + public void Max66() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2335,7 +2307,7 @@ public void Max67() } [Fact] - public void Max68() + public void Max67() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2345,16 +2317,17 @@ public void Max68() } [Fact] - public void Min1() + public void Max68() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min2() + public void Min1() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2363,7 +2336,7 @@ public void Min2() } [Fact] - public void Min3() + public void Min2() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2372,7 +2345,7 @@ public void Min3() } [Fact] - public void Min4() + public void Min3() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2381,7 +2354,7 @@ public void Min4() } [Fact] - public void Min5() + public void Min4() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2390,7 +2363,7 @@ public void Min5() } [Fact] - public void Min6() + public void Min5() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2399,7 +2372,7 @@ public void Min6() } [Fact] - public void Min7() + public void Min6() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2408,7 +2381,7 @@ public void Min7() } [Fact] - public void Min8() + public void Min7() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2417,7 +2390,7 @@ public void Min8() } [Fact] - public void Min9() + public void Min8() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2426,7 +2399,7 @@ public void Min9() } [Fact] - public void Min10() + public void Min9() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2435,35 +2408,25 @@ public void Min10() } [Fact] - public void Min11() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min12() + public void Min10() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min13() + public void Min11() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min14() + public void Min12() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2473,7 +2436,7 @@ public void Min14() } [Fact] - public void Min15() + public void Min13() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2482,7 +2445,7 @@ public void Min15() } [Fact] - public void Min16() + public void Min14() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2492,7 +2455,7 @@ public void Min16() } [Fact] - public void Min17() + public void Min15() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2502,7 +2465,7 @@ public void Min17() } [Fact] - public void Min18() + public void Min16() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2511,7 +2474,7 @@ public void Min18() } [Fact] - public void Min19() + public void Min17() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2521,7 +2484,7 @@ public void Min19() } [Fact] - public void Min20() + public void Min18() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2531,7 +2494,7 @@ public void Min20() } [Fact] - public void Min21() + public void Min19() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2540,7 +2503,7 @@ public void Min21() } [Fact] - public void Min22() + public void Min20() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2550,7 +2513,7 @@ public void Min22() } [Fact] - public void Min23() + public void Min21() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2560,7 +2523,7 @@ public void Min23() } [Fact] - public void Min24() + public void Min22() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2569,7 +2532,7 @@ public void Min24() } [Fact] - public void Min25() + public void Min23() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2579,7 +2542,7 @@ public void Min25() } [Fact] - public void Min26() + public void Min24() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2589,7 +2552,7 @@ public void Min26() } [Fact] - public void Min27() + public void Min25() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2598,7 +2561,7 @@ public void Min27() } [Fact] - public void Min28() + public void Min26() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2608,7 +2571,7 @@ public void Min28() } [Fact] - public void Min29() + public void Min27() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2618,7 +2581,7 @@ public void Min29() } [Fact] - public void Min30() + public void Min28() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2627,7 +2590,7 @@ public void Min30() } [Fact] - public void Min31() + public void Min29() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2637,7 +2600,7 @@ public void Min31() } [Fact] - public void Min32() + public void Min30() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2647,7 +2610,7 @@ public void Min32() } [Fact] - public void Min33() + public void Min31() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2656,7 +2619,7 @@ public void Min33() } [Fact] - public void Min34() + public void Min32() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2666,7 +2629,7 @@ public void Min34() } [Fact] - public void Min35() + public void Min33() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2676,7 +2639,7 @@ public void Min35() } [Fact] - public void Min36() + public void Min34() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2685,7 +2648,7 @@ public void Min36() } [Fact] - public void Min37() + public void Min35() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2695,7 +2658,7 @@ public void Min37() } [Fact] - public void Min38() + public void Min36() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2705,7 +2668,7 @@ public void Min38() } [Fact] - public void Min39() + public void Min37() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2714,7 +2677,7 @@ public void Min39() } [Fact] - public void Min40() + public void Min38() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2724,7 +2687,7 @@ public void Min40() } [Fact] - public void Min41() + public void Min39() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2733,6 +2696,25 @@ public void Min41() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Min40() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min41() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Min42() { @@ -2774,16 +2756,6 @@ public void Min45() [Fact] public void Min46() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min47() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2793,7 +2765,7 @@ public void Min47() } [Fact] - public void Min48() + public void Min47() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2803,7 +2775,7 @@ public void Min48() } [Fact] - public void Min49() + public void Min48() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2813,7 +2785,7 @@ public void Min49() } [Fact] - public void Min50() + public void Min49() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2823,7 +2795,7 @@ public void Min50() } [Fact] - public void Min51() + public void Min50() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2833,7 +2805,7 @@ public void Min51() } [Fact] - public void Min52() + public void Min51() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2843,7 +2815,7 @@ public void Min52() } [Fact] - public void Min53() + public void Min52() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2853,7 +2825,7 @@ public void Min53() } [Fact] - public void Min54() + public void Min53() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2863,7 +2835,7 @@ public void Min54() } [Fact] - public void Min55() + public void Min54() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2873,7 +2845,7 @@ public void Min55() } [Fact] - public void Min56() + public void Min55() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2883,7 +2855,7 @@ public void Min56() } [Fact] - public void Min57() + public void Min56() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2893,7 +2865,7 @@ public void Min57() } [Fact] - public void Min58() + public void Min57() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2903,7 +2875,7 @@ public void Min58() } [Fact] - public void Min59() + public void Min58() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2913,7 +2885,7 @@ public void Min59() } [Fact] - public void Min60() + public void Min59() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2923,7 +2895,7 @@ public void Min60() } [Fact] - public void Min61() + public void Min60() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2933,7 +2905,7 @@ public void Min61() } [Fact] - public void Min62() + public void Min61() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2943,7 +2915,7 @@ public void Min62() } [Fact] - public void Min63() + public void Min62() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2953,7 +2925,7 @@ public void Min63() } [Fact] - public void Min64() + public void Min63() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2963,12 +2935,22 @@ public void Min64() } [Fact] - public void Min65() + public void Min64() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min65() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3177,10 +3159,10 @@ public void Select4() [Fact] public void SelectMany1() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3188,10 +3170,10 @@ public void SelectMany1() [Fact] public void SelectMany2() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3199,10 +3181,10 @@ public void SelectMany2() [Fact] public void SelectMany3() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3210,10 +3192,10 @@ public void SelectMany3() [Fact] public void SelectMany4() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3580,35 +3562,6 @@ public void Sum10() [Fact] public void Sum11() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum12() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum13() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum14() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3617,7 +3570,7 @@ public void Sum14() } [Fact] - public void Sum15() + public void Sum12() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3627,7 +3580,7 @@ public void Sum15() } [Fact] - public void Sum16() + public void Sum13() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3637,7 +3590,7 @@ public void Sum16() } [Fact] - public void Sum17() + public void Sum14() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3646,7 +3599,7 @@ public void Sum17() } [Fact] - public void Sum18() + public void Sum15() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3656,7 +3609,7 @@ public void Sum18() } [Fact] - public void Sum19() + public void Sum16() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3666,7 +3619,7 @@ public void Sum19() } [Fact] - public void Sum20() + public void Sum17() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3675,7 +3628,7 @@ public void Sum20() } [Fact] - public void Sum21() + public void Sum18() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3685,7 +3638,7 @@ public void Sum21() } [Fact] - public void Sum22() + public void Sum19() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3695,7 +3648,7 @@ public void Sum22() } [Fact] - public void Sum23() + public void Sum20() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3704,7 +3657,7 @@ public void Sum23() } [Fact] - public void Sum24() + public void Sum21() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3714,7 +3667,7 @@ public void Sum24() } [Fact] - public void Sum25() + public void Sum22() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3724,7 +3677,7 @@ public void Sum25() } [Fact] - public void Sum26() + public void Sum23() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3733,7 +3686,7 @@ public void Sum26() } [Fact] - public void Sum27() + public void Sum24() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3743,7 +3696,7 @@ public void Sum27() } [Fact] - public void Sum28() + public void Sum25() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3753,7 +3706,7 @@ public void Sum28() } [Fact] - public void Sum29() + public void Sum26() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3762,7 +3715,7 @@ public void Sum29() } [Fact] - public void Sum30() + public void Sum27() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3772,7 +3725,7 @@ public void Sum30() } [Fact] - public void Sum31() + public void Sum28() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3782,7 +3735,7 @@ public void Sum31() } [Fact] - public void Sum32() + public void Sum29() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3791,7 +3744,7 @@ public void Sum32() } [Fact] - public void Sum33() + public void Sum30() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3801,7 +3754,7 @@ public void Sum33() } [Fact] - public void Sum34() + public void Sum31() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3811,7 +3764,7 @@ public void Sum34() } [Fact] - public void Sum35() + public void Sum32() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3820,7 +3773,7 @@ public void Sum35() } [Fact] - public void Sum36() + public void Sum33() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3830,7 +3783,7 @@ public void Sum36() } [Fact] - public void Sum37() + public void Sum34() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3840,7 +3793,7 @@ public void Sum37() } [Fact] - public void Sum38() + public void Sum35() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3849,7 +3802,7 @@ public void Sum38() } [Fact] - public void Sum39() + public void Sum36() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3859,7 +3812,7 @@ public void Sum39() } [Fact] - public void Sum40() + public void Sum37() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3869,17 +3822,36 @@ public void Sum40() } [Fact] - public void Sum41() + public void Sum38() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum42() + public void Sum39() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum40() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum41() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3889,7 +3861,7 @@ public void Sum42() } [Fact] - public void Sum43() + public void Sum42() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3899,7 +3871,7 @@ public void Sum43() } [Fact] - public void Sum44() + public void Sum43() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3909,7 +3881,7 @@ public void Sum44() } [Fact] - public void Sum45() + public void Sum44() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3919,7 +3891,7 @@ public void Sum45() } [Fact] - public void Sum46() + public void Sum45() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3929,7 +3901,7 @@ public void Sum46() } [Fact] - public void Sum47() + public void Sum46() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3939,7 +3911,7 @@ public void Sum47() } [Fact] - public void Sum48() + public void Sum47() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3949,7 +3921,7 @@ public void Sum48() } [Fact] - public void Sum49() + public void Sum48() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3959,7 +3931,7 @@ public void Sum49() } [Fact] - public void Sum50() + public void Sum49() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3969,7 +3941,7 @@ public void Sum50() } [Fact] - public void Sum51() + public void Sum50() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3979,7 +3951,7 @@ public void Sum51() } [Fact] - public void Sum52() + public void Sum51() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3989,7 +3961,7 @@ public void Sum52() } [Fact] - public void Sum53() + public void Sum52() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3999,7 +3971,7 @@ public void Sum53() } [Fact] - public void Sum54() + public void Sum53() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4009,7 +3981,7 @@ public void Sum54() } [Fact] - public void Sum55() + public void Sum54() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4019,7 +3991,7 @@ public void Sum55() } [Fact] - public void Sum56() + public void Sum55() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4029,7 +4001,7 @@ public void Sum56() } [Fact] - public void Sum57() + public void Sum56() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4039,7 +4011,7 @@ public void Sum57() } [Fact] - public void Sum58() + public void Sum57() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4049,7 +4021,7 @@ public void Sum58() } [Fact] - public void Sum59() + public void Sum58() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4059,7 +4031,7 @@ public void Sum59() } [Fact] - public void Sum60() + public void Sum59() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4068,6 +4040,16 @@ public void Sum60() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Sum60() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Take1() { @@ -4248,80 +4230,69 @@ public void ToDictionary2() [Fact] public void ToDictionary3() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary5() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary6() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary7() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary8() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary9() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionary10() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4332,7 +4303,7 @@ public void ToDictionary10() } [Fact] - public void ToDictionary11() + public void ToDictionary10() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4343,7 +4314,7 @@ public void ToDictionary11() } [Fact] - public void ToDictionary12() + public void ToDictionary11() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4354,7 +4325,7 @@ public void ToDictionary12() } [Fact] - public void ToDictionary13() + public void ToDictionary12() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4366,7 +4337,7 @@ public void ToDictionary13() } [Fact] - public void ToDictionary14() + public void ToDictionary13() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4377,6 +4348,17 @@ public void ToDictionary14() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void ToDictionary14() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void ToDictionary15() { diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 602b6f713a..f64c495387 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -1968,30 +1968,6 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable IsEmpty(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task IsEmpty(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.IsEmpty(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { if (outer == null) @@ -2248,33 +2224,33 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) + public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task LongCount(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task LongCount(this IAsyncQueryable source, Expression> predicate) + public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2282,7 +2258,7 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -2352,18 +2328,6 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - public static Task Max(this IAsyncQueryable source) { if (source == null) @@ -2448,29 +2412,15 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } @@ -2608,18 +2558,6 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Max(this IAsyncQueryable source, IComparer comparer) { if (source == null) @@ -2902,7 +2840,19 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2910,9 +2860,21 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3224,15 +3186,17 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3344,41 +3308,27 @@ public static Task Min(this IAsyncQueryable source) #endif } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } @@ -3756,6 +3706,32 @@ public static Task Min(this IAsyncQueryable source, E #endif } + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -3810,20 +3786,6 @@ public static Task Min(this IAsyncQueryable #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) @@ -4090,6 +4052,20 @@ public static Task Min(this IAsyncQueryable source, E #endif } + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -4368,7 +4344,7 @@ public static IAsyncQueryable Select(this IAsyncQuery #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4376,13 +4352,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4390,13 +4366,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4404,13 +4380,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4418,7 +4394,7 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif @@ -4908,46 +4884,6 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -5308,7 +5244,19 @@ public static Task Sum(this IAsyncQueryable source, Exp #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5316,9 +5264,23 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -5588,6 +5550,20 @@ public static Task Sum(this IAsyncQueryable source, Exp #endif } + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static IAsyncQueryable Take(this IAsyncQueryable source, int count) { if (source == null) @@ -5840,99 +5816,83 @@ public static Task> ToDictionary(this I #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5942,9 +5902,9 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } @@ -6032,6 +5992,22 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) From 1647285672f53c0e518fd0c1f67f9e0139d4dccb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:23:18 -0700 Subject: [PATCH 165/862] Remove blocking ForEach. --- .../AsyncTests.Single.cs | 70 ------------------- .../System/Linq/Operators/ForEach.cs | 40 ----------- 2 files changed, 110 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index eb12664a4a..0b96459c01 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -746,20 +746,6 @@ public async Task ForEachAsync_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); } - [Fact] - public void ForEach_Null() - { - AssertThrows(() => AsyncEnumerable.ForEach(null, x => { })); - AssertThrows(() => AsyncEnumerable.ForEach(AsyncEnumerable.Return(42), default(Action))); - AssertThrows(() => AsyncEnumerable.ForEach(null, (x, i) => { })); - AssertThrows(() => AsyncEnumerable.ForEach(AsyncEnumerable.Return(42), default(Action))); - - AssertThrows(() => AsyncEnumerable.ForEach(null, x => { }, CancellationToken.None)); - AssertThrows(() => AsyncEnumerable.ForEach(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); - AssertThrows(() => AsyncEnumerable.ForEach(null, (x, i) => { }, CancellationToken.None)); - AssertThrows(() => AsyncEnumerable.ForEach(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); - } - [Fact] public void ForEachAsync1() { @@ -770,32 +756,12 @@ public void ForEachAsync1() Assert.Equal(10, sum); } - [Fact] - public void ForEach1() - { - var sum = 0; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - - xs.ForEach(x => sum += x); - Assert.Equal(10, sum); - } - [Fact] public void ForEachAsync2() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - xs.ForEach((x, i) => sum += x * i); - Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum); - } - - [Fact] - public void ForEach2() - { - var sum = 0; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - xs.ForEachAsync((x, i) => sum += x * i).Wait(WaitTimeoutMs); Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum); } @@ -809,15 +775,6 @@ public void ForEachAsync3() AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void ForEach3() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - - AssertThrows(() => xs.ForEach(x => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public void ForEachAsync4() { @@ -827,15 +784,6 @@ public void ForEachAsync4() AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void ForEach4() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - - AssertThrows(() => xs.ForEach((x, i) => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public void ForEachAsync5() { @@ -845,15 +793,6 @@ public void ForEachAsync5() AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void ForEach5() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - - AssertThrows(() => xs.ForEach(x => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public void ForEachAsync6() { @@ -863,15 +802,6 @@ public void ForEachAsync6() AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void ForEach6() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - - AssertThrows(() => xs.ForEach((x, i) => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public void Take_Null() { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 3081b16f63..47386a28a8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -10,46 +10,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static void ForEach(this IAsyncEnumerable source, Action action) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (action == null) - throw new ArgumentNullException(nameof(action)); - - source.ForEach(action, CancellationToken.None); - } - - public static void ForEach(this IAsyncEnumerable source, Action action) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (action == null) - throw new ArgumentNullException(nameof(action)); - - source.ForEach(action, CancellationToken.None); - } - - public static void ForEach(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (action == null) - throw new ArgumentNullException(nameof(action)); - - source.ForEachAsync(action, cancellationToken).Wait(cancellationToken); - } - - public static void ForEach(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (action == null) - throw new ArgumentNullException(nameof(action)); - - source.ForEachAsync(action, cancellationToken).Wait(cancellationToken); - } - public static Task ForEachAsync(this IAsyncEnumerable source, Action action) { if (source == null) From d590e49d6a6b44d5fb58f08ca18b8f07e82d1ca9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:34:54 -0700 Subject: [PATCH 166/862] Moving non-standard Min and Max overloads to AsyncEnumerableEx. --- .../System/Linq/AsyncQueryableEx.Generated.cs | 80 +- .../AsyncQueryableExTests.Generated.cs | 78 +- .../AsyncQueryableTests.Generated.cs | 948 +++++++++--------- .../AsyncTests.Aggregates.cs | 16 +- .../System/Linq/Operators/Max.cs | 62 ++ .../System/Linq/Operators/Min.cs | 62 ++ .../System/Linq/AsyncQueryable.Generated.cs | 736 +++++++------- .../System/Linq/Operators/Max.cs | 20 - .../System/Linq/Operators/Min.cs | 20 - 9 files changed, 1053 insertions(+), 969 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 70a6b84f7f..edf53ed957 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -458,6 +458,34 @@ public static Task IsEmpty(this IAsyncQueryable source, #endif } + public static Task Max(this IAsyncQueryable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -486,7 +514,7 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -494,13 +522,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -510,13 +538,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -524,13 +552,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -540,13 +568,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -556,13 +584,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -572,12 +600,40 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } + public static Task Min(this IAsyncQueryable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); +#endif + } + + public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs index 75cdce96f1..8e9622b46b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs @@ -357,6 +357,26 @@ public void IsEmpty2() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Max1() + { + AssertEx.Throws(() => AsyncQueryableEx.Max(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max2() + { + AssertEx.Throws(() => AsyncQueryableEx.Max(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void MaxBy1() { @@ -380,47 +400,58 @@ public void MaxBy2() [Fact] public void MaxBy3() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxBy4() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxBy5() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxBy6() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxBy7() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy8() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -431,13 +462,22 @@ public void MaxBy7() } [Fact] - public void MaxBy8() + public void Min1() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.Min(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min2() + { + AssertEx.Throws(() => AsyncQueryableEx.Min(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs index 065b3d61ec..d3de1d8937 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs @@ -1158,10 +1158,10 @@ public void FirstOrDefault6() [Fact] public void GroupBy1() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1169,10 +1169,10 @@ public void GroupBy1() [Fact] public void GroupBy2() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1670,24 +1670,6 @@ public void LongCount6() [Fact] public void Max1() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max2() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max3() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1696,7 +1678,7 @@ public void Max3() } [Fact] - public void Max4() + public void Max2() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1705,7 +1687,7 @@ public void Max4() } [Fact] - public void Max5() + public void Max3() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1714,7 +1696,7 @@ public void Max5() } [Fact] - public void Max6() + public void Max4() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1723,7 +1705,7 @@ public void Max6() } [Fact] - public void Max7() + public void Max5() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1732,7 +1714,7 @@ public void Max7() } [Fact] - public void Max8() + public void Max6() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1741,7 +1723,7 @@ public void Max8() } [Fact] - public void Max9() + public void Max7() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1750,7 +1732,7 @@ public void Max9() } [Fact] - public void Max10() + public void Max8() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1759,64 +1741,34 @@ public void Max10() } [Fact] - public void Max11() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max12() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max13() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max14() + public void Max9() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max15() + public void Max10() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max16() + public void Max11() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max17() + public void Max12() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1826,7 +1778,7 @@ public void Max17() } [Fact] - public void Max18() + public void Max13() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1836,7 +1788,7 @@ public void Max18() } [Fact] - public void Max19() + public void Max14() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1845,7 +1797,7 @@ public void Max19() } [Fact] - public void Max20() + public void Max15() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1855,7 +1807,7 @@ public void Max20() } [Fact] - public void Max21() + public void Max16() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1865,37 +1817,7 @@ public void Max21() } [Fact] - public void Max22() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max23() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max24() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max25() + public void Max17() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1904,7 +1826,7 @@ public void Max25() } [Fact] - public void Max26() + public void Max18() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1914,7 +1836,7 @@ public void Max26() } [Fact] - public void Max27() + public void Max19() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1924,7 +1846,7 @@ public void Max27() } [Fact] - public void Max28() + public void Max20() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1933,7 +1855,7 @@ public void Max28() } [Fact] - public void Max29() + public void Max21() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1943,7 +1865,7 @@ public void Max29() } [Fact] - public void Max30() + public void Max22() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1953,7 +1875,7 @@ public void Max30() } [Fact] - public void Max31() + public void Max23() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1962,7 +1884,7 @@ public void Max31() } [Fact] - public void Max32() + public void Max24() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1972,7 +1894,7 @@ public void Max32() } [Fact] - public void Max33() + public void Max25() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1982,7 +1904,7 @@ public void Max33() } [Fact] - public void Max34() + public void Max26() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1991,7 +1913,7 @@ public void Max34() } [Fact] - public void Max35() + public void Max27() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2001,7 +1923,7 @@ public void Max35() } [Fact] - public void Max36() + public void Max28() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2011,7 +1933,7 @@ public void Max36() } [Fact] - public void Max37() + public void Max29() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2020,7 +1942,7 @@ public void Max37() } [Fact] - public void Max38() + public void Max30() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2030,7 +1952,7 @@ public void Max38() } [Fact] - public void Max39() + public void Max31() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2040,7 +1962,7 @@ public void Max39() } [Fact] - public void Max40() + public void Max32() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2049,7 +1971,7 @@ public void Max40() } [Fact] - public void Max41() + public void Max33() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2059,7 +1981,7 @@ public void Max41() } [Fact] - public void Max42() + public void Max34() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2069,7 +1991,7 @@ public void Max42() } [Fact] - public void Max43() + public void Max35() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2078,7 +2000,7 @@ public void Max43() } [Fact] - public void Max44() + public void Max36() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2088,126 +2010,134 @@ public void Max44() } [Fact] - public void Max45() + public void Max37() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max46() + public void Max38() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max47() + public void Max39() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max48() + public void Max40() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max49() + public void Max41() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max50() + public void Max42() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max51() + public void Max43() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max52() + public void Max44() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max53() + public void Max45() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max54() + public void Max46() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max55() + public void Max47() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max56() + public void Max48() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max49() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max57() + public void Max50() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2217,7 +2147,7 @@ public void Max57() } [Fact] - public void Max58() + public void Max51() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2227,7 +2157,7 @@ public void Max58() } [Fact] - public void Max59() + public void Max52() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2237,7 +2167,7 @@ public void Max59() } [Fact] - public void Max60() + public void Max53() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2247,7 +2177,7 @@ public void Max60() } [Fact] - public void Max61() + public void Max54() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2257,7 +2187,7 @@ public void Max61() } [Fact] - public void Max62() + public void Max55() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2267,7 +2197,7 @@ public void Max62() } [Fact] - public void Max63() + public void Max56() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2277,7 +2207,7 @@ public void Max63() } [Fact] - public void Max64() + public void Max57() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2287,7 +2217,7 @@ public void Max64() } [Fact] - public void Max65() + public void Max58() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2297,7 +2227,7 @@ public void Max65() } [Fact] - public void Max66() + public void Max59() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2307,7 +2237,7 @@ public void Max66() } [Fact] - public void Max67() + public void Max60() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2317,7 +2247,7 @@ public void Max67() } [Fact] - public void Max68() + public void Max61() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2327,145 +2257,156 @@ public void Max68() } [Fact] - public void Min1() + public void Max62() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min2() + public void Max63() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min3() + public void Max64() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min4() + public void Max65() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min5() + public void Max66() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min6() + public void Min1() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min7() + public void Min2() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min8() + public void Min3() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min9() + public void Min4() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min10() + public void Min5() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min11() + public void Min6() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min12() + public void Min7() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min13() + public void Min8() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min14() + public void Min9() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min15() + public void Min10() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min16() + public void Min11() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min12() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2474,7 +2415,7 @@ public void Min16() } [Fact] - public void Min17() + public void Min13() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2484,7 +2425,7 @@ public void Min17() } [Fact] - public void Min18() + public void Min14() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2494,7 +2435,7 @@ public void Min18() } [Fact] - public void Min19() + public void Min15() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2503,7 +2444,7 @@ public void Min19() } [Fact] - public void Min20() + public void Min16() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2513,7 +2454,7 @@ public void Min20() } [Fact] - public void Min21() + public void Min17() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2523,7 +2464,7 @@ public void Min21() } [Fact] - public void Min22() + public void Min18() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2532,7 +2473,7 @@ public void Min22() } [Fact] - public void Min23() + public void Min19() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2542,7 +2483,7 @@ public void Min23() } [Fact] - public void Min24() + public void Min20() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2552,7 +2493,7 @@ public void Min24() } [Fact] - public void Min25() + public void Min21() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2561,7 +2502,7 @@ public void Min25() } [Fact] - public void Min26() + public void Min22() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2571,7 +2512,7 @@ public void Min26() } [Fact] - public void Min27() + public void Min23() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2581,7 +2522,7 @@ public void Min27() } [Fact] - public void Min28() + public void Min24() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2590,7 +2531,7 @@ public void Min28() } [Fact] - public void Min29() + public void Min25() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2600,7 +2541,7 @@ public void Min29() } [Fact] - public void Min30() + public void Min26() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2610,7 +2551,7 @@ public void Min30() } [Fact] - public void Min31() + public void Min27() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2619,7 +2560,7 @@ public void Min31() } [Fact] - public void Min32() + public void Min28() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2629,7 +2570,7 @@ public void Min32() } [Fact] - public void Min33() + public void Min29() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2639,7 +2580,7 @@ public void Min33() } [Fact] - public void Min34() + public void Min30() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2648,7 +2589,7 @@ public void Min34() } [Fact] - public void Min35() + public void Min31() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2658,7 +2599,7 @@ public void Min35() } [Fact] - public void Min36() + public void Min32() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2668,7 +2609,7 @@ public void Min36() } [Fact] - public void Min37() + public void Min33() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2677,7 +2618,7 @@ public void Min37() } [Fact] - public void Min38() + public void Min34() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2687,7 +2628,7 @@ public void Min38() } [Fact] - public void Min39() + public void Min35() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2697,7 +2638,7 @@ public void Min39() } [Fact] - public void Min40() + public void Min36() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2706,7 +2647,7 @@ public void Min40() } [Fact] - public void Min41() + public void Min37() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2716,86 +2657,75 @@ public void Min41() } [Fact] - public void Min42() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min43() + public void Min38() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min44() + public void Min39() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min45() + public void Min40() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min46() + public void Min41() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min47() + public void Min42() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min48() + public void Min43() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min49() + public void Min44() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min50() + public void Min45() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2805,7 +2735,7 @@ public void Min50() } [Fact] - public void Min51() + public void Min46() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2815,7 +2745,7 @@ public void Min51() } [Fact] - public void Min52() + public void Min47() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2825,7 +2755,7 @@ public void Min52() } [Fact] - public void Min53() + public void Min48() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2835,7 +2765,7 @@ public void Min53() } [Fact] - public void Min54() + public void Min49() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2845,7 +2775,7 @@ public void Min54() } [Fact] - public void Min55() + public void Min50() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2855,7 +2785,7 @@ public void Min55() } [Fact] - public void Min56() + public void Min51() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2865,7 +2795,7 @@ public void Min56() } [Fact] - public void Min57() + public void Min52() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2875,7 +2805,7 @@ public void Min57() } [Fact] - public void Min58() + public void Min53() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2885,7 +2815,7 @@ public void Min58() } [Fact] - public void Min59() + public void Min54() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2895,7 +2825,7 @@ public void Min59() } [Fact] - public void Min60() + public void Min55() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2905,7 +2835,7 @@ public void Min60() } [Fact] - public void Min61() + public void Min56() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2915,7 +2845,7 @@ public void Min61() } [Fact] - public void Min62() + public void Min57() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2925,7 +2855,7 @@ public void Min62() } [Fact] - public void Min63() + public void Min58() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2935,7 +2865,7 @@ public void Min63() } [Fact] - public void Min64() + public void Min59() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2945,7 +2875,7 @@ public void Min64() } [Fact] - public void Min65() + public void Min60() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2955,17 +2885,47 @@ public void Min65() } [Fact] - public void Min66() + public void Min61() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min62() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min63() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min64() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min67() + public void Min65() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2975,7 +2935,7 @@ public void Min67() } [Fact] - public void Min68() + public void Min66() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3159,10 +3119,10 @@ public void Select4() [Fact] public void SelectMany1() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3170,10 +3130,10 @@ public void SelectMany1() [Fact] public void SelectMany2() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3181,10 +3141,10 @@ public void SelectMany2() [Fact] public void SelectMany3() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3192,10 +3152,10 @@ public void SelectMany3() [Fact] public void SelectMany4() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3261,21 +3221,21 @@ public void SequenceEqual1() [Fact] public void SequenceEqual2() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SequenceEqual3() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3472,24 +3432,6 @@ public void SkipWhile4() [Fact] public void Sum1() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum2() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum3() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3498,7 +3440,7 @@ public void Sum3() } [Fact] - public void Sum4() + public void Sum2() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3507,7 +3449,7 @@ public void Sum4() } [Fact] - public void Sum5() + public void Sum3() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3516,7 +3458,7 @@ public void Sum5() } [Fact] - public void Sum6() + public void Sum4() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3525,7 +3467,7 @@ public void Sum6() } [Fact] - public void Sum7() + public void Sum5() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3534,7 +3476,7 @@ public void Sum7() } [Fact] - public void Sum8() + public void Sum6() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3543,7 +3485,7 @@ public void Sum8() } [Fact] - public void Sum9() + public void Sum7() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3552,7 +3494,7 @@ public void Sum9() } [Fact] - public void Sum10() + public void Sum8() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3561,55 +3503,25 @@ public void Sum10() } [Fact] - public void Sum11() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum12() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum13() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum14() + public void Sum9() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum15() + public void Sum10() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum16() + public void Sum11() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3619,7 +3531,7 @@ public void Sum16() } [Fact] - public void Sum17() + public void Sum12() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3628,7 +3540,7 @@ public void Sum17() } [Fact] - public void Sum18() + public void Sum13() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3638,7 +3550,7 @@ public void Sum18() } [Fact] - public void Sum19() + public void Sum14() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3648,7 +3560,7 @@ public void Sum19() } [Fact] - public void Sum20() + public void Sum15() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3657,7 +3569,7 @@ public void Sum20() } [Fact] - public void Sum21() + public void Sum16() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3667,7 +3579,7 @@ public void Sum21() } [Fact] - public void Sum22() + public void Sum17() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3677,7 +3589,7 @@ public void Sum22() } [Fact] - public void Sum23() + public void Sum18() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3686,7 +3598,7 @@ public void Sum23() } [Fact] - public void Sum24() + public void Sum19() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3696,7 +3608,7 @@ public void Sum24() } [Fact] - public void Sum25() + public void Sum20() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3706,7 +3618,7 @@ public void Sum25() } [Fact] - public void Sum26() + public void Sum21() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3715,7 +3627,7 @@ public void Sum26() } [Fact] - public void Sum27() + public void Sum22() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3725,7 +3637,7 @@ public void Sum27() } [Fact] - public void Sum28() + public void Sum23() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3735,7 +3647,7 @@ public void Sum28() } [Fact] - public void Sum29() + public void Sum24() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3744,7 +3656,7 @@ public void Sum29() } [Fact] - public void Sum30() + public void Sum25() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3754,7 +3666,7 @@ public void Sum30() } [Fact] - public void Sum31() + public void Sum26() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3764,7 +3676,7 @@ public void Sum31() } [Fact] - public void Sum32() + public void Sum27() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3773,7 +3685,7 @@ public void Sum32() } [Fact] - public void Sum33() + public void Sum28() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3783,7 +3695,7 @@ public void Sum33() } [Fact] - public void Sum34() + public void Sum29() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3793,7 +3705,7 @@ public void Sum34() } [Fact] - public void Sum35() + public void Sum30() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3802,7 +3714,7 @@ public void Sum35() } [Fact] - public void Sum36() + public void Sum31() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3812,7 +3724,7 @@ public void Sum36() } [Fact] - public void Sum37() + public void Sum32() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3822,7 +3734,7 @@ public void Sum37() } [Fact] - public void Sum38() + public void Sum33() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3831,7 +3743,7 @@ public void Sum38() } [Fact] - public void Sum39() + public void Sum34() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3841,7 +3753,7 @@ public void Sum39() } [Fact] - public void Sum40() + public void Sum35() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3851,37 +3763,55 @@ public void Sum40() } [Fact] - public void Sum41() + public void Sum36() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum42() + public void Sum37() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum43() + public void Sum38() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum44() + public void Sum39() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum40() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum41() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3891,7 +3821,7 @@ public void Sum44() } [Fact] - public void Sum45() + public void Sum42() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3901,7 +3831,7 @@ public void Sum45() } [Fact] - public void Sum46() + public void Sum43() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3911,7 +3841,7 @@ public void Sum46() } [Fact] - public void Sum47() + public void Sum44() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3921,7 +3851,7 @@ public void Sum47() } [Fact] - public void Sum48() + public void Sum45() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3931,7 +3861,7 @@ public void Sum48() } [Fact] - public void Sum49() + public void Sum46() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3941,7 +3871,7 @@ public void Sum49() } [Fact] - public void Sum50() + public void Sum47() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3951,7 +3881,7 @@ public void Sum50() } [Fact] - public void Sum51() + public void Sum48() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3961,7 +3891,7 @@ public void Sum51() } [Fact] - public void Sum52() + public void Sum49() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3971,7 +3901,7 @@ public void Sum52() } [Fact] - public void Sum53() + public void Sum50() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3981,7 +3911,7 @@ public void Sum53() } [Fact] - public void Sum54() + public void Sum51() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3991,7 +3921,7 @@ public void Sum54() } [Fact] - public void Sum55() + public void Sum52() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4001,7 +3931,7 @@ public void Sum55() } [Fact] - public void Sum56() + public void Sum53() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4011,7 +3941,7 @@ public void Sum56() } [Fact] - public void Sum57() + public void Sum54() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4021,7 +3951,7 @@ public void Sum57() } [Fact] - public void Sum58() + public void Sum55() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4031,7 +3961,7 @@ public void Sum58() } [Fact] - public void Sum59() + public void Sum56() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4041,7 +3971,7 @@ public void Sum59() } [Fact] - public void Sum60() + public void Sum57() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4050,6 +3980,36 @@ public void Sum60() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Sum58() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum59() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum60() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Take1() { @@ -4230,69 +4190,80 @@ public void ToDictionary2() [Fact] public void ToDictionary3() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary5() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary6() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary7() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary8() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary9() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionary10() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4303,7 +4274,7 @@ public void ToDictionary9() } [Fact] - public void ToDictionary10() + public void ToDictionary11() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4314,7 +4285,7 @@ public void ToDictionary10() } [Fact] - public void ToDictionary11() + public void ToDictionary12() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4325,7 +4296,7 @@ public void ToDictionary11() } [Fact] - public void ToDictionary12() + public void ToDictionary13() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4337,7 +4308,7 @@ public void ToDictionary12() } [Fact] - public void ToDictionary13() + public void ToDictionary14() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4349,18 +4320,19 @@ public void ToDictionary13() } [Fact] - public void ToDictionary14() + public void ToDictionary15() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary15() + public void ToDictionary16() { AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4371,18 +4343,6 @@ public void ToDictionary15() AssertEx.SucceedOrFailProper(() => res.Wait()); } - [Fact] - public void ToDictionary16() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - [Fact] public void ToList1() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 51f1255c32..f78c19a3e4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -1632,11 +1632,11 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); } [Fact] @@ -1815,11 +1815,11 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs new file mode 100644 index 0000000000..a18417dacb --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -0,0 +1,62 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static Task Max(this IAsyncEnumerable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Max(comparer, CancellationToken.None); + } + + public static Task Max(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return Max_(source, comparer, cancellationToken); + } + + private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + var max = e.Current; + + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var cur = e.Current; + + if (comparer.Compare(cur, max) > 0) + { + max = cur; + } + } + + return max; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs new file mode 100644 index 0000000000..24b7382d91 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -0,0 +1,62 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static Task Min(this IAsyncEnumerable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Min(comparer, CancellationToken.None); + } + + public static Task Min(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return Min_(source, comparer, cancellationToken); + } + + private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + throw new InvalidOperationException(Strings.NO_ELEMENTS); + + var min = e.Current; + + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var cur = e.Current; + + if (comparer.Compare(cur, min) < 0) + { + min = cur; + } + } + + return min; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index f64c495387..3acb885f43 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -1582,7 +1582,7 @@ public static Task FirstOrDefault(this IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1590,13 +1590,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1604,7 +1604,7 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif @@ -2292,30 +2292,6 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - public static Task Max(this IAsyncQueryable source) { if (source == null) @@ -2412,81 +2388,39 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } @@ -2558,48 +2492,6 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); -#endif - } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -2866,33 +2758,33 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2900,13 +2792,13 @@ public static Task Max(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2914,27 +2806,37 @@ public static Task Max(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2942,13 +2844,13 @@ public static Task Max(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2956,13 +2858,13 @@ public static Task Max(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2970,27 +2872,27 @@ public static Task Max(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2998,13 +2900,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3012,9 +2914,9 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3200,189 +3102,205 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } @@ -3732,47 +3650,33 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Min(this IAsyncQueryable source, IComparer comparer) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3780,13 +3684,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3794,27 +3698,25 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3822,13 +3724,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3836,9 +3738,9 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } @@ -4066,17 +3968,59 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -4344,7 +4288,7 @@ public static IAsyncQueryable Select(this IAsyncQuery #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4352,13 +4296,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4366,13 +4310,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4380,13 +4324,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4394,7 +4338,7 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif @@ -4478,33 +4422,33 @@ public static Task SequenceEqual(this IAsyncQueryable fi #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } @@ -4764,30 +4708,6 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - public static Task Sum(this IAsyncQueryable source) { if (source == null) @@ -4884,69 +4804,27 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -5284,7 +5162,19 @@ public static Task Sum(this IAsyncQueryable source, Ex #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5292,13 +5182,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5306,13 +5196,25 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5320,9 +5222,9 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -5564,6 +5466,48 @@ public static Task Sum(this IAsyncQueryable source, Ex #endif } + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static IAsyncQueryable Take(this IAsyncQueryable source, int count) { if (source == null) @@ -5816,83 +5760,99 @@ public static Task> ToDictionary(this I #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); +#endif + } + + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5902,9 +5862,9 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -5992,23 +5952,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6020,13 +5964,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6038,7 +5982,7 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index bc6d3366fd..5bbced0c04 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -27,26 +27,6 @@ public static Task Max(this IAsyncEnumerable source, return source.Aggregate((x, y) => comparer.Compare(x, y) >= 0 ? x : y, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Max(comparer, CancellationToken.None); - } - - public static Task Max(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return Max_(source, comparer, cancellationToken); - } - public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index ccc9b973cf..3da6c74a25 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -27,26 +27,6 @@ public static Task Min(this IAsyncEnumerable source, return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Min(comparer, CancellationToken.None); - } - - public static Task Min(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return Min_(source, comparer, cancellationToken); - } - public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) From cda68c7aeb0b0c91c9bcfcb8b157878ec68064d2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:41:34 -0700 Subject: [PATCH 167/862] Excluding ForEachAsync from API comparison. --- Ix.NET/Source/ApiCompare/Program.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/ApiCompare/Program.cs b/Ix.NET/Source/ApiCompare/Program.cs index 744625e144..a797f84ebe 100644 --- a/Ix.NET/Source/ApiCompare/Program.cs +++ b/Ix.NET/Source/ApiCompare/Program.cs @@ -29,8 +29,10 @@ class Program "Cast", // Non-generic methods "OfType", // Non-generic methods - "AsEnumerable", // Trivially renamed - "AsAsyncEnumerable" // Trivially renamed + "AsEnumerable", // Trivially renamed + "AsAsyncEnumerable", // Trivially renamed + + "ForEachAsync", // "foreach await" language substitute for the time being }; private static readonly TypeSubstitutor subst = new TypeSubstitutor(new Dictionary From 636d4ebd68f4178cdc24cc88744f2eaf5c4e7284 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:47:32 -0700 Subject: [PATCH 168/862] Moving non-standard Repeat overloads to AsyncEnumerableEx. --- .../System/Linq/AsyncQueryableEx.Generated.cs | 24 +++ .../AsyncQueryableExTests.Generated.cs | 22 ++ .../AsyncQueryableTests.Generated.cs | 196 ++++++++---------- .../AsyncTests.Creation.cs | 4 +- .../AsyncTests.Single.cs | 6 +- .../System/Linq/Operators/Repeat.cs | 128 ++++++++++++ .../System/Linq/AsyncQueryable.Generated.cs | 110 ++++------ .../System/Linq/Operators/Repeat.cs | 115 ---------- 8 files changed, 309 insertions(+), 296 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index edf53ed957..a7bb567b96 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -768,6 +768,30 @@ public static IAsyncQueryable OnErrorResumeNext(this IAsyncQue #endif } + public static IAsyncQueryable Repeat(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Repeat(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); +#endif + } + + public static IAsyncQueryable Repeat(this IAsyncQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); +#endif + } + public static IAsyncQueryable Retry(this IAsyncQueryable source) { if (source == null) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs index 8e9622b46b..6f752613f9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs @@ -576,6 +576,28 @@ public void OnErrorResumeNext1() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Repeat1() + { + AssertEx.Throws(() => AsyncQueryableEx.Repeat(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + res = res.Take(5); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Repeat2() + { + AssertEx.Throws(() => AsyncQueryableEx.Repeat(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + res = res.Take(5); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Retry1() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs index d3de1d8937..435108d6d5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs @@ -3040,28 +3040,6 @@ public void Prepend1() AssertEx.SucceedOrFailProper(() => task.Wait()); } - [Fact] - public void Repeat1() - { - AssertEx.Throws(() => AsyncQueryable.Repeat(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - res = res.Take(5); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Repeat2() - { - AssertEx.Throws(() => AsyncQueryable.Repeat(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Repeat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - res = res.Take(5); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - [Fact] public void Reverse1() { @@ -3221,21 +3199,21 @@ public void SequenceEqual1() [Fact] public void SequenceEqual2() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SequenceEqual3() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3522,16 +3500,6 @@ public void Sum10() [Fact] public void Sum11() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum12() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3540,7 +3508,7 @@ public void Sum12() } [Fact] - public void Sum13() + public void Sum12() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3550,7 +3518,7 @@ public void Sum13() } [Fact] - public void Sum14() + public void Sum13() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3560,7 +3528,7 @@ public void Sum14() } [Fact] - public void Sum15() + public void Sum14() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3569,7 +3537,7 @@ public void Sum15() } [Fact] - public void Sum16() + public void Sum15() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3579,7 +3547,7 @@ public void Sum16() } [Fact] - public void Sum17() + public void Sum16() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3589,7 +3557,7 @@ public void Sum17() } [Fact] - public void Sum18() + public void Sum17() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3598,7 +3566,7 @@ public void Sum18() } [Fact] - public void Sum19() + public void Sum18() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3608,7 +3576,7 @@ public void Sum19() } [Fact] - public void Sum20() + public void Sum19() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3618,7 +3586,7 @@ public void Sum20() } [Fact] - public void Sum21() + public void Sum20() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3627,7 +3595,7 @@ public void Sum21() } [Fact] - public void Sum22() + public void Sum21() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3637,7 +3605,7 @@ public void Sum22() } [Fact] - public void Sum23() + public void Sum22() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3647,7 +3615,7 @@ public void Sum23() } [Fact] - public void Sum24() + public void Sum23() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3656,7 +3624,7 @@ public void Sum24() } [Fact] - public void Sum25() + public void Sum24() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3666,7 +3634,7 @@ public void Sum25() } [Fact] - public void Sum26() + public void Sum25() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3676,7 +3644,7 @@ public void Sum26() } [Fact] - public void Sum27() + public void Sum26() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3685,7 +3653,7 @@ public void Sum27() } [Fact] - public void Sum28() + public void Sum27() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3695,7 +3663,7 @@ public void Sum28() } [Fact] - public void Sum29() + public void Sum28() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3705,7 +3673,7 @@ public void Sum29() } [Fact] - public void Sum30() + public void Sum29() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3714,7 +3682,7 @@ public void Sum30() } [Fact] - public void Sum31() + public void Sum30() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3724,7 +3692,7 @@ public void Sum31() } [Fact] - public void Sum32() + public void Sum31() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3734,7 +3702,7 @@ public void Sum32() } [Fact] - public void Sum33() + public void Sum32() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3743,7 +3711,7 @@ public void Sum33() } [Fact] - public void Sum34() + public void Sum33() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3753,7 +3721,7 @@ public void Sum34() } [Fact] - public void Sum35() + public void Sum34() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3763,7 +3731,7 @@ public void Sum35() } [Fact] - public void Sum36() + public void Sum35() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3772,7 +3740,7 @@ public void Sum36() } [Fact] - public void Sum37() + public void Sum36() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3782,7 +3750,7 @@ public void Sum37() } [Fact] - public void Sum38() + public void Sum37() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3792,7 +3760,7 @@ public void Sum38() } [Fact] - public void Sum39() + public void Sum38() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3801,7 +3769,7 @@ public void Sum39() } [Fact] - public void Sum40() + public void Sum39() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3811,27 +3779,17 @@ public void Sum40() } [Fact] - public void Sum41() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum42() + public void Sum40() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum43() + public void Sum41() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3841,7 +3799,7 @@ public void Sum43() } [Fact] - public void Sum44() + public void Sum42() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3851,7 +3809,7 @@ public void Sum44() } [Fact] - public void Sum45() + public void Sum43() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3861,7 +3819,7 @@ public void Sum45() } [Fact] - public void Sum46() + public void Sum44() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3871,7 +3829,7 @@ public void Sum46() } [Fact] - public void Sum47() + public void Sum45() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3881,7 +3839,7 @@ public void Sum47() } [Fact] - public void Sum48() + public void Sum46() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3891,7 +3849,7 @@ public void Sum48() } [Fact] - public void Sum49() + public void Sum47() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3901,7 +3859,7 @@ public void Sum49() } [Fact] - public void Sum50() + public void Sum48() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3911,7 +3869,7 @@ public void Sum50() } [Fact] - public void Sum51() + public void Sum49() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3921,7 +3879,7 @@ public void Sum51() } [Fact] - public void Sum52() + public void Sum50() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3931,7 +3889,7 @@ public void Sum52() } [Fact] - public void Sum53() + public void Sum51() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3941,7 +3899,7 @@ public void Sum53() } [Fact] - public void Sum54() + public void Sum52() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3951,7 +3909,7 @@ public void Sum54() } [Fact] - public void Sum55() + public void Sum53() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3961,7 +3919,7 @@ public void Sum55() } [Fact] - public void Sum56() + public void Sum54() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3971,7 +3929,7 @@ public void Sum56() } [Fact] - public void Sum57() + public void Sum55() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3981,7 +3939,7 @@ public void Sum57() } [Fact] - public void Sum58() + public void Sum56() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3991,7 +3949,7 @@ public void Sum58() } [Fact] - public void Sum59() + public void Sum57() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4001,7 +3959,7 @@ public void Sum59() } [Fact] - public void Sum60() + public void Sum58() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4010,6 +3968,26 @@ public void Sum60() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Sum59() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum60() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Take1() { @@ -4322,24 +4300,24 @@ public void ToDictionary14() [Fact] public void ToDictionary15() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary16() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index fd3bd3366f..9a96732b81 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -155,7 +155,7 @@ public void Repeat2() [Fact] public async Task Repeat3() { - var xs = AsyncEnumerable.Repeat(2); + var xs = AsyncEnumerableEx.Repeat(2); var e = xs.GetAsyncEnumerator(); HasNext(e, 2); @@ -169,7 +169,7 @@ public async Task Repeat3() [Fact] public async Task Repeat4() { - var xs = AsyncEnumerable.Repeat(2).Take(5); + var xs = AsyncEnumerableEx.Repeat(2).Take(5); await SequenceIdentity(xs); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 0b96459c01..c096713bc1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -2700,9 +2700,9 @@ public void AsAsyncEnumerable1() [Fact] public void RepeatSeq_Null() { - AssertThrows(() => AsyncEnumerable.Repeat(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Repeat(default(IAsyncEnumerable), 3)); - AssertThrows(() => AsyncEnumerable.Repeat(AsyncEnumerable.Return(42), -1)); + AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); + AssertThrows(() => AsyncEnumerableEx.Repeat(AsyncEnumerable.Return(42), -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs new file mode 100644 index 0000000000..a1ca5459f0 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Repeat(TResult element) + { + return new RepeatElementAsyncIterator(element); + } + + public static IAsyncEnumerable Repeat(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return new RepeatSequenceAsyncIterator(source, -1); + } + + public static IAsyncEnumerable Repeat(this IAsyncEnumerable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + return new RepeatSequenceAsyncIterator(source, count); + } + + private sealed class RepeatElementAsyncIterator : AsyncIterator + { + private readonly TResult element; + + public RepeatElementAsyncIterator(TResult element) + { + this.element = element; + } + + public override AsyncIterator Clone() + { + return new RepeatElementAsyncIterator(element); + } + + protected override Task MoveNextCore() + { + current = element; + return TaskExt.True; + } + } + + private sealed class RepeatSequenceAsyncIterator : AsyncIterator + { + private readonly int count; + private readonly bool isInfinite; + private readonly IAsyncEnumerable source; + + private int currentCount; + private IAsyncEnumerator enumerator; + + public RepeatSequenceAsyncIterator(IAsyncEnumerable source, int count) + { + Debug.Assert(source != null); + + this.source = source; + this.count = count; + isInfinite = count < 0; + currentCount = count; + } + + public override AsyncIterator Clone() + { + return new RepeatSequenceAsyncIterator(source, count); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + if (!isInfinite && currentCount-- == 0) + break; + + enumerator = source.GetAsyncEnumerator(); + state = AsyncIteratorState.Iterating; + + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + goto case AsyncIteratorState.Allocated; + } + + await DisposeAsync().ConfigureAwait(false); + + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 3acb885f43..8d1c3d1f29 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -4196,30 +4196,6 @@ public static IAsyncQueryable Prepend(this IAsyncQueryable Repeat(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif - } - - public static IAsyncQueryable Repeat(this IAsyncQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif - } - public static IAsyncQueryable Reverse(this IAsyncQueryable source) { if (source == null) @@ -4422,33 +4398,33 @@ public static Task SequenceEqual(this IAsyncQueryable fi #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -4828,20 +4804,6 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -5228,21 +5190,7 @@ public static Task Sum(this IAsyncQueryable source, E #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5250,9 +5198,9 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -5508,6 +5456,34 @@ public static Task Sum(this IAsyncQueryable source, E #endif } + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static IAsyncQueryable Take(this IAsyncQueryable source, int count) { if (source == null) @@ -5952,7 +5928,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5964,13 +5940,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5982,7 +5958,7 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index af40b94206..0b928d1b9f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -10,11 +10,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Repeat(TResult element) - { - return new RepeatElementAsyncIterator(element); - } - public static IAsyncEnumerable Repeat(TResult element, int count) { if (count < 0) @@ -22,115 +17,5 @@ public static IAsyncEnumerable Repeat(TResult element, int cou return Enumerable.Repeat(element, count).ToAsyncEnumerable(); } - - public static IAsyncEnumerable Repeat(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return new RepeatSequenceAsyncIterator(source, -1); - } - - public static IAsyncEnumerable Repeat(this IAsyncEnumerable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - return new RepeatSequenceAsyncIterator(source, count); - } - - private sealed class RepeatElementAsyncIterator : AsyncIterator - { - private readonly TResult element; - - public RepeatElementAsyncIterator(TResult element) - { - this.element = element; - } - - public override AsyncIterator Clone() - { - return new RepeatElementAsyncIterator(element); - } - - protected override Task MoveNextCore() - { - current = element; - return TaskExt.True; - } - } - - private sealed class RepeatSequenceAsyncIterator : AsyncIterator - { - private readonly int count; - private readonly bool isInfinite; - private readonly IAsyncEnumerable source; - - private int currentCount; - private IAsyncEnumerator enumerator; - - public RepeatSequenceAsyncIterator(IAsyncEnumerable source, int count) - { - Debug.Assert(source != null); - - this.source = source; - this.count = count; - isInfinite = count < 0; - currentCount = count; - } - - public override AsyncIterator Clone() - { - return new RepeatSequenceAsyncIterator(source, count); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - if (!isInfinite && currentCount-- == 0) - break; - - enumerator = source.GetAsyncEnumerator(); - state = AsyncIteratorState.Iterating; - - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = enumerator.Current; - return true; - } - - goto case AsyncIteratorState.Allocated; - } - - await DisposeAsync().ConfigureAwait(false); - - return false; - } - } } } From 11c4f43fc8d1f58a0e92998841488496e98bbe6c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:51:22 -0700 Subject: [PATCH 169/862] Fix a few typos. --- .../System.Interactive.Async.Tests/AsyncTests.Conversions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs index 1c20417870..45562ec04c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs @@ -165,7 +165,7 @@ public async Task ToAsyncEnumerable10() } [Fact] - public void ToAsyncEnumerabl11() + public void ToAsyncEnumerable11() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -191,7 +191,7 @@ public void ToAsyncEnumerabl11() } [Fact] - public void ToAsyncEnumerabl12() + public void ToAsyncEnumerable12() { var set = new List { 1, 2, 3, 4 }; var xs = set.ToAsyncEnumerable(); From 4d0bb3e4c5c4848dd9606b8997418af2e36860d8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:55:35 -0700 Subject: [PATCH 170/862] Restructuring project folder layout. --- .../System.Interactive.Providers/{ => System/Linq}/QueryableEx.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Ix.NET/Source/System.Interactive.Providers/{ => System/Linq}/QueryableEx.cs (100%) diff --git a/Ix.NET/Source/System.Interactive.Providers/QueryableEx.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Providers/QueryableEx.cs rename to Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs From e1e6d627941d2eb85a478d3abb4d6ffdeac3fbce Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:59:04 -0700 Subject: [PATCH 171/862] Splitting QueryableEx into separate files. --- .../System/Linq/QueryableEx.Generated.cs | 2362 +++++++++++++++++ .../System/Linq/QueryableEx.cs | 2350 +--------------- 2 files changed, 2363 insertions(+), 2349 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs new file mode 100644 index 0000000000..2b63929605 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs @@ -0,0 +1,2362 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq.Expressions; +using System.Reflection; + +namespace System.Linq +{ + public static partial class QueryableEx + { + /// + /// Determines whether an enumerable sequence is empty. + /// + /// Source sequence element type. + /// Source sequence. + /// true if the sequence is empty; false otherwise. + public static bool IsEmpty(this IQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.Execute( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.IsEmpty(default(IQueryable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsEmpty(IEnumerable source) + { + return EnumerableEx.IsEmpty(source); + } +#pragma warning restore 1591 + + /// + /// Returns the minimum value in the enumerable sequence by using the specified comparer to compare values. + /// + /// Source sequence element type. + /// Source sequence. + /// Comparer used to determine the minimum value. + /// Minimum value in the sequence. + public static TSource Min(this IQueryable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Provider.Execute( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Min(default(IQueryable), default(IComparer))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(comparer, typeof(IComparer)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static TSource Min(IEnumerable source, IComparer comparer) + { + return EnumerableEx.Min(source, comparer); + } +#pragma warning restore 1591 + + /// + /// Returns the elements with the minimum key value by using the default comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// List with the elements that share the same minimum key value. + public static IList MinBy(this IQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.Provider.Execute>( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.MinBy(default(IQueryable), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IList MinBy(IEnumerable source, Func keySelector) + { + return EnumerableEx.MinBy(source, keySelector); + } +#pragma warning restore 1591 + + /// + /// Returns the elements with the minimum key value by using the specified comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// Comparer used to determine the minimum key value. + /// List with the elements that share the same minimum key value. + public static IList MinBy(this IQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Provider.Execute>( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.MinBy(default(IQueryable), default(Expression>), default(IComparer))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector, + Expression.Constant(comparer, typeof(IComparer)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IList MinBy(IEnumerable source, Func keySelector, IComparer comparer) + { + return EnumerableEx.MinBy(source, keySelector, comparer); + } +#pragma warning restore 1591 + + /// + /// Returns the maximum value in the enumerable sequence by using the specified comparer to compare values. + /// + /// Source sequence element type. + /// Source sequence. + /// Comparer used to determine the maximum value. + /// Maximum value in the sequence. + public static TSource Max(this IQueryable source, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Provider.Execute( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Max(default(IQueryable), default(IComparer))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(comparer, typeof(IComparer)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static TSource Max(IEnumerable source, IComparer comparer) + { + return EnumerableEx.Max(source, comparer); + } +#pragma warning restore 1591 + + /// + /// Returns the elements with the maximum key value by using the default comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// List with the elements that share the same maximum key value. + public static IList MaxBy(this IQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.Provider.Execute>( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.MaxBy(default(IQueryable), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IList MaxBy(IEnumerable source, Func keySelector) + { + return EnumerableEx.MaxBy(source, keySelector); + } +#pragma warning restore 1591 + + /// + /// Returns the elements with the minimum key value by using the specified comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector used to extract the key for each element in the sequence. + /// Comparer used to determine the maximum key value. + /// List with the elements that share the same maximum key value. + public static IList MaxBy(this IQueryable source, Expression> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Provider.Execute>( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.MaxBy(default(IQueryable), default(Expression>), default(IComparer))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector, + Expression.Constant(comparer, typeof(IComparer)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IList MaxBy(IEnumerable source, Func keySelector, IComparer comparer) + { + return EnumerableEx.MaxBy(source, keySelector, comparer); + } +#pragma warning restore 1591 + + /// + /// Shares the source sequence within a selector function where each enumerator can fetch the next element from the source sequence. + /// + /// Source sequence element type. + /// Result sequence element type. + /// Source sequence. + /// Selector function with shared access to the source sequence for each enumerator. + /// Sequence resulting from applying the selector function to the shared view over the source sequence. + public static IQueryable Share(this IQueryable source, Expression, IEnumerable>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Share(default(IQueryable), default(Expression, IEnumerable>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), +#endif + source.Expression, + selector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Share(IEnumerable source, Func, IEnumerable> selector) + { + return EnumerableEx.Share(source, selector); + } +#pragma warning restore 1591 + + /// + /// Publishes the source sequence within a selector function where each enumerator can obtain a view over a tail of the source sequence. + /// + /// Source sequence element type. + /// Result sequence element type. + /// Source sequence. + /// Selector function with published access to the source sequence for each enumerator. + /// Sequence resulting from applying the selector function to the published view over the source sequence. + public static IQueryable Publish(this IQueryable source, Expression, IEnumerable>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Publish(default(IQueryable), default(Expression, IEnumerable>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), +#endif + source.Expression, + selector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Publish(IEnumerable source, Func, IEnumerable> selector) + { + return EnumerableEx.Publish(source, selector); + } +#pragma warning restore 1591 + + /// + /// Memoizes the source sequence within a selector function where each enumerator can get access to all of the sequence's elements without causing multiple enumerations over the source. + /// + /// Source sequence element type. + /// Result sequence element type. + /// Source sequence. + /// Selector function with memoized access to the source sequence for each enumerator. + /// Sequence resulting from applying the selector function to the memoized view over the source sequence. + public static IQueryable Memoize(this IQueryable source, Expression, IEnumerable>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Memoize(default(IQueryable), default(Expression, IEnumerable>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), +#endif + source.Expression, + selector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Memoize(IEnumerable source, Func, IEnumerable> selector) + { + return EnumerableEx.Memoize(source, selector); + } +#pragma warning restore 1591 + + /// + /// Memoizes the source sequence within a selector function where a specified number of enumerators can get access to all of the sequence's elements without causing multiple enumerations over the source. + /// + /// Source sequence element type. + /// Result sequence element type. + /// Source sequence. + /// Number of enumerators that can access the underlying buffer. Once every enumerator has obtained an element from the buffer, the element is removed from the buffer. + /// Selector function with memoized access to the source sequence for a specified number of enumerators. + /// Sequence resulting from applying the selector function to the memoized view over the source sequence. + public static IQueryable Memoize(this IQueryable source, int readerCount, Expression, IEnumerable>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Memoize(default(IQueryable), default(int), default(Expression, IEnumerable>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), +#endif + source.Expression, + Expression.Constant(readerCount, typeof(int)), + selector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Memoize(IEnumerable source, int readerCount, Func, IEnumerable> selector) + { + return EnumerableEx.Memoize(source, readerCount, selector); + } +#pragma warning restore 1591 + + /// + /// Creates an enumerable sequence based on an enumerator factory function. + /// + /// Result sequence element type. + /// Query provider. + /// Enumerator factory function. + /// Sequence that will invoke the enumerator factory upon a call to GetEnumerator. + public static IQueryable Create(this IQueryProvider provider, Expression>> getEnumerator) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (getEnumerator == null) + throw new ArgumentNullException(nameof(getEnumerator)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Create(default(IQueryProvider), default(Expression>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + getEnumerator + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Create(Func> getEnumerator) + { + return EnumerableEx.Create(getEnumerator); + } +#pragma warning restore 1591 + + /// + /// Returns a sequence with a single element. + /// + /// Result sequence element type. + /// Query provider. + /// Single element of the resulting sequence. + /// Sequence with a single element. + public static IQueryable Return(this IQueryProvider provider, TResult value) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Return(default(IQueryProvider), default(TResult))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + Expression.Constant(value, typeof(TResult)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Return(TResult value) + { + return EnumerableEx.Return(value).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Returns a sequence that throws an exception upon enumeration. + /// + /// Result sequence element type. + /// Query provider. + /// Exception to throw upon enumerating the resulting sequence. + /// Sequence that throws the specified exception upon enumeration. + public static IQueryable Throw(this IQueryProvider provider, Exception exception) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (exception == null) + throw new ArgumentNullException(nameof(exception)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Throw(default(IQueryProvider), default(Exception))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + Expression.Constant(exception, typeof(Exception)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Throw(Exception exception) + { + return EnumerableEx.Throw(exception).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Creates an enumerable sequence based on an enumerable factory function. + /// + /// Result sequence element type. + /// Query provider. + /// Enumerable factory function. + /// Sequence that will invoke the enumerable factory upon a call to GetEnumerator. + public static IQueryable Defer(this IQueryProvider provider, Expression>> enumerableFactory) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (enumerableFactory == null) + throw new ArgumentNullException(nameof(enumerableFactory)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Defer(default(IQueryProvider), default(Expression>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + enumerableFactory + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Defer(Func> enumerableFactory) + { + return EnumerableEx.Defer(enumerableFactory).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence by mimicking a for loop. + /// + /// State type. + /// Result sequence element type. + /// Query provider. + /// Initial state of the generator loop. + /// Loop condition. + /// State update function to run after every iteration of the generator loop. + /// Result selector to compute resulting sequence elements. + /// Sequence obtained by running the generator loop, yielding computed elements. + public static IQueryable Generate(this IQueryProvider provider, TState initialState, Expression> condition, Expression> iterate, Expression> resultSelector) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (condition == null) + throw new ArgumentNullException(nameof(condition)); + if (iterate == null) + throw new ArgumentNullException(nameof(iterate)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Generate(default(IQueryProvider), default(TState), default(Expression>), default(Expression>), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + Expression.Constant(initialState), + condition, + iterate, + resultSelector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Generate(TState initialState, Func condition, Func iterate, Func resultSelector) + { + return EnumerableEx.Generate(initialState, condition, iterate, resultSelector).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence that's dependent on a resource object whose lifetime is determined by the sequence usage duration. + /// + /// Source element type. + /// Resource type. + /// Query provider. + /// Resource factory function. + /// Enumerable factory function, having access to the obtained resource. + /// Sequence whose use controls the lifetime of the associated obtained resource. + public static IQueryable Using(this IQueryProvider provider, Expression> resourceFactory, Expression>> enumerableFactory) where TResource : IDisposable + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (resourceFactory == null) + throw new ArgumentNullException(nameof(resourceFactory)); + if (enumerableFactory == null) + throw new ArgumentNullException(nameof(enumerableFactory)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Using(default(IQueryProvider), default(Expression>), default(Expression>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResource)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + resourceFactory, + enumerableFactory + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Using(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable + { + return EnumerableEx.Using(resourceFactory, enumerableFactory).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence by repeating the given value infinitely. + /// + /// Result sequence element type. + /// Query provider. + /// Value to repreat in the resulting sequence. + /// Sequence repeating the given value infinitely. + public static IEnumerable Repeat(this IQueryProvider provider, TResult value) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Repeat(default(IQueryProvider), default(TResult))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + Expression.Constant(value, typeof(TResult)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Repeat(TResult value) + { + return EnumerableEx.Repeat(value).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence that corresponds to the source sequence, concatenating it with the sequence resulting from calling an exception handler function in case of an error. + /// + /// Source sequence element type. + /// Exception type to catch. + /// Source sequence. + /// Handler to invoke when an exception of the specified type occurs. + /// Source sequence, concatenated with an exception handler result sequence in case of an error. + public static IQueryable Catch(this IQueryable source, Expression>> handler) + where TException : Exception + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (handler == null) + throw new ArgumentNullException(nameof(handler)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Catch(default(IQueryable), default(Expression>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), +#endif + source.Expression, + handler + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Catch(IEnumerable source, Func> handler) + where TException : Exception + { + return EnumerableEx.Catch(source, handler); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. + /// + /// Source sequence element type. + /// Source sequences. + /// Sequence that continues to concatenate source sequences while errors occur. + public static IQueryable Catch(this IQueryable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return sources.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Catch(default(IQueryable>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + sources.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Catch(IEnumerable> sources) + { + return EnumerableEx.Catch(sources); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. + /// + /// Source sequence element type. + /// Query provider. + /// Source sequences. + /// Sequence that continues to concatenate source sequences while errors occur. + public static IQueryable Catch(this IQueryProvider provider, params IEnumerable[] sources) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Catch(default(IQueryProvider), default(IEnumerable[]))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + GetSourceExpression(sources) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Catch(params IEnumerable[] sources) + { + return EnumerableEx.Catch(sources).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence that returns the elements of the first sequence, switching to the second in case of an error. + /// + /// Source sequence element type. + /// First sequence. + /// Second sequence, concatenated to the result in case the first sequence completes exceptionally. + /// The first sequence, followed by the second sequence in case an error is produced. + public static IQueryable Catch(this IQueryable first, IEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + + return first.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Catch(default(IQueryable), default(IEnumerable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + first.Expression, + GetSourceExpression(second) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Catch(IEnumerable first, IEnumerable second) + { + return EnumerableEx.Catch(first, second); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed. + /// + /// Source sequence element type. + /// Source sequence. + /// Action to run upon termination of the sequence, or when an enumerator is disposed. + /// Source sequence with guarantees on the invocation of the finally action. + public static IQueryable Finally(this IQueryable source, Expression finallyAction) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (finallyAction == null) + throw new ArgumentNullException(nameof(finallyAction)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Finally(default(IQueryable), default(Expression))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + finallyAction + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Finally(IEnumerable source, Action finallyAction) + { + return EnumerableEx.Finally(source, finallyAction); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence that concatenates both given sequences, regardless of whether an error occurs. + /// + /// Source sequence element type. + /// First sequence. + /// Second sequence. + /// Sequence concatenating the elements of both sequences, ignoring errors. + public static IQueryable OnErrorResumeNext(this IQueryable first, IEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + + return first.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryable), default(IEnumerable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + first.Expression, + GetSourceExpression(second) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable OnErrorResumeNext(IEnumerable first, IEnumerable second) + { + return EnumerableEx.OnErrorResumeNext(first, second); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the sequences. + /// + /// Source sequence element type. + /// Query provider. + /// Source sequences. + /// Sequence concatenating the elements of the given sequences, ignoring errors. + public static IEnumerable OnErrorResumeNext(this IQueryProvider provider, params IEnumerable[] sources) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryProvider), default(IEnumerable[]))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + GetSourceExpression(sources) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable OnErrorResumeNext(params IEnumerable[] sources) + { + return EnumerableEx.OnErrorResumeNext(sources).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the sequences. + /// + /// Source sequence element type. + /// Source sequences. + /// Sequence concatenating the elements of the given sequences, ignoring errors. + public static IQueryable OnErrorResumeNext(this IQueryable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return sources.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryable>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + sources.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable OnErrorResumeNext(IEnumerable> sources) + { + return EnumerableEx.OnErrorResumeNext(sources); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence that retries enumerating the source sequence as long as an error occurs. + /// + /// Source sequence element type. + /// Source sequence. + /// Sequence concatenating the results of the source sequence as long as an error occurs. + public static IQueryable Retry(this IQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Retry(default(IQueryable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Retry(IEnumerable source) + { + return EnumerableEx.Retry(source); + } +#pragma warning restore 1591 + + /// + /// Creates a sequence that retries enumerating the source sequence as long as an error occurs, with the specified maximum number of retries. + /// + /// Source sequence element type. + /// Source sequence. + /// Maximum number of retries. + /// Sequence concatenating the results of the source sequence as long as an error occurs. + public static IQueryable Retry(this IQueryable source, int retryCount) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Retry(default(IQueryable), default(int))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(retryCount, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Retry(IEnumerable source, int retryCount) + { + return EnumerableEx.Retry(source, retryCount); + } +#pragma warning restore 1591 + + /// + /// Generates an enumerable sequence by repeating a source sequence as long as the given loop condition holds. + /// + /// Result sequence element type. + /// Query provider. + /// Loop condition. + /// Sequence to repeat while the condition evaluates true. + /// Sequence generated by repeating the given sequence while the condition evaluates to true. + public static IQueryable While(this IQueryProvider provider, Expression> condition, IEnumerable source) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (condition == null) + throw new ArgumentNullException(nameof(condition)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.While(default(IQueryProvider), default(Expression>), default(IEnumerable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + condition, + GetSourceExpression(source) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable While(Func condition, IEnumerable source) + { + return EnumerableEx.While(condition, source).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Returns an enumerable sequence based on the evaluation result of the given condition. + /// + /// Result sequence element type. + /// Query provider. + /// Condition to evaluate. + /// Sequence to return in case the condition evaluates true. + /// Sequence to return in case the condition evaluates false. + /// Either of the two input sequences based on the result of evaluating the condition. + public static IQueryable If(this IQueryProvider provider, Expression> condition, IEnumerable thenSource, IEnumerable elseSource) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (condition == null) + throw new ArgumentNullException(nameof(condition)); + if (thenSource == null) + throw new ArgumentNullException(nameof(thenSource)); + if (elseSource == null) + throw new ArgumentNullException(nameof(elseSource)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.If(default(IQueryProvider), default(Expression>), default(IEnumerable), default(IEnumerable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + condition, + GetSourceExpression(thenSource), + GetSourceExpression(elseSource) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable If(Func condition, IEnumerable thenSource, IEnumerable elseSource) + { + return EnumerableEx.If(condition, thenSource, elseSource).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty sequence. + /// + /// Result sequence element type. + /// Query provider. + /// Condition to evaluate. + /// Sequence to return in case the condition evaluates true. + /// The given input sequence if the condition evaluates true; otherwise, an empty sequence. + public static IQueryable If(this IQueryProvider provider, Expression> condition, IEnumerable thenSource) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (condition == null) + throw new ArgumentNullException(nameof(condition)); + if (thenSource == null) + throw new ArgumentNullException(nameof(thenSource)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.If(default(IQueryProvider), default(Expression>), default(IEnumerable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + condition, + GetSourceExpression(thenSource) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable If(Func condition, IEnumerable thenSource) + { + return EnumerableEx.If(condition, thenSource).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds. + /// + /// Result sequence element type. + /// Source sequence to repeat while the condition evaluates true. + /// Loop condition. + /// Sequence generated by repeating the given sequence until the condition evaluates to false. + public static IQueryable DoWhile(this IQueryable source, Expression> condition) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (condition == null) + throw new ArgumentNullException(nameof(condition)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.DoWhile(default(IQueryable), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + source.Expression, + condition + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable DoWhile(IEnumerable source, Func condition) + { + return EnumerableEx.DoWhile(source, condition); + } +#pragma warning restore 1591 + + /// + /// Returns a sequence from a dictionary based on the result of evaluating a selector function. + /// + /// Type of the selector value. + /// Result sequence element type. + /// Query provider. + /// Selector function used to pick a sequence from the given sources. + /// Dictionary mapping selector values onto resulting sequences. + /// The source sequence corresponding with the evaluated selector value; otherwise, an empty sequence. + public static IQueryable Case(this IQueryProvider provider, Expression> selector, IDictionary> sources) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Case(default(IQueryProvider), default(Expression>), default(IDictionary>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)), +#endif + selector, + Expression.Constant(sources, typeof(IDictionary>)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Case(Func selector, IDictionary> sources) + { + return EnumerableEx.Case(selector, sources).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Returns a sequence from a dictionary based on the result of evaluating a selector function, also specifying a default sequence. + /// + /// Type of the selector value. + /// Result sequence element type. + /// Query provider. + /// Selector function used to pick a sequence from the given sources. + /// Dictionary mapping selector values onto resulting sequences. + /// Default sequence to return in case there's no corresponding source for the computed selector value. + /// The source sequence corresponding with the evaluated selector value; otherwise, the default source. + public static IQueryable Case(this IQueryProvider provider, Expression> selector, IDictionary> sources, IEnumerable defaultSource) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + if (defaultSource == null) + throw new ArgumentNullException(nameof(defaultSource)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Case(default(IQueryProvider), default(Expression>), default(IDictionary>), default(IEnumerable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)), +#endif + selector, + Expression.Constant(sources, typeof(IDictionary>)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Case(Func selector, IDictionary> sources, IEnumerable defaultSource) + { + return EnumerableEx.Case(selector, sources, defaultSource).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence by enumerating a source sequence, mapping its elements on result sequences, and concatenating those sequences. + /// + /// Source sequence element type. + /// Result sequence element type. + /// Query provider. + /// Source sequence. + /// Result selector to evaluate for each iteration over the source. + /// Sequence concatenating the inner sequences that result from evaluating the result selector on elements from the source. + public static IQueryable For(this IQueryProvider provider, IEnumerable source, Expression>> resultSelector) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.For(default(IQueryProvider), default(IEnumerable), default(Expression>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), +#endif + GetSourceExpression(source), + resultSelector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable For(IEnumerable source, Func> resultSelector) + { + return EnumerableEx.For(source, resultSelector).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Concatenates the input sequences. + /// + /// Source sequence element type. + /// Source sequences. + /// Sequence with the elements of the source sequences concatenated. + public static IQueryable Concat(this IQueryable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return sources.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Concat(default(IQueryable>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + GetSourceExpression(sources) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Concat(IEnumerable> sources) + { + return EnumerableEx.Concat(sources); + } +#pragma warning restore 1591 + + /// + /// Concatenates the input sequences. + /// + /// Source sequence element type. + /// Query provider. + /// Source sequences. + /// Sequence with the elements of the source sequences concatenated. + public static IQueryable Concat(this IQueryProvider provider, params IEnumerable[] sources) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Concat(default(IQueryProvider), default(IEnumerable[]))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + GetSourceExpression(sources) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Concat(params IEnumerable[] sources) + { + return EnumerableEx.Concat(sources).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Projects each element of a sequence to an given sequence and flattens the resulting sequences into one sequence. + /// + /// First source sequence element type. + /// Second source sequence element type. + /// A sequence of values to project. + /// Inner sequence each source sequenec element is projected onto. + /// Sequence flattening the sequences that result from projecting elements in the source sequence. + public static IQueryable SelectMany(this IQueryable source, IEnumerable other) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (other == null) + throw new ArgumentNullException(nameof(other)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.SelectMany(default(IQueryable), default(IEnumerable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), +#endif + source.Expression, + GetSourceExpression(other) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable SelectMany(IEnumerable source, IEnumerable other) + { + return EnumerableEx.SelectMany(source, other); + } +#pragma warning restore 1591 + + /// + /// Hides the enumerable sequence object identity. + /// + /// Source sequence element type. + /// Source sequence. + /// Enumerable sequence with the same behavior as the original, but hiding the source object identity. + /// AsQueryable doesn't hide the object identity, and simply acts as a cast to the IQueryable<TSource> interface. + public static IQueryable Hide(this IQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Hide(default(IQueryable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Hide(IEnumerable source) + { + return EnumerableEx.Hide(source); + } +#pragma warning restore 1591 + + /// + /// Lazily invokes an action for each value in the sequence. + /// + /// Source sequence element type. + /// Source sequence. + /// Action to invoke for each element. + /// Sequence exhibiting the specified side-effects upon enumeration. + public static IQueryable Do(this IQueryable source, Expression> onNext) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + onNext + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Do(IEnumerable source, Action onNext) + { + return EnumerableEx.Do(source, onNext); + } +#pragma warning restore 1591 + + /// + /// Lazily invokes an action for each value in the sequence, and executes an action for successful termination. + /// + /// Source sequence element type. + /// Source sequence. + /// Action to invoke for each element. + /// Action to invoke on successful termination of the sequence. + /// Sequence exhibiting the specified side-effects upon enumeration. + public static IQueryable Do(this IQueryable source, Expression> onNext, Expression onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + onNext, + onCompleted + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Do(IEnumerable source, Action onNext, Action onCompleted) + { + return EnumerableEx.Do(source, onNext, onCompleted); + } +#pragma warning restore 1591 + + /// + /// Lazily invokes an action for each value in the sequence, and executes an action upon exceptional termination. + /// + /// Source sequence element type. + /// Source sequence. + /// Action to invoke for each element. + /// Action to invoke on exceptional termination of the sequence. + /// Sequence exhibiting the specified side-effects upon enumeration. + public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + onNext, + onError + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Do(IEnumerable source, Action onNext, Action onError) + { + return EnumerableEx.Do(source, onNext, onError); + } +#pragma warning restore 1591 + + /// + /// Lazily invokes an action for each value in the sequence, and executes an action upon successful or exceptional termination. + /// + /// Source sequence element type. + /// Source sequence. + /// Action to invoke for each element. + /// Action to invoke on exceptional termination of the sequence. + /// Action to invoke on successful termination of the sequence. + /// Sequence exhibiting the specified side-effects upon enumeration. + public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError, Expression onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression>), default(Expression))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + onNext, + onError, + onCompleted + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Do(IEnumerable source, Action onNext, Action onError, Action onCompleted) + { + return EnumerableEx.Do(source, onNext, onError, onCompleted); + } +#pragma warning restore 1591 + + /// + /// Lazily invokes observer methods for each value in the sequence, and upon successful or exceptional termination. + /// + /// Source sequence element type. + /// Source sequence. + /// Observer to invoke notification calls on. + /// Sequence exhibiting the side-effects of observer method invocation upon enumeration. + public static IQueryable Do(this IQueryable source, IObserver observer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (observer == null) + throw new ArgumentNullException(nameof(observer)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Do(default(IQueryable), default(IObserver))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(observer, typeof(IObserver)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Do(IEnumerable source, IObserver observer) + { + return EnumerableEx.Do(source, observer); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence of non-overlapping adjacent buffers over the source sequence. + /// + /// Source sequence element type. + /// Source sequence. + /// Number of elements for allocated buffers. + /// Sequence of buffers containing source sequence elements. + public static IQueryable> Buffer(this IQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery>( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Buffer(default(IQueryable), default(int))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(count, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable> Buffer(IEnumerable source, int count) + { + return EnumerableEx.Buffer(source, count); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence of buffers over the source sequence, with specified length and possible overlap. + /// + /// Source sequence element type. + /// Source sequence. + /// Number of elements for allocated buffers. + /// Number of elements to skip between the start of consecutive buffers. + /// Sequence of buffers containing source sequence elements. + public static IQueryable> Buffer(this IQueryable source, int count, int skip) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery>( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Buffer(default(IQueryable), default(int), default(int))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(count, typeof(int)), + Expression.Constant(skip, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable> Buffer(IEnumerable source, int count, int skip) + { + return EnumerableEx.Buffer(source, count, skip); + } +#pragma warning restore 1591 + + /// + /// Ignores all elements in the source sequence. + /// + /// Source sequence element type. + /// Source sequence. + /// Source sequence without its elements. + public static IQueryable IgnoreElements(this IQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.IgnoreElements(default(IQueryable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable IgnoreElements(IEnumerable source) + { + return EnumerableEx.IgnoreElements(source); + } +#pragma warning restore 1591 + + /// + /// Returns elements with a distinct key value by using the default equality comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector. + /// Sequence that contains the elements from the source sequence with distinct key values. + public static IQueryable Distinct(this IQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Distinct(default(IQueryable), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Distinct(IEnumerable source, Func keySelector) + { + return EnumerableEx.Distinct(source, keySelector); + } +#pragma warning restore 1591 + + /// + /// Returns elements with a distinct key value by using the specified equality comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector. + /// Comparer used to compare key values. + /// Sequence that contains the elements from the source sequence with distinct key values. + public static IQueryable Distinct(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Distinct(default(IQueryable), default(Expression>), default(IEqualityComparer))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector, + Expression.Constant(comparer, typeof(IEqualityComparer)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Distinct(IEnumerable source, Func keySelector, IEqualityComparer comparer) + { + return EnumerableEx.Distinct(source, keySelector, comparer); + } +#pragma warning restore 1591 + + /// + /// Returns consecutive distinct elements by using the default equality comparer to compare values. + /// + /// Source sequence element type. + /// Source sequence. + /// Sequence without adjacent non-distinct elements. + public static IQueryable DistinctUntilChanged(this IQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable DistinctUntilChanged(IEnumerable source) + { + return EnumerableEx.DistinctUntilChanged(source); + } +#pragma warning restore 1591 + + /// + /// Returns consecutive distinct elements by using the specified equality comparer to compare values. + /// + /// Source sequence element type. + /// Source sequence. + /// Comparer used to compare values. + /// Sequence without adjacent non-distinct elements. + public static IQueryable DistinctUntilChanged(this IQueryable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(IEqualityComparer))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(comparer, typeof(IEqualityComparer)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable DistinctUntilChanged(IEnumerable source, IEqualityComparer comparer) + { + return EnumerableEx.DistinctUntilChanged(source, comparer); + } +#pragma warning restore 1591 + + /// + /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector. + /// Sequence without adjacent non-distinct elements. + public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector) + { + return EnumerableEx.DistinctUntilChanged(source, keySelector); + } +#pragma warning restore 1591 + + /// + /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. + /// + /// Source sequence element type. + /// Key type. + /// Source sequence. + /// Key selector. + /// Comparer used to compare key values. + /// Sequence without adjacent non-distinct elements. + public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(Expression>), default(IEqualityComparer))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), +#endif + source.Expression, + keySelector, + Expression.Constant(comparer, typeof(IEqualityComparer)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector, IEqualityComparer comparer) + { + return EnumerableEx.DistinctUntilChanged(source, keySelector, comparer); + } +#pragma warning restore 1591 + + /// + /// Expands the sequence by recursively applying a selector function. + /// + /// Source sequence element type. + /// Source sequence. + /// Selector function to retrieve the next sequence to expand. + /// Sequence with results from the recursive expansion of the source sequence. + public static IQueryable Expand(this IQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Expand(default(IQueryable), default(Expression>>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + selector + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Expand(IEnumerable source, Func> selector) + { + return EnumerableEx.Expand(source, selector); + } +#pragma warning restore 1591 + + /// + /// Returns the source sequence prefixed with the specified value. + /// + /// Source sequence element type. + /// Source sequence. + /// Values to prefix the sequence with. + /// Sequence starting with the specified prefix value, followed by the source sequence. + public static IQueryable StartWith(this IQueryable source, params TSource[] values) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.StartWith(default(IQueryable), default(TSource[]))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(values, typeof(TSource[])) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable StartWith(IEnumerable source, params TSource[] values) + { + return EnumerableEx.StartWith(source, values); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. + /// + /// Source sequence element type. + /// Accumulation type. + /// Source sequence. + /// Accumulator seed value. + /// Accumulation function to apply to the current accumulation value and each element of the sequence. + /// Sequence with all intermediate accumulation values resulting from scanning the sequence. + public static IQueryable Scan(this IQueryable source, TAccumulate seed, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Scan(default(IQueryable), default(TAccumulate), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), +#endif + source.Expression, + Expression.Constant(seed, typeof(TAccumulate)), + accumulator + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Scan(IEnumerable source, TAccumulate seed, Func accumulator) + { + return EnumerableEx.Scan(source, seed, accumulator); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. + /// + /// Source sequence element type. + /// Source sequence. + /// Accumulation function to apply to the current accumulation value and each element of the sequence. + /// Sequence with all intermediate accumulation values resulting from scanning the sequence. + public static IQueryable Scan(this IQueryable source, Expression> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Scan(default(IQueryable), default(Expression>))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + accumulator + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Scan(IEnumerable source, Func accumulator) + { + return EnumerableEx.Scan(source, accumulator); + } +#pragma warning restore 1591 + + /// + /// Returns a specified number of contiguous elements from the end of the sequence. + /// + /// Source sequence element type. + /// Source sequence. + /// The number of elements to take from the end of the sequence. + /// Sequence with the specified number of elements counting from the end of the source sequence. + public static IQueryable TakeLast(this IQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.TakeLast(default(IQueryable), default(int))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(count, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable TakeLast(IEnumerable source, int count) + { + return EnumerableEx.TakeLast(source, count); + } +#pragma warning restore 1591 + + /// + /// Bypasses a specified number of contiguous elements from the end of the sequence and returns the remaining elements. + /// + /// Source sequence element type. + /// Source sequence. + /// The number of elements to skip from the end of the sequence before returning the remaining elements. + /// Sequence bypassing the specified number of elements counting from the end of the source sequence. + public static IQueryable SkipLast(this IQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.SkipLast(default(IQueryable), default(int))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(count, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable SkipLast(IEnumerable source, int count) + { + return EnumerableEx.SkipLast(source, count); + } +#pragma warning restore 1591 + + /// + /// Repeats and concatenates the source sequence infinitely. + /// + /// Source sequence element type. + /// Source sequence. + /// Sequence obtained by concatenating the source sequence to itself infinitely. + public static IQueryable Repeat(this IQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Repeat(default(IQueryable))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Repeat(IEnumerable source) + { + return EnumerableEx.Repeat(source); + } +#pragma warning restore 1591 + + /// + /// Repeats and concatenates the source sequence the given number of times. + /// + /// Source sequence element type. + /// Source sequence. + /// Number of times to repeat the source sequence. + /// Sequence obtained by concatenating the source sequence to itself the specified number of times. + public static IQueryable Repeat(this IQueryable source, int count) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return source.Provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Repeat(default(IQueryable), default(int))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), +#endif + source.Expression, + Expression.Constant(count, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable Repeat(IEnumerable source, int count) + { + return EnumerableEx.Repeat(source, count); + } +#pragma warning restore 1591 + + /// + /// Returns a sequence with no elements. + /// + /// Result sequence element type. + /// Query provider. + /// Sequence with no elements. + public static IQueryable Empty(this IQueryProvider provider) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Empty(default(IQueryProvider))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Empty() + { + return Enumerable.Empty().AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence of integral numbers within a specified range. + /// + /// Query provider. + /// The value of the first integer in the sequence. + /// The number of sequential integers to generate. + /// Sequence that contains a range of sequential integral numbers. + public static IQueryable Range(this IQueryProvider provider, int start, int count) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Range(default(IQueryProvider), default(int), default(int))), +#else + (MethodInfo)MethodInfo.GetCurrentMethod(), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + Expression.Constant(start, typeof(int)), + Expression.Constant(count, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Range(int start, int count) + { + return Enumerable.Range(start, count).AsQueryable(); + } +#pragma warning restore 1591 + + /// + /// Generates a sequence that contains one repeated value. + /// + /// Result sequence element type. + /// Query provider. + /// The value to be repeated. + /// The number of times to repeat the value in the generated sequence. + /// Sequence that contains a repeated value. + public static IQueryable Repeat(this IQueryProvider provider, TResult element, int count) + { + if (provider == null) + throw new ArgumentNullException(nameof(provider)); + + return provider.CreateQuery( + Expression.Call( + null, +#if CRIPPLED_REFLECTION + InfoOf(() => QueryableEx.Repeat(default(IQueryProvider), default(TResult), default(int))), +#else + ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), +#endif + Expression.Constant(provider, typeof(IQueryProvider)), + Expression.Constant(element, typeof(TResult)), + Expression.Constant(count, typeof(int)) + ) + ); + } + +#pragma warning disable 1591 + [EditorBrowsable(EditorBrowsableState.Never)] + public static /*!*/IQueryable Repeat(TResult element, int count) + { + return EnumerableEx.Repeat(element, count).AsQueryable(); + } +#pragma warning restore 1591 + } +} diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs index 53e082310f..2c22082ed3 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs @@ -12,2356 +12,8 @@ namespace System.Linq /// /// Provides a set of additional static methods that allow querying enumerable sequences. /// - public static class QueryableEx + public static partial class QueryableEx { - /// - /// Determines whether an enumerable sequence is empty. - /// - /// Source sequence element type. - /// Source sequence. - /// true if the sequence is empty; false otherwise. - public static bool IsEmpty(this IQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.Execute( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.IsEmpty(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static bool IsEmpty(IEnumerable source) - { - return EnumerableEx.IsEmpty(source); - } -#pragma warning restore 1591 - - /// - /// Returns the minimum value in the enumerable sequence by using the specified comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Comparer used to determine the minimum value. - /// Minimum value in the sequence. - public static TSource Min(this IQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Provider.Execute( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Min(default(IQueryable), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static TSource Min(IEnumerable source, IComparer comparer) - { - return EnumerableEx.Min(source, comparer); - } -#pragma warning restore 1591 - - /// - /// Returns the elements with the minimum key value by using the default comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// List with the elements that share the same minimum key value. - public static IList MinBy(this IQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MinBy(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MinBy(IEnumerable source, Func keySelector) - { - return EnumerableEx.MinBy(source, keySelector); - } -#pragma warning restore 1591 - - /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// Comparer used to determine the minimum key value. - /// List with the elements that share the same minimum key value. - public static IList MinBy(this IQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MinBy(default(IQueryable), default(Expression>), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MinBy(IEnumerable source, Func keySelector, IComparer comparer) - { - return EnumerableEx.MinBy(source, keySelector, comparer); - } -#pragma warning restore 1591 - - /// - /// Returns the maximum value in the enumerable sequence by using the specified comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Comparer used to determine the maximum value. - /// Maximum value in the sequence. - public static TSource Max(this IQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Provider.Execute( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Max(default(IQueryable), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static TSource Max(IEnumerable source, IComparer comparer) - { - return EnumerableEx.Max(source, comparer); - } -#pragma warning restore 1591 - - /// - /// Returns the elements with the maximum key value by using the default comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// List with the elements that share the same maximum key value. - public static IList MaxBy(this IQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MaxBy(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MaxBy(IEnumerable source, Func keySelector) - { - return EnumerableEx.MaxBy(source, keySelector); - } -#pragma warning restore 1591 - - /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector used to extract the key for each element in the sequence. - /// Comparer used to determine the maximum key value. - /// List with the elements that share the same maximum key value. - public static IList MaxBy(this IQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Provider.Execute>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.MaxBy(default(IQueryable), default(Expression>), default(IComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IComparer)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IList MaxBy(IEnumerable source, Func keySelector, IComparer comparer) - { - return EnumerableEx.MaxBy(source, keySelector, comparer); - } -#pragma warning restore 1591 - - /// - /// Shares the source sequence within a selector function where each enumerator can fetch the next element from the source sequence. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Selector function with shared access to the source sequence for each enumerator. - /// Sequence resulting from applying the selector function to the shared view over the source sequence. - public static IQueryable Share(this IQueryable source, Expression, IEnumerable>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Share(default(IQueryable), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - selector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Share(IEnumerable source, Func, IEnumerable> selector) - { - return EnumerableEx.Share(source, selector); - } -#pragma warning restore 1591 - - /// - /// Publishes the source sequence within a selector function where each enumerator can obtain a view over a tail of the source sequence. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Selector function with published access to the source sequence for each enumerator. - /// Sequence resulting from applying the selector function to the published view over the source sequence. - public static IQueryable Publish(this IQueryable source, Expression, IEnumerable>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Publish(default(IQueryable), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - selector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Publish(IEnumerable source, Func, IEnumerable> selector) - { - return EnumerableEx.Publish(source, selector); - } -#pragma warning restore 1591 - - /// - /// Memoizes the source sequence within a selector function where each enumerator can get access to all of the sequence's elements without causing multiple enumerations over the source. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Selector function with memoized access to the source sequence for each enumerator. - /// Sequence resulting from applying the selector function to the memoized view over the source sequence. - public static IQueryable Memoize(this IQueryable source, Expression, IEnumerable>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Memoize(default(IQueryable), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - selector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Memoize(IEnumerable source, Func, IEnumerable> selector) - { - return EnumerableEx.Memoize(source, selector); - } -#pragma warning restore 1591 - - /// - /// Memoizes the source sequence within a selector function where a specified number of enumerators can get access to all of the sequence's elements without causing multiple enumerations over the source. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Source sequence. - /// Number of enumerators that can access the underlying buffer. Once every enumerator has obtained an element from the buffer, the element is removed from the buffer. - /// Selector function with memoized access to the source sequence for a specified number of enumerators. - /// Sequence resulting from applying the selector function to the memoized view over the source sequence. - public static IQueryable Memoize(this IQueryable source, int readerCount, Expression, IEnumerable>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Memoize(default(IQueryable), default(int), default(Expression, IEnumerable>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - source.Expression, - Expression.Constant(readerCount, typeof(int)), - selector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Memoize(IEnumerable source, int readerCount, Func, IEnumerable> selector) - { - return EnumerableEx.Memoize(source, readerCount, selector); - } -#pragma warning restore 1591 - - /// - /// Creates an enumerable sequence based on an enumerator factory function. - /// - /// Result sequence element type. - /// Query provider. - /// Enumerator factory function. - /// Sequence that will invoke the enumerator factory upon a call to GetEnumerator. - public static IQueryable Create(this IQueryProvider provider, Expression>> getEnumerator) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (getEnumerator == null) - throw new ArgumentNullException(nameof(getEnumerator)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Create(default(IQueryProvider), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - getEnumerator - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Create(Func> getEnumerator) - { - return EnumerableEx.Create(getEnumerator); - } -#pragma warning restore 1591 - - /// - /// Returns a sequence with a single element. - /// - /// Result sequence element type. - /// Query provider. - /// Single element of the resulting sequence. - /// Sequence with a single element. - public static IQueryable Return(this IQueryProvider provider, TResult value) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Return(default(IQueryProvider), default(TResult))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(value, typeof(TResult)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Return(TResult value) - { - return EnumerableEx.Return(value).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Returns a sequence that throws an exception upon enumeration. - /// - /// Result sequence element type. - /// Query provider. - /// Exception to throw upon enumerating the resulting sequence. - /// Sequence that throws the specified exception upon enumeration. - public static IQueryable Throw(this IQueryProvider provider, Exception exception) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (exception == null) - throw new ArgumentNullException(nameof(exception)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Throw(default(IQueryProvider), default(Exception))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(exception, typeof(Exception)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Throw(Exception exception) - { - return EnumerableEx.Throw(exception).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Creates an enumerable sequence based on an enumerable factory function. - /// - /// Result sequence element type. - /// Query provider. - /// Enumerable factory function. - /// Sequence that will invoke the enumerable factory upon a call to GetEnumerator. - public static IQueryable Defer(this IQueryProvider provider, Expression>> enumerableFactory) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (enumerableFactory == null) - throw new ArgumentNullException(nameof(enumerableFactory)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Defer(default(IQueryProvider), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - enumerableFactory - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Defer(Func> enumerableFactory) - { - return EnumerableEx.Defer(enumerableFactory).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence by mimicking a for loop. - /// - /// State type. - /// Result sequence element type. - /// Query provider. - /// Initial state of the generator loop. - /// Loop condition. - /// State update function to run after every iteration of the generator loop. - /// Result selector to compute resulting sequence elements. - /// Sequence obtained by running the generator loop, yielding computed elements. - public static IQueryable Generate(this IQueryProvider provider, TState initialState, Expression> condition, Expression> iterate, Expression> resultSelector) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - if (iterate == null) - throw new ArgumentNullException(nameof(iterate)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Generate(default(IQueryProvider), default(TState), default(Expression>), default(Expression>), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(initialState), - condition, - iterate, - resultSelector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Generate(TState initialState, Func condition, Func iterate, Func resultSelector) - { - return EnumerableEx.Generate(initialState, condition, iterate, resultSelector).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence that's dependent on a resource object whose lifetime is determined by the sequence usage duration. - /// - /// Source element type. - /// Resource type. - /// Query provider. - /// Resource factory function. - /// Enumerable factory function, having access to the obtained resource. - /// Sequence whose use controls the lifetime of the associated obtained resource. - public static IQueryable Using(this IQueryProvider provider, Expression> resourceFactory, Expression>> enumerableFactory) where TResource : IDisposable - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (resourceFactory == null) - throw new ArgumentNullException(nameof(resourceFactory)); - if (enumerableFactory == null) - throw new ArgumentNullException(nameof(enumerableFactory)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Using(default(IQueryProvider), default(Expression>), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - resourceFactory, - enumerableFactory - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Using(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable - { - return EnumerableEx.Using(resourceFactory, enumerableFactory).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence by repeating the given value infinitely. - /// - /// Result sequence element type. - /// Query provider. - /// Value to repreat in the resulting sequence. - /// Sequence repeating the given value infinitely. - public static IEnumerable Repeat(this IQueryProvider provider, TResult value) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryProvider), default(TResult))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(value, typeof(TResult)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Repeat(TResult value) - { - return EnumerableEx.Repeat(value).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that corresponds to the source sequence, concatenating it with the sequence resulting from calling an exception handler function in case of an error. - /// - /// Source sequence element type. - /// Exception type to catch. - /// Source sequence. - /// Handler to invoke when an exception of the specified type occurs. - /// Source sequence, concatenated with an exception handler result sequence in case of an error. - public static IQueryable Catch(this IQueryable source, Expression>> handler) - where TException : Exception - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (handler == null) - throw new ArgumentNullException(nameof(handler)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryable), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), -#endif - source.Expression, - handler - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Catch(IEnumerable source, Func> handler) - where TException : Exception - { - return EnumerableEx.Catch(source, handler); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. - /// - /// Source sequence element type. - /// Source sequences. - /// Sequence that continues to concatenate source sequences while errors occur. - public static IQueryable Catch(this IQueryable> sources) - { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return sources.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryable>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - sources.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Catch(IEnumerable> sources) - { - return EnumerableEx.Catch(sources); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. - /// - /// Source sequence element type. - /// Query provider. - /// Source sequences. - /// Sequence that continues to concatenate source sequences while errors occur. - public static IQueryable Catch(this IQueryProvider provider, params IEnumerable[] sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryProvider), default(IEnumerable[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - GetSourceExpression(sources) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Catch(params IEnumerable[] sources) - { - return EnumerableEx.Catch(sources).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that returns the elements of the first sequence, switching to the second in case of an error. - /// - /// Source sequence element type. - /// First sequence. - /// Second sequence, concatenated to the result in case the first sequence completes exceptionally. - /// The first sequence, followed by the second sequence in case an error is produced. - public static IQueryable Catch(this IQueryable first, IEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - - return first.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Catch(default(IQueryable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - first.Expression, - GetSourceExpression(second) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Catch(IEnumerable first, IEnumerable second) - { - return EnumerableEx.Catch(first, second); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to run upon termination of the sequence, or when an enumerator is disposed. - /// Source sequence with guarantees on the invocation of the finally action. - public static IQueryable Finally(this IQueryable source, Expression finallyAction) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (finallyAction == null) - throw new ArgumentNullException(nameof(finallyAction)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Finally(default(IQueryable), default(Expression))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - finallyAction - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Finally(IEnumerable source, Action finallyAction) - { - return EnumerableEx.Finally(source, finallyAction); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that concatenates both given sequences, regardless of whether an error occurs. - /// - /// Source sequence element type. - /// First sequence. - /// Second sequence. - /// Sequence concatenating the elements of both sequences, ignoring errors. - public static IQueryable OnErrorResumeNext(this IQueryable first, IEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - - return first.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - first.Expression, - GetSourceExpression(second) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable OnErrorResumeNext(IEnumerable first, IEnumerable second) - { - return EnumerableEx.OnErrorResumeNext(first, second); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the sequences. - /// - /// Source sequence element type. - /// Query provider. - /// Source sequences. - /// Sequence concatenating the elements of the given sequences, ignoring errors. - public static IEnumerable OnErrorResumeNext(this IQueryProvider provider, params IEnumerable[] sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryProvider), default(IEnumerable[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - GetSourceExpression(sources) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable OnErrorResumeNext(params IEnumerable[] sources) - { - return EnumerableEx.OnErrorResumeNext(sources).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the sequences. - /// - /// Source sequence element type. - /// Source sequences. - /// Sequence concatenating the elements of the given sequences, ignoring errors. - public static IQueryable OnErrorResumeNext(this IQueryable> sources) - { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return sources.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.OnErrorResumeNext(default(IQueryable>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - sources.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable OnErrorResumeNext(IEnumerable> sources) - { - return EnumerableEx.OnErrorResumeNext(sources); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that retries enumerating the source sequence as long as an error occurs. - /// - /// Source sequence element type. - /// Source sequence. - /// Sequence concatenating the results of the source sequence as long as an error occurs. - public static IQueryable Retry(this IQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Retry(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Retry(IEnumerable source) - { - return EnumerableEx.Retry(source); - } -#pragma warning restore 1591 - - /// - /// Creates a sequence that retries enumerating the source sequence as long as an error occurs, with the specified maximum number of retries. - /// - /// Source sequence element type. - /// Source sequence. - /// Maximum number of retries. - /// Sequence concatenating the results of the source sequence as long as an error occurs. - public static IQueryable Retry(this IQueryable source, int retryCount) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Retry(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(retryCount, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Retry(IEnumerable source, int retryCount) - { - return EnumerableEx.Retry(source, retryCount); - } -#pragma warning restore 1591 - - /// - /// Generates an enumerable sequence by repeating a source sequence as long as the given loop condition holds. - /// - /// Result sequence element type. - /// Query provider. - /// Loop condition. - /// Sequence to repeat while the condition evaluates true. - /// Sequence generated by repeating the given sequence while the condition evaluates to true. - public static IQueryable While(this IQueryProvider provider, Expression> condition, IEnumerable source) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.While(default(IQueryProvider), default(Expression>), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - condition, - GetSourceExpression(source) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable While(Func condition, IEnumerable source) - { - return EnumerableEx.While(condition, source).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Returns an enumerable sequence based on the evaluation result of the given condition. - /// - /// Result sequence element type. - /// Query provider. - /// Condition to evaluate. - /// Sequence to return in case the condition evaluates true. - /// Sequence to return in case the condition evaluates false. - /// Either of the two input sequences based on the result of evaluating the condition. - public static IQueryable If(this IQueryProvider provider, Expression> condition, IEnumerable thenSource, IEnumerable elseSource) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - if (thenSource == null) - throw new ArgumentNullException(nameof(thenSource)); - if (elseSource == null) - throw new ArgumentNullException(nameof(elseSource)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.If(default(IQueryProvider), default(Expression>), default(IEnumerable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - condition, - GetSourceExpression(thenSource), - GetSourceExpression(elseSource) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable If(Func condition, IEnumerable thenSource, IEnumerable elseSource) - { - return EnumerableEx.If(condition, thenSource, elseSource).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty sequence. - /// - /// Result sequence element type. - /// Query provider. - /// Condition to evaluate. - /// Sequence to return in case the condition evaluates true. - /// The given input sequence if the condition evaluates true; otherwise, an empty sequence. - public static IQueryable If(this IQueryProvider provider, Expression> condition, IEnumerable thenSource) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - if (thenSource == null) - throw new ArgumentNullException(nameof(thenSource)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.If(default(IQueryProvider), default(Expression>), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - condition, - GetSourceExpression(thenSource) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable If(Func condition, IEnumerable thenSource) - { - return EnumerableEx.If(condition, thenSource).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds. - /// - /// Result sequence element type. - /// Source sequence to repeat while the condition evaluates true. - /// Loop condition. - /// Sequence generated by repeating the given sequence until the condition evaluates to false. - public static IQueryable DoWhile(this IQueryable source, Expression> condition) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DoWhile(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - source.Expression, - condition - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DoWhile(IEnumerable source, Func condition) - { - return EnumerableEx.DoWhile(source, condition); - } -#pragma warning restore 1591 - - /// - /// Returns a sequence from a dictionary based on the result of evaluating a selector function. - /// - /// Type of the selector value. - /// Result sequence element type. - /// Query provider. - /// Selector function used to pick a sequence from the given sources. - /// Dictionary mapping selector values onto resulting sequences. - /// The source sequence corresponding with the evaluated selector value; otherwise, an empty sequence. - public static IQueryable Case(this IQueryProvider provider, Expression> selector, IDictionary> sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Case(default(IQueryProvider), default(Expression>), default(IDictionary>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)), -#endif - selector, - Expression.Constant(sources, typeof(IDictionary>)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Case(Func selector, IDictionary> sources) - { - return EnumerableEx.Case(selector, sources).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Returns a sequence from a dictionary based on the result of evaluating a selector function, also specifying a default sequence. - /// - /// Type of the selector value. - /// Result sequence element type. - /// Query provider. - /// Selector function used to pick a sequence from the given sources. - /// Dictionary mapping selector values onto resulting sequences. - /// Default sequence to return in case there's no corresponding source for the computed selector value. - /// The source sequence corresponding with the evaluated selector value; otherwise, the default source. - public static IQueryable Case(this IQueryProvider provider, Expression> selector, IDictionary> sources, IEnumerable defaultSource) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - if (defaultSource == null) - throw new ArgumentNullException(nameof(defaultSource)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Case(default(IQueryProvider), default(Expression>), default(IDictionary>), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)), -#endif - selector, - Expression.Constant(sources, typeof(IDictionary>)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Case(Func selector, IDictionary> sources, IEnumerable defaultSource) - { - return EnumerableEx.Case(selector, sources, defaultSource).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence by enumerating a source sequence, mapping its elements on result sequences, and concatenating those sequences. - /// - /// Source sequence element type. - /// Result sequence element type. - /// Query provider. - /// Source sequence. - /// Result selector to evaluate for each iteration over the source. - /// Sequence concatenating the inner sequences that result from evaluating the result selector on elements from the source. - public static IQueryable For(this IQueryProvider provider, IEnumerable source, Expression>> resultSelector) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.For(default(IQueryProvider), default(IEnumerable), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), -#endif - GetSourceExpression(source), - resultSelector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable For(IEnumerable source, Func> resultSelector) - { - return EnumerableEx.For(source, resultSelector).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Concatenates the input sequences. - /// - /// Source sequence element type. - /// Source sequences. - /// Sequence with the elements of the source sequences concatenated. - public static IQueryable Concat(this IQueryable> sources) - { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return sources.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Concat(default(IQueryable>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - GetSourceExpression(sources) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Concat(IEnumerable> sources) - { - return EnumerableEx.Concat(sources); - } -#pragma warning restore 1591 - - /// - /// Concatenates the input sequences. - /// - /// Source sequence element type. - /// Query provider. - /// Source sequences. - /// Sequence with the elements of the source sequences concatenated. - public static IQueryable Concat(this IQueryProvider provider, params IEnumerable[] sources) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Concat(default(IQueryProvider), default(IEnumerable[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - GetSourceExpression(sources) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Concat(params IEnumerable[] sources) - { - return EnumerableEx.Concat(sources).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Projects each element of a sequence to an given sequence and flattens the resulting sequences into one sequence. - /// - /// First source sequence element type. - /// Second source sequence element type. - /// A sequence of values to project. - /// Inner sequence each source sequenec element is projected onto. - /// Sequence flattening the sequences that result from projecting elements in the source sequence. - public static IQueryable SelectMany(this IQueryable source, IEnumerable other) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (other == null) - throw new ArgumentNullException(nameof(other)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.SelectMany(default(IQueryable), default(IEnumerable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), -#endif - source.Expression, - GetSourceExpression(other) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable SelectMany(IEnumerable source, IEnumerable other) - { - return EnumerableEx.SelectMany(source, other); - } -#pragma warning restore 1591 - - /// - /// Hides the enumerable sequence object identity. - /// - /// Source sequence element type. - /// Source sequence. - /// Enumerable sequence with the same behavior as the original, but hiding the source object identity. - /// AsQueryable doesn't hide the object identity, and simply acts as a cast to the IQueryable<TSource> interface. - public static IQueryable Hide(this IQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Hide(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Hide(IEnumerable source) - { - return EnumerableEx.Hide(source); - } -#pragma warning restore 1591 - - /// - /// Lazily invokes an action for each value in the sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext) - { - return EnumerableEx.Do(source, onNext); - } -#pragma warning restore 1591 - - /// - /// Lazily invokes an action for each value in the sequence, and executes an action for successful termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Action to invoke on successful termination of the sequence. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext, Expression onCompleted) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext, - onCompleted - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext, Action onCompleted) - { - return EnumerableEx.Do(source, onNext, onCompleted); - } -#pragma warning restore 1591 - - /// - /// Lazily invokes an action for each value in the sequence, and executes an action upon exceptional termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Action to invoke on exceptional termination of the sequence. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext, - onError - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext, Action onError) - { - return EnumerableEx.Do(source, onNext, onError); - } -#pragma warning restore 1591 - - /// - /// Lazily invokes an action for each value in the sequence, and executes an action upon successful or exceptional termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Action to invoke for each element. - /// Action to invoke on exceptional termination of the sequence. - /// Action to invoke on successful termination of the sequence. - /// Sequence exhibiting the specified side-effects upon enumeration. - public static IQueryable Do(this IQueryable source, Expression> onNext, Expression> onError, Expression onCompleted) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(Expression>), default(Expression>), default(Expression))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - onNext, - onError, - onCompleted - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, Action onNext, Action onError, Action onCompleted) - { - return EnumerableEx.Do(source, onNext, onError, onCompleted); - } -#pragma warning restore 1591 - - /// - /// Lazily invokes observer methods for each value in the sequence, and upon successful or exceptional termination. - /// - /// Source sequence element type. - /// Source sequence. - /// Observer to invoke notification calls on. - /// Sequence exhibiting the side-effects of observer method invocation upon enumeration. - public static IQueryable Do(this IQueryable source, IObserver observer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (observer == null) - throw new ArgumentNullException(nameof(observer)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Do(default(IQueryable), default(IObserver))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(observer, typeof(IObserver)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Do(IEnumerable source, IObserver observer) - { - return EnumerableEx.Do(source, observer); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence of non-overlapping adjacent buffers over the source sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// Number of elements for allocated buffers. - /// Sequence of buffers containing source sequence elements. - public static IQueryable> Buffer(this IQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Buffer(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable> Buffer(IEnumerable source, int count) - { - return EnumerableEx.Buffer(source, count); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence of buffers over the source sequence, with specified length and possible overlap. - /// - /// Source sequence element type. - /// Source sequence. - /// Number of elements for allocated buffers. - /// Number of elements to skip between the start of consecutive buffers. - /// Sequence of buffers containing source sequence elements. - public static IQueryable> Buffer(this IQueryable source, int count, int skip) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery>( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Buffer(default(IQueryable), default(int), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)), - Expression.Constant(skip, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable> Buffer(IEnumerable source, int count, int skip) - { - return EnumerableEx.Buffer(source, count, skip); - } -#pragma warning restore 1591 - - /// - /// Ignores all elements in the source sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// Source sequence without its elements. - public static IQueryable IgnoreElements(this IQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.IgnoreElements(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable IgnoreElements(IEnumerable source) - { - return EnumerableEx.IgnoreElements(source); - } -#pragma warning restore 1591 - - /// - /// Returns elements with a distinct key value by using the default equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Sequence that contains the elements from the source sequence with distinct key values. - public static IQueryable Distinct(this IQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Distinct(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Distinct(IEnumerable source, Func keySelector) - { - return EnumerableEx.Distinct(source, keySelector); - } -#pragma warning restore 1591 - - /// - /// Returns elements with a distinct key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Comparer used to compare key values. - /// Sequence that contains the elements from the source sequence with distinct key values. - public static IQueryable Distinct(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Distinct(default(IQueryable), default(Expression>), default(IEqualityComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IEqualityComparer)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Distinct(IEnumerable source, Func keySelector, IEqualityComparer comparer) - { - return EnumerableEx.Distinct(source, keySelector, comparer); - } -#pragma warning restore 1591 - - /// - /// Returns consecutive distinct elements by using the default equality comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source) - { - return EnumerableEx.DistinctUntilChanged(source); - } -#pragma warning restore 1591 - - /// - /// Returns consecutive distinct elements by using the specified equality comparer to compare values. - /// - /// Source sequence element type. - /// Source sequence. - /// Comparer used to compare values. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(IEqualityComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(comparer, typeof(IEqualityComparer)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source, IEqualityComparer comparer) - { - return EnumerableEx.DistinctUntilChanged(source, comparer); - } -#pragma warning restore 1591 - - /// - /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector) - { - return EnumerableEx.DistinctUntilChanged(source, keySelector); - } -#pragma warning restore 1591 - - /// - /// Returns consecutive distinct elements based on a key value by using the specified equality comparer to compare key values. - /// - /// Source sequence element type. - /// Key type. - /// Source sequence. - /// Key selector. - /// Comparer used to compare key values. - /// Sequence without adjacent non-distinct elements. - public static IQueryable DistinctUntilChanged(this IQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.DistinctUntilChanged(default(IQueryable), default(Expression>), default(IEqualityComparer))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), -#endif - source.Expression, - keySelector, - Expression.Constant(comparer, typeof(IEqualityComparer)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable DistinctUntilChanged(IEnumerable source, Func keySelector, IEqualityComparer comparer) - { - return EnumerableEx.DistinctUntilChanged(source, keySelector, comparer); - } -#pragma warning restore 1591 - - /// - /// Expands the sequence by recursively applying a selector function. - /// - /// Source sequence element type. - /// Source sequence. - /// Selector function to retrieve the next sequence to expand. - /// Sequence with results from the recursive expansion of the source sequence. - public static IQueryable Expand(this IQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Expand(default(IQueryable), default(Expression>>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - selector - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Expand(IEnumerable source, Func> selector) - { - return EnumerableEx.Expand(source, selector); - } -#pragma warning restore 1591 - - /// - /// Returns the source sequence prefixed with the specified value. - /// - /// Source sequence element type. - /// Source sequence. - /// Values to prefix the sequence with. - /// Sequence starting with the specified prefix value, followed by the source sequence. - public static IQueryable StartWith(this IQueryable source, params TSource[] values) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.StartWith(default(IQueryable), default(TSource[]))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(values, typeof(TSource[])) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable StartWith(IEnumerable source, params TSource[] values) - { - return EnumerableEx.StartWith(source, values); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. - /// - /// Source sequence element type. - /// Accumulation type. - /// Source sequence. - /// Accumulator seed value. - /// Accumulation function to apply to the current accumulation value and each element of the sequence. - /// Sequence with all intermediate accumulation values resulting from scanning the sequence. - public static IQueryable Scan(this IQueryable source, TAccumulate seed, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Scan(default(IQueryable), default(TAccumulate), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), -#endif - source.Expression, - Expression.Constant(seed, typeof(TAccumulate)), - accumulator - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Scan(IEnumerable source, TAccumulate seed, Func accumulator) - { - return EnumerableEx.Scan(source, seed, accumulator); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. - /// - /// Source sequence element type. - /// Source sequence. - /// Accumulation function to apply to the current accumulation value and each element of the sequence. - /// Sequence with all intermediate accumulation values resulting from scanning the sequence. - public static IQueryable Scan(this IQueryable source, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Scan(default(IQueryable), default(Expression>))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - accumulator - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Scan(IEnumerable source, Func accumulator) - { - return EnumerableEx.Scan(source, accumulator); - } -#pragma warning restore 1591 - - /// - /// Returns a specified number of contiguous elements from the end of the sequence. - /// - /// Source sequence element type. - /// Source sequence. - /// The number of elements to take from the end of the sequence. - /// Sequence with the specified number of elements counting from the end of the source sequence. - public static IQueryable TakeLast(this IQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.TakeLast(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable TakeLast(IEnumerable source, int count) - { - return EnumerableEx.TakeLast(source, count); - } -#pragma warning restore 1591 - - /// - /// Bypasses a specified number of contiguous elements from the end of the sequence and returns the remaining elements. - /// - /// Source sequence element type. - /// Source sequence. - /// The number of elements to skip from the end of the sequence before returning the remaining elements. - /// Sequence bypassing the specified number of elements counting from the end of the source sequence. - public static IQueryable SkipLast(this IQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.SkipLast(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable SkipLast(IEnumerable source, int count) - { - return EnumerableEx.SkipLast(source, count); - } -#pragma warning restore 1591 - - /// - /// Repeats and concatenates the source sequence infinitely. - /// - /// Source sequence element type. - /// Source sequence. - /// Sequence obtained by concatenating the source sequence to itself infinitely. - public static IQueryable Repeat(this IQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryable))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Repeat(IEnumerable source) - { - return EnumerableEx.Repeat(source); - } -#pragma warning restore 1591 - - /// - /// Repeats and concatenates the source sequence the given number of times. - /// - /// Source sequence element type. - /// Source sequence. - /// Number of times to repeat the source sequence. - /// Sequence obtained by concatenating the source sequence to itself the specified number of times. - public static IQueryable Repeat(this IQueryable source, int count) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return source.Provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryable), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#endif - source.Expression, - Expression.Constant(count, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static IEnumerable Repeat(IEnumerable source, int count) - { - return EnumerableEx.Repeat(source, count); - } -#pragma warning restore 1591 - - /// - /// Returns a sequence with no elements. - /// - /// Result sequence element type. - /// Query provider. - /// Sequence with no elements. - public static IQueryable Empty(this IQueryProvider provider) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Empty(default(IQueryProvider))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Empty() - { - return Enumerable.Empty().AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence of integral numbers within a specified range. - /// - /// Query provider. - /// The value of the first integer in the sequence. - /// The number of sequential integers to generate. - /// Sequence that contains a range of sequential integral numbers. - public static IQueryable Range(this IQueryProvider provider, int start, int count) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Range(default(IQueryProvider), default(int), default(int))), -#else - (MethodInfo)MethodInfo.GetCurrentMethod(), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(start, typeof(int)), - Expression.Constant(count, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Range(int start, int count) - { - return Enumerable.Range(start, count).AsQueryable(); - } -#pragma warning restore 1591 - - /// - /// Generates a sequence that contains one repeated value. - /// - /// Result sequence element type. - /// Query provider. - /// The value to be repeated. - /// The number of times to repeat the value in the generated sequence. - /// Sequence that contains a repeated value. - public static IQueryable Repeat(this IQueryProvider provider, TResult element, int count) - { - if (provider == null) - throw new ArgumentNullException(nameof(provider)); - - return provider.CreateQuery( - Expression.Call( - null, -#if CRIPPLED_REFLECTION - InfoOf(() => QueryableEx.Repeat(default(IQueryProvider), default(TResult), default(int))), -#else - ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), -#endif - Expression.Constant(provider, typeof(IQueryProvider)), - Expression.Constant(element, typeof(TResult)), - Expression.Constant(count, typeof(int)) - ) - ); - } - -#pragma warning disable 1591 - [EditorBrowsable(EditorBrowsableState.Never)] - public static /*!*/IQueryable Repeat(TResult element, int count) - { - return EnumerableEx.Repeat(element, count).AsQueryable(); - } -#pragma warning restore 1591 - /// /// Gets the local Queryable provider. /// From 6c5b21b57fb319d26c6fc8ced6c264af2877991d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:59:24 -0700 Subject: [PATCH 172/862] Modernizing some code. --- .../System/Linq/QueryableEx.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs index 2c22082ed3..d3786ea749 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs @@ -17,15 +17,9 @@ public static partial class QueryableEx /// /// Gets the local Queryable provider. /// - public static IQueryProvider Provider - { - get - { - return new QueryProviderShim(); - } - } + public static IQueryProvider Provider => new QueryProviderShim(); - class QueryProviderShim : IQueryProvider + private sealed class QueryProviderShim : IQueryProvider { public IQueryable CreateQuery(Expression expression) { From 339231c463cefe1a1fedfeff8e727f6a5c4dcde6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 14:59:40 -0700 Subject: [PATCH 173/862] Some code cosmetics. --- .../System/Linq/QueryableEx.Generated.cs | 2 +- .../System.Interactive.Providers/System/Linq/QueryableEx.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs index 2b63929605..aa2a046c0c 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs @@ -1,9 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Collections.Generic; using System.ComponentModel; -using System.Globalization; using System.Linq.Expressions; using System.Reflection; diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs index d3786ea749..f5ff470a6c 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System.Collections.Generic; -using System.ComponentModel; using System.Globalization; using System.Linq.Expressions; using System.Reflection; From 72bb5fce334849ba1f105c43eae455d062527b56 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:02:03 -0700 Subject: [PATCH 174/862] Reducing allocations. --- .../System.Interactive.Providers/System/Linq/QueryableEx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs index f5ff470a6c..e9cdbc678b 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.cs @@ -17,7 +17,7 @@ public static partial class QueryableEx /// /// Gets the local Queryable provider. /// - public static IQueryProvider Provider => new QueryProviderShim(); + public static IQueryProvider Provider { get; } = new QueryProviderShim(); private sealed class QueryProviderShim : IQueryProvider { From 24991b228cdf68646310812f675f973803149692 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:07:05 -0700 Subject: [PATCH 175/862] Cleaning up some test code. --- .../AppendPrependTests.cs | 2 +- .../AssertEx.cs | 5 ++- .../AsyncEnumerableQueryTest.cs | 4 ++ .../AsyncQueryableExTests.Generated.cs | 6 ++- .../AsyncQueryableExTests.Generated.tt | 6 ++- .../AsyncQueryableTests.Generated.cs | 6 ++- .../AsyncQueryableTests.Generated.tt | 6 ++- .../AsyncTests.Aggregates.cs | 2 +- .../AsyncTests.Bugs.cs | 2 +- .../AsyncTests.Conversions.cs | 10 ++--- .../AsyncTests.Creation.cs | 2 +- .../AsyncTests.Exceptions.cs | 4 +- .../AsyncTests.Multiple.cs | 5 ++- .../AsyncTests.Single.cs | 41 +++++++++---------- .../NopObserver.cs | 1 + .../TaskExtTests.cs | 2 +- 16 files changed, 62 insertions(+), 42 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs index c8fd63e5c5..47f4f7f668 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs @@ -636,4 +636,4 @@ public async Task AppendPrepend9() } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs index a0f563b82d..a76ba747ce 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using Xunit; using System; @@ -37,7 +38,7 @@ internal static void SucceedOrFailProper(Action action) { try { - action(); + action(); } catch (AggregateException ex) { @@ -47,4 +48,4 @@ internal static void SucceedOrFailProper(Action action) } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncEnumerableQueryTest.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncEnumerableQueryTest.cs index 9f403ccf5b..7c91df938d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncEnumerableQueryTest.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncEnumerableQueryTest.cs @@ -1,3 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + using System.Linq; using Xunit; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs index 6f752613f9..d42e7fac07 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs @@ -1,4 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt index bcb2add8d7..3a9f87da18 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt @@ -1,4 +1,8 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net46\System.Interactive.Async.dll" #> diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs index 435108d6d5..aafb9a9650 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs @@ -1,4 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt index 183f359d60..d20394a958 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt @@ -1,4 +1,8 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ import namespace="System.Linq" #> diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index f78c19a3e4..6eb079a354 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -2205,4 +2205,4 @@ public void MaxBy5() AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 0fac06763e..abf6f57eec 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -288,4 +288,4 @@ public void Reset() } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs index 45562ec04c..17ca19ad18 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs @@ -4,12 +4,10 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; -using System.Text; +using System.Threading; using System.Threading.Tasks; using Xunit; -using System.Threading; namespace Tests { @@ -171,11 +169,11 @@ public void ToAsyncEnumerable11() var xs = set.ToAsyncEnumerable(); var xc = xs as ICollection; - + Assert.NotNull(xc); Assert.False(xc.IsReadOnly); - + xc.Add(5); @@ -590,4 +588,4 @@ public void OnNext(T value) } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 9a96732b81..25e58be2d7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -423,4 +423,4 @@ public void Dispose() } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index 298781cc81..1c6f6d90b9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -400,9 +400,9 @@ public async Task Finally7() await SequenceIdentity(xs); Assert.Equal(2, i); } - - [Fact] + + [Fact] public void OnErrorResumeNext_Null() { AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index d15e901209..1cf29143b0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -622,7 +622,7 @@ public int GetHashCode(int obj) throw new NotImplementedException(); } } - + [Fact] public void GroupJoin_Null() { @@ -729,7 +729,8 @@ public void GroupJoin7() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => { + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => + { if (x == 1) throw ex; return x + " - " + i.Aggregate("", (s, j) => s + j).Result; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index c096713bc1..f5a697e0b5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -4,12 +4,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Text; -using Xunit; using System.Threading; using System.Threading.Tasks; +using Xunit; + namespace Tests { @@ -251,7 +250,7 @@ public async Task Where8() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0); - + await SequenceIdentity(ys); } @@ -563,7 +562,7 @@ public void Cast1() [Fact] public void Cast2() { - var xs = new [] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable(); + var xs = new[] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable(); var ys = xs.Cast(); Assert.Same(xs, ys); @@ -1333,7 +1332,7 @@ public async Task DefaultIfEmpty10() public async Task DefaultIfEmpty11() { var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); - + Assert.Equal(1, await xs.Count()); } @@ -1415,8 +1414,8 @@ public void Distinct2() public async Task Distinct3() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - - var res = new [] { 1, 2, 3, 5, 4 }; + + var res = new[] { 1, 2, 3, 5, 4 }; Assert.True(res.SequenceEqual(await xs.ToArray())); } @@ -1433,7 +1432,7 @@ public async Task Distinct4() public async Task Distinct5() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - + Assert.Equal(5, await xs.Count()); } @@ -1485,7 +1484,7 @@ public void Distinct11() var xs = AsyncEnumerable.Empty().Distinct(k => k); var e = xs.GetAsyncEnumerator(); - + NoNext(e); } @@ -1988,7 +1987,7 @@ public void GroupBy5() //var g2e = g2.GetEnumerator(); //HasNext(g2e, 43); - + //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); } @@ -2010,7 +2009,7 @@ public void GroupBy6() //HasNext(g1e, 42); //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - + } static IEnumerable GetXs() @@ -2054,7 +2053,7 @@ public void GroupBy8() //var g2e = g2.GetEnumerator(); //HasNext(g2e, 2); - + //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -2326,7 +2325,7 @@ public async Task GroupBy19() var ys = xs.ToAsyncEnumerable(); - var res = ys.GroupBy(x => x.Item/10); + var res = ys.GroupBy(x => x.Item / 10); await SequenceIdentity(res); } @@ -2359,7 +2358,7 @@ public async Task GroupBy22() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - + Assert.Equal(3, await ys.Count()); } @@ -2388,7 +2387,7 @@ public async Task GroupBy24() var gg1 = gar[0]; var gg1a = await gg1.ToArray(); - + Assert.Equal(g1a, gg1a); var gg2 = gar[1]; @@ -2398,7 +2397,7 @@ public async Task GroupBy24() var gg3 = gar[2]; var gg3a = await gg3.ToArray(); - Assert.Equal(g3a, gg3a); + Assert.Equal(g3a, gg3a); } [Fact] @@ -2433,7 +2432,7 @@ public async Task GroupBy26() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - + var gar = await ys.ToList(); Assert.Equal(3, gar.Count); @@ -2632,7 +2631,7 @@ public override int GetHashCode() { unchecked { - return ((Key != null ? Key.GetHashCode() : 0)*397) ^ Item; + return ((Key != null ? Key.GetHashCode() : 0) * 397) ^ Item; } } @@ -3270,7 +3269,7 @@ public void TakeLast_BugFix_TakeLast_Zero_TakesForever() var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(0); var e = xs.GetAsyncEnumerator(); - + NoNext(e); } @@ -3322,4 +3321,4 @@ public void SkipLast4() NoNext(e); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/NopObserver.cs b/Ix.NET/Source/System.Interactive.Async.Tests/NopObserver.cs index 1b7f9ee697..314a84f1c0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/NopObserver.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/NopObserver.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; namespace Tests diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs index 3471192f15..02aaa6fb0b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using Xunit; using System; using System.Collections.Generic; @@ -52,4 +53,3 @@ public async Task ExceptionHandling_ShouldThrowUnwrappedException2() } } } - From 52528a1adff62946735f441b56bada7b65b29416 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:09:07 -0700 Subject: [PATCH 176/862] Cleaning up more test code. --- Ix.NET/Source/System.Interactive.Tests/AssertEx.cs | 5 +++-- Ix.NET/Source/System.Interactive.Tests/NopObserver.cs | 1 + .../Source/System.Interactive.Tests/Tests.Aggregates.cs | 1 + Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs | 3 ++- Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs | 6 +++--- .../Source/System.Interactive.Tests/Tests.Exceptions.cs | 2 +- .../Source/System.Interactive.Tests/Tests.Imperative.cs | 2 +- Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs | 4 ++-- .../Source/System.Interactive.Tests/Tests.Qbservable.cs | 8 +++----- Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs | 4 ++-- Ix.NET/Source/System.Interactive.Tests/Tests.cs | 5 +---- 11 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Tests/AssertEx.cs b/Ix.NET/Source/System.Interactive.Tests/AssertEx.cs index a0f563b82d..a76ba747ce 100644 --- a/Ix.NET/Source/System.Interactive.Tests/AssertEx.cs +++ b/Ix.NET/Source/System.Interactive.Tests/AssertEx.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using Xunit; using System; @@ -37,7 +38,7 @@ internal static void SucceedOrFailProper(Action action) { try { - action(); + action(); } catch (AggregateException ex) { @@ -47,4 +48,4 @@ internal static void SucceedOrFailProper(Action action) } } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Tests/NopObserver.cs b/Ix.NET/Source/System.Interactive.Tests/NopObserver.cs index 1b7f9ee697..314a84f1c0 100644 --- a/Ix.NET/Source/System.Interactive.Tests/NopObserver.cs +++ b/Ix.NET/Source/System.Interactive.Tests/NopObserver.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; namespace Tests diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs index 852882bed1..e7e87e7e63 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; using System.Text; using System.Collections.Generic; diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs index e72da1de56..2dba167205 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; using System.Text; using System.Collections.Generic; @@ -278,7 +279,7 @@ public void Publish7() HasNext(e1, 0); HasNext(e1, 1); HasNext(e1, 2); - + var e2 = rng.GetEnumerator(); HasNext(e2, 3); HasNext(e2, 4); diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs index 349994142b..24aaaa60ce 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs @@ -1,13 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; -using System.Text; +using System.Collections; using System.Collections.Generic; using System.Linq; -using Xunit; -using System.Collections; using System.Threading; +using Xunit; namespace Tests { diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs index 43274b728b..e01ffcc52f 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; -using System.Text; using System.Collections.Generic; using System.Linq; using Xunit; diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs index 8ffdd0793f..b0c33763fe 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; -using System.Text; using System.Collections.Generic; using System.Linq; using Xunit; diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs index 560f094471..b90524ed2b 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; -using System.Text; using System.Collections.Generic; using System.Linq; using Xunit; @@ -38,7 +38,7 @@ public void Concat2() var res = xss.Concat().Select(x => i + " - " + x).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { + Assert.True(Enumerable.SequenceEqual(res, new[] { "1 - 0", "2 - 0", "2 - 1", diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Qbservable.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Qbservable.cs index 2cc36d0d7d..be578692ff 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Qbservable.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Qbservable.cs @@ -3,14 +3,12 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; +using System.ComponentModel; using System.Linq; -using System.Text; +using System.Linq.Expressions; using System.Reflection; -using Xunit; using System.Runtime.CompilerServices; -using System.Linq.Expressions; -using System.ComponentModel; +using Xunit; namespace Tests { diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs index 699ed20acd..285f0ac7c1 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; -using System.Text; using System.Collections.Generic; using System.Linq; using Xunit; @@ -351,7 +351,7 @@ public void TakeLast_Arguments() [Fact] public void TakeLast_TakeZero() { - var e = Enumerable.Range(1, 5) ; + var e = Enumerable.Range(1, 5); var r = e.TakeLast(0).ToList(); Assert.True(Enumerable.SequenceEqual(r, Enumerable.Empty())); } diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.cs index bce92167a9..33f746f761 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.cs @@ -1,16 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. + using System; -using System.Text; using System.Collections.Generic; -using System.Linq; using Xunit; - namespace Tests { - public partial class Tests { #pragma warning disable xUnit1013 // Public method should be marked as test From 7c892285286d51e54b2372859cef1a33a60c8a5b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:16:11 -0700 Subject: [PATCH 177/862] Adding some more test projects. --- Ix.NET/Source/Ix.NET.sln | 38 +++++++++++++++++++ .../System.Linq.Async.Queryable.Tests.csproj | 30 +++++++++++++++ .../xunit.runner.json | 5 +++ .../System.Linq.Async.Tests.csproj | 29 ++++++++++++++ .../System.Linq.Async.Tests/xunit.runner.json | 5 +++ 5 files changed, 107 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable.Tests/xunit.runner.json create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/xunit.runner.json diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index 0c11677c64..e91e01fdba 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -45,6 +45,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playground", "Playground\Pl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiCompare", "ApiCompare\ApiCompare.csproj", "{792093F9-83E4-4630-9652-4328FDAED15F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Tests", "System.Linq.Async.Tests\System.Linq.Async.Tests.csproj", "{2E23D7AD-0B21-4725-87C4-BD43271260A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable.Tests", "System.Linq.Async.Queryable.Tests\System.Linq.Async.Queryable.Tests.csproj", "{134E9066-6217-4AF0-B408-47D92AB595BD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -241,6 +245,38 @@ Global {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x64.Build.0 = Release|Any CPU {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x86.ActiveCfg = Release|Any CPU {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x86.Build.0 = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|ARM.ActiveCfg = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|ARM.Build.0 = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x64.ActiveCfg = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x64.Build.0 = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x86.ActiveCfg = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x86.Build.0 = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.Build.0 = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|ARM.ActiveCfg = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|ARM.Build.0 = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x64.ActiveCfg = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x64.Build.0 = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x86.ActiveCfg = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x86.Build.0 = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|ARM.ActiveCfg = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|ARM.Build.0 = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x64.ActiveCfg = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x64.Build.0 = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x86.ActiveCfg = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x86.Build.0 = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.Build.0 = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|ARM.ActiveCfg = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|ARM.Build.0 = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x64.ActiveCfg = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x64.Build.0 = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.ActiveCfg = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -257,6 +293,8 @@ Global {513F9ABD-4FB8-4AC1-89DA-C3300399F34C} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0} = {61683064-A120-44A7-A174-E19154F6D84F} {792093F9-83E4-4630-9652-4328FDAED15F} = {61683064-A120-44A7-A174-E19154F6D84F} + {2E23D7AD-0B21-4725-87C4-BD43271260A1} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} + {134E9066-6217-4AF0-B408-47D92AB595BD} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj new file mode 100644 index 0000000000..9be91e5813 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp1.1;net461 + $(NoWarn);CS0618 + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/xunit.runner.json b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/xunit.runner.json new file mode 100644 index 0000000000..0a67ebc934 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "diagnosticMessages": true, + "methodDisplay": "classAndMethod", + "longRunningTestSeconds": 30 +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj new file mode 100644 index 0000000000..9cfe536513 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -0,0 +1,29 @@ + + + + netcoreapp1.1;net461 + $(NoWarn);CS0618 + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + diff --git a/Ix.NET/Source/System.Linq.Async.Tests/xunit.runner.json b/Ix.NET/Source/System.Linq.Async.Tests/xunit.runner.json new file mode 100644 index 0000000000..0a67ebc934 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "diagnosticMessages": true, + "methodDisplay": "classAndMethod", + "longRunningTestSeconds": 30 +} From 705d26d529c53d07b98a43a39cb714f8186a35e5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:32:13 -0700 Subject: [PATCH 178/862] Initial restructuring of test projects. --- .../AsyncTests.Single.cs | 205 ------------------ .../System/Linq/AsyncEnumerableTests.cs | 88 ++++++++ .../System/Linq/Operators/Select.cs | 100 +++++++++ .../System/Linq/Operators/Where.cs | 132 +++++++++++ 4 files changed, 320 insertions(+), 205 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index f5a697e0b5..393b630fe0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -22,92 +22,6 @@ public void MoveNextExtension_Null() Assert.ThrowsAsync(() => en.MoveNextAsync()); } - [Fact] - public void Select_Null() - { - AssertThrows(() => AsyncEnumerable.Select(null, x => x)); - AssertThrows(() => AsyncEnumerable.Select(null, (x, i) => x)); - AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); - } - - [Fact] - public void Select1() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(x => (char)('a' + x)); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 'a'); - HasNext(e, 'b'); - HasNext(e, 'c'); - NoNext(e); - } - - [Fact] - public void Select2() - { - var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i) => (char)('a' + i)); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 'a'); - HasNext(e, 'b'); - HasNext(e, 'c'); - NoNext(e); - } - - [Fact] - public void Select3() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(x => 1 / x); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); - } - - [Fact] - public void Select4() - { - var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i) => 1 / i); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); - } - - [Fact] - public void Select5() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x)); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 'd'); - HasNext(e, 'e'); - HasNext(e, 'f'); - NoNext(e); - } - - [Fact] - public async Task Select7() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(x => (char)('a' + x)); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task Select8() - { - var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i) => (char)('a' + i)); - - await SequenceIdentity(ys); - } - [Fact] public void SelectWhere2() { @@ -145,125 +59,6 @@ public void WhereSelect3() NoNext(e); } - [Fact] - public void Where_Null() - { - AssertThrows(() => AsyncEnumerable.Where(null, x => true)); - AssertThrows(() => AsyncEnumerable.Where(null, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); - } - - [Fact] - public void Where1() - { - var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where(x => x % 2 == 0); - var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 4); - HasNext(e, 6); - HasNext(e, 2); - HasNext(e, 0); - NoNext(e); - } - - [Fact] - public void Where2() - { - var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((x, i) => i % 2 == 0); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 7); - HasNext(e, 6); - HasNext(e, 2); - HasNext(e, 0); - NoNext(e); - } - - [Fact] - public void Where3() - { - var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ex = new Exception("Bang"); - var ys = xs.Where(x => { if (x == 4) throw ex; return true; }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 5); - HasNext(e, 7); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Where4() - { - var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ex = new Exception("Bang"); - var ys = xs.Where((x, i) => { if (i == 3) throw ex; return true; }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 5); - HasNext(e, 7); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Where5() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Where(x => true); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Where6() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - - var ys = xs.Where((x, i) => true); - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - - [Fact] - public void Where7() - { - var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where(x => x % 2 == 0).Where(x => x > 5); - var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public async Task Where8() - { - var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where(x => x % 2 == 0); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task Where9() - { - var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((x, i) => i % 2 == 0); - - await SequenceIdentity(ys); - } - - [Fact] public void SelectMany_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs new file mode 100644 index 0000000000..b208a64ec4 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using FluentAssertions; +using Xunit; + +namespace Tests +{ + public class AsyncEnumerableTests + { + protected const int WaitTimeoutMs = 5000; + +#pragma warning disable xUnit1013 // Public method should be marked as test + public void AssertThrows(Action a) + where E : Exception + { + Assert.Throws(a); + } + + [Obsolete("Don't use this, use Assert.ThrowsAsync and await it", true)] + public Task AssertThrows(Func func) + where E : Exception + { + return Assert.ThrowsAsync(func); + } + + public void AssertThrows(Action a, Func assert) + where E : Exception + { + + var hasFailed = false; + + try + { + a(); + } + catch (E e) + { + Assert.True(assert(e)); + hasFailed = true; + } + + if (!hasFailed) + { + Assert.True(false); + } + } + + public void NoNext(IAsyncEnumerator e) + { + Assert.False(e.MoveNextAsync().Result); + } + + public void HasNext(IAsyncEnumerator e, T value) + { + Assert.True(e.MoveNextAsync().Result); + Assert.Equal(value, e.Current); + } + + public async Task SequenceIdentity(IAsyncEnumerable enumerable) + { + var en1 = enumerable.GetAsyncEnumerator(); + var en2 = enumerable.GetAsyncEnumerator(); + + Assert.Equal(en1.GetType(), en2.GetType()); + + await en1.DisposeAsync(); + await en2.DisposeAsync(); + + var e1t = enumerable.ToList(); + var e2t = enumerable.ToList(); + + await Task.WhenAll(e1t, e2t); + + + var e1Result = e1t.Result; + var e2Result = e2t.Result; + + e1Result.ShouldAllBeEquivalentTo(e2Result); + } +#pragma warning restore xUnit1013 // Public method should be marked as test + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs new file mode 100644 index 0000000000..f3e05bca59 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -0,0 +1,100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Select : AsyncEnumerableTests + { + [Fact] + public void Select_Null() + { + AssertThrows(() => AsyncEnumerable.Select(null, x => x)); + AssertThrows(() => AsyncEnumerable.Select(null, (x, i) => x)); + AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); + } + + [Fact] + public void Select1() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = xs.Select(x => (char)('a' + x)); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 'a'); + HasNext(e, 'b'); + HasNext(e, 'c'); + NoNext(e); + } + + [Fact] + public void Select2() + { + var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); + var ys = xs.Select((x, i) => (char)('a' + i)); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 'a'); + HasNext(e, 'b'); + HasNext(e, 'c'); + NoNext(e); + } + + [Fact] + public void Select3() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = xs.Select(x => 1 / x); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); + } + + [Fact] + public void Select4() + { + var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); + var ys = xs.Select((x, i) => 1 / i); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); + } + + [Fact] + public void Select5() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x)); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 'd'); + HasNext(e, 'e'); + HasNext(e, 'f'); + NoNext(e); + } + + [Fact] + public async Task Select7() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = xs.Select(x => (char)('a' + x)); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task Select8() + { + var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); + var ys = xs.Select((x, i) => (char)('a' + i)); + + await SequenceIdentity(ys); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs new file mode 100644 index 0000000000..098e651b35 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -0,0 +1,132 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Where : AsyncEnumerableTests + { + [Fact] + public void Where_Null() + { + AssertThrows(() => AsyncEnumerable.Where(null, x => true)); + AssertThrows(() => AsyncEnumerable.Where(null, (x, i) => true)); + AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); + } + + [Fact] + public void Where1() + { + var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); + var ys = xs.Where(x => x % 2 == 0); + var e = ys.GetAsyncEnumerator(); + HasNext(e, 8); + HasNext(e, 4); + HasNext(e, 6); + HasNext(e, 2); + HasNext(e, 0); + NoNext(e); + } + + [Fact] + public void Where2() + { + var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); + var ys = xs.Where((x, i) => i % 2 == 0); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 8); + HasNext(e, 7); + HasNext(e, 6); + HasNext(e, 2); + HasNext(e, 0); + NoNext(e); + } + + [Fact] + public void Where3() + { + var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); + var ex = new Exception("Bang"); + var ys = xs.Where(x => { if (x == 4) throw ex; return true; }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 8); + HasNext(e, 5); + HasNext(e, 7); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Where4() + { + var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); + var ex = new Exception("Bang"); + var ys = xs.Where((x, i) => { if (i == 3) throw ex; return true; }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 8); + HasNext(e, 5); + HasNext(e, 7); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Where5() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Where(x => true); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Where6() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + + var ys = xs.Where((x, i) => true); + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + + [Fact] + public void Where7() + { + var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); + var ys = xs.Where(x => x % 2 == 0).Where(x => x > 5); + var e = ys.GetAsyncEnumerator(); + HasNext(e, 8); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public async Task Where8() + { + var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); + var ys = xs.Where(x => x % 2 == 0); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task Where9() + { + var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); + var ys = xs.Where((x, i) => i % 2 == 0); + + await SequenceIdentity(ys); + } + } +} From dc74fc79507e208c5322dc2b785016378d0848c8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:33:59 -0700 Subject: [PATCH 179/862] Moving Cast and OfType tests. --- .../AsyncTests.Single.cs | 47 ------------------- .../System/Linq/Operators/Cast.cs | 42 +++++++++++++++++ .../System/Linq/Operators/OfType.cs | 31 ++++++++++++ 3 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 393b630fe0..40ec889920 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -316,53 +316,6 @@ public async Task SelectMany16() await SequenceIdentity(ys); } - [Fact] - public void OfType_Null() - { - AssertThrows(() => AsyncEnumerable.OfType(null)); - } - - [Fact] - public void OfType() - { - var xs = new object[] { 1, 1.2, true, 4, "" }.ToAsyncEnumerable(); - var ys = xs.OfType(); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Cast_Null() - { - AssertThrows(() => AsyncEnumerable.Cast(null)); - } - - [Fact] - public void Cast1() - { - var xs = new object[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Cast(); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Cast2() - { - var xs = new[] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable(); - var ys = xs.Cast(); - - Assert.Same(xs, ys); - } - [Fact] public void Do_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs new file mode 100644 index 0000000000..72ac62a9f7 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Cast : AsyncEnumerableTests + { + [Fact] + public void Cast_Null() + { + AssertThrows(() => AsyncEnumerable.Cast(null)); + } + + [Fact] + public void Cast1() + { + var xs = new object[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Cast(); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void Cast2() + { + var xs = new[] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable(); + var ys = xs.Cast(); + + Assert.Same(xs, ys); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs new file mode 100644 index 0000000000..faaabe7290 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class OfType : AsyncEnumerableTests + { + [Fact] + public void OfType_Null() + { + AssertThrows(() => AsyncEnumerable.OfType(null)); + } + + [Fact] + public void OfType1() + { + var xs = new object[] { 1, 1.2, true, 4, "" }.ToAsyncEnumerable(); + var ys = xs.OfType(); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 4); + NoNext(e); + } + } +} From c942c10526152813b04394b4e31f5f5c575d48c3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:35:45 -0700 Subject: [PATCH 180/862] Moving Skip and Take tests. --- .../AsyncTests.Single.cs | 144 ------------------ .../System/Linq/Operators/Skip.cs | 86 +++++++++++ .../System/Linq/Operators/Take.cs | 85 +++++++++++ 3 files changed, 171 insertions(+), 144 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 40ec889920..73ab55aaa3 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -549,78 +549,6 @@ public void ForEachAsync6() AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void Take_Null() - { - AssertThrows(() => AsyncEnumerable.Take(null, 5)); - } - - [Fact] - public void Take0() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Take(-2); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void Take1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Take(2); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void Take2() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Take(10); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Take3() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Take(0); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void Take4() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Take(2); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Take5() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Take(2); - - await SequenceIdentity(ys); - } - [Fact] public void TakeWhile_Null() { @@ -755,78 +683,6 @@ public async Task TakeWhile11() await SequenceIdentity(ys); } - [Fact] - public void Skip_Null() - { - AssertThrows(() => AsyncEnumerable.Skip(null, 5)); - } - - //[Fact] - //public void Skip0() - //{ - // var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - // var ys = xs.Skip(-2); - - // var e = ys.GetEnumerator(); - // NoNext(e); - //} - - [Fact] - public void Skip1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Skip(2); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Skip2() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Skip(10); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void Skip3() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Skip(0); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Skip4() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Skip(2); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Skip5() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Skip(2); - - await SequenceIdentity(ys); - } - [Fact] public void SkipWhile_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs new file mode 100644 index 0000000000..165d837fb9 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -0,0 +1,86 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Skip : AsyncEnumerableTests + { + [Fact] + public void Skip_Null() + { + AssertThrows(() => AsyncEnumerable.Skip(null, 5)); + } + + //[Fact] + //public void Skip0() + //{ + // var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + // var ys = xs.Skip(-2); + + // var e = ys.GetEnumerator(); + // NoNext(e); + //} + + [Fact] + public void Skip1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Skip(2); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void Skip2() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Skip(10); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void Skip3() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Skip(0); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void Skip4() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Skip(2); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task Skip5() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Skip(2); + + await SequenceIdentity(ys); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs new file mode 100644 index 0000000000..ac01b1a196 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -0,0 +1,85 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Take : AsyncEnumerableTests + { + [Fact] + public void Take_Null() + { + AssertThrows(() => AsyncEnumerable.Take(null, 5)); + } + + [Fact] + public void Take0() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Take(-2); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void Take1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Take(2); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void Take2() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Take(10); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void Take3() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Take(0); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void Take4() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Take(2); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task Take5() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Take(2); + + await SequenceIdentity(ys); + } + } +} From a015cefb5ce41cf854209d8dcdf0bfe55f7804e1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:37:15 -0700 Subject: [PATCH 181/862] Moving DefaultIfEmpty tests. --- .../AsyncTests.Single.cs | 158 ---------------- .../System/Linq/Operators/DefaultIfEmpty.cs | 172 ++++++++++++++++++ 2 files changed, 172 insertions(+), 158 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 73ab55aaa3..eba2700af3 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -819,164 +819,6 @@ public async Task SkipWhile11() await SequenceIdentity(ys); } - [Fact] - public void DefaultIfEmpty_Null() - { - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(null)); - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(null, 42)); - } - - [Fact] - public void DefaultIfEmpty1() - { - var xs = AsyncEnumerable.Empty().DefaultIfEmpty(); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - NoNext(e); - } - - [Fact] - public void DefaultIfEmpty2() - { - var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); - } - - [Fact] - public void DefaultIfEmpty3() - { - var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); - } - - [Fact] - public void DefaultIfEmpty4() - { - var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(24); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); - } - - [Fact] - public void DefaultIfEmpty5() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void DefaultIfEmpty6() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void DefaultIfEmpty7() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void DefaultIfEmpty8() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(24); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task DefaultIfEmpty9() - { - var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); - - var res = new[] { 42 }; - - Assert.True(res.SequenceEqual(await xs.ToArray())); - } - - [Fact] - public async Task DefaultIfEmpty10() - { - var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); - - var res = new List { 42 }; - - Assert.True(res.SequenceEqual(await xs.ToList())); - } - - [Fact] - public async Task DefaultIfEmpty11() - { - var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); - - Assert.Equal(1, await xs.Count()); - } - - - [Fact] - public async Task DefaultIfEmpty12() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); - - var res = new[] { 1, 2, 3, 4 }; - - Assert.True(res.SequenceEqual(await xs.ToArray())); - } - - [Fact] - public async Task DefaultIfEmpty13() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); - - var res = new List { 1, 2, 3, 4 }; - - Assert.True(res.SequenceEqual(await xs.ToList())); - } - - [Fact] - public async Task DefaultIfEmpty14() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); - - Assert.Equal(4, await xs.Count()); - } - - [Fact] - public async Task DefaultIfEmpty15() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); - - await SequenceIdentity(xs); - } - [Fact] public void Distinct_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs new file mode 100644 index 0000000000..be7a7c8838 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -0,0 +1,172 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class DefaultIfEmpty : AsyncEnumerableTests + { + [Fact] + public void DefaultIfEmpty_Null() + { + AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(null)); + AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(null, 42)); + } + + [Fact] + public void DefaultIfEmpty1() + { + var xs = AsyncEnumerable.Empty().DefaultIfEmpty(); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 0); + NoNext(e); + } + + [Fact] + public void DefaultIfEmpty2() + { + var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 42); + NoNext(e); + } + + [Fact] + public void DefaultIfEmpty3() + { + var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 42); + NoNext(e); + } + + [Fact] + public void DefaultIfEmpty4() + { + var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(24); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 42); + NoNext(e); + } + + [Fact] + public void DefaultIfEmpty5() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void DefaultIfEmpty6() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void DefaultIfEmpty7() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void DefaultIfEmpty8() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(24); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task DefaultIfEmpty9() + { + var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); + + var res = new[] { 42 }; + + Assert.True(res.SequenceEqual(await xs.ToArray())); + } + + [Fact] + public async Task DefaultIfEmpty10() + { + var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); + + var res = new List { 42 }; + + Assert.True(res.SequenceEqual(await xs.ToList())); + } + + [Fact] + public async Task DefaultIfEmpty11() + { + var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); + + Assert.Equal(1, await xs.Count()); + } + + + [Fact] + public async Task DefaultIfEmpty12() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); + + var res = new[] { 1, 2, 3, 4 }; + + Assert.True(res.SequenceEqual(await xs.ToArray())); + } + + [Fact] + public async Task DefaultIfEmpty13() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); + + var res = new List { 1, 2, 3, 4 }; + + Assert.True(res.SequenceEqual(await xs.ToList())); + } + + [Fact] + public async Task DefaultIfEmpty14() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); + + Assert.Equal(4, await xs.Count()); + } + + [Fact] + public async Task DefaultIfEmpty15() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); + + await SequenceIdentity(xs); + } + } +} From 005aad3e169d8f681c4b651667f103f86b2d9b0a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:37:39 -0700 Subject: [PATCH 182/862] Fixing some test code. --- .../System/Linq/Operators/DefaultIfEmpty.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index be7a7c8838..2312fb6b41 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; From d2fa147e0c674a0359f2e369254fb46e05ec2bff Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:41:57 -0700 Subject: [PATCH 183/862] Moving SkipWhile and TakeWhile tests. --- .../AsyncTests.Single.cs | 384 ------------------ .../System/Linq/Operators/SkipLast.cs | 63 +++ .../System/Linq/Operators/SkipWhile.cs | 150 +++++++ .../System/Linq/Operators/TakeLast.cs | 80 ++++ .../System/Linq/Operators/TakeWhile.cs | 148 +++++++ 5 files changed, 441 insertions(+), 384 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index eba2700af3..4f0436bc03 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -11,7 +11,6 @@ namespace Tests { - public partial class AsyncTests { [Fact] @@ -549,276 +548,6 @@ public void ForEachAsync6() AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void TakeWhile_Null() - { - AssertThrows(() => AsyncEnumerable.TakeWhile(null, x => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(null, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); - } - - [Fact] - public void TakeWhile1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => x < 3); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void TakeWhile2() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => false); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void TakeWhile3() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => true); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void TakeWhile4() - { - var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => x < 3); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void TakeWhile5() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(new Func(x => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void TakeWhile6() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i) => i < 2); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void TakeWhile7() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i) => false); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void TakeWhile8() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i) => true); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void TakeWhile9() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(new Func((x, i) => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - - [Fact] - public async Task TakeWhile10() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => x < 3); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task TakeWhile11() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i) => i < 2); - - await SequenceIdentity(ys); - } - - [Fact] - public void SkipWhile_Null() - { - AssertThrows(() => AsyncEnumerable.SkipWhile(null, x => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(null, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); - } - - [Fact] - public void SkipWhile1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => x < 3); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void SkipWhile2() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => false); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void SkipWhile3() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => true); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void SkipWhile4() - { - var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => x < 3); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 3); - HasNext(e, 2); - HasNext(e, 1); - NoNext(e); - } - - [Fact] - public void SkipWhile5() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(new Func(x => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SkipWhile6() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i) => i < 2); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void SkipWhile7() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i) => false); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void SkipWhile8() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i) => true); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void SkipWhile9() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(new Func((x, i) => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task SkipWhile10() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => x < 3); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task SkipWhile11() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i) => false); - - await SequenceIdentity(ys); - } - [Fact] public void Distinct_Null() { @@ -2653,118 +2382,5 @@ public void DistinctKey1() HasNext(e, 4); NoNext(e); } - - [Fact] - public void TakeLast_Null() - { - AssertThrows(() => AsyncEnumerable.TakeLast(default(IAsyncEnumerable), 5)); - } - - [Fact] - public void TakeLast0() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(-2); - - var e = xs.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void TakeLast1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void TakeLast2() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(5); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public async Task TakeLast3() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); - - await SequenceIdentity(xs); - } - - [Fact] - public void TakeLast_BugFix_TakeLast_Zero_TakesForever() - { - var isSet = false; - new int[] { 1, 2, 3, 4 }.ToAsyncEnumerable() - .TakeLast(0) - .ForEachAsync(_ => { isSet = true; }) - .Wait(WaitTimeoutMs); - - Assert.False(isSet); - - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(0); - - var e = xs.GetAsyncEnumerator(); - - NoNext(e); - } - - [Fact] - public void SkipLast_Null() - { - AssertThrows(() => AsyncEnumerable.SkipLast(default(IAsyncEnumerable), 5)); - } - - [Fact] - public void SkipLast1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void SkipLast2() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(5); - - var e = xs.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public async Task SkipLast3() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); - - await SequenceIdentity(xs); - } - - [Fact] - public void SkipLast4() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(0); - - var e = xs.GetAsyncEnumerator(); - - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs new file mode 100644 index 0000000000..c204b8e700 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class SkipLast : AsyncEnumerableTests + { + [Fact] + public void SkipLast_Null() + { + AssertThrows(() => AsyncEnumerable.SkipLast(default(IAsyncEnumerable), 5)); + } + + [Fact] + public void SkipLast1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void SkipLast2() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(5); + + var e = xs.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public async Task SkipLast3() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); + + await SequenceIdentity(xs); + } + + [Fact] + public void SkipLast4() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(0); + + var e = xs.GetAsyncEnumerator(); + + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs new file mode 100644 index 0000000000..4e5fd20dd5 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -0,0 +1,150 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class SkipWhile : AsyncEnumerableTests + { + [Fact] + public void SkipWhile_Null() + { + AssertThrows(() => AsyncEnumerable.SkipWhile(null, x => true)); + AssertThrows(() => AsyncEnumerable.SkipWhile(null, (x, i) => true)); + AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); + } + + [Fact] + public void SkipWhile1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile(x => x < 3); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void SkipWhile2() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile(x => false); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void SkipWhile3() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile(x => true); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void SkipWhile4() + { + var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile(x => x < 3); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 3); + HasNext(e, 2); + HasNext(e, 1); + NoNext(e); + } + + [Fact] + public void SkipWhile5() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile(new Func(x => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SkipWhile6() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile((x, i) => i < 2); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void SkipWhile7() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile((x, i) => false); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void SkipWhile8() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile((x, i) => true); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void SkipWhile9() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile(new Func((x, i) => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task SkipWhile10() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile(x => x < 3); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task SkipWhile11() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipWhile((x, i) => false); + + await SequenceIdentity(ys); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs new file mode 100644 index 0000000000..f81271bd87 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs @@ -0,0 +1,80 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class TakeLast : AsyncEnumerableTests + { + [Fact] + public void TakeLast_Null() + { + AssertThrows(() => AsyncEnumerable.TakeLast(default(IAsyncEnumerable), 5)); + } + + [Fact] + public void TakeLast0() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(-2); + + var e = xs.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void TakeLast1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void TakeLast2() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(5); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public async Task TakeLast3() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); + + await SequenceIdentity(xs); + } + + [Fact] + public void TakeLast_BugFix_TakeLast_Zero_TakesForever() + { + var isSet = false; + new int[] { 1, 2, 3, 4 }.ToAsyncEnumerable() + .TakeLast(0) + .ForEachAsync(_ => { isSet = true; }) + .Wait(WaitTimeoutMs); + + Assert.False(isSet); + + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(0); + + var e = xs.GetAsyncEnumerator(); + + NoNext(e); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs new file mode 100644 index 0000000000..a6ed27e715 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -0,0 +1,148 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class TakeWhile : AsyncEnumerableTests + { + [Fact] + public void TakeWhile_Null() + { + AssertThrows(() => AsyncEnumerable.TakeWhile(null, x => true)); + AssertThrows(() => AsyncEnumerable.TakeWhile(null, (x, i) => true)); + AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); + } + + [Fact] + public void TakeWhile1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile(x => x < 3); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void TakeWhile2() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile(x => false); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void TakeWhile3() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile(x => true); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void TakeWhile4() + { + var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile(x => x < 3); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void TakeWhile5() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile(new Func(x => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void TakeWhile6() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile((x, i) => i < 2); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void TakeWhile7() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile((x, i) => false); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void TakeWhile8() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile((x, i) => true); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void TakeWhile9() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile(new Func((x, i) => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + + [Fact] + public async Task TakeWhile10() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile(x => x < 3); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task TakeWhile11() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.TakeWhile((x, i) => i < 2); + + await SequenceIdentity(ys); + } + } +} From 9a9cfc135af4223cc88b3343343b0d178797838e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:42:52 -0700 Subject: [PATCH 184/862] Moving Reverse tests. --- .../AsyncTests.Single.cs | 96 --------------- .../System/Linq/Operators/Reverse.cs | 110 ++++++++++++++++++ 2 files changed, 110 insertions(+), 96 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 4f0436bc03..cb09b155cc 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -673,102 +673,6 @@ public void Distinct12() NoNext(e); } - [Fact] - public void Reverse_Null() - { - AssertThrows(() => AsyncEnumerable.Reverse(null)); - } - - [Fact] - public void Reverse1() - { - var xs = AsyncEnumerable.Empty(); - var ys = xs.Reverse(); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void Reverse2() - { - var xs = AsyncEnumerable.Return(42); - var ys = xs.Reverse(); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); - } - - [Fact] - public void Reverse3() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.Reverse(); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 2); - HasNext(e, 1); - NoNext(e); - } - - [Fact] - public void Reverse4() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Reverse(); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Reverse5() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.Reverse(); - - Assert.Equal(new[] { 3, 2, 1 }, await ys.ToArray()); - } - - [Fact] - public async Task Reverse6() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.Reverse(); - - Assert.Equal(new[] { 3, 2, 1 }, await ys.ToList()); - } - - [Fact] - public async Task Reverse7() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.Reverse(); - - Assert.Equal(3, await ys.Count()); - } - - [Fact] - public async Task Reverse8() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.Reverse(); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task Reverse9() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.Reverse().Prepend(4); // to trigger onlyIfCheap - - Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArray()); - } - [Fact] public void OrderBy_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs new file mode 100644 index 0000000000..76f35bd61a --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -0,0 +1,110 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Reverse : AsyncEnumerableTests + { + [Fact] + public void Reverse_Null() + { + AssertThrows(() => AsyncEnumerable.Reverse(null)); + } + + [Fact] + public void Reverse1() + { + var xs = AsyncEnumerable.Empty(); + var ys = xs.Reverse(); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void Reverse2() + { + var xs = AsyncEnumerable.Return(42); + var ys = xs.Reverse(); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 42); + NoNext(e); + } + + [Fact] + public void Reverse3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.Reverse(); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 2); + HasNext(e, 1); + NoNext(e); + } + + [Fact] + public void Reverse4() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Reverse(); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task Reverse5() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.Reverse(); + + Assert.Equal(new[] { 3, 2, 1 }, await ys.ToArray()); + } + + [Fact] + public async Task Reverse6() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.Reverse(); + + Assert.Equal(new[] { 3, 2, 1 }, await ys.ToList()); + } + + [Fact] + public async Task Reverse7() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.Reverse(); + + Assert.Equal(3, await ys.Count()); + } + + [Fact] + public async Task Reverse8() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.Reverse(); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task Reverse9() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.Reverse().Prepend(4); // to trigger onlyIfCheap + + Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArray()); + } + } +} From df7ce673407186caad83199b363bfbad8d912dab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Sep 2017 15:43:50 -0700 Subject: [PATCH 185/862] Moving OrderBy tests. --- .../AsyncTests.Single.cs | 204 ---------------- .../System/Linq/Operators/OrderBy.cs | 219 ++++++++++++++++++ 2 files changed, 219 insertions(+), 204 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index cb09b155cc..e1d37aaf23 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -673,210 +673,6 @@ public void Distinct12() NoNext(e); } - [Fact] - public void OrderBy_Null() - { - AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func))); - - AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); - - AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func))); - - AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), x => x, default(IComparer))); - - var xs = AsyncEnumerable.Return(42).OrderBy(x => x); - - AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); - - AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, x => x, default(IComparer))); - - AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); - - AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, x => x, default(IComparer))); - } - - [Fact] - public void OrderBy1() - { - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x); - - var e = ys.GetAsyncEnumerator(); - for (var i = 0; i < 10; i++) - HasNext(e, i); - NoNext(e); - } - - [Fact] - public void OrderBy2() - { - var ex = new Exception("Bang!"); - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(new Func(x => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task OrderBy3() - { - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x); - - await SequenceIdentity(ys); - } - - [Fact] - public void ThenBy2() - { - var ex = new Exception("Bang!"); - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void OrderByDescending1() - { - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderByDescending(x => x); - - var e = ys.GetAsyncEnumerator(); - for (var i = 9; i >= 0; i--) - HasNext(e, i); - NoNext(e); - } - - [Fact] - public void OrderByDescending2() - { - var ex = new Exception("Bang!"); - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderByDescending(new Func(x => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task OrderByDescending3() - { - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderByDescending(x => x); - - await SequenceIdentity(ys); - } - - [Fact] - public void ThenByDescending2() - { - var ex = new Exception("Bang!"); - var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void OrderByThenBy1() - { - var xs = new[] { - new { Name = "Bart", Age = 27 }, - new { Name = "John", Age = 62 }, - new { Name = "Eric", Age = 27 }, - new { Name = "Lisa", Age = 14 }, - new { Name = "Brad", Age = 27 }, - new { Name = "Lisa", Age = 23 }, - new { Name = "Eric", Age = 42 }, - }; - - var ys = xs.ToAsyncEnumerable(); - - var ress = xs.OrderBy(x => x.Name).ThenBy(x => x.Age); - var resa = ys.OrderBy(x => x.Name).ThenBy(x => x.Age); - - Assert.True(ress.SequenceEqual(resa.ToEnumerable())); - } - - [Fact] - public void OrderByThenBy2() - { - var xs = new[] { - new { Name = "Bart", Age = 27 }, - new { Name = "John", Age = 62 }, - new { Name = "Eric", Age = 27 }, - new { Name = "Lisa", Age = 14 }, - new { Name = "Brad", Age = 27 }, - new { Name = "Lisa", Age = 23 }, - new { Name = "Eric", Age = 42 }, - }; - - var ys = xs.ToAsyncEnumerable(); - - var ress = xs.OrderBy(x => x.Name).ThenByDescending(x => x.Age); - var resa = ys.OrderBy(x => x.Name).ThenByDescending(x => x.Age); - - Assert.True(ress.SequenceEqual(resa.ToEnumerable())); - } - - [Fact] - public void OrderByThenBy3() - { - var xs = new[] { - new { Name = "Bart", Age = 27 }, - new { Name = "John", Age = 62 }, - new { Name = "Eric", Age = 27 }, - new { Name = "Lisa", Age = 14 }, - new { Name = "Brad", Age = 27 }, - new { Name = "Lisa", Age = 23 }, - new { Name = "Eric", Age = 42 }, - }; - - var ys = xs.ToAsyncEnumerable(); - - var ress = xs.OrderByDescending(x => x.Name).ThenBy(x => x.Age); - var resa = ys.OrderByDescending(x => x.Name).ThenBy(x => x.Age); - - Assert.True(ress.SequenceEqual(resa.ToEnumerable())); - } - - [Fact] - public void OrderByThenBy4() - { - var xs = new[] { - new { Name = "Bart", Age = 27 }, - new { Name = "John", Age = 62 }, - new { Name = "Eric", Age = 27 }, - new { Name = "Lisa", Age = 14 }, - new { Name = "Brad", Age = 27 }, - new { Name = "Lisa", Age = 23 }, - new { Name = "Eric", Age = 42 }, - }; - - var ys = xs.ToAsyncEnumerable(); - - var ress = xs.OrderByDescending(x => x.Name).ThenByDescending(x => x.Age); - var resa = ys.OrderByDescending(x => x.Name).ThenByDescending(x => x.Age); - - Assert.True(ress.SequenceEqual(resa.ToEnumerable())); - } - [Fact] public void GroupBy_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs new file mode 100644 index 0000000000..21d08af186 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -0,0 +1,219 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class OrderBy : AsyncEnumerableTests + { + [Fact] + public void OrderBy_Null() + { + AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func))); + + AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + + AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func))); + + AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), x => x, default(IComparer))); + + var xs = AsyncEnumerable.Return(42).OrderBy(x => x); + + AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); + + AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, x => x, default(IComparer))); + + AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); + + AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, x => x, default(IComparer))); + } + + [Fact] + public void OrderBy1() + { + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderBy(x => x); + + var e = ys.GetAsyncEnumerator(); + for (var i = 0; i < 10; i++) + HasNext(e, i); + NoNext(e); + } + + [Fact] + public void OrderBy2() + { + var ex = new Exception("Bang!"); + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderBy(new Func(x => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task OrderBy3() + { + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderBy(x => x); + + await SequenceIdentity(ys); + } + + [Fact] + public void ThenBy2() + { + var ex = new Exception("Bang!"); + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void OrderByDescending1() + { + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderByDescending(x => x); + + var e = ys.GetAsyncEnumerator(); + for (var i = 9; i >= 0; i--) + HasNext(e, i); + NoNext(e); + } + + [Fact] + public void OrderByDescending2() + { + var ex = new Exception("Bang!"); + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderByDescending(new Func(x => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task OrderByDescending3() + { + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderByDescending(x => x); + + await SequenceIdentity(ys); + } + + [Fact] + public void ThenByDescending2() + { + var ex = new Exception("Bang!"); + var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); + var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void OrderByThenBy1() + { + var xs = new[] { + new { Name = "Bart", Age = 27 }, + new { Name = "John", Age = 62 }, + new { Name = "Eric", Age = 27 }, + new { Name = "Lisa", Age = 14 }, + new { Name = "Brad", Age = 27 }, + new { Name = "Lisa", Age = 23 }, + new { Name = "Eric", Age = 42 }, + }; + + var ys = xs.ToAsyncEnumerable(); + + var ress = xs.OrderBy(x => x.Name).ThenBy(x => x.Age); + var resa = ys.OrderBy(x => x.Name).ThenBy(x => x.Age); + + Assert.True(ress.SequenceEqual(resa.ToEnumerable())); + } + + [Fact] + public void OrderByThenBy2() + { + var xs = new[] { + new { Name = "Bart", Age = 27 }, + new { Name = "John", Age = 62 }, + new { Name = "Eric", Age = 27 }, + new { Name = "Lisa", Age = 14 }, + new { Name = "Brad", Age = 27 }, + new { Name = "Lisa", Age = 23 }, + new { Name = "Eric", Age = 42 }, + }; + + var ys = xs.ToAsyncEnumerable(); + + var ress = xs.OrderBy(x => x.Name).ThenByDescending(x => x.Age); + var resa = ys.OrderBy(x => x.Name).ThenByDescending(x => x.Age); + + Assert.True(ress.SequenceEqual(resa.ToEnumerable())); + } + + [Fact] + public void OrderByThenBy3() + { + var xs = new[] { + new { Name = "Bart", Age = 27 }, + new { Name = "John", Age = 62 }, + new { Name = "Eric", Age = 27 }, + new { Name = "Lisa", Age = 14 }, + new { Name = "Brad", Age = 27 }, + new { Name = "Lisa", Age = 23 }, + new { Name = "Eric", Age = 42 }, + }; + + var ys = xs.ToAsyncEnumerable(); + + var ress = xs.OrderByDescending(x => x.Name).ThenBy(x => x.Age); + var resa = ys.OrderByDescending(x => x.Name).ThenBy(x => x.Age); + + Assert.True(ress.SequenceEqual(resa.ToEnumerable())); + } + + [Fact] + public void OrderByThenBy4() + { + var xs = new[] { + new { Name = "Bart", Age = 27 }, + new { Name = "John", Age = 62 }, + new { Name = "Eric", Age = 27 }, + new { Name = "Lisa", Age = 14 }, + new { Name = "Brad", Age = 27 }, + new { Name = "Lisa", Age = 23 }, + new { Name = "Eric", Age = 42 }, + }; + + var ys = xs.ToAsyncEnumerable(); + + var ress = xs.OrderByDescending(x => x.Name).ThenByDescending(x => x.Age); + var resa = ys.OrderByDescending(x => x.Name).ThenByDescending(x => x.Age); + + Assert.True(ress.SequenceEqual(resa.ToEnumerable())); + } + } +} From fd1a2e6c6cc4d9a152f098e98b237353bc76a7bc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:21:32 -0700 Subject: [PATCH 186/862] Moving SelectMany tests to a separate file. --- .../AsyncTests.Single.cs | 257 ----------------- .../System/Linq/Operators/SelectMany.cs | 272 ++++++++++++++++++ 2 files changed, 272 insertions(+), 257 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index e1d37aaf23..42c0f6c439 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -58,263 +58,6 @@ public void WhereSelect3() NoNext(e); } - [Fact] - public void SelectMany_Null() - { - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); - - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), x => null, default(Func))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), (x, i) => null, default(Func))); - } - - [Fact] - public void SelectMany1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); - HasNext(e, 0); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void SelectMany2() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany(x => - { - if (x < 3) - return Enumerable.Range(0, x).ToAsyncEnumerable(); - else - return AsyncEnumerable.Throw(ex); - }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SelectMany3() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SelectMany4() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany(x => - { - if (x < 3) - return Enumerable.Range(0, x).ToAsyncEnumerable(); - else - throw ex; - }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SelectMany5() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 5, x).ToAsyncEnumerable()); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 7); - HasNext(e, 8); - HasNext(e, 9); - NoNext(e); - } - - [Fact] - public void SelectMany6() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany((x, i) => - { - if (i < 2) - return Enumerable.Range(0, x).ToAsyncEnumerable(); - else - return AsyncEnumerable.Throw(ex); - }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SelectMany7() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SelectMany8() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany((x, i) => - { - if (i < 2) - return Enumerable.Range(0, x).ToAsyncEnumerable(); - else - throw ex; - }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SelectMany9() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => x * y); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 6); - HasNext(e, 8); - HasNext(e, 9); - HasNext(e, 12); - HasNext(e, 15); - NoNext(e); - } - - [Fact] - public void SelectMany10() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => x * y); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 8); - HasNext(e, 10); - HasNext(e, 15); - HasNext(e, 18); - HasNext(e, 21); - NoNext(e); - } - - [Fact] - public void SelectMany11() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => - { - if (x * y > 10) - throw ex; - return x * y; - }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 6); - HasNext(e, 8); - HasNext(e, 9); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SelectMany12() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => - { - if (x * y > 10) - throw ex; - return x * y; - }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 8); - HasNext(e, 10); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task SelectMany13() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task SelectMany14() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 5, x).ToAsyncEnumerable()); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task SelectMany15() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => x * y); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task SelectMany16() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => x * y); - - await SequenceIdentity(ys); - } - [Fact] public void Do_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs new file mode 100644 index 0000000000..6f6c2d036e --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -0,0 +1,272 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class SelectMany : AsyncEnumerableTests + { + [Fact] + public void SelectMany_Null() + { + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); + + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), x => null, default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), (x, i) => null, default(Func))); + } + + [Fact] + public void SelectMany1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 0); + HasNext(e, 0); + HasNext(e, 1); + HasNext(e, 0); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void SelectMany2() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany(x => + { + if (x < 3) + return Enumerable.Range(0, x).ToAsyncEnumerable(); + else + return AsyncEnumerable.Throw(ex); + }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 0); + HasNext(e, 0); + HasNext(e, 1); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SelectMany3() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SelectMany4() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany(x => + { + if (x < 3) + return Enumerable.Range(0, x).ToAsyncEnumerable(); + else + throw ex; + }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 0); + HasNext(e, 0); + HasNext(e, 1); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SelectMany5() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 5, x).ToAsyncEnumerable()); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 5); + HasNext(e, 6); + HasNext(e, 7); + HasNext(e, 7); + HasNext(e, 8); + HasNext(e, 9); + NoNext(e); + } + + [Fact] + public void SelectMany6() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany((x, i) => + { + if (i < 2) + return Enumerable.Range(0, x).ToAsyncEnumerable(); + else + return AsyncEnumerable.Throw(ex); + }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 0); + HasNext(e, 0); + HasNext(e, 1); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SelectMany7() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SelectMany8() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany((x, i) => + { + if (i < 2) + return Enumerable.Range(0, x).ToAsyncEnumerable(); + else + throw ex; + }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 0); + HasNext(e, 0); + HasNext(e, 1); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SelectMany9() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => x * y); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 6); + HasNext(e, 8); + HasNext(e, 9); + HasNext(e, 12); + HasNext(e, 15); + NoNext(e); + } + + [Fact] + public void SelectMany10() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => x * y); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 8); + HasNext(e, 10); + HasNext(e, 15); + HasNext(e, 18); + HasNext(e, 21); + NoNext(e); + } + + [Fact] + public void SelectMany11() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => + { + if (x * y > 10) + throw ex; + return x * y; + }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 6); + HasNext(e, 8); + HasNext(e, 9); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SelectMany12() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => + { + if (x * y > 10) + throw ex; + return x * y; + }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 8); + HasNext(e, 10); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task SelectMany13() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task SelectMany14() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 5, x).ToAsyncEnumerable()); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task SelectMany15() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => x * y); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task SelectMany16() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => x * y); + + await SequenceIdentity(ys); + } + } +} From 3ba441525c96367c9b13d9d256502c3356754249 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:24:06 -0700 Subject: [PATCH 187/862] Moving Aggregate tests to a separate file. --- .../AsyncTests.Aggregates.cs | 135 ---------------- .../System/Linq/Operators/Aggregate.cs | 150 ++++++++++++++++++ 2 files changed, 150 insertions(+), 135 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 6eb079a354..4966afa0e0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -19,141 +19,6 @@ public partial class AsyncTests { private const int WaitTimeoutMs = 5000; - [Fact] - public async Task Aggregate_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func), CancellationToken.None)); - } - - [Fact] - public void Aggregate1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate((x, y) => x * y); - Assert.Equal(24, ys.Result); - } - - [Fact] - public void Aggregate2() - { - var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.Aggregate((x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Aggregate3() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Aggregate((x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Aggregate4() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Aggregate5() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y); - Assert.Equal(24, ys.Result); - } - - [Fact] - public void Aggregate6() - { - var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y); - Assert.Equal(1, ys.Result); - } - - [Fact] - public void Aggregate7() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Aggregate(1, (x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Aggregate8() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Aggregate9() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - Assert.Equal(25, ys.Result); - } - - [Fact] - public void Aggregate10() - { - var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - Assert.Equal(2, ys.Result); - } - - [Fact] - public void Aggregate11() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Aggregate12() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => { throw ex; }, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Aggregate13() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y, x => { throw ex; }); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public async Task Count_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs new file mode 100644 index 0000000000..d38bf1d0c6 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -0,0 +1,150 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Aggregate : AsyncEnumerableTests + { + [Fact] + public async Task Aggregate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func), CancellationToken.None)); + } + + [Fact] + public void Aggregate1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Aggregate((x, y) => x * y); + Assert.Equal(24, ys.Result); + } + + [Fact] + public void Aggregate2() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.Aggregate((x, y) => x * y); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Aggregate3() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Aggregate((x, y) => x * y); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Aggregate4() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Aggregate5() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Aggregate(1, (x, y) => x * y); + Assert.Equal(24, ys.Result); + } + + [Fact] + public void Aggregate6() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.Aggregate(1, (x, y) => x * y); + Assert.Equal(1, ys.Result); + } + + [Fact] + public void Aggregate7() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Aggregate(1, (x, y) => x * y); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Aggregate8() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Aggregate9() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); + Assert.Equal(25, ys.Result); + } + + [Fact] + public void Aggregate10() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); + Assert.Equal(2, ys.Result); + } + + [Fact] + public void Aggregate11() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Aggregate12() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Aggregate(1, (x, y) => { throw ex; }, x => x + 1); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Aggregate13() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Aggregate(1, (x, y) => x * y, x => { throw ex; }); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From 8a42792f1526ff8569f880cdd6aa8ebbea882f4c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:25:18 -0700 Subject: [PATCH 188/862] Moving Count and LongCount tests. --- .../AsyncTests.Aggregates.cs | 72 ------------------- .../System/Linq/Operators/Count.cs | 51 +++++++++++++ .../System/Linq/Operators/LongCount.cs | 51 +++++++++++++ 3 files changed, 102 insertions(+), 72 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 4966afa0e0..c65cf2a926 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -19,78 +19,6 @@ public partial class AsyncTests { private const int WaitTimeoutMs = 5000; - [Fact] - public async Task Count_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void Count1() - { - Assert.Equal(0, new int[0].ToAsyncEnumerable().Count().Result); - Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count().Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).Count().Wait(WaitTimeoutMs)); - } - - [Fact] - public void Count2() - { - Assert.Equal(0, new int[0].ToAsyncEnumerable().Count(x => x < 3).Result); - Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3).Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).Count(x => x < 3).Wait(WaitTimeoutMs)); - } - - [Fact] - public void Count3() - { - var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task LongCount_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void LongCount1() - { - Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount().Result); - Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount().Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).LongCount().Wait(WaitTimeoutMs)); - } - - [Fact] - public void LongCount2() - { - Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount(x => x < 3).Result); - Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3).Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).LongCount(x => x < 3).Wait(WaitTimeoutMs)); - } - - [Fact] - public void LongCount3() - { - var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public async Task All_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs new file mode 100644 index 0000000000..fb9e5d565d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Count : AsyncEnumerableTests + { + [Fact] + public async Task Count_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void Count1() + { + Assert.Equal(0, new int[0].ToAsyncEnumerable().Count().Result); + Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count().Result); + AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).Count().Wait(WaitTimeoutMs)); + } + + [Fact] + public void Count2() + { + Assert.Equal(0, new int[0].ToAsyncEnumerable().Count(x => x < 3).Result); + Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3).Result); + AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).Count(x => x < 3).Wait(WaitTimeoutMs)); + } + + [Fact] + public void Count3() + { + var ex = new Exception("Bang!"); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs new file mode 100644 index 0000000000..b6c3f460d9 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class LongCount : AsyncEnumerableTests + { + [Fact] + public async Task LongCount_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void LongCount1() + { + Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount().Result); + Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount().Result); + AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).LongCount().Wait(WaitTimeoutMs)); + } + + [Fact] + public void LongCount2() + { + Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount(x => x < 3).Result); + Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3).Result); + AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).LongCount(x => x < 3).Wait(WaitTimeoutMs)); + } + + [Fact] + public void LongCount3() + { + var ex = new Exception("Bang!"); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); + AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From a168ae579b0ccedb82f7ec0b606f3238b14fd2d6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:26:47 -0700 Subject: [PATCH 189/862] Moving All and Any tests. --- .../AsyncTests.Aggregates.cs | 96 ------------------- .../System/Linq/Operators/All.cs | 55 +++++++++++ .../System/Linq/Operators/Any.cs | 71 ++++++++++++++ 3 files changed, 126 insertions(+), 96 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index c65cf2a926..9af1971bef 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -19,102 +19,6 @@ public partial class AsyncTests { private const int WaitTimeoutMs = 5000; - [Fact] - public async Task All_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void All1() - { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); - Assert.False(res.Result); - } - - [Fact] - public void All2() - { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); - Assert.True(res.Result); - } - - [Fact] - public void All3() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).All(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void All4() - { - var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Any_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void Any1() - { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(x => x % 2 == 0); - Assert.True(res.Result); - } - - [Fact] - public void Any2() - { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(x => x % 2 != 0); - Assert.False(res.Result); - } - - [Fact] - public void Any3() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Any(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Any4() - { - var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Any5() - { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(); - Assert.True(res.Result); - } - - [Fact] - public void Any6() - { - var res = new int[0].ToAsyncEnumerable().Any(); - Assert.False(res.Result); - } - [Fact] public async Task Contains_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs new file mode 100644 index 0000000000..a84e2b9a2e --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class All : AsyncEnumerableTests + { + [Fact] + public async Task All_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void All1() + { + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); + Assert.False(res.Result); + } + + [Fact] + public void All2() + { + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); + Assert.True(res.Result); + } + + [Fact] + public void All3() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).All(x => x % 2 == 0); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void All4() + { + var ex = new Exception("Bang!"); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs new file mode 100644 index 0000000000..5a9f42ce32 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -0,0 +1,71 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Any : AsyncEnumerableTests + { + [Fact] + public async Task Any_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void Any1() + { + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(x => x % 2 == 0); + Assert.True(res.Result); + } + + [Fact] + public void Any2() + { + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(x => x % 2 != 0); + Assert.False(res.Result); + } + + [Fact] + public void Any3() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).Any(x => x % 2 == 0); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Any4() + { + var ex = new Exception("Bang!"); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Any5() + { + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(); + Assert.True(res.Result); + } + + [Fact] + public void Any6() + { + var res = new int[0].ToAsyncEnumerable().Any(); + Assert.False(res.Result); + } + } +} From 148081fe794df7420814ceaf96a687deacdbb60b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:28:38 -0700 Subject: [PATCH 190/862] Moving Contains tests. --- .../AsyncTests.Aggregates.cs | 70 ++++-------------- .../System/Linq/Operators/Contains.cs | 73 +++++++++++++++++++ 2 files changed, 86 insertions(+), 57 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 9af1971bef..ca6d888144 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -19,63 +19,6 @@ public partial class AsyncTests { private const int WaitTimeoutMs = 5000; - [Fact] - public async Task Contains_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null, CancellationToken.None)); - } - - [Fact] - public void Contains1() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(3); - Assert.True(ys.Result); - } - - [Fact] - public void Contains2() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(6); - Assert.False(ys.Result); - } - - [Fact] - public void Contains3() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(-3, new Eq()); - Assert.True(ys.Result); - } - - [Fact] - public void Contains4() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(-6, new Eq()); - Assert.False(ys.Result); - } - - class Eq : IEqualityComparer - { - public bool Equals(int x, int y) - { - return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); - } - - public int GetHashCode(int obj) - { - return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); - } - } - [Fact] public async Task First_Null() { @@ -1901,5 +1844,18 @@ public void MaxBy5() AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs new file mode 100644 index 0000000000..de17c51980 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Contains : AsyncEnumerableTests + { + [Fact] + public async Task Contains_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null, CancellationToken.None)); + } + + [Fact] + public void Contains1() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); + var ys = xs.Contains(3); + Assert.True(ys.Result); + } + + [Fact] + public void Contains2() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); + var ys = xs.Contains(6); + Assert.False(ys.Result); + } + + [Fact] + public void Contains3() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); + var ys = xs.Contains(-3, new Eq()); + Assert.True(ys.Result); + } + + [Fact] + public void Contains4() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); + var ys = xs.Contains(-6, new Eq()); + Assert.False(ys.Result); + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} From c2045b56df97d3cedfe3c29bbec0b5f37a5c50ee Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:30:45 -0700 Subject: [PATCH 191/862] Moving ToList and ToArray tests. --- .../AsyncTests.Aggregates.cs | 82 ------------------- .../System/Linq/Operators/ToArray.cs | 67 +++++++++++++++ .../System/Linq/Operators/ToList.cs | 46 +++++++++++ 3 files changed, 113 insertions(+), 82 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index ca6d888144..fc9be63282 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -636,88 +636,6 @@ public void ElementAtOrDefault6() AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public async Task ToList_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(null, CancellationToken.None)); - } - - [Fact] - public void ToList1() - { - var xs = new[] { 42, 25, 39 }; - var res = xs.ToAsyncEnumerable().ToList(); - Assert.True(res.Result.SequenceEqual(xs)); - } - - [Fact] - public void ToList2() - { - var xs = AsyncEnumerable.Empty(); - var res = xs.ToList(); - Assert.True(res.Result.Count == 0); - } - - [Fact] - public void ToList3() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ToList(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task ToArray_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(null, CancellationToken.None)); - } - - [Fact] - public void ToArray1() - { - var xs = new[] { 42, 25, 39 }; - var res = xs.ToAsyncEnumerable().ToArray(); - Assert.True(res.Result.SequenceEqual(xs)); - } - - [Fact] - public void ToArray2() - { - var xs = AsyncEnumerable.Empty(); - var res = xs.ToArray(); - Assert.True(res.Result.Length == 0); - } - - [Fact] - public void ToArray3() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ToArray(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task ToArray4() - { - var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArray(); - var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; - - Assert.True(ex.SequenceEqual(xs)); - } - - [Fact] - public async Task ToArray5() - { - var res = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; - var xs = new HashSet(res); - - var arr = await xs.ToAsyncEnumerable().ToArray(); - - Assert.True(res.SequenceEqual(arr)); - } - [Fact] public async Task ToDictionary_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs new file mode 100644 index 0000000000..1b3504b3f8 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -0,0 +1,67 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ToArray : AsyncEnumerableTests + { + [Fact] + public async Task ToArray_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(null, CancellationToken.None)); + } + + [Fact] + public void ToArray1() + { + var xs = new[] { 42, 25, 39 }; + var res = xs.ToAsyncEnumerable().ToArray(); + Assert.True(res.Result.SequenceEqual(xs)); + } + + [Fact] + public void ToArray2() + { + var xs = AsyncEnumerable.Empty(); + var res = xs.ToArray(); + Assert.True(res.Result.Length == 0); + } + + [Fact] + public void ToArray3() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).ToArray(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task ToArray4() + { + var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArray(); + var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + + Assert.True(ex.SequenceEqual(xs)); + } + + [Fact] + public async Task ToArray5() + { + var res = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; + var xs = new HashSet(res); + + var arr = await xs.ToAsyncEnumerable().ToArray(); + + Assert.True(res.SequenceEqual(arr)); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs new file mode 100644 index 0000000000..6fdbe5c228 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ToList : AsyncEnumerableTests + { + [Fact] + public async Task ToList_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(null, CancellationToken.None)); + } + + [Fact] + public void ToList1() + { + var xs = new[] { 42, 25, 39 }; + var res = xs.ToAsyncEnumerable().ToList(); + Assert.True(res.Result.SequenceEqual(xs)); + } + + [Fact] + public void ToList2() + { + var xs = AsyncEnumerable.Empty(); + var res = xs.ToList(); + Assert.True(res.Result.Count == 0); + } + + [Fact] + public void ToList3() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).ToList(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From dcc94a8b1409af1279849277fff9347265288b0a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:31:49 -0700 Subject: [PATCH 192/862] Moving Average tests. --- .../AsyncTests.Aggregates.cs | 240 ---------------- .../System/Linq/Operators/Average.cs | 256 ++++++++++++++++++ 2 files changed, 256 insertions(+), 240 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index fc9be63282..d3d4426e1d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -873,246 +873,6 @@ public void ToLookup9() Assert.True(res.Count == 2); } - [Fact] - public async Task Average_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - } - - [Fact] - public void Average1() - { - var xs = new[] { 1, 2, 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average2() - { - var xs = new[] { 1, default(int?), 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average3() - { - var xs = new[] { 1L, 2L, 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average4() - { - var xs = new[] { 1L, default(long?), 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average5() - { - var xs = new[] { 1.0, 2.0, 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average6() - { - var xs = new[] { 1.0, default(double?), 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average7() - { - var xs = new[] { 1.0f, 2.0f, 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average8() - { - var xs = new[] { 1.0f, default(float?), 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average9() - { - var xs = new[] { 1.0m, 2.0m, 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average10() - { - var xs = new[] { 1.0m, default(decimal?), 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); - } - - [Fact] - public void Average11() - { - var xs = new int[0]; - var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Average12() - { - var xs = new int?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); - } - - [Fact] - public void Average13() - { - var xs = new long[0]; - var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Average14() - { - var xs = new long?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); - } - - [Fact] - public void Average15() - { - var xs = new double[0]; - var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Average16() - { - var xs = new double?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); - } - - [Fact] - public void Average17() - { - var xs = new float[0]; - var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Average18() - { - var xs = new float?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); - } - - [Fact] - public void Average19() - { - var xs = new decimal[0]; - var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Average20() - { - var xs = new decimal?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); - } - [Fact] public async Task Min_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs new file mode 100644 index 0000000000..673a4da1e3 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs @@ -0,0 +1,256 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Average : AsyncEnumerableTests + { + [Fact] + public async Task Average_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + } + + [Fact] + public void Average1() + { + var xs = new[] { 1, 2, 3 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average2() + { + var xs = new[] { 1, default(int?), 3 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average3() + { + var xs = new[] { 1L, 2L, 3L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average4() + { + var xs = new[] { 1L, default(long?), 3L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average5() + { + var xs = new[] { 1.0, 2.0, 3.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average6() + { + var xs = new[] { 1.0, default(double?), 3.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average7() + { + var xs = new[] { 1.0f, 2.0f, 3.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average8() + { + var xs = new[] { 1.0f, default(float?), 3.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average9() + { + var xs = new[] { 1.0m, 2.0m, 3.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average10() + { + var xs = new[] { 1.0m, default(decimal?), 3.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), ys.Average().Result); + Assert.Equal(xs.Average(), ys.Average(x => x).Result); + } + + [Fact] + public void Average11() + { + var xs = new int[0]; + var ys = xs.ToAsyncEnumerable(); + AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Average12() + { + var xs = new int?[0]; + var ys = xs.ToAsyncEnumerable(); + Assert.Null(ys.Average().Result); + } + + [Fact] + public void Average13() + { + var xs = new long[0]; + var ys = xs.ToAsyncEnumerable(); + AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Average14() + { + var xs = new long?[0]; + var ys = xs.ToAsyncEnumerable(); + Assert.Null(ys.Average().Result); + } + + [Fact] + public void Average15() + { + var xs = new double[0]; + var ys = xs.ToAsyncEnumerable(); + AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Average16() + { + var xs = new double?[0]; + var ys = xs.ToAsyncEnumerable(); + Assert.Null(ys.Average().Result); + } + + [Fact] + public void Average17() + { + var xs = new float[0]; + var ys = xs.ToAsyncEnumerable(); + AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Average18() + { + var xs = new float?[0]; + var ys = xs.ToAsyncEnumerable(); + Assert.Null(ys.Average().Result); + } + + [Fact] + public void Average19() + { + var xs = new decimal[0]; + var ys = xs.ToAsyncEnumerable(); + AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Average20() + { + var xs = new decimal?[0]; + var ys = xs.ToAsyncEnumerable(); + Assert.Null(ys.Average().Result); + } + } +} From 02fea8ce72e1fdec2a698ea7107dc00493cbef95 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:35:56 -0700 Subject: [PATCH 193/862] Moving Sum tests. --- .../AsyncTests.Aggregates.cs | 160 ---------------- .../System/Linq/Operators/Sum.cs | 176 ++++++++++++++++++ 2 files changed, 176 insertions(+), 160 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index d3d4426e1d..1249c0b2ec 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -1239,166 +1239,6 @@ public void Max11() Assert.Equal(xs.Max(), ys.Max(x => x).Result); } - [Fact] - public async Task Sum_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - } - - [Fact] - public void Sum1() - { - var xs = new[] { 1, 2, 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum2() - { - var xs = new[] { 1, default(int?), 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum3() - { - var xs = new[] { 1L, 2L, 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum4() - { - var xs = new[] { 1L, default(long?), 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum5() - { - var xs = new[] { 1.0, 2.0, 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum6() - { - var xs = new[] { 1.0, default(double?), 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum7() - { - var xs = new[] { 1.0f, 2.0f, 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum8() - { - var xs = new[] { 1.0f, default(float?), 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum9() - { - var xs = new[] { 1.0m, 2.0m, 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - - [Fact] - public void Sum10() - { - var xs = new[] { 1.0m, default(decimal?), 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); - } - [Fact] public async Task MinBy_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs new file mode 100644 index 0000000000..a281b6044a --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs @@ -0,0 +1,176 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Sum : AsyncEnumerableTests + { + [Fact] + public async Task Sum_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + } + + [Fact] + public void Sum1() + { + var xs = new[] { 1, 2, 3 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum2() + { + var xs = new[] { 1, default(int?), 3 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum3() + { + var xs = new[] { 1L, 2L, 3L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum4() + { + var xs = new[] { 1L, default(long?), 3L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum5() + { + var xs = new[] { 1.0, 2.0, 3.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum6() + { + var xs = new[] { 1.0, default(double?), 3.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum7() + { + var xs = new[] { 1.0f, 2.0f, 3.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum8() + { + var xs = new[] { 1.0f, default(float?), 3.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum9() + { + var xs = new[] { 1.0m, 2.0m, 3.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + + [Fact] + public void Sum10() + { + var xs = new[] { 1.0m, default(decimal?), 3.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Sum(), ys.Sum().Result); + Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + } + } +} From 3b8ef6e3e8ffa9d5db8b4d18bf0622054bc0afc2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:39:04 -0700 Subject: [PATCH 194/862] Moving Min and Max tests. --- .../AsyncTests.Aggregates.cs | 346 ------------------ .../System/Linq/Operators/Max.cs | 193 ++++++++++ .../System/Linq/Operators/Min.cs | 193 ++++++++++ 3 files changed, 386 insertions(+), 346 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 1249c0b2ec..aa852a4f83 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -876,80 +876,6 @@ public void ToLookup9() [Fact] public async Task Min_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer))); @@ -957,182 +883,9 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); } - [Fact] - public void Min1() - { - var xs = new[] { 2, 1, 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min2() - { - var xs = new[] { 2, default(int?), 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min3() - { - var xs = new[] { 2L, 1L, 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min4() - { - var xs = new[] { 2L, default(long?), 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min5() - { - var xs = new[] { 2.0, 1.0, 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min6() - { - var xs = new[] { 2.0, default(double?), 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min7() - { - var xs = new[] { 2.0f, 1.0f, 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min8() - { - var xs = new[] { 2.0f, default(float?), 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min9() - { - var xs = new[] { 2.0m, 1.0m, 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min10() - { - var xs = new[] { 2.0m, default(decimal?), 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - - [Fact] - public void Min11() - { - var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); - } - [Fact] public async Task Max_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer))); @@ -1140,105 +893,6 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); } - [Fact] - public void Max1() - { - var xs = new[] { 2, 7, 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max2() - { - var xs = new[] { 2, default(int?), 3, 1 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max3() - { - var xs = new[] { 2L, 7L, 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max4() - { - var xs = new[] { 2L, default(long?), 3L, 1L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max5() - { - var xs = new[] { 2.0, 7.0, 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max6() - { - var xs = new[] { 2.0, default(double?), 3.0, 1.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max7() - { - var xs = new[] { 2.0f, 7.0f, 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max8() - { - var xs = new[] { 2.0f, default(float?), 3.0f, 1.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max9() - { - var xs = new[] { 2.0m, 7.0m, 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max10() - { - var xs = new[] { 2.0m, default(decimal?), 3.0m, 1.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - - [Fact] - public void Max11() - { - var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); - } - [Fact] public async Task MinBy_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs new file mode 100644 index 0000000000..6e05802dfd --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -0,0 +1,193 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Max : AsyncEnumerableTests + { + [Fact] + public async Task Max_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + } + + [Fact] + public void Max1() + { + var xs = new[] { 2, 7, 3 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max2() + { + var xs = new[] { 2, default(int?), 3, 1 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max3() + { + var xs = new[] { 2L, 7L, 3L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max4() + { + var xs = new[] { 2L, default(long?), 3L, 1L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max5() + { + var xs = new[] { 2.0, 7.0, 3.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max6() + { + var xs = new[] { 2.0, default(double?), 3.0, 1.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max7() + { + var xs = new[] { 2.0f, 7.0f, 3.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max8() + { + var xs = new[] { 2.0f, default(float?), 3.0f, 1.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max9() + { + var xs = new[] { 2.0m, 7.0m, 3.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max10() + { + var xs = new[] { 2.0m, default(decimal?), 3.0m, 1.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + + [Fact] + public void Max11() + { + var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), ys.Max().Result); + Assert.Equal(xs.Max(), ys.Max(x => x).Result); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs new file mode 100644 index 0000000000..04c7c74fe8 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -0,0 +1,193 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Min : AsyncEnumerableTests + { + [Fact] + public async Task Min_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + } + + [Fact] + public void Min1() + { + var xs = new[] { 2, 1, 3 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min2() + { + var xs = new[] { 2, default(int?), 3 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min3() + { + var xs = new[] { 2L, 1L, 3L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min4() + { + var xs = new[] { 2L, default(long?), 3L }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min5() + { + var xs = new[] { 2.0, 1.0, 3.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min6() + { + var xs = new[] { 2.0, default(double?), 3.0 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min7() + { + var xs = new[] { 2.0f, 1.0f, 3.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min8() + { + var xs = new[] { 2.0f, default(float?), 3.0f }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min9() + { + var xs = new[] { 2.0m, 1.0m, 3.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min10() + { + var xs = new[] { 2.0m, default(decimal?), 3.0m }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + + [Fact] + public void Min11() + { + var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), ys.Min().Result); + Assert.Equal(xs.Min(), ys.Min(x => x).Result); + } + } +} From f74ccee73e717ac99781deb7883718d3eb7fb084 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:42:17 -0700 Subject: [PATCH 195/862] Moving Empty tests. --- .../AsyncTests.Aggregates.cs | 7 ++++ .../AsyncTests.Creation.cs | 24 ------------- .../System/Linq/Operators/Empty.cs | 34 +++++++++++++++++++ 3 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index aa852a4f83..d4a1413753 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -19,6 +19,13 @@ public partial class AsyncTests { private const int WaitTimeoutMs = 5000; + [Fact] + public async Task IsEmpty_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); + } + [Fact] public async Task First_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 25e58be2d7..958d52086b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -49,30 +49,6 @@ public async Task Never() await e.DisposeAsync(); } - [Fact] - public async Task Empty_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); - } - - [Fact] - public void Empty1() - { - var xs = AsyncEnumerable.Empty(); - NoNext(xs.GetAsyncEnumerator()); - } - - [Fact] - public void Empty2() - { - var xs = AsyncEnumerable.Empty(); - - var e = xs.GetAsyncEnumerator(); - Assert.False(e.MoveNextAsync().Result); - AssertThrows(() => Nop(e.Current)); - } - [Fact] public void Throw_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs new file mode 100644 index 0000000000..1d283ab225 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Empty : AsyncEnumerableTests + { + [Fact] + public void Empty1() + { + var xs = AsyncEnumerable.Empty(); + NoNext(xs.GetAsyncEnumerator()); + } + + [Fact] + public void Empty2() + { + var xs = AsyncEnumerable.Empty(); + + var e = xs.GetAsyncEnumerator(); + Assert.False(e.MoveNextAsync().Result); + AssertThrows(() => Nop(e.Current)); + } + + private void Nop(object o) + { + } + } +} From 881058f21c0205b9668470f3c647fd4aafb28394 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 08:44:49 -0700 Subject: [PATCH 196/862] Some cleanup. --- .../System.Interactive.Async.Tests/AsyncTests.Multiple.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index 1cf29143b0..fe13991ec4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -6,10 +6,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Text; -using Xunit; using System.Threading; using System.Threading.Tasks; +using Xunit; namespace Tests { @@ -204,7 +203,6 @@ public async Task Concat12() Assert.Equal(8, await c.Count()); } - static IEnumerable> ConcatXss() { yield return new[] { 1, 2, 3 }.ToAsyncEnumerable(); From 4d99075a0c893fcc3f20f537d196569ddbaf011d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:24:16 -0700 Subject: [PATCH 197/862] Moving [First|Last|Single][OrDefault] tests. --- .../AsyncTests.Aggregates.cs | 511 ------------------ .../System/Linq/Operators/First.cs | 92 ++++ .../System/Linq/Operators/FirstOrDefault.cs | 99 ++++ .../System/Linq/Operators/Last.cs | 92 ++++ .../System/Linq/Operators/LastOrDefault.cs | 99 ++++ .../System/Linq/Operators/Single.cs | 106 ++++ .../System/Linq/Operators/SingleOrDefault.cs | 113 ++++ 7 files changed, 601 insertions(+), 511 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index d4a1413753..b3d1c4a152 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -26,517 +26,6 @@ public async Task IsEmpty_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); } - [Fact] - public async Task First_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void First1() - { - var res = AsyncEnumerable.Empty().First(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void First2() - { - var res = AsyncEnumerable.Empty().First(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void First3() - { - var res = AsyncEnumerable.Return(42).First(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void First4() - { - var res = AsyncEnumerable.Return(42).First(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void First5() - { - var res = AsyncEnumerable.Return(42).First(x => x % 2 == 0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void First6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).First(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void First7() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).First(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void First8() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void First9() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(x => x % 2 != 0); - Assert.Equal(45, res.Result); - } - - [Fact] - public async Task FirstOrDefault_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void FirstOrDefault1() - { - var res = AsyncEnumerable.Empty().FirstOrDefault(); - Assert.Equal(0, res.Result); - } - - [Fact] - public void FirstOrDefault2() - { - var res = AsyncEnumerable.Empty().FirstOrDefault(x => true); - Assert.Equal(0, res.Result); - } - - [Fact] - public void FirstOrDefault3() - { - var res = AsyncEnumerable.Return(42).FirstOrDefault(x => x % 2 != 0); - Assert.Equal(0, res.Result); - } - - [Fact] - public void FirstOrDefault4() - { - var res = AsyncEnumerable.Return(42).FirstOrDefault(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void FirstOrDefault5() - { - var res = AsyncEnumerable.Return(42).FirstOrDefault(x => x % 2 == 0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void FirstOrDefault6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).FirstOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void FirstOrDefault7() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).FirstOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void FirstOrDefault8() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void FirstOrDefault9() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x % 2 != 0); - Assert.Equal(45, res.Result); - } - - [Fact] - public void FirstOrDefault10() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x < 10); - Assert.Equal(0, res.Result); - } - - [Fact] - public async Task Last_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void Last1() - { - var res = AsyncEnumerable.Empty().Last(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Last2() - { - var res = AsyncEnumerable.Empty().Last(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Last3() - { - var res = AsyncEnumerable.Return(42).Last(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Last4() - { - var res = AsyncEnumerable.Return(42).Last(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void Last5() - { - var res = AsyncEnumerable.Return(42).Last(x => x % 2 == 0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void Last6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Last(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Last7() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Last(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Last8() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Last(); - Assert.Equal(90, res.Result); - } - - [Fact] - public void Last9() - { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Last(x => x % 2 != 0); - Assert.Equal(45, res.Result); - } - - [Fact] - public async Task LastOrDefault_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void LastOrDefault1() - { - var res = AsyncEnumerable.Empty().LastOrDefault(); - Assert.Equal(0, res.Result); - } - - [Fact] - public void LastOrDefault2() - { - var res = AsyncEnumerable.Empty().LastOrDefault(x => true); - Assert.Equal(0, res.Result); - } - - [Fact] - public void LastOrDefault3() - { - var res = AsyncEnumerable.Return(42).LastOrDefault(x => x % 2 != 0); - Assert.Equal(0, res.Result); - } - - [Fact] - public void LastOrDefault4() - { - var res = AsyncEnumerable.Return(42).LastOrDefault(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void LastOrDefault5() - { - var res = AsyncEnumerable.Return(42).LastOrDefault(x => x % 2 == 0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void LastOrDefault6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).LastOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void LastOrDefault7() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).LastOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void LastOrDefault8() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(); - Assert.Equal(90, res.Result); - } - - [Fact] - public void LastOrDefault9() - { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x % 2 != 0); - Assert.Equal(45, res.Result); - } - - [Fact] - public void LastOrDefault10() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x < 10); - Assert.Equal(0, res.Result); - } - - [Fact] - public async Task Single_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void Single1() - { - var res = AsyncEnumerable.Empty().Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Single2() - { - var res = AsyncEnumerable.Empty().Single(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Single3() - { - var res = AsyncEnumerable.Return(42).Single(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Single4() - { - var res = AsyncEnumerable.Return(42).Single(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void Single5() - { - var res = AsyncEnumerable.Return(42).Single(x => x % 2 == 0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void Single6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Single7() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Single(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Single8() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Single9() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); - Assert.Equal(45, res.Result); - } - - [Fact] - public void Single10() - { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void Single11() - { - var res = new int[0].ToAsyncEnumerable().Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public async Task SingleOrDefault_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - } - - [Fact] - public void SingleOrDefault1() - { - var res = AsyncEnumerable.Empty().SingleOrDefault(); - Assert.Equal(0, res.Result); - } - - [Fact] - public void SingleOrDefault2() - { - var res = AsyncEnumerable.Empty().SingleOrDefault(x => true); - Assert.Equal(0, res.Result); - } - - [Fact] - public void SingleOrDefault3() - { - var res = AsyncEnumerable.Return(42).SingleOrDefault(x => x % 2 != 0); - Assert.Equal(0, res.Result); - } - - [Fact] - public void SingleOrDefault4() - { - var res = AsyncEnumerable.Return(42).SingleOrDefault(); - Assert.Equal(42, res.Result); - } - - [Fact] - public void SingleOrDefault5() - { - var res = AsyncEnumerable.Return(42).SingleOrDefault(x => x % 2 == 0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void SingleOrDefault6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).SingleOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SingleOrDefault7() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).SingleOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SingleOrDefault8() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void SingleOrDefault9() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x % 2 != 0); - Assert.Equal(45, res.Result); - } - - [Fact] - public void SingleOrDefault10() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x < 10); - Assert.Equal(0, res.Result); - } - - [Fact] - public void SingleOrDefault11() - { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void SingleOrDefault12() - { - var res = new int[0].ToAsyncEnumerable().SingleOrDefault(); - Assert.Equal(0, res.Result); - } - [Fact] public async Task ElementAt_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs new file mode 100644 index 0000000000..c5e2debcc0 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class First : AsyncEnumerableTests + { + [Fact] + public async Task First_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.First(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void First1() + { + var res = AsyncEnumerable.Empty().First(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void First2() + { + var res = AsyncEnumerable.Empty().First(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void First3() + { + var res = AsyncEnumerable.Return(42).First(x => x % 2 != 0); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void First4() + { + var res = AsyncEnumerable.Return(42).First(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void First5() + { + var res = AsyncEnumerable.Return(42).First(x => x % 2 == 0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void First6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).First(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void First7() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).First(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void First8() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void First9() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(x => x % 2 != 0); + Assert.Equal(45, res.Result); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs new file mode 100644 index 0000000000..b5e7f66e23 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -0,0 +1,99 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class FirstOrDefault : AsyncEnumerableTests + { + [Fact] + public async Task FirstOrDefault_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void FirstOrDefault1() + { + var res = AsyncEnumerable.Empty().FirstOrDefault(); + Assert.Equal(0, res.Result); + } + + [Fact] + public void FirstOrDefault2() + { + var res = AsyncEnumerable.Empty().FirstOrDefault(x => true); + Assert.Equal(0, res.Result); + } + + [Fact] + public void FirstOrDefault3() + { + var res = AsyncEnumerable.Return(42).FirstOrDefault(x => x % 2 != 0); + Assert.Equal(0, res.Result); + } + + [Fact] + public void FirstOrDefault4() + { + var res = AsyncEnumerable.Return(42).FirstOrDefault(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void FirstOrDefault5() + { + var res = AsyncEnumerable.Return(42).FirstOrDefault(x => x % 2 == 0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void FirstOrDefault6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).FirstOrDefault(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void FirstOrDefault7() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).FirstOrDefault(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void FirstOrDefault8() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void FirstOrDefault9() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x % 2 != 0); + Assert.Equal(45, res.Result); + } + + [Fact] + public void FirstOrDefault10() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x < 10); + Assert.Equal(0, res.Result); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs new file mode 100644 index 0000000000..27594aa294 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Last : AsyncEnumerableTests + { + [Fact] + public async Task Last_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void Last1() + { + var res = AsyncEnumerable.Empty().Last(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Last2() + { + var res = AsyncEnumerable.Empty().Last(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Last3() + { + var res = AsyncEnumerable.Return(42).Last(x => x % 2 != 0); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Last4() + { + var res = AsyncEnumerable.Return(42).Last(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void Last5() + { + var res = AsyncEnumerable.Return(42).Last(x => x % 2 == 0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void Last6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).Last(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Last7() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).Last(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Last8() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Last(); + Assert.Equal(90, res.Result); + } + + [Fact] + public void Last9() + { + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Last(x => x % 2 != 0); + Assert.Equal(45, res.Result); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs new file mode 100644 index 0000000000..282b8aca95 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -0,0 +1,99 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class LastOrDefault : AsyncEnumerableTests + { + [Fact] + public async Task LastOrDefault_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void LastOrDefault1() + { + var res = AsyncEnumerable.Empty().LastOrDefault(); + Assert.Equal(0, res.Result); + } + + [Fact] + public void LastOrDefault2() + { + var res = AsyncEnumerable.Empty().LastOrDefault(x => true); + Assert.Equal(0, res.Result); + } + + [Fact] + public void LastOrDefault3() + { + var res = AsyncEnumerable.Return(42).LastOrDefault(x => x % 2 != 0); + Assert.Equal(0, res.Result); + } + + [Fact] + public void LastOrDefault4() + { + var res = AsyncEnumerable.Return(42).LastOrDefault(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void LastOrDefault5() + { + var res = AsyncEnumerable.Return(42).LastOrDefault(x => x % 2 == 0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void LastOrDefault6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).LastOrDefault(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void LastOrDefault7() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).LastOrDefault(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void LastOrDefault8() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(); + Assert.Equal(90, res.Result); + } + + [Fact] + public void LastOrDefault9() + { + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x % 2 != 0); + Assert.Equal(45, res.Result); + } + + [Fact] + public void LastOrDefault10() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x < 10); + Assert.Equal(0, res.Result); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs new file mode 100644 index 0000000000..b2c1ccf760 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -0,0 +1,106 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Single : AsyncEnumerableTests + { + [Fact] + public async Task Single_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void Single1() + { + var res = AsyncEnumerable.Empty().Single(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Single2() + { + var res = AsyncEnumerable.Empty().Single(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Single3() + { + var res = AsyncEnumerable.Return(42).Single(x => x % 2 != 0); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Single4() + { + var res = AsyncEnumerable.Return(42).Single(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void Single5() + { + var res = AsyncEnumerable.Return(42).Single(x => x % 2 == 0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void Single6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).Single(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Single7() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).Single(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Single8() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Single9() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); + Assert.Equal(45, res.Result); + } + + [Fact] + public void Single10() + { + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void Single11() + { + var res = new int[0].ToAsyncEnumerable().Single(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs new file mode 100644 index 0000000000..4eb9f2ee6e --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -0,0 +1,113 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class SingleOrDefault : AsyncEnumerableTests + { + [Fact] + public async Task SingleOrDefault_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + } + + [Fact] + public void SingleOrDefault1() + { + var res = AsyncEnumerable.Empty().SingleOrDefault(); + Assert.Equal(0, res.Result); + } + + [Fact] + public void SingleOrDefault2() + { + var res = AsyncEnumerable.Empty().SingleOrDefault(x => true); + Assert.Equal(0, res.Result); + } + + [Fact] + public void SingleOrDefault3() + { + var res = AsyncEnumerable.Return(42).SingleOrDefault(x => x % 2 != 0); + Assert.Equal(0, res.Result); + } + + [Fact] + public void SingleOrDefault4() + { + var res = AsyncEnumerable.Return(42).SingleOrDefault(); + Assert.Equal(42, res.Result); + } + + [Fact] + public void SingleOrDefault5() + { + var res = AsyncEnumerable.Return(42).SingleOrDefault(x => x % 2 == 0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void SingleOrDefault6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).SingleOrDefault(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SingleOrDefault7() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).SingleOrDefault(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SingleOrDefault8() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void SingleOrDefault9() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x % 2 != 0); + Assert.Equal(45, res.Result); + } + + [Fact] + public void SingleOrDefault10() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x < 10); + Assert.Equal(0, res.Result); + } + + [Fact] + public void SingleOrDefault11() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => true); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void SingleOrDefault12() + { + var res = new int[0].ToAsyncEnumerable().SingleOrDefault(); + Assert.Equal(0, res.Result); + } + } +} From 0e2892d19d936b7d4c43bc76571883d0ea5384e0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:25:48 -0700 Subject: [PATCH 198/862] Moving ElementAt[OrDefault] tests. --- .../AsyncTests.Aggregates.cs | 106 ------------------ .../System/Linq/Operators/ElementAt.cs | 68 +++++++++++ .../Linq/Operators/ElementAtOrDefault.cs | 68 +++++++++++ 3 files changed, 136 insertions(+), 106 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index b3d1c4a152..84a88f637c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -26,112 +26,6 @@ public async Task IsEmpty_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); } - [Fact] - public async Task ElementAt_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(null, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(null, 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1, CancellationToken.None)); - } - - [Fact] - public void ElementAt1() - { - var res = AsyncEnumerable.Empty().ElementAt(0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); - } - - [Fact] - public void ElementAt2() - { - var res = AsyncEnumerable.Return(42).ElementAt(0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void ElementAt3() - { - var res = AsyncEnumerable.Return(42).ElementAt(1); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); - } - - [Fact] - public void ElementAt4() - { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(1); - Assert.Equal(42, res.Result); - } - - [Fact] - public void ElementAt5() - { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(7); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); - } - - [Fact] - public void ElementAt6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ElementAt(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task ElementAtOrDefault_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(null, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(null, 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1, CancellationToken.None)); - } - - [Fact] - public void ElementAtOrDefault1() - { - var res = AsyncEnumerable.Empty().ElementAtOrDefault(0); - Assert.Equal(0, res.Result); - } - - [Fact] - public void ElementAtOrDefault2() - { - var res = AsyncEnumerable.Return(42).ElementAtOrDefault(0); - Assert.Equal(42, res.Result); - } - - [Fact] - public void ElementAtOrDefault3() - { - var res = AsyncEnumerable.Return(42).ElementAtOrDefault(1); - Assert.Equal(0, res.Result); - } - - [Fact] - public void ElementAtOrDefault4() - { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(1); - Assert.Equal(42, res.Result); - } - - [Fact] - public void ElementAtOrDefault5() - { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(7); - Assert.Equal(0, res.Result); - } - - [Fact] - public void ElementAtOrDefault6() - { - var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ElementAtOrDefault(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public async Task ToDictionary_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs new file mode 100644 index 0000000000..5fb6d6599d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -0,0 +1,68 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ElementAt : AsyncEnumerableTests + { + [Fact] + public async Task ElementAt_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(null, 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(null, 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1, CancellationToken.None)); + } + + [Fact] + public void ElementAt1() + { + var res = AsyncEnumerable.Empty().ElementAt(0); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); + } + + [Fact] + public void ElementAt2() + { + var res = AsyncEnumerable.Return(42).ElementAt(0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void ElementAt3() + { + var res = AsyncEnumerable.Return(42).ElementAt(1); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); + } + + [Fact] + public void ElementAt4() + { + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(1); + Assert.Equal(42, res.Result); + } + + [Fact] + public void ElementAt5() + { + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(7); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); + } + + [Fact] + public void ElementAt6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).ElementAt(15); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs new file mode 100644 index 0000000000..e093f39537 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -0,0 +1,68 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ElementAtOrDefault : AsyncEnumerableTests + { + [Fact] + public async Task ElementAtOrDefault_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(null, 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(null, 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1, CancellationToken.None)); + } + + [Fact] + public void ElementAtOrDefault1() + { + var res = AsyncEnumerable.Empty().ElementAtOrDefault(0); + Assert.Equal(0, res.Result); + } + + [Fact] + public void ElementAtOrDefault2() + { + var res = AsyncEnumerable.Return(42).ElementAtOrDefault(0); + Assert.Equal(42, res.Result); + } + + [Fact] + public void ElementAtOrDefault3() + { + var res = AsyncEnumerable.Return(42).ElementAtOrDefault(1); + Assert.Equal(0, res.Result); + } + + [Fact] + public void ElementAtOrDefault4() + { + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(1); + Assert.Equal(42, res.Result); + } + + [Fact] + public void ElementAtOrDefault5() + { + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(7); + Assert.Equal(0, res.Result); + } + + [Fact] + public void ElementAtOrDefault6() + { + var ex = new Exception("Bang!"); + var res = AsyncEnumerable.Throw(ex).ElementAtOrDefault(15); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From de6a1c101f6ccb13f915b8acd306793769ef2c43 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:27:42 -0700 Subject: [PATCH 199/862] Moving ToDictionary tests. --- .../AsyncTests.Aggregates.cs | 93 ------------- .../System/Linq/Operators/ToDictionary.cs | 122 ++++++++++++++++++ 2 files changed, 122 insertions(+), 93 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 84a88f637c..ca15f51c52 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -26,99 +26,6 @@ public async Task IsEmpty_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); } - [Fact] - public async Task ToDictionary_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); - } - - [Fact] - public void ToDictionary1() - { - var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2).Result; - Assert.True(res[0] == 4); - Assert.True(res[1] == 1); - } - - [Fact] - public void ToDictionary2() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ToDictionary(x => x % 2).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); - } - - [Fact] - public void ToDictionary3() - { - var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2, x => x + 1).Result; - Assert.True(res[0] == 5); - Assert.True(res[1] == 2); - } - - [Fact] - public void ToDictionary4() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ToDictionary(x => x % 2, x => x + 1).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); - } - - [Fact] - public void ToDictionary5() - { - var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2, new Eq()).Result; - Assert.True(res[0] == 4); - Assert.True(res[1] == 1); - } - - [Fact] - public void ToDictionary6() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ToDictionary(x => x % 2, new Eq()).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); - } - - [Fact] - public void ToDictionary7() - { - var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2, x => x, new Eq()).Result; - Assert.True(res[0] == 4); - Assert.True(res[1] == 1); - } - [Fact] public async Task ToLookup_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs new file mode 100644 index 0000000000..dd00c58d98 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -0,0 +1,122 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ToDictionary : AsyncEnumerableTests + { + [Fact] + public async Task ToDictionary_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); + } + + [Fact] + public void ToDictionary1() + { + var xs = new[] { 1, 4 }.ToAsyncEnumerable(); + var res = xs.ToDictionary(x => x % 2).Result; + Assert.True(res[0] == 4); + Assert.True(res[1] == 1); + } + + [Fact] + public void ToDictionary2() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + AssertThrows(() => xs.ToDictionary(x => x % 2).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); + } + + [Fact] + public void ToDictionary3() + { + var xs = new[] { 1, 4 }.ToAsyncEnumerable(); + var res = xs.ToDictionary(x => x % 2, x => x + 1).Result; + Assert.True(res[0] == 5); + Assert.True(res[1] == 2); + } + + [Fact] + public void ToDictionary4() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + AssertThrows(() => xs.ToDictionary(x => x % 2, x => x + 1).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); + } + + [Fact] + public void ToDictionary5() + { + var xs = new[] { 1, 4 }.ToAsyncEnumerable(); + var res = xs.ToDictionary(x => x % 2, new Eq()).Result; + Assert.True(res[0] == 4); + Assert.True(res[1] == 1); + } + + [Fact] + public void ToDictionary6() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + AssertThrows(() => xs.ToDictionary(x => x % 2, new Eq()).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); + } + + [Fact] + public void ToDictionary7() + { + var xs = new[] { 1, 4 }.ToAsyncEnumerable(); + var res = xs.ToDictionary(x => x % 2, x => x, new Eq()).Result; + Assert.True(res[0] == 4); + Assert.True(res[1] == 1); + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} From 107460bb3bc7ac64376f0ff4ffe40e81c3e28526 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:29:27 -0700 Subject: [PATCH 200/862] Moving ToLookup tests. --- .../AsyncTests.Aggregates.cs | 144 --------------- .../System/Linq/Operators/ToLookup.cs | 174 ++++++++++++++++++ 2 files changed, 174 insertions(+), 144 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index ca15f51c52..8ab31d7b8f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -26,150 +26,6 @@ public async Task IsEmpty_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); } - [Fact] - public async Task ToLookup_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); - } - - [Fact] - public void ToLookup1() - { - var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; - Assert.True(res.Contains(0)); - Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[1].Contains(1)); - Assert.True(res.Count == 2); - } - - [Fact] - public void ToLookup2() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; - Assert.True(res.Contains(0)); - Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[0].Contains(2)); - Assert.True(res[1].Contains(1)); - Assert.True(res.Count == 2); - } - - [Fact] - public void ToLookup3() - { - var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, x => x + 1).Result; - Assert.True(res.Contains(0)); - Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(5)); - Assert.True(res[1].Contains(2)); - Assert.True(res.Count == 2); - } - - [Fact] - public void ToLookup4() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, x => x + 1).Result; - Assert.True(res.Contains(0)); - Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(5)); - Assert.True(res[0].Contains(3)); - Assert.True(res[1].Contains(2)); - Assert.True(res.Count == 2); - } - - [Fact] - public void ToLookup5() - { - var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, new Eq()).Result; - Assert.True(res.Contains(0)); - Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[1].Contains(1)); - Assert.True(res.Count == 2); - } - - [Fact] - public void ToLookup6() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, new Eq()).Result; - Assert.True(res.Contains(0)); - Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[0].Contains(2)); - Assert.True(res[1].Contains(1)); - Assert.True(res.Count == 2); - } - - [Fact] - public void ToLookup7() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; - foreach (var g in res) - Assert.True(g.Key == 0 || g.Key == 1); - } - - [Fact] - public void ToLookup8() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; -#pragma warning disable IDE0007 // Use implicit type - foreach (IGrouping g in (IEnumerable)res) - Assert.True(g.Key == 0 || g.Key == 1); -#pragma warning restore IDE0007 // Use implicit type - } - - [Fact] - public void ToLookup9() - { - var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, x => x, new Eq()).Result; - Assert.True(res.Contains(0)); - Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[0].Contains(2)); - Assert.True(res[1].Contains(1)); - Assert.True(res.Count == 2); - } - [Fact] public async Task Min_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs new file mode 100644 index 0000000000..ca93f05912 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -0,0 +1,174 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ToLookup : AsyncEnumerableTests + { + [Fact] + public async Task ToLookup_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); + } + + [Fact] + public void ToLookup1() + { + var xs = new[] { 1, 4 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2).Result; + Assert.True(res.Contains(0)); + Assert.True(res.Contains(1)); + Assert.True(res[0].Contains(4)); + Assert.True(res[1].Contains(1)); + Assert.True(res.Count == 2); + } + + [Fact] + public void ToLookup2() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2).Result; + Assert.True(res.Contains(0)); + Assert.True(res.Contains(1)); + Assert.True(res[0].Contains(4)); + Assert.True(res[0].Contains(2)); + Assert.True(res[1].Contains(1)); + Assert.True(res.Count == 2); + } + + [Fact] + public void ToLookup3() + { + var xs = new[] { 1, 4 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2, x => x + 1).Result; + Assert.True(res.Contains(0)); + Assert.True(res.Contains(1)); + Assert.True(res[0].Contains(5)); + Assert.True(res[1].Contains(2)); + Assert.True(res.Count == 2); + } + + [Fact] + public void ToLookup4() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2, x => x + 1).Result; + Assert.True(res.Contains(0)); + Assert.True(res.Contains(1)); + Assert.True(res[0].Contains(5)); + Assert.True(res[0].Contains(3)); + Assert.True(res[1].Contains(2)); + Assert.True(res.Count == 2); + } + + [Fact] + public void ToLookup5() + { + var xs = new[] { 1, 4 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2, new Eq()).Result; + Assert.True(res.Contains(0)); + Assert.True(res.Contains(1)); + Assert.True(res[0].Contains(4)); + Assert.True(res[1].Contains(1)); + Assert.True(res.Count == 2); + } + + [Fact] + public void ToLookup6() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2, new Eq()).Result; + Assert.True(res.Contains(0)); + Assert.True(res.Contains(1)); + Assert.True(res[0].Contains(4)); + Assert.True(res[0].Contains(2)); + Assert.True(res[1].Contains(1)); + Assert.True(res.Count == 2); + } + + [Fact] + public void ToLookup7() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2).Result; + foreach (var g in res) + Assert.True(g.Key == 0 || g.Key == 1); + } + + [Fact] + public void ToLookup8() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2).Result; +#pragma warning disable IDE0007 // Use implicit type + foreach (IGrouping g in (IEnumerable)res) + Assert.True(g.Key == 0 || g.Key == 1); +#pragma warning restore IDE0007 // Use implicit type + } + + [Fact] + public void ToLookup9() + { + var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); + var res = xs.ToLookup(x => x % 2, x => x, new Eq()).Result; + Assert.True(res.Contains(0)); + Assert.True(res.Contains(1)); + Assert.True(res[0].Contains(4)); + Assert.True(res[0].Contains(2)); + Assert.True(res[1].Contains(1)); + Assert.True(res.Count == 2); + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} From 0515cdbf6cf1547c9221bb4ee9128264420bc476 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:30:53 -0700 Subject: [PATCH 201/862] Adding System.Interactive.Async.Tests folder structure. --- .../System.Interactive.Async.Tests.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index 8021058693..d7a7a7a0dd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -53,4 +53,8 @@ + + + + From db0e378ce89a32a880af19ea311a55043bc61565 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:32:25 -0700 Subject: [PATCH 202/862] Adding base class for tests. --- .../System/Linq/AsyncEnumerableExTests.cs | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs new file mode 100644 index 0000000000..fe0d12efdd --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using FluentAssertions; +using Xunit; + +namespace Tests +{ + public class AsyncEnumerableExTests + { + protected const int WaitTimeoutMs = 5000; + +#pragma warning disable xUnit1013 // Public method should be marked as test + public void AssertThrows(Action a) + where E : Exception + { + Assert.Throws(a); + } + + [Obsolete("Don't use this, use Assert.ThrowsAsync and await it", true)] + public Task AssertThrows(Func func) + where E : Exception + { + return Assert.ThrowsAsync(func); + } + + public void AssertThrows(Action a, Func assert) + where E : Exception + { + + var hasFailed = false; + + try + { + a(); + } + catch (E e) + { + Assert.True(assert(e)); + hasFailed = true; + } + + if (!hasFailed) + { + Assert.True(false); + } + } + + public void NoNext(IAsyncEnumerator e) + { + Assert.False(e.MoveNextAsync().Result); + } + + public void HasNext(IAsyncEnumerator e, T value) + { + Assert.True(e.MoveNextAsync().Result); + Assert.Equal(value, e.Current); + } + + public async Task SequenceIdentity(IAsyncEnumerable enumerable) + { + var en1 = enumerable.GetAsyncEnumerator(); + var en2 = enumerable.GetAsyncEnumerator(); + + Assert.Equal(en1.GetType(), en2.GetType()); + + await en1.DisposeAsync(); + await en2.DisposeAsync(); + + var e1t = enumerable.ToList(); + var e2t = enumerable.ToList(); + + await Task.WhenAll(e1t, e2t); + + + var e1Result = e1t.Result; + var e2Result = e2t.Result; + + e1Result.ShouldAllBeEquivalentTo(e2Result); + } +#pragma warning restore xUnit1013 // Public method should be marked as test + } +} From ed1dca5bb107ffb7ab819e17c3fb49c189dac72b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:32:49 -0700 Subject: [PATCH 203/862] Some code cosmetics. --- .../System/Linq/AsyncEnumerableExTests.cs | 1 - .../System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index fe0d12efdd..57dd283126 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -32,7 +32,6 @@ public Task AssertThrows(Func func) public void AssertThrows(Action a, Func assert) where E : Exception { - var hasFailed = false; try diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index b208a64ec4..39faf57c03 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -32,7 +32,6 @@ public Task AssertThrows(Func func) public void AssertThrows(Action a, Func assert) where E : Exception { - var hasFailed = false; try From b60dad4cee9ad1a6093d54acd5e79f59c883c5e3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:34:55 -0700 Subject: [PATCH 204/862] Moving MinBy and MaxBy tests. --- .../AsyncTests.Aggregates.cs | 124 ------------------ .../System.Interactive.Async.Tests.csproj | 4 - .../System/Linq/Operators/MaxBy.cs | 78 +++++++++++ .../System/Linq/Operators/MinBy.cs | 78 +++++++++++ 4 files changed, 156 insertions(+), 128 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index 8ab31d7b8f..cee97f2a57 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -46,130 +46,6 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); } - [Fact] - public async Task MinBy_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); - } - - [Fact] - public void MinBy1() - { - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => x / 2); - var res = xs.Result; - - Assert.True(res.SequenceEqual(new[] { 3, 2 })); - } - - [Fact] - public void MinBy2() - { - var xs = new int[0].ToAsyncEnumerable().MinBy(x => x / 2); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void MinBy3() - { - var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 3) throw ex; return x; }); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void MinBy4() - { - var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 4) throw ex; return x; }); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void MinBy5() - { - var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)).MinBy(x => x, Comparer.Default); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task MaxBy_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); - } - - [Fact] - public void MaxBy1() - { - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => x / 2); - var res = xs.Result; - - Assert.True(res.SequenceEqual(new[] { 7, 6 })); - } - - [Fact] - public void MaxBy2() - { - var xs = new int[0].ToAsyncEnumerable().MaxBy(x => x / 2); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); - } - - [Fact] - public void MaxBy3() - { - var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 3) throw ex; return x; }); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void MaxBy4() - { - var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 4) throw ex; return x; }); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void MaxBy5() - { - var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)).MaxBy(x => x, Comparer.Default); - - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - private sealed class Eq : IEqualityComparer { public bool Equals(int x, int y) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index d7a7a7a0dd..8021058693 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -53,8 +53,4 @@ - - - - diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs new file mode 100644 index 0000000000..c1fa62b02e --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class MaxBy : AsyncEnumerableExTests + { + [Fact] + public async Task MaxBy_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); + } + + [Fact] + public void MaxBy1() + { + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => x / 2); + var res = xs.Result; + + Assert.True(res.SequenceEqual(new[] { 7, 6 })); + } + + [Fact] + public void MaxBy2() + { + var xs = new int[0].ToAsyncEnumerable().MaxBy(x => x / 2); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void MaxBy3() + { + var ex = new Exception("Bang!"); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 3) throw ex; return x; }); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void MaxBy4() + { + var ex = new Exception("Bang!"); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 4) throw ex; return x; }); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void MaxBy5() + { + var ex = new Exception("Bang!"); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)).MaxBy(x => x, Comparer.Default); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs new file mode 100644 index 0000000000..61fb60a6e2 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class MinBy : AsyncEnumerableExTests + { + [Fact] + public async Task MinBy_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); + } + + [Fact] + public void MinBy1() + { + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => x / 2); + var res = xs.Result; + + Assert.True(res.SequenceEqual(new[] { 3, 2 })); + } + + [Fact] + public void MinBy2() + { + var xs = new int[0].ToAsyncEnumerable().MinBy(x => x / 2); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + } + + [Fact] + public void MinBy3() + { + var ex = new Exception("Bang!"); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 3) throw ex; return x; }); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void MinBy4() + { + var ex = new Exception("Bang!"); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 4) throw ex; return x; }); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void MinBy5() + { + var ex = new Exception("Bang!"); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)).MinBy(x => x, Comparer.Default); + + AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From 245eae29bb9c639b30c36c3a1f27200b4e64f890 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:35:53 -0700 Subject: [PATCH 205/862] Moving IsEmpty tests. --- .../AsyncTests.Aggregates.cs | 10 +-------- .../System/Linq/Operators/IsEmpty.cs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index cee97f2a57..d264b75706 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -5,10 +5,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Xunit; -using System.Collections; using System.Threading; using System.Threading.Tasks; +using Xunit; // ReSharper disable InvokeAsExtensionMethod // ReSharper disable InconsistentNaming // ReSharper disable RedundantTypeArgumentsOfMethod @@ -19,13 +18,6 @@ public partial class AsyncTests { private const int WaitTimeoutMs = 5000; - [Fact] - public async Task IsEmpty_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); - } - [Fact] public async Task Min_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs new file mode 100644 index 0000000000..a5e955cb72 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class IsEmpty : AsyncEnumerableExTests + { + [Fact] + public async Task IsEmpty_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); + } + } +} From b2ee5664b98b34d7ec656c1dd5818e2371ccfb08 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:37:06 -0700 Subject: [PATCH 206/862] Moving Min and Max tests. --- .../AsyncTests.Aggregates.cs | 20 -------------- .../System/Linq/Operators/Max.cs | 26 +++++++++++++++++++ .../System/Linq/Operators/Min.cs | 26 +++++++++++++++++++ 3 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index d264b75706..ef6ab50ef5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -18,26 +18,6 @@ public partial class AsyncTests { private const int WaitTimeoutMs = 5000; - [Fact] - public async Task Min_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); - } - - [Fact] - public async Task Max_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer))); - - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); - } - private sealed class Eq : IEqualityComparer { public bool Equals(int x, int y) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs new file mode 100644 index 0000000000..873bb23e8d --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Max : AsyncEnumerableExTests + { + [Fact] + public async Task Max_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs new file mode 100644 index 0000000000..bd56968c0f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Min : AsyncEnumerableExTests + { + [Fact] + public async Task Min_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer))); + + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); + } + } +} From c75b9a304fff2e981e685486cdd3d0628df11051 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:37:58 -0700 Subject: [PATCH 207/862] Cleaning up test project. --- .../AsyncTests.Aggregates.cs | 15 +-------------- .../AsyncTests.Multiple.cs | 12 ++++++++++++ .../System.Interactive.Async.Tests/AsyncTests.cs | 2 ++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs index ef6ab50ef5..9b333c9965 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs @@ -16,19 +16,6 @@ namespace Tests { public partial class AsyncTests { - private const int WaitTimeoutMs = 5000; - - private sealed class Eq : IEqualityComparer - { - public bool Equals(int x, int y) - { - return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); - } - - public int GetHashCode(int obj) - { - return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); - } - } + } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index fe13991ec4..1d795ac6e2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -1035,5 +1035,17 @@ public override int GetHashCode() public string CustomerId { get; set; } } + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs index 643fa31f01..72fac9befe 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs @@ -13,6 +13,8 @@ namespace Tests { public partial class AsyncTests { + private const int WaitTimeoutMs = 5000; + #pragma warning disable xUnit1013 // Public method should be marked as test public void AssertThrows(Action a) where E : Exception From f7bee62749e4ca7ad5b6aa2607ecef70ab71b019 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:38:14 -0700 Subject: [PATCH 208/862] Removing unused test code. --- .../AsyncTests.Aggregates.cs | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs deleted file mode 100644 index 9b333c9965..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Xunit; -// ReSharper disable InvokeAsExtensionMethod -// ReSharper disable InconsistentNaming -// ReSharper disable RedundantTypeArgumentsOfMethod - -namespace Tests -{ - public partial class AsyncTests - { - - } -} From 39ad7449d389da1630a2edf78b9ab7ccb379fd4e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:42:29 -0700 Subject: [PATCH 209/862] Moving and splitting Distinct tests. --- .../AsyncTests.Single.cs | 125 ------------------ .../System/Linq/Operators/Distinct.cs | 65 +++++++++ .../System/Linq/Operators/Distinct.cs | 108 +++++++++++++++ 3 files changed, 173 insertions(+), 125 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 42c0f6c439..3120f6abb6 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -291,131 +291,6 @@ public void ForEachAsync6() AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void Distinct_Null() - { - AssertThrows(() => AsyncEnumerable.Distinct(null)); - AssertThrows(() => AsyncEnumerable.Distinct(null, new Eq())); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), null)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), (Func)null)); - } - - [Fact] - public void Distinct1() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Distinct2() - { - var xs = new[] { 1, -2, -1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(new Eq()); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, -2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public async Task Distinct3() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - - var res = new[] { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToArray())); - } - - [Fact] - public async Task Distinct4() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - - var res = new List { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToList())); - } - - [Fact] - public async Task Distinct5() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - - Assert.Equal(5, await xs.Count()); - } - - [Fact] - public async Task Distinct6() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); - - var res = new[] { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToArray())); - } - - [Fact] - public async Task Distinct7() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); - - var res = new List { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToList())); - } - - [Fact] - public async Task Distinct8() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); - - Assert.Equal(5, await xs.Count()); - } - - [Fact] - public async Task Distinct9() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); - - await SequenceIdentity(xs); - } - - [Fact] - public async Task Distinct10() - { - var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - - await SequenceIdentity(xs); - } - - [Fact] - public void Distinct11() - { - var xs = AsyncEnumerable.Empty().Distinct(k => k); - - var e = xs.GetAsyncEnumerator(); - - NoNext(e); - } - - [Fact] - public void Distinct12() - { - var xs = AsyncEnumerable.Empty().Distinct(); - - var e = xs.GetAsyncEnumerator(); - - NoNext(e); - } - [Fact] public void GroupBy_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs new file mode 100644 index 0000000000..83509be4da --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Distinct : AsyncEnumerableExTests + { + [Fact] + public void Distinct_Null() + { + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), (Func)null)); + } + + [Fact] + public async Task Distinct6() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); + + var res = new[] { 1, 2, 3, 5, 4 }; + Assert.True(res.SequenceEqual(await xs.ToArray())); + } + + [Fact] + public async Task Distinct7() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); + + var res = new List { 1, 2, 3, 5, 4 }; + Assert.True(res.SequenceEqual(await xs.ToList())); + } + + [Fact] + public async Task Distinct8() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); + + Assert.Equal(5, await xs.Count()); + } + + [Fact] + public async Task Distinct9() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); + + await SequenceIdentity(xs); + } + + [Fact] + public void Distinct11() + { + var xs = AsyncEnumerable.Empty().Distinct(k => k); + + var e = xs.GetAsyncEnumerator(); + + NoNext(e); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs new file mode 100644 index 0000000000..9827cf7168 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -0,0 +1,108 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Distinct : AsyncEnumerableTests + { + [Fact] + public void Distinct_Null() + { + AssertThrows(() => AsyncEnumerable.Distinct(null)); + AssertThrows(() => AsyncEnumerable.Distinct(null, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), null)); + } + + [Fact] + public void Distinct1() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 5); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void Distinct2() + { + var xs = new[] { 1, -2, -1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(new Eq()); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, -2); + HasNext(e, 3); + HasNext(e, 5); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public async Task Distinct3() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); + + var res = new[] { 1, 2, 3, 5, 4 }; + Assert.True(res.SequenceEqual(await xs.ToArray())); + } + + [Fact] + public async Task Distinct4() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); + + var res = new List { 1, 2, 3, 5, 4 }; + Assert.True(res.SequenceEqual(await xs.ToList())); + } + + [Fact] + public async Task Distinct5() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); + + Assert.Equal(5, await xs.Count()); + } + + [Fact] + public async Task Distinct10() + { + var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); + + await SequenceIdentity(xs); + } + + [Fact] + public void Distinct12() + { + var xs = AsyncEnumerable.Empty().Distinct(); + + var e = xs.GetAsyncEnumerator(); + + NoNext(e); + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} From c691f0d3505b39a4332bfd7a1a36db26db247952 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:43:43 -0700 Subject: [PATCH 210/862] Moving more Distinct tests. --- .../AsyncTests.Single.cs | 23 ------------------- .../System/Linq/Operators/Distinct.cs | 19 +++++++++++++++ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 3120f6abb6..2ffe88e6a5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -1677,28 +1677,5 @@ public async Task Scan6() await SequenceIdentity(xs); } - - [Fact] - public void DistinctKey_Null() - { - AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func))); - - AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), x => x, null)); - } - - [Fact] - public void DistinctKey1() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Distinct(x => x / 2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 4); - NoNext(e); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index 83509be4da..97393486c7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -16,6 +16,25 @@ public class Distinct : AsyncEnumerableExTests public void Distinct_Null() { AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), (Func)null)); + + AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func))); + + AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), x => x, null)); + } + + [Fact] + public void Distinct1() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Distinct(x => x / 2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 4); + NoNext(e); } [Fact] From b94d5ad371526f3160d134c742e65d332a703017 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:44:43 -0700 Subject: [PATCH 211/862] Moving DistinctUntilChanged tests. --- .../AsyncTests.Single.cs | 77 ---------------- .../Linq/Operators/DistinctUntilChanged.cs | 92 +++++++++++++++++++ 2 files changed, 92 insertions(+), 77 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 2ffe88e6a5..ce2c05c503 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -1480,83 +1480,6 @@ public async Task Buffer4() await SequenceIdentity(xs); } - [Fact] - public void DistinctUntilChanged_Null() - { - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); - - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(IEqualityComparer))); - - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func))); - - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); - } - - [Fact] - public void DistinctUntilChanged1() - { - var xs = new[] { 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 6, 7, 3, 2, 2, 1, 1 }.ToAsyncEnumerable().DistinctUntilChanged(); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 3); - HasNext(e, 2); - HasNext(e, 1); - NoNext(e); - } - - [Fact] - public void DistinctUntilChanged2() - { - var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => (x + 1) / 2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void DistinctUntilChanged3() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => { if (x == 4) throw ex; return x; }); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task DistinctUntilChanged4() - { - var xs = new[] { 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 6, 7, 3, 2, 2, 1, 1 }.ToAsyncEnumerable().DistinctUntilChanged(); - - await SequenceIdentity(xs); - } - - [Fact] - public async Task DistinctUntilChanged5() - { - var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => (x + 1) / 2); - - await SequenceIdentity(xs); - } - [Fact] public void Expand_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs new file mode 100644 index 0000000000..2558f48ad3 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class DistinctUntilChanged : AsyncEnumerableExTests + { + [Fact] + public void DistinctUntilChanged_Null() + { + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); + + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(IEqualityComparer))); + + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func))); + + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); + } + + [Fact] + public void DistinctUntilChanged1() + { + var xs = new[] { 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 6, 7, 3, 2, 2, 1, 1 }.ToAsyncEnumerable().DistinctUntilChanged(); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + HasNext(e, 7); + HasNext(e, 3); + HasNext(e, 2); + HasNext(e, 1); + NoNext(e); + } + + [Fact] + public void DistinctUntilChanged2() + { + var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => (x + 1) / 2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 3); + HasNext(e, 5); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void DistinctUntilChanged3() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => { if (x == 4) throw ex; return x; }); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task DistinctUntilChanged4() + { + var xs = new[] { 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 6, 7, 3, 2, 2, 1, 1 }.ToAsyncEnumerable().DistinctUntilChanged(); + + await SequenceIdentity(xs); + } + + [Fact] + public async Task DistinctUntilChanged5() + { + var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => (x + 1) / 2); + + await SequenceIdentity(xs); + } + } +} From 477fd4e98681c5f8726f9edc589f7dbc6815d150 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:46:03 -0700 Subject: [PATCH 212/862] Moving Scan tests. --- .../AsyncTests.Single.cs | 69 --------------- .../System/Linq/Operators/Scan.cs | 84 +++++++++++++++++++ 2 files changed, 84 insertions(+), 69 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index ce2c05c503..6336673c8e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -1531,74 +1531,5 @@ public async Task Expand4() await SequenceIdentity(xs); } - - [Fact] - public void Scan_Null() - { - AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), 3, default(Func))); - - AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), default(Func))); - } - - [Fact] - public void Scan1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => x + y); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 9); - HasNext(e, 11); - HasNext(e, 14); - NoNext(e); - } - - [Fact] - public void Scan2() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => x + y); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void Scan3() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, new Func((x, y) => { throw ex; })); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Scan4() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(new Func((x, y) => { throw ex; })); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Scan5() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => x + y); - - await SequenceIdentity(xs); - } - - [Fact] - public async Task Scan6() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => x + y); - - await SequenceIdentity(xs); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs new file mode 100644 index 0000000000..c328ad60d0 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs @@ -0,0 +1,84 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Scan : AsyncEnumerableExTests + { + [Fact] + public void Scan_Null() + { + AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); + AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), 3, default(Func))); + + AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), (x, y) => x + y)); + AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), default(Func))); + } + + [Fact] + public void Scan1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => x + y); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 9); + HasNext(e, 11); + HasNext(e, 14); + NoNext(e); + } + + [Fact] + public void Scan2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => x + y); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void Scan3() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, new Func((x, y) => { throw ex; })); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Scan4() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(new Func((x, y) => { throw ex; })); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task Scan5() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => x + y); + + await SequenceIdentity(xs); + } + + [Fact] + public async Task Scan6() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => x + y); + + await SequenceIdentity(xs); + } + } +} From 10ff5152bdd3708fd164b9ae5f964d47c3fb3d7a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:46:45 -0700 Subject: [PATCH 213/862] Moving Expand tests. --- .../AsyncTests.Single.cs | 52 -------------- .../System/Linq/Operators/Expand.cs | 67 +++++++++++++++++++ 2 files changed, 67 insertions(+), 52 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 6336673c8e..57a052ef8e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -1479,57 +1479,5 @@ public async Task Buffer4() await SequenceIdentity(xs); } - - [Fact] - public void Expand_Null() - { - AssertThrows(() => AsyncEnumerableEx.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Expand(AsyncEnumerable.Return(42), default(Func>))); - } - - [Fact] - public void Expand1() - { - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerable.Return(x - 1).Repeat(x - 1)); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 1); - HasNext(e, 1); - NoNext(e); - } - - [Fact] - public void Expand2() - { - var ex = new Exception("Bang!"); - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(new Func>(x => { throw ex; })); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Expand3() - { - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => default(IAsyncEnumerable)); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NullReferenceException); - } - - [Fact] - public async Task Expand4() - { - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerable.Return(x - 1).Repeat(x - 1)); - - await SequenceIdentity(xs); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs new file mode 100644 index 0000000000..66b1963a2d --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs @@ -0,0 +1,67 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Expand : AsyncEnumerableExTests + { + [Fact] + public void Expand_Null() + { + AssertThrows(() => AsyncEnumerableEx.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Expand(AsyncEnumerable.Return(42), default(Func>))); + } + + [Fact] + public void Expand1() + { + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerable.Return(x - 1).Repeat(x - 1)); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 2); + HasNext(e, 1); + HasNext(e, 1); + NoNext(e); + } + + [Fact] + public void Expand2() + { + var ex = new Exception("Bang!"); + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(new Func>(x => { throw ex; })); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Expand3() + { + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => default(IAsyncEnumerable)); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 2); + HasNext(e, 3); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NullReferenceException); + } + + [Fact] + public async Task Expand4() + { + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerable.Return(x - 1).Repeat(x - 1)); + + await SequenceIdentity(xs); + } + } +} From cb92b5af3f371183f5547a0247fca3dfbdec833c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:49:50 -0700 Subject: [PATCH 214/862] Moving GroupBy tests. --- .../AsyncTests.Single.cs | 879 ----------------- .../System/Linq/Operators/GroupBy.cs | 893 ++++++++++++++++++ 2 files changed, 893 insertions(+), 879 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 57a052ef8e..75175bdd09 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -291,885 +291,6 @@ public void ForEachAsync6() AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - [Fact] - public void GroupBy_Null() - { - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func))); - - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); - - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func))); - - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(IEqualityComparer))); - - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>))); - - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, (x, ys) => x, default(IEqualityComparer))); - - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>))); - - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, (x, ys) => x, default(IEqualityComparer))); - } - - [Fact] - public void GroupBy1() - { - var xs = new[] { - new { Name = "Bart", Age = 27 }, - new { Name = "John", Age = 62 }, - new { Name = "Eric", Age = 27 }, - new { Name = "Lisa", Age = 14 }, - new { Name = "Brad", Age = 27 }, - new { Name = "Lisa", Age = 23 }, - new { Name = "Eric", Age = 42 }, - }; - - var ys = xs.ToAsyncEnumerable(); - - var res = ys.GroupBy(x => x.Age / 10); - - var e = res.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - Assert.Equal(2, e.Current.Key); - var g1 = e.Current.GetAsyncEnumerator(); - HasNext(g1, xs[0]); - HasNext(g1, xs[2]); - HasNext(g1, xs[4]); - HasNext(g1, xs[5]); - NoNext(g1); - - Assert.True(e.MoveNextAsync().Result); - Assert.Equal(6, e.Current.Key); - var g2 = e.Current.GetAsyncEnumerator(); - HasNext(g2, xs[1]); - NoNext(g2); - - Assert.True(e.MoveNextAsync().Result); - Assert.Equal(1, e.Current.Key); - var g3 = e.Current.GetAsyncEnumerator(); - HasNext(g3, xs[3]); - NoNext(g3); - - Assert.True(e.MoveNextAsync().Result); - Assert.Equal(4, e.Current.Key); - var g4 = e.Current.GetAsyncEnumerator(); - HasNext(g4, xs[6]); - NoNext(g4); - - NoNext(e); - } - - [Fact] - public void GroupBy2() - { - var xs = new[] { - new { Name = "Bart", Age = 27 }, - new { Name = "John", Age = 62 }, - new { Name = "Eric", Age = 27 }, - new { Name = "Lisa", Age = 14 }, - new { Name = "Brad", Age = 27 }, - new { Name = "Lisa", Age = 23 }, - new { Name = "Eric", Age = 42 }, - }; - - var ys = xs.ToAsyncEnumerable(); - - var res = ys.GroupBy(x => x.Age / 10); - - var e = res.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - var g1 = e.Current; - Assert.Equal(2, g1.Key); - - Assert.True(e.MoveNextAsync().Result); - var g2 = e.Current; - Assert.Equal(6, g2.Key); - - Assert.True(e.MoveNextAsync().Result); - var g3 = e.Current; - Assert.Equal(1, g3.Key); - - Assert.True(e.MoveNextAsync().Result); - var g4 = e.Current; - Assert.Equal(4, g4.Key); - - NoNext(e); - - var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, xs[0]); - HasNext(g1e, xs[2]); - HasNext(g1e, xs[4]); - HasNext(g1e, xs[5]); - NoNext(g1e); - - var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, xs[1]); - NoNext(g2e); - - var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, xs[3]); - NoNext(g3e); - - var g4e = g4.GetAsyncEnumerator(); - HasNext(g4e, xs[6]); - NoNext(g4e); - } - - [Fact] - public void GroupBy3() - { - var xs = AsyncEnumerable.Empty(); - var ys = xs.GroupBy(x => x); - - var e = ys.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public void GroupBy4() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.GroupBy(x => x); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void GroupBy5() - { - var xs = GetXs().ToAsyncEnumerable(); - var ys = xs.GroupBy(x => x); - - var e = ys.GetAsyncEnumerator(); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - - //Assert.True(e.MoveNext().Result); - //var g1 = e.Current; - //Assert.Equal(g1.Key, 42); - //var g1e = g1.GetEnumerator(); - //HasNext(g1e, 42); - - //Assert.True(e.MoveNext().Result); - //var g2 = e.Current; - //Assert.Equal(g2.Key, 43); - //var g2e = g2.GetEnumerator(); - //HasNext(g2e, 43); - - - //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - } - - [Fact] - public void GroupBy6() - { - var xs = GetXs().ToAsyncEnumerable(); - var ys = xs.GroupBy(x => x); - - var e = ys.GetAsyncEnumerator(); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - - //Assert.True(e.MoveNext().Result); - //var g1 = e.Current; - //Assert.Equal(g1.Key, 42); - //var g1e = g1.GetEnumerator(); - //HasNext(g1e, 42); - //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - - - } - - static IEnumerable GetXs() - { - yield return 42; - yield return 43; - throw new Exception("Bang!"); - } - - [Fact] - public void GroupBy7() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Return(42); - var ys = xs.GroupBy(new Func(x => { throw ex; })); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void GroupBy8() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.GroupBy(x => { if (x == 3) throw ex; return x; }); - - var e = ys.GetAsyncEnumerator(); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - - //Assert.True(e.MoveNext().Result); - //var g1 = e.Current; - //Assert.Equal(g1.Key, 1); - //var g1e = g1.GetEnumerator(); - //HasNext(g1e, 1); - - //Assert.True(e.MoveNext().Result); - //var g2 = e.Current; - //Assert.Equal(g2.Key, 2); - //var g2e = g2.GetEnumerator(); - //HasNext(g2e, 2); - - - //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void GroupBy9() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - - var e = ys.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - var g1 = e.Current; - Assert.Equal(0, g1.Key); - var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); - - Assert.True(e.MoveNextAsync().Result); - var g2 = e.Current; - Assert.Equal(1, g2.Key); - var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 'b'); - HasNext(g2e, 'e'); - HasNext(g2e, 'h'); - NoNext(g2e); - - Assert.True(e.MoveNextAsync().Result); - var g3 = e.Current; - Assert.Equal(2, g3.Key); - var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 'c'); - HasNext(g3e, 'f'); - HasNext(g3e, 'i'); - NoNext(g3e); - - NoNext(e); - } - - [Fact] - public void GroupBy10() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - adgj"); - HasNext(e, "1 - beh"); - HasNext(e, "2 - cfi"); - NoNext(e); - } - - [Fact] - public void GroupBy11() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - 0369"); - HasNext(e, "1 - 147"); - HasNext(e, "2 - 258"); - NoNext(e); - } - - [Fact] - public void GroupBy12() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, new EqMod(3)); - - var e = ys.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - var g1 = e.Current; - Assert.Equal(0, g1.Key); - var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 0); - HasNext(g1e, 3); - HasNext(g1e, 6); - HasNext(g1e, 9); - NoNext(g1e); - - Assert.True(e.MoveNextAsync().Result); - var g2 = e.Current; - Assert.Equal(1, g2.Key); - var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 1); - HasNext(g2e, 4); - HasNext(g2e, 7); - NoNext(g2e); - - Assert.True(e.MoveNextAsync().Result); - var g3 = e.Current; - Assert.Equal(2, g3.Key); - var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 2); - HasNext(g3e, 5); - HasNext(g3e, 8); - NoNext(g3e); - - NoNext(e); - } - - [Fact] - public void GroupBy13() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - - var e = ys.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - var g1 = e.Current; - Assert.Equal(0, g1.Key); - var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); - - Assert.True(e.MoveNextAsync().Result); - var g2 = e.Current; - Assert.Equal(1, g2.Key); - var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 'b'); - HasNext(g2e, 'e'); - HasNext(g2e, 'h'); - NoNext(g2e); - - Assert.True(e.MoveNextAsync().Result); - var g3 = e.Current; - Assert.Equal(2, g3.Key); - var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 'c'); - HasNext(g3e, 'f'); - HasNext(g3e, 'i'); - NoNext(g3e); - - NoNext(e); - } - - [Fact] - public void GroupBy14() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - adgj"); - HasNext(e, "1 - beh"); - HasNext(e, "2 - cfi"); - NoNext(e); - } - - [Fact] - public void GroupBy15() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - 0369"); - HasNext(e, "1 - 147"); - HasNext(e, "2 - 258"); - NoNext(e); - } - - [Fact] - public async Task GroupBy16() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - - var e = ys.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - var g1 = e.Current; - Assert.Equal(0, g1.Key); - var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); - await g1e.DisposeAsync(); - - Assert.True(e.MoveNextAsync().Result); - var g2 = e.Current; - Assert.Equal(1, g2.Key); - var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 'b'); - HasNext(g2e, 'e'); - HasNext(g2e, 'h'); - NoNext(g2e); - await g2e.DisposeAsync(); - - Assert.True(e.MoveNextAsync().Result); - var g3 = e.Current; - Assert.Equal(2, g3.Key); - var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 'c'); - HasNext(g3e, 'f'); - HasNext(g3e, 'i'); - NoNext(g3e); - await g3e.DisposeAsync(); - - NoNext(e); - - await e.DisposeAsync(); - } - - [Fact] - public async Task GroupBy17() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - - var e = ys.GetAsyncEnumerator(); - await e.DisposeAsync(); - - Assert.False(e.MoveNextAsync().Result); - } - - [Fact] - public async Task GroupBy18() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); - - var e = ys.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - var g1 = e.Current; - Assert.Equal(0, g1.Key); - var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); - - await e.DisposeAsync(); - - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); - await g1e.DisposeAsync(); - - Assert.False(e.MoveNextAsync().Result); - } - - [Fact] - public async Task GroupBy19() - { - // We're using Kvp here because the types will eval as equal for this test - var xs = new[] - { - new Kvp("Bart", 27), - new Kvp("John", 62), - new Kvp("Eric", 27), - new Kvp("Lisa", 14), - new Kvp("Brad", 27), - new Kvp("Lisa", 23), - new Kvp("Eric", 42) - }; - - var ys = xs.ToAsyncEnumerable(); - - var res = ys.GroupBy(x => x.Item / 10); - - await SequenceIdentity(res); - } - - - [Fact] - public async Task GroupBy20() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - - var arr = new[] { "0 - adgj", "1 - beh", "2 - cfi" }; - - Assert.Equal(arr, await ys.ToArray()); - } - - [Fact] - public async Task GroupBy21() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - - var arr = new List { "0 - adgj", "1 - beh", "2 - cfi" }; - - Assert.Equal(arr, await ys.ToList()); - } - - [Fact] - public async Task GroupBy22() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - - Assert.Equal(3, await ys.Count()); - } - - [Fact] - public async Task GroupBy23() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task GroupBy24() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - - var g1a = new[] { 'a', 'd', 'g', 'j' }; - var g2a = new[] { 'b', 'e', 'h' }; - var g3a = new[] { 'c', 'f', 'i' }; - - var gar = await ys.ToArray(); - - Assert.Equal(3, gar.Length); - - var gg1 = gar[0]; - var gg1a = await gg1.ToArray(); - - Assert.Equal(g1a, gg1a); - - var gg2 = gar[1]; - var gg2a = await gg2.ToArray(); - - Assert.Equal(g2a, gg2a); - - var gg3 = gar[2]; - var gg3a = await gg3.ToArray(); - Assert.Equal(g3a, gg3a); - } - - [Fact] - public async Task GroupBy25() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - - var g1a = new List { 'a', 'd', 'g', 'j' }; - var g2a = new List { 'b', 'e', 'h' }; - var g3a = new List { 'c', 'f', 'i' }; - - var gar = await ys.ToList(); - - Assert.Equal(3, gar.Count); - - var gg1 = gar[0]; - var gg1a = await gg1.ToList(); - Assert.Equal(g1a, gg1a); - - var gg2 = gar[1]; - var gg2a = await gg2.ToList(); - Assert.Equal(g2a, gg2a); - - var gg3 = gar[2]; - var gg3a = await gg3.ToList(); - Assert.Equal(g3a, gg3a); - } - - [Fact] - public async Task GroupBy26() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - - var gar = await ys.ToList(); - - Assert.Equal(3, gar.Count); - - var gg1 = gar[0]; - var gg1a = await gg1.Count(); - Assert.Equal(4, gg1a); - - var gg2 = gar[1]; - var gg2a = await gg2.Count(); - Assert.Equal(3, gg2a); - - var gg3 = gar[2]; - var gg3a = await gg3.Count(); - Assert.Equal(3, gg3a); - } - - [Fact] - public async Task GroupBy27() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - - var gar = await ys.Count(); - - Assert.Equal(3, gar); - } - - [Fact] - public async Task GroupBy28() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task GroupBy29() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, new EqMod(3)); - - var g1a = new List { 0, 3, 6, 9 }; - var g2a = new List { 1, 4, 7 }; - var g3a = new List { 2, 5, 8 }; - - var gar = await ys.ToList(); - - Assert.Equal(3, gar.Count); - - var gg1 = gar[0]; - var gg1a = await gg1.ToList(); - Assert.Equal(g1a, gg1a); - - var gg2 = gar[1]; - var gg2a = await gg2.ToList(); - Assert.Equal(g2a, gg2a); - - var gg3 = gar[2]; - var gg3a = await gg3.ToList(); - Assert.Equal(g3a, gg3a); - } - - [Fact] - public async Task GroupBy30() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, new EqMod(3)); - - - var gar = await ys.ToList(); - - Assert.Equal(3, gar.Count); - - var gg1 = gar[0]; - var gg1a = await gg1.Count(); - Assert.Equal(4, gg1a); - - var gg2 = gar[1]; - var gg2a = await gg2.Count(); - Assert.Equal(3, gg2a); - - var gg3 = gar[2]; - var gg3a = await gg3.Count(); - Assert.Equal(3, gg3a); - } - - [Fact] - public async Task GroupBy31() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, new EqMod(3)); - - var g1a = new[] { 0, 3, 6, 9 }; - var g2a = new[] { 1, 4, 7 }; - var g3a = new[] { 2, 5, 8 }; - - var gar = await ys.ToArray(); - - Assert.Equal(3, gar.Length); - - var gg1 = gar[0]; - var gg1a = await gg1.ToArray(); - - Assert.Equal(g1a, gg1a); - - var gg2 = gar[1]; - var gg2a = await gg2.ToArray(); - - Assert.Equal(g2a, gg2a); - - var gg3 = gar[2]; - var gg3a = await gg3.ToArray(); - Assert.Equal(g3a, gg3a); - } - - [Fact] - public async Task GroupBy32() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, new EqMod(3)); - - var gar = await ys.Count(); - - Assert.Equal(3, gar); - } - - [Fact] - public async Task GroupBy33() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, new EqMod(3)); - - await SequenceIdentity(ys); - } - - [Fact] - public async Task GroupBy34() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - - var arr = new[] { "0 - 0369", "1 - 147", "2 - 258" }; - - Assert.Equal(arr, await ys.ToArray()); - } - - [Fact] - public async Task GroupBy35() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - - var arr = new List { "0 - 0369", "1 - 147", "2 - 258" }; - - Assert.Equal(arr, await ys.ToList()); - } - - [Fact] - public async Task GroupBy36() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - - Assert.Equal(3, await ys.Count()); - } - - [Fact] - public async Task GroupBy37() - { - var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); - - await SequenceIdentity(ys); - } - - class Kvp : IEquatable - { - public bool Equals(Kvp other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return string.Equals(Key, other.Key) && Item == other.Item; - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != GetType()) return false; - return Equals((Kvp)obj); - } - - public override int GetHashCode() - { - unchecked - { - return ((Key != null ? Key.GetHashCode() : 0) * 397) ^ Item; - } - } - - public static bool operator ==(Kvp left, Kvp right) - { - return Equals(left, right); - } - - public static bool operator !=(Kvp left, Kvp right) - { - return !Equals(left, right); - } - - - public string Key { get; } - public int Item { get; } - - public Kvp(string key, int item) - { - Key = key; - Item = item; - } - } - - - class EqMod : IEqualityComparer - { - private readonly int _d; - - public EqMod(int d) - { - _d = d; - } - - public bool Equals(int x, int y) - { - return EqualityComparer.Default.Equals(x % _d, y % _d); - } - - public int GetHashCode(int obj) - { - return EqualityComparer.Default.GetHashCode(obj % _d); - } - } - [Fact] public void AsAsyncEnumerable_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs new file mode 100644 index 0000000000..c2febbbdb6 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -0,0 +1,893 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class GroupBy : AsyncEnumerableTests + { + [Fact] + public void GroupBy_Null() + { + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func))); + + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); + + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func))); + + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(IEqualityComparer))); + + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>))); + + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, (x, ys) => x, default(IEqualityComparer))); + + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>))); + + AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, (x, ys) => x, default(IEqualityComparer))); + } + + [Fact] + public void GroupBy1() + { + var xs = new[] { + new { Name = "Bart", Age = 27 }, + new { Name = "John", Age = 62 }, + new { Name = "Eric", Age = 27 }, + new { Name = "Lisa", Age = 14 }, + new { Name = "Brad", Age = 27 }, + new { Name = "Lisa", Age = 23 }, + new { Name = "Eric", Age = 42 }, + }; + + var ys = xs.ToAsyncEnumerable(); + + var res = ys.GroupBy(x => x.Age / 10); + + var e = res.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + Assert.Equal(2, e.Current.Key); + var g1 = e.Current.GetAsyncEnumerator(); + HasNext(g1, xs[0]); + HasNext(g1, xs[2]); + HasNext(g1, xs[4]); + HasNext(g1, xs[5]); + NoNext(g1); + + Assert.True(e.MoveNextAsync().Result); + Assert.Equal(6, e.Current.Key); + var g2 = e.Current.GetAsyncEnumerator(); + HasNext(g2, xs[1]); + NoNext(g2); + + Assert.True(e.MoveNextAsync().Result); + Assert.Equal(1, e.Current.Key); + var g3 = e.Current.GetAsyncEnumerator(); + HasNext(g3, xs[3]); + NoNext(g3); + + Assert.True(e.MoveNextAsync().Result); + Assert.Equal(4, e.Current.Key); + var g4 = e.Current.GetAsyncEnumerator(); + HasNext(g4, xs[6]); + NoNext(g4); + + NoNext(e); + } + + [Fact] + public void GroupBy2() + { + var xs = new[] { + new { Name = "Bart", Age = 27 }, + new { Name = "John", Age = 62 }, + new { Name = "Eric", Age = 27 }, + new { Name = "Lisa", Age = 14 }, + new { Name = "Brad", Age = 27 }, + new { Name = "Lisa", Age = 23 }, + new { Name = "Eric", Age = 42 }, + }; + + var ys = xs.ToAsyncEnumerable(); + + var res = ys.GroupBy(x => x.Age / 10); + + var e = res.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + var g1 = e.Current; + Assert.Equal(2, g1.Key); + + Assert.True(e.MoveNextAsync().Result); + var g2 = e.Current; + Assert.Equal(6, g2.Key); + + Assert.True(e.MoveNextAsync().Result); + var g3 = e.Current; + Assert.Equal(1, g3.Key); + + Assert.True(e.MoveNextAsync().Result); + var g4 = e.Current; + Assert.Equal(4, g4.Key); + + NoNext(e); + + var g1e = g1.GetAsyncEnumerator(); + HasNext(g1e, xs[0]); + HasNext(g1e, xs[2]); + HasNext(g1e, xs[4]); + HasNext(g1e, xs[5]); + NoNext(g1e); + + var g2e = g2.GetAsyncEnumerator(); + HasNext(g2e, xs[1]); + NoNext(g2e); + + var g3e = g3.GetAsyncEnumerator(); + HasNext(g3e, xs[3]); + NoNext(g3e); + + var g4e = g4.GetAsyncEnumerator(); + HasNext(g4e, xs[6]); + NoNext(g4e); + } + + [Fact] + public void GroupBy3() + { + var xs = AsyncEnumerable.Empty(); + var ys = xs.GroupBy(x => x); + + var e = ys.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public void GroupBy4() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.GroupBy(x => x); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void GroupBy5() + { + var xs = GetXs().ToAsyncEnumerable(); + var ys = xs.GroupBy(x => x); + + var e = ys.GetAsyncEnumerator(); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + + //Assert.True(e.MoveNext().Result); + //var g1 = e.Current; + //Assert.Equal(g1.Key, 42); + //var g1e = g1.GetEnumerator(); + //HasNext(g1e, 42); + + //Assert.True(e.MoveNext().Result); + //var g2 = e.Current; + //Assert.Equal(g2.Key, 43); + //var g2e = g2.GetEnumerator(); + //HasNext(g2e, 43); + + + //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + } + + [Fact] + public void GroupBy6() + { + var xs = GetXs().ToAsyncEnumerable(); + var ys = xs.GroupBy(x => x); + + var e = ys.GetAsyncEnumerator(); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + + //Assert.True(e.MoveNext().Result); + //var g1 = e.Current; + //Assert.Equal(g1.Key, 42); + //var g1e = g1.GetEnumerator(); + //HasNext(g1e, 42); + //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + + + } + + static IEnumerable GetXs() + { + yield return 42; + yield return 43; + throw new Exception("Bang!"); + } + + [Fact] + public void GroupBy7() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Return(42); + var ys = xs.GroupBy(new Func(x => { throw ex; })); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void GroupBy8() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = xs.GroupBy(x => { if (x == 3) throw ex; return x; }); + + var e = ys.GetAsyncEnumerator(); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + + //Assert.True(e.MoveNext().Result); + //var g1 = e.Current; + //Assert.Equal(g1.Key, 1); + //var g1e = g1.GetEnumerator(); + //HasNext(g1e, 1); + + //Assert.True(e.MoveNext().Result); + //var g2 = e.Current; + //Assert.Equal(g2.Key, 2); + //var g2e = g2.GetEnumerator(); + //HasNext(g2e, 2); + + + //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void GroupBy9() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); + + var e = ys.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + var g1 = e.Current; + Assert.Equal(0, g1.Key); + var g1e = g1.GetAsyncEnumerator(); + HasNext(g1e, 'a'); + HasNext(g1e, 'd'); + HasNext(g1e, 'g'); + HasNext(g1e, 'j'); + NoNext(g1e); + + Assert.True(e.MoveNextAsync().Result); + var g2 = e.Current; + Assert.Equal(1, g2.Key); + var g2e = g2.GetAsyncEnumerator(); + HasNext(g2e, 'b'); + HasNext(g2e, 'e'); + HasNext(g2e, 'h'); + NoNext(g2e); + + Assert.True(e.MoveNextAsync().Result); + var g3 = e.Current; + Assert.Equal(2, g3.Key); + var g3e = g3.GetAsyncEnumerator(); + HasNext(g3e, 'c'); + HasNext(g3e, 'f'); + HasNext(g3e, 'i'); + NoNext(g3e); + + NoNext(e); + } + + [Fact] + public void GroupBy10() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, "0 - adgj"); + HasNext(e, "1 - beh"); + HasNext(e, "2 - cfi"); + NoNext(e); + } + + [Fact] + public void GroupBy11() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, "0 - 0369"); + HasNext(e, "1 - 147"); + HasNext(e, "2 - 258"); + NoNext(e); + } + + [Fact] + public void GroupBy12() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, new EqMod(3)); + + var e = ys.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + var g1 = e.Current; + Assert.Equal(0, g1.Key); + var g1e = g1.GetAsyncEnumerator(); + HasNext(g1e, 0); + HasNext(g1e, 3); + HasNext(g1e, 6); + HasNext(g1e, 9); + NoNext(g1e); + + Assert.True(e.MoveNextAsync().Result); + var g2 = e.Current; + Assert.Equal(1, g2.Key); + var g2e = g2.GetAsyncEnumerator(); + HasNext(g2e, 1); + HasNext(g2e, 4); + HasNext(g2e, 7); + NoNext(g2e); + + Assert.True(e.MoveNextAsync().Result); + var g3 = e.Current; + Assert.Equal(2, g3.Key); + var g3e = g3.GetAsyncEnumerator(); + HasNext(g3e, 2); + HasNext(g3e, 5); + HasNext(g3e, 8); + NoNext(g3e); + + NoNext(e); + } + + [Fact] + public void GroupBy13() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); + + var e = ys.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + var g1 = e.Current; + Assert.Equal(0, g1.Key); + var g1e = g1.GetAsyncEnumerator(); + HasNext(g1e, 'a'); + HasNext(g1e, 'd'); + HasNext(g1e, 'g'); + HasNext(g1e, 'j'); + NoNext(g1e); + + Assert.True(e.MoveNextAsync().Result); + var g2 = e.Current; + Assert.Equal(1, g2.Key); + var g2e = g2.GetAsyncEnumerator(); + HasNext(g2e, 'b'); + HasNext(g2e, 'e'); + HasNext(g2e, 'h'); + NoNext(g2e); + + Assert.True(e.MoveNextAsync().Result); + var g3 = e.Current; + Assert.Equal(2, g3.Key); + var g3e = g3.GetAsyncEnumerator(); + HasNext(g3e, 'c'); + HasNext(g3e, 'f'); + HasNext(g3e, 'i'); + NoNext(g3e); + + NoNext(e); + } + + [Fact] + public void GroupBy14() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, "0 - adgj"); + HasNext(e, "1 - beh"); + HasNext(e, "2 - cfi"); + NoNext(e); + } + + [Fact] + public void GroupBy15() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, "0 - 0369"); + HasNext(e, "1 - 147"); + HasNext(e, "2 - 258"); + NoNext(e); + } + + [Fact] + public async Task GroupBy16() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); + + var e = ys.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + var g1 = e.Current; + Assert.Equal(0, g1.Key); + var g1e = g1.GetAsyncEnumerator(); + HasNext(g1e, 'a'); + HasNext(g1e, 'd'); + HasNext(g1e, 'g'); + HasNext(g1e, 'j'); + NoNext(g1e); + await g1e.DisposeAsync(); + + Assert.True(e.MoveNextAsync().Result); + var g2 = e.Current; + Assert.Equal(1, g2.Key); + var g2e = g2.GetAsyncEnumerator(); + HasNext(g2e, 'b'); + HasNext(g2e, 'e'); + HasNext(g2e, 'h'); + NoNext(g2e); + await g2e.DisposeAsync(); + + Assert.True(e.MoveNextAsync().Result); + var g3 = e.Current; + Assert.Equal(2, g3.Key); + var g3e = g3.GetAsyncEnumerator(); + HasNext(g3e, 'c'); + HasNext(g3e, 'f'); + HasNext(g3e, 'i'); + NoNext(g3e); + await g3e.DisposeAsync(); + + NoNext(e); + + await e.DisposeAsync(); + } + + [Fact] + public async Task GroupBy17() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); + + var e = ys.GetAsyncEnumerator(); + await e.DisposeAsync(); + + Assert.False(e.MoveNextAsync().Result); + } + + [Fact] + public async Task GroupBy18() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); + + var e = ys.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + var g1 = e.Current; + Assert.Equal(0, g1.Key); + var g1e = g1.GetAsyncEnumerator(); + HasNext(g1e, 'a'); + + await e.DisposeAsync(); + + HasNext(g1e, 'd'); + HasNext(g1e, 'g'); + HasNext(g1e, 'j'); + NoNext(g1e); + await g1e.DisposeAsync(); + + Assert.False(e.MoveNextAsync().Result); + } + + [Fact] + public async Task GroupBy19() + { + // We're using Kvp here because the types will eval as equal for this test + var xs = new[] + { + new Kvp("Bart", 27), + new Kvp("John", 62), + new Kvp("Eric", 27), + new Kvp("Lisa", 14), + new Kvp("Brad", 27), + new Kvp("Lisa", 23), + new Kvp("Eric", 42) + }; + + var ys = xs.ToAsyncEnumerable(); + + var res = ys.GroupBy(x => x.Item / 10); + + await SequenceIdentity(res); + } + + + [Fact] + public async Task GroupBy20() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + + var arr = new[] { "0 - adgj", "1 - beh", "2 - cfi" }; + + Assert.Equal(arr, await ys.ToArray()); + } + + [Fact] + public async Task GroupBy21() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + + var arr = new List { "0 - adgj", "1 - beh", "2 - cfi" }; + + Assert.Equal(arr, await ys.ToList()); + } + + [Fact] + public async Task GroupBy22() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + + Assert.Equal(3, await ys.Count()); + } + + [Fact] + public async Task GroupBy23() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task GroupBy24() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); + + var g1a = new[] { 'a', 'd', 'g', 'j' }; + var g2a = new[] { 'b', 'e', 'h' }; + var g3a = new[] { 'c', 'f', 'i' }; + + var gar = await ys.ToArray(); + + Assert.Equal(3, gar.Length); + + var gg1 = gar[0]; + var gg1a = await gg1.ToArray(); + + Assert.Equal(g1a, gg1a); + + var gg2 = gar[1]; + var gg2a = await gg2.ToArray(); + + Assert.Equal(g2a, gg2a); + + var gg3 = gar[2]; + var gg3a = await gg3.ToArray(); + Assert.Equal(g3a, gg3a); + } + + [Fact] + public async Task GroupBy25() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); + + var g1a = new List { 'a', 'd', 'g', 'j' }; + var g2a = new List { 'b', 'e', 'h' }; + var g3a = new List { 'c', 'f', 'i' }; + + var gar = await ys.ToList(); + + Assert.Equal(3, gar.Count); + + var gg1 = gar[0]; + var gg1a = await gg1.ToList(); + Assert.Equal(g1a, gg1a); + + var gg2 = gar[1]; + var gg2a = await gg2.ToList(); + Assert.Equal(g2a, gg2a); + + var gg3 = gar[2]; + var gg3a = await gg3.ToList(); + Assert.Equal(g3a, gg3a); + } + + [Fact] + public async Task GroupBy26() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); + + var gar = await ys.ToList(); + + Assert.Equal(3, gar.Count); + + var gg1 = gar[0]; + var gg1a = await gg1.Count(); + Assert.Equal(4, gg1a); + + var gg2 = gar[1]; + var gg2a = await gg2.Count(); + Assert.Equal(3, gg2a); + + var gg3 = gar[2]; + var gg3a = await gg3.Count(); + Assert.Equal(3, gg3a); + } + + [Fact] + public async Task GroupBy27() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); + + var gar = await ys.Count(); + + Assert.Equal(3, gar); + } + + [Fact] + public async Task GroupBy28() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task GroupBy29() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, new EqMod(3)); + + var g1a = new List { 0, 3, 6, 9 }; + var g2a = new List { 1, 4, 7 }; + var g3a = new List { 2, 5, 8 }; + + var gar = await ys.ToList(); + + Assert.Equal(3, gar.Count); + + var gg1 = gar[0]; + var gg1a = await gg1.ToList(); + Assert.Equal(g1a, gg1a); + + var gg2 = gar[1]; + var gg2a = await gg2.ToList(); + Assert.Equal(g2a, gg2a); + + var gg3 = gar[2]; + var gg3a = await gg3.ToList(); + Assert.Equal(g3a, gg3a); + } + + [Fact] + public async Task GroupBy30() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, new EqMod(3)); + + + var gar = await ys.ToList(); + + Assert.Equal(3, gar.Count); + + var gg1 = gar[0]; + var gg1a = await gg1.Count(); + Assert.Equal(4, gg1a); + + var gg2 = gar[1]; + var gg2a = await gg2.Count(); + Assert.Equal(3, gg2a); + + var gg3 = gar[2]; + var gg3a = await gg3.Count(); + Assert.Equal(3, gg3a); + } + + [Fact] + public async Task GroupBy31() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, new EqMod(3)); + + var g1a = new[] { 0, 3, 6, 9 }; + var g2a = new[] { 1, 4, 7 }; + var g3a = new[] { 2, 5, 8 }; + + var gar = await ys.ToArray(); + + Assert.Equal(3, gar.Length); + + var gg1 = gar[0]; + var gg1a = await gg1.ToArray(); + + Assert.Equal(g1a, gg1a); + + var gg2 = gar[1]; + var gg2a = await gg2.ToArray(); + + Assert.Equal(g2a, gg2a); + + var gg3 = gar[2]; + var gg3a = await gg3.ToArray(); + Assert.Equal(g3a, gg3a); + } + + [Fact] + public async Task GroupBy32() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, new EqMod(3)); + + var gar = await ys.Count(); + + Assert.Equal(3, gar); + } + + [Fact] + public async Task GroupBy33() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, new EqMod(3)); + + await SequenceIdentity(ys); + } + + [Fact] + public async Task GroupBy34() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + + var arr = new[] { "0 - 0369", "1 - 147", "2 - 258" }; + + Assert.Equal(arr, await ys.ToArray()); + } + + [Fact] + public async Task GroupBy35() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + + var arr = new List { "0 - 0369", "1 - 147", "2 - 258" }; + + Assert.Equal(arr, await ys.ToList()); + } + + [Fact] + public async Task GroupBy36() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + + Assert.Equal(3, await ys.Count()); + } + + [Fact] + public async Task GroupBy37() + { + var xs = AsyncEnumerable.Range(0, 10); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + + await SequenceIdentity(ys); + } + + private sealed class EqMod : IEqualityComparer + { + private readonly int _d; + + public EqMod(int d) + { + _d = d; + } + + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(x % _d, y % _d); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(obj % _d); + } + } + + private sealed class Kvp : IEquatable + { + public Kvp(string key, int item) + { + Key = key; + Item = item; + } + + public string Key { get; } + public int Item { get; } + + public bool Equals(Kvp other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return string.Equals(Key, other.Key) && Item == other.Item; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((Kvp)obj); + } + + public override int GetHashCode() + { + unchecked + { + return ((Key != null ? Key.GetHashCode() : 0) * 397) ^ Item; + } + } + + public static bool operator ==(Kvp left, Kvp right) + { + return Equals(left, right); + } + + public static bool operator !=(Kvp left, Kvp right) + { + return !Equals(left, right); + } + } + } +} From cdc94e5d78a8379a5fb3522768dbfd6764b84da2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:53:10 -0700 Subject: [PATCH 215/862] Moving Append and Prepend tests. --- .../AppendPrependTests.cs | 454 ------------------ .../System/Linq/Operators/Append.cs | 237 +++++++++ .../System/Linq/Operators/Prepend.cs | 250 ++++++++++ 3 files changed, 487 insertions(+), 454 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs index 47f4f7f668..2bf6e33018 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs @@ -12,460 +12,6 @@ namespace Tests { public partial class AsyncTests { - - [Fact] - public void AppendPrepend_Null() - { - AssertThrows(() => AsyncEnumerable.Append(null, 42)); - AssertThrows(() => AsyncEnumerable.Prepend(null, 42)); - } - - [Fact] - public void Append1() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Append(4); - - var e = res.GetAsyncEnumerator(); - - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public async Task Append2() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Append(4); - - var a = new[] {1, 2, 3, 4}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task Append3() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - var res = xs.Append(4); - var a = new List - { - 1, - 2, - 3, - 4 - }; - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task Append4() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Append(4); - Assert.Equal(4, await res.Count()); - } - - [Fact] - public async Task Append5() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Append(4); - - var a = new[] {1, 2, 3, 4}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task Append6() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Append(4); - Assert.Equal(4, await res.Count()); - } - - [Fact] - public async Task Append7() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - var res = xs.Append(4); - var a = new List - { - 1, - 2, - 3, - 4 - }; - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - - [Fact] - public void AppendN1() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Append(4) - .Append(5) - .Append(6); - - var e = res.GetAsyncEnumerator(); - - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public async Task AppendN2() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Append(4) - .Append(5) - .Append(6); - - var a = new[] {1, 2, 3, 4, 5, 6}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task AppendN3() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - var res = xs.Append(4) - .Append(5) - .Append(6); - - var a = new List - { - 1, - 2, - 3, - 4, - 5, - 6 - }; - - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - - [Fact] - public async Task AppendN5() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Append(4) - .Append(5) - .Append(6); - - var a = new[] {1, 2, 3, 4, 5, 6}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task AppendN6() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - var res = xs.Append(4) - .Append(5) - .Append(6); - - var a = new List - { - 1, - 2, - 3, - 4, - 5, - 6 - }; - - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task AppendN7() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Append(4) - .Append(5) - .Append(6); - Assert.Equal(6, await res.Count()); - } - - [Fact] - public async Task AppenN4() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Append(4) - .Append(5) - .Append(6); - Assert.Equal(6, await res.Count()); - } - - [Fact] - public void Prepend1() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Prepend(4); - - var e = res.GetAsyncEnumerator(); - - HasNext(e, 4); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); - } - - [Fact] - public async Task Prepend2() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Prepend(4); - - var a = new[] {4, 1, 2, 3}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task Prepend3() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - var res = xs.Prepend(4); - var a = new List - { - 4, - 1, - 2, - 3 - }; - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - - [Fact] - public async Task Prepend4() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Prepend(4); - Assert.Equal(4, await res.Count()); - } - - - [Fact] - public async Task Prepend5() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Prepend(4); - - var a = new[] {4, 1, 2, 3}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task Prepend6() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - var res = xs.Prepend(4); - var a = new List - { - 4, - 1, - 2, - 3 - }; - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - - [Fact] - public async Task Prepend7() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Prepend(4); - Assert.Equal(4, await res.Count()); - } - - - [Fact] - public async Task Prepend8() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Prepend(4); - - await SequenceIdentity(res); - } - - [Fact] - public void PrependN1() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Prepend(4) - .Prepend(5) - .Prepend(6); - - var e = res.GetAsyncEnumerator(); - - HasNext(e, 6); - HasNext(e, 5); - HasNext(e, 4); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); - } - - [Fact] - public async Task PrependN2() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Prepend(4) - .Prepend(5) - .Prepend(6); - - var a = new[] {6, 5, 4, 1, 2, 3}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task PrependN3() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - var res = xs.Prepend(4) - .Prepend(5) - .Prepend(6); - - var a = new List - { - 6, - 5, - 4, - 1, - 2, - 3 - }; - - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task PrependN4() - { - var xs = new[] {1, 2, 3}.ToAsyncEnumerable(); - - var res = xs.Prepend(4) - .Prepend(5) - .Prepend(6); - Assert.Equal(6, await res.Count()); - } - - [Fact] - public async Task PrependN5() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Prepend(4) - .Prepend(5) - .Prepend(6); - - var a = new[] {6, 5, 4, 1, 2, 3}; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task PrependN6() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - var res = xs.Prepend(4) - .Prepend(5) - .Prepend(6); - - var a = new List - { - 6, - 5, - 4, - 1, - 2, - 3 - }; - - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task PrependN7() - { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); - - var res = xs.Prepend(4) - .Prepend(5) - .Prepend(6); - Assert.Equal(6, await res.Count()); - } - - [Fact] public void AppendPrepend1() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs new file mode 100644 index 0000000000..a6fff733ee --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs @@ -0,0 +1,237 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Append : AsyncEnumerableTests + { + [Fact] + public void Append_Null() + { + AssertThrows(() => AsyncEnumerable.Append(null, 42)); + } + + [Fact] + public void Append1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4); + + var e = res.GetAsyncEnumerator(); + + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public async Task Append2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4); + + var a = new[] { 1, 2, 3, 4 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Append3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Append(4); + var a = new List + { + 1, + 2, + 3, + 4 + }; + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Append4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4); + Assert.Equal(4, await res.Count()); + } + + [Fact] + public async Task Append5() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Append(4); + + var a = new[] { 1, 2, 3, 4 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Append6() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Append(4); + Assert.Equal(4, await res.Count()); + } + + [Fact] + public async Task Append7() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + var res = xs.Append(4); + var a = new List + { + 1, + 2, + 3, + 4 + }; + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + + [Fact] + public void AppendN1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4) + .Append(5) + .Append(6); + + var e = res.GetAsyncEnumerator(); + + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public async Task AppendN2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4) + .Append(5) + .Append(6); + + var a = new[] { 1, 2, 3, 4, 5, 6 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task AppendN3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Append(4) + .Append(5) + .Append(6); + + var a = new List + { + 1, + 2, + 3, + 4, + 5, + 6 + }; + + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + + [Fact] + public async Task AppendN5() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Append(4) + .Append(5) + .Append(6); + + var a = new[] { 1, 2, 3, 4, 5, 6 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task AppendN6() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + var res = xs.Append(4) + .Append(5) + .Append(6); + + var a = new List + { + 1, + 2, + 3, + 4, + 5, + 6 + }; + + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task AppendN7() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Append(4) + .Append(5) + .Append(6); + Assert.Equal(6, await res.Count()); + } + + [Fact] + public async Task AppenN4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4) + .Append(5) + .Append(6); + Assert.Equal(6, await res.Count()); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs new file mode 100644 index 0000000000..d33956198d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs @@ -0,0 +1,250 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Prepend : AsyncEnumerableTests + { + [Fact] + public void Prepend_Null() + { + AssertThrows(() => AsyncEnumerable.Prepend(null, 42)); + } + + [Fact] + public void Prepend1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4); + + var e = res.GetAsyncEnumerator(); + + HasNext(e, 4); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + NoNext(e); + } + + [Fact] + public async Task Prepend2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4); + + var a = new[] { 4, 1, 2, 3 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Prepend3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Prepend(4); + var a = new List + { + 4, + 1, + 2, + 3 + }; + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + + [Fact] + public async Task Prepend4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4); + Assert.Equal(4, await res.Count()); + } + + + [Fact] + public async Task Prepend5() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Prepend(4); + + var a = new[] { 4, 1, 2, 3 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Prepend6() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + var res = xs.Prepend(4); + var a = new List + { + 4, + 1, + 2, + 3 + }; + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + + [Fact] + public async Task Prepend7() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Prepend(4); + Assert.Equal(4, await res.Count()); + } + + + [Fact] + public async Task Prepend8() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Prepend(4); + + await SequenceIdentity(res); + } + + [Fact] + public void PrependN1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4) + .Prepend(5) + .Prepend(6); + + var e = res.GetAsyncEnumerator(); + + HasNext(e, 6); + HasNext(e, 5); + HasNext(e, 4); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + NoNext(e); + } + + [Fact] + public async Task PrependN2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4) + .Prepend(5) + .Prepend(6); + + var a = new[] { 6, 5, 4, 1, 2, 3 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task PrependN3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Prepend(4) + .Prepend(5) + .Prepend(6); + + var a = new List + { + 6, + 5, + 4, + 1, + 2, + 3 + }; + + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task PrependN4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4) + .Prepend(5) + .Prepend(6); + Assert.Equal(6, await res.Count()); + } + + [Fact] + public async Task PrependN5() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Prepend(4) + .Prepend(5) + .Prepend(6); + + var a = new[] { 6, 5, 4, 1, 2, 3 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task PrependN6() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + var res = xs.Prepend(4) + .Prepend(5) + .Prepend(6); + + var a = new List + { + 6, + 5, + 4, + 1, + 2, + 3 + }; + + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task PrependN7() + { + var xs = AsyncEnumerable.Range(1, 3) + .Where(i => true); + + var res = xs.Prepend(4) + .Prepend(5) + .Prepend(6); + Assert.Equal(6, await res.Count()); + } + } +} From 9472aa9f83196a19a90473ebb13c6a6a8a924622 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:57:06 -0700 Subject: [PATCH 216/862] Cleaning up test code. --- .../System/Linq/Operators/Append.cs | 85 +++++++------------ .../System/Linq/Operators/Prepend.cs | 71 +++++----------- 2 files changed, 52 insertions(+), 104 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs index a6fff733ee..e61f88e1ea 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs @@ -51,14 +51,11 @@ public async Task Append2() public async Task Append3() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Append(4); - var a = new List - { - 1, - 2, - 3, - 4 - }; + + var a = new List { 1, 2, 3, 4 }; + var arr = await res.ToList(); Assert.Equal(a, arr); } @@ -69,14 +66,14 @@ public async Task Append4() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var res = xs.Append(4); + Assert.Equal(4, await res.Count()); } [Fact] public async Task Append5() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Append(4); @@ -89,26 +86,22 @@ public async Task Append5() [Fact] public async Task Append6() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Append(4); + Assert.Equal(4, await res.Count()); } [Fact] public async Task Append7() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + var res = xs.Append(4); - var a = new List - { - 1, - 2, - 3, - 4 - }; + + var a = new List { 1, 2, 3, 4 }; + var arr = await res.ToList(); Assert.Equal(a, arr); } @@ -153,30 +146,33 @@ public async Task AppendN2() public async Task AppendN3() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Append(4) .Append(5) .Append(6); - var a = new List - { - 1, - 2, - 3, - 4, - 5, - 6 - }; + var a = new List { 1, 2, 3, 4, 5, 6 }; var arr = await res.ToList(); Assert.Equal(a, arr); } + [Fact] + public async Task AppendN4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4) + .Append(5) + .Append(6); + + Assert.Equal(6, await res.Count()); + } [Fact] public async Task AppendN5() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Append(4) .Append(5) @@ -191,21 +187,13 @@ public async Task AppendN5() [Fact] public async Task AppendN6() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + var res = xs.Append(4) .Append(5) .Append(6); - var a = new List - { - 1, - 2, - 3, - 4, - 5, - 6 - }; + var a = new List { 1, 2, 3, 4, 5, 6 }; var arr = await res.ToList(); Assert.Equal(a, arr); @@ -214,23 +202,12 @@ public async Task AppendN6() [Fact] public async Task AppendN7() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Append(4) .Append(5) .Append(6); - Assert.Equal(6, await res.Count()); - } - [Fact] - public async Task AppenN4() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - - var res = xs.Append(4) - .Append(5) - .Append(6); Assert.Equal(6, await res.Count()); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs index d33956198d..a4f1556772 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs @@ -51,19 +51,15 @@ public async Task Prepend2() public async Task Prepend3() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Prepend(4); - var a = new List - { - 4, - 1, - 2, - 3 - }; + + var a = new List { 4, 1, 2, 3 }; + var arr = await res.ToList(); Assert.Equal(a, arr); } - [Fact] public async Task Prepend4() { @@ -73,12 +69,10 @@ public async Task Prepend4() Assert.Equal(4, await res.Count()); } - [Fact] public async Task Prepend5() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4); @@ -91,37 +85,29 @@ public async Task Prepend5() [Fact] public async Task Prepend6() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + var res = xs.Prepend(4); - var a = new List - { - 4, - 1, - 2, - 3 - }; + + var a = new List { 4, 1, 2, 3 }; + var arr = await res.ToList(); Assert.Equal(a, arr); } - [Fact] public async Task Prepend7() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4); Assert.Equal(4, await res.Count()); } - [Fact] public async Task Prepend8() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4); @@ -167,19 +153,12 @@ public async Task PrependN2() public async Task PrependN3() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Prepend(4) .Prepend(5) .Prepend(6); - var a = new List - { - 6, - 5, - 4, - 1, - 2, - 3 - }; + var a = new List { 6, 5, 4, 1, 2, 3 }; var arr = await res.ToList(); Assert.Equal(a, arr); @@ -193,14 +172,14 @@ public async Task PrependN4() var res = xs.Prepend(4) .Prepend(5) .Prepend(6); + Assert.Equal(6, await res.Count()); } [Fact] public async Task PrependN5() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4) .Prepend(5) @@ -215,21 +194,13 @@ public async Task PrependN5() [Fact] public async Task PrependN6() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + var res = xs.Prepend(4) .Prepend(5) .Prepend(6); - var a = new List - { - 6, - 5, - 4, - 1, - 2, - 3 - }; + var a = new List { 6, 5, 4, 1, 2, 3 }; var arr = await res.ToList(); Assert.Equal(a, arr); @@ -238,12 +209,12 @@ public async Task PrependN6() [Fact] public async Task PrependN7() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4) .Prepend(5) .Prepend(6); + Assert.Equal(6, await res.Count()); } } From dc627b85b5478407b7b4d7fad5dc6a45382129a8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:57:57 -0700 Subject: [PATCH 217/862] Some more cleanup. --- .../AppendPrependTests.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs index 2bf6e33018..ece24f734a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -26,7 +25,6 @@ public void AppendPrepend1() .Prepend(10); var e = res.GetAsyncEnumerator(); - HasNext(e, 10); HasNext(e, 9); @@ -94,12 +92,10 @@ public async Task AppendPrepend4() Assert.Equal(10, await res.Count()); } - [Fact] public async Task AppendPrepend5() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4) .Append(5) @@ -118,8 +114,7 @@ public async Task AppendPrepend5() [Fact] public async Task AppendPrepend6() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4) .Append(5) @@ -138,8 +133,7 @@ public async Task AppendPrepend6() [Fact] public async Task AppendPrepend7() { - var xs = AsyncEnumerable.Range(1, 3) - .Where(i => true); + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4) .Append(5) @@ -161,7 +155,7 @@ public void AppendPrepend8() .Prepend(5); var e = res.GetAsyncEnumerator(); - + HasNext(e, 5); HasNext(e, 1); HasNext(e, 2); @@ -180,6 +174,5 @@ public async Task AppendPrepend9() await SequenceIdentity(res); } - } } From dd56f5fe7f69b37442371717d2e937db6ee56595 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 21:59:24 -0700 Subject: [PATCH 218/862] Moving Buffer tests. --- .../AsyncTests.Single.cs | 74 ---------------- .../System/Linq/Operators/Buffer.cs | 88 +++++++++++++++++++ 2 files changed, 88 insertions(+), 74 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 75175bdd09..949c45a954 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -31,7 +31,6 @@ public void SelectWhere2() HasNext(e, 2); HasNext(e, 4); NoNext(e); - } [Fact] @@ -527,78 +526,5 @@ public void StartWith3() HasNext(e, 2); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } - - [Fact] - public void Buffer_Null() - { - AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1, 1)); - - AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1, 1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), 1, -1)); - } - - [Fact] - public void Buffer1() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2); - - var e = xs.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 3, 4 })); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 5 })); - - Assert.False(e.MoveNextAsync().Result); - } - - [Fact] - public void Buffer2() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2); - - var e = xs.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 1, 2, 3 })); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 3, 4, 5 })); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 5 })); - - Assert.False(e.MoveNextAsync().Result); - } - - [Fact] - public void Buffer3() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2, 3); - - var e = xs.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); - - Assert.True(e.MoveNextAsync().Result); - Assert.True(e.Current.SequenceEqual(new[] { 4, 5 })); - - Assert.False(e.MoveNextAsync().Result); - } - - [Fact] - public async Task Buffer4() - { - var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2); - - await SequenceIdentity(xs); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs new file mode 100644 index 0000000000..9726424be9 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Buffer : AsyncEnumerableExTests + { + [Fact] + public void Buffer_Null() + { + AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1, 1)); + + AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1, 1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), 1, -1)); + } + + [Fact] + public void Buffer1() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2); + + var e = xs.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 3, 4 })); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 5 })); + + Assert.False(e.MoveNextAsync().Result); + } + + [Fact] + public void Buffer2() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2); + + var e = xs.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 1, 2, 3 })); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 3, 4, 5 })); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 5 })); + + Assert.False(e.MoveNextAsync().Result); + } + + [Fact] + public void Buffer3() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2, 3); + + var e = xs.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); + + Assert.True(e.MoveNextAsync().Result); + Assert.True(e.Current.SequenceEqual(new[] { 4, 5 })); + + Assert.False(e.MoveNextAsync().Result); + } + + [Fact] + public async Task Buffer4() + { + var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2); + + await SequenceIdentity(xs); + } + } +} From c4b8bb10f99e94c1527a33b569fb058d3f4aab73 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:00:09 -0700 Subject: [PATCH 219/862] Moving StartWith tests. --- .../AsyncTests.Single.cs | 42 -------------- .../System/Linq/Operators/StartWith.cs | 56 +++++++++++++++++++ 2 files changed, 56 insertions(+), 42 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 949c45a954..c094322b7f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -484,47 +484,5 @@ public async Task IgnoreElements5() await SequenceIdentity(xs); } - - [Fact] - public void StartWith_Null() - { - AssertThrows(() => AsyncEnumerableEx.StartWith(default(IAsyncEnumerable), new[] { 1 })); - AssertThrows(() => AsyncEnumerableEx.StartWith(AsyncEnumerable.Return(42), null)); - } - - [Fact] - public void StartWith1() - { - var xs = AsyncEnumerable.Empty().StartWith(1, 2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void StartWith2() - { - var xs = AsyncEnumerable.Return(0).StartWith(1, 2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 0); - NoNext(e); - } - - [Fact] - public void StartWith3() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).StartWith(1, 2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs new file mode 100644 index 0000000000..6fdb0b79ff --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class StartWith : AsyncEnumerableExTests + { + [Fact] + public void StartWith_Null() + { + AssertThrows(() => AsyncEnumerableEx.StartWith(default(IAsyncEnumerable), new[] { 1 })); + AssertThrows(() => AsyncEnumerableEx.StartWith(AsyncEnumerable.Return(42), null)); + } + + [Fact] + public void StartWith1() + { + var xs = AsyncEnumerable.Empty().StartWith(1, 2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void StartWith2() + { + var xs = AsyncEnumerable.Return(0).StartWith(1, 2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 0); + NoNext(e); + } + + [Fact] + public void StartWith3() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex).StartWith(1, 2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From 47703e9d3665da32ce496a93592032299eb22ea2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:00:57 -0700 Subject: [PATCH 220/862] Moving IgnoreElements tests. --- .../AsyncTests.Single.cs | 57 --------------- .../System/Linq/Operators/IgnoreElements.cs | 72 +++++++++++++++++++ 2 files changed, 72 insertions(+), 57 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index c094322b7f..ed86324b1d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -427,62 +427,5 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() throw new NotImplementedException(); } } - - [Fact] - public void IgnoreElements_Null() - { - AssertThrows(() => AsyncEnumerableEx.IgnoreElements(default(IAsyncEnumerable))); - } - - [Fact] - public void IgnoreElements1() - { - var xs = AsyncEnumerable.Empty().IgnoreElements(); - - var e = xs.GetAsyncEnumerator(); - NoNext(e); - - AssertThrows(() => { var ignored = e.Current; }); - } - - [Fact] - public void IgnoreElements2() - { - var xs = AsyncEnumerable.Return(42).IgnoreElements(); - - var e = xs.GetAsyncEnumerator(); - NoNext(e); - - AssertThrows(() => { var ignored = e.Current; }); - } - - [Fact] - public void IgnoreElements3() - { - var xs = AsyncEnumerable.Range(0, 10).IgnoreElements(); - - var e = xs.GetAsyncEnumerator(); - NoNext(e); - - AssertThrows(() => { var ignored = e.Current; }); - } - - [Fact] - public void IgnoreElements4() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).IgnoreElements(); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task IgnoreElements5() - { - var xs = AsyncEnumerable.Range(0, 10).IgnoreElements(); - - await SequenceIdentity(xs); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs new file mode 100644 index 0000000000..2ef60a4b05 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class IgnoreElements : AsyncEnumerableExTests + { + [Fact] + public void IgnoreElements_Null() + { + AssertThrows(() => AsyncEnumerableEx.IgnoreElements(default(IAsyncEnumerable))); + } + + [Fact] + public void IgnoreElements1() + { + var xs = AsyncEnumerable.Empty().IgnoreElements(); + + var e = xs.GetAsyncEnumerator(); + NoNext(e); + + AssertThrows(() => { var ignored = e.Current; }); + } + + [Fact] + public void IgnoreElements2() + { + var xs = AsyncEnumerable.Return(42).IgnoreElements(); + + var e = xs.GetAsyncEnumerator(); + NoNext(e); + + AssertThrows(() => { var ignored = e.Current; }); + } + + [Fact] + public void IgnoreElements3() + { + var xs = AsyncEnumerable.Range(0, 10).IgnoreElements(); + + var e = xs.GetAsyncEnumerator(); + NoNext(e); + + AssertThrows(() => { var ignored = e.Current; }); + } + + [Fact] + public void IgnoreElements4() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex).IgnoreElements(); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task IgnoreElements5() + { + var xs = AsyncEnumerable.Range(0, 10).IgnoreElements(); + + await SequenceIdentity(xs); + } + } +} From da0cec9c9a7d4829d8873dadbec0083ca5ad5267 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:02:45 -0700 Subject: [PATCH 221/862] Moving Do tests. --- .../AsyncTests.Single.cs | 163 ---------------- .../System/Linq/Operators/Do.cs | 177 ++++++++++++++++++ 2 files changed, 177 insertions(+), 163 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index ed86324b1d..3d04a454ed 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -57,169 +57,6 @@ public void WhereSelect3() NoNext(e); } - [Fact] - public void Do_Null() - { - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action))); - - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); - - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); - - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action), () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, ex => { }, default(Action))); - - AssertThrows(() => AsyncEnumerableEx.Do(null, new MyObs())); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(IObserver))); - } - - class MyObs : IObserver - { - public void OnCompleted() - { - throw new NotImplementedException(); - } - - public void OnError(Exception error) - { - throw new NotImplementedException(); - } - - public void OnNext(int value) - { - throw new NotImplementedException(); - } - } - - [Fact] - public void Do1() - { - var sum = 0; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Do(x => sum += x); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - Assert.Equal(1, sum); - HasNext(e, 2); - Assert.Equal(3, sum); - HasNext(e, 3); - Assert.Equal(6, sum); - HasNext(e, 4); - Assert.Equal(10, sum); - NoNext(e); - } - - [Fact] - public void Do2() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Do(x => { throw ex; }); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Do3() - { - var sum = 0; - var fail = false; - var done = false; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Do(x => sum += x, ex => { fail = true; }, () => { done = true; }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - Assert.Equal(1, sum); - HasNext(e, 2); - Assert.Equal(3, sum); - HasNext(e, 3); - Assert.Equal(6, sum); - HasNext(e, 4); - Assert.Equal(10, sum); - NoNext(e); - - Assert.False(fail); - Assert.True(done); - } - - [Fact] - public void Do4() - { - var sum = 0; - var done = false; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Do(x => sum += x, () => { done = true; }); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - Assert.Equal(1, sum); - HasNext(e, 2); - Assert.Equal(3, sum); - HasNext(e, 3); - Assert.Equal(6, sum); - HasNext(e, 4); - Assert.Equal(10, sum); - NoNext(e); - - Assert.True(done); - } - - [Fact] - public void Do5() - { - var ex = new Exception("Bang"); - var exa = default(Exception); - var done = false; - var hasv = false; - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }, () => { done = true; }); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); - - Assert.False(hasv); - Assert.False(done); - Assert.Same(exa, ex); - } - - [Fact] - public void Do6() - { - var ex = new Exception("Bang"); - var exa = default(Exception); - var hasv = false; - var xs = AsyncEnumerable.Throw(ex); - var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); - - Assert.False(hasv); - Assert.Same(exa, ex); - } - - [Fact] - public async Task Do7() - { - var sum = 0; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Do(x => sum += x); - - await SequenceIdentity(ys); - - Assert.Equal(20, sum); - } - [Fact] public async Task ForEachAsync_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs new file mode 100644 index 0000000000..21cfba9e16 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -0,0 +1,177 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Do : AsyncEnumerableExTests + { + [Fact] + public void Do_Null() + { + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action))); + + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); + + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); + + AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action), () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, ex => { }, default(Action))); + + AssertThrows(() => AsyncEnumerableEx.Do(null, new MyObs())); + AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(IObserver))); + } + + [Fact] + public void Do1() + { + var sum = 0; + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Do(x => sum += x); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + Assert.Equal(1, sum); + HasNext(e, 2); + Assert.Equal(3, sum); + HasNext(e, 3); + Assert.Equal(6, sum); + HasNext(e, 4); + Assert.Equal(10, sum); + NoNext(e); + } + + [Fact] + public void Do2() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Do(x => { throw ex; }); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Do3() + { + var sum = 0; + var fail = false; + var done = false; + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Do(x => sum += x, ex => { fail = true; }, () => { done = true; }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + Assert.Equal(1, sum); + HasNext(e, 2); + Assert.Equal(3, sum); + HasNext(e, 3); + Assert.Equal(6, sum); + HasNext(e, 4); + Assert.Equal(10, sum); + NoNext(e); + + Assert.False(fail); + Assert.True(done); + } + + [Fact] + public void Do4() + { + var sum = 0; + var done = false; + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Do(x => sum += x, () => { done = true; }); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + Assert.Equal(1, sum); + HasNext(e, 2); + Assert.Equal(3, sum); + HasNext(e, 3); + Assert.Equal(6, sum); + HasNext(e, 4); + Assert.Equal(10, sum); + NoNext(e); + + Assert.True(done); + } + + [Fact] + public void Do5() + { + var ex = new Exception("Bang"); + var exa = default(Exception); + var done = false; + var hasv = false; + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }, () => { done = true; }); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); + + Assert.False(hasv); + Assert.False(done); + Assert.Same(exa, ex); + } + + [Fact] + public void Do6() + { + var ex = new Exception("Bang"); + var exa = default(Exception); + var hasv = false; + var xs = AsyncEnumerable.Throw(ex); + var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); + + Assert.False(hasv); + Assert.Same(exa, ex); + } + + [Fact] + public async Task Do7() + { + var sum = 0; + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.Do(x => sum += x); + + await SequenceIdentity(ys); + + Assert.Equal(20, sum); + } + + private sealed class MyObs : IObserver + { + public void OnCompleted() + { + throw new NotImplementedException(); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnNext(int value) + { + throw new NotImplementedException(); + } + } + } +} From 4ac18e26ac16b68f96aae649f97a73a07d11855a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:12:35 -0700 Subject: [PATCH 222/862] Moving ForEachAsync tests. --- .../AsyncTests.Single.cs | 70 --------------- .../System/Linq/Operators/ForEachAsync.cs | 85 +++++++++++++++++++ 2 files changed, 85 insertions(+), 70 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 3d04a454ed..2b98926908 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -57,76 +57,6 @@ public void WhereSelect3() NoNext(e); } - [Fact] - public async Task ForEachAsync_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, x => { })); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, (x, i) => { })); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, x => { }, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, (x, i) => { }, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); - } - - [Fact] - public void ForEachAsync1() - { - var sum = 0; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - - xs.ForEachAsync(x => sum += x).Wait(WaitTimeoutMs); - Assert.Equal(10, sum); - } - - [Fact] - public void ForEachAsync2() - { - var sum = 0; - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - - xs.ForEachAsync((x, i) => sum += x * i).Wait(WaitTimeoutMs); - Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum); - } - - [Fact] - public void ForEachAsync3() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void ForEachAsync4() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void ForEachAsync5() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void ForEachAsync6() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public void AsAsyncEnumerable_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs new file mode 100644 index 0000000000..5446233a12 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -0,0 +1,85 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ForEachAsync : AsyncEnumerableTests + { + [Fact] + public async Task ForEachAsync_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, x => { })); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, (x, i) => { })); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, x => { }, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, (x, i) => { }, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); + } + + [Fact] + public void ForEachAsync1() + { + var sum = 0; + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + + xs.ForEachAsync(x => sum += x).Wait(WaitTimeoutMs); + Assert.Equal(10, sum); + } + + [Fact] + public void ForEachAsync2() + { + var sum = 0; + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + + xs.ForEachAsync((x, i) => sum += x * i).Wait(WaitTimeoutMs); + Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum); + } + + [Fact] + public void ForEachAsync3() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + + AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void ForEachAsync4() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + + AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void ForEachAsync5() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + + AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void ForEachAsync6() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + + AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From 48a01d05764b1a3b2cf21271ad9ab4834deb257b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:13:50 -0700 Subject: [PATCH 223/862] Moving AsAsyncEnumerable tests. --- .../AsyncTests.Single.cs | 20 ----------- .../Linq/Operators/AsAsyncEnumerable.cs | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 2b98926908..d6a40430f9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Xunit; @@ -57,25 +56,6 @@ public void WhereSelect3() NoNext(e); } - [Fact] - public void AsAsyncEnumerable_Null() - { - AssertThrows(() => AsyncEnumerable.AsAsyncEnumerable((IAsyncEnumerable)null)); - } - - [Fact] - public void AsAsyncEnumerable1() - { - var xs = AsyncEnumerable.Return(42); - var ys = xs.AsAsyncEnumerable(); - - Assert.NotSame(xs, ys); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); - } - [Fact] public void RepeatSeq_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs new file mode 100644 index 0000000000..8342d8d1da --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class AsAsyncEnumerable : AsyncEnumerableTests + { + [Fact] + public void AsAsyncEnumerable_Null() + { + AssertThrows(() => AsyncEnumerable.AsAsyncEnumerable((IAsyncEnumerable)null)); + } + + [Fact] + public void AsAsyncEnumerable1() + { + var xs = AsyncEnumerable.Return(42); + var ys = xs.AsAsyncEnumerable(); + + Assert.NotSame(xs, ys); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 42); + NoNext(e); + } + } +} From bfb1487bb76e95724bee05bec7139da4ef8d52e5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:15:18 -0700 Subject: [PATCH 224/862] Moving Catch tests. --- .../AsyncTests.Exceptions.cs | 284 ----------------- .../System/Linq/Operators/Catch.cs | 299 ++++++++++++++++++ 2 files changed, 299 insertions(+), 284 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index 1c6f6d90b9..0c535ee087 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -12,290 +12,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void Catch_Null() - { - AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(Func>))); - - AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable[]))); - AssertThrows(() => AsyncEnumerableEx.Catch(default(IEnumerable>))); - } - - [Fact] - public void Catch1() - { - var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = xs.Catch(ex_ => { err = true; return ys; }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); - - Assert.False(err); - } - - [Fact] - public void Catch2() - { - var ex = new InvalidOperationException("Bang!"); - - var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = xs.Catch(ex_ => { err = true; return ys; }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - Assert.False(err); - - HasNext(e, 4); - - Assert.True(err); - - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void Catch3() - { - var ex = new InvalidOperationException("Bang!"); - - var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = xs.Catch(ex_ => { err = true; return ys; }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - Assert.False(err); - - HasNext(e, 4); - - Assert.True(err); - - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void Catch4() - { - var ex = new DivideByZeroException(); - - var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = xs.Catch(ex_ => { err = true; return ys; }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - - Assert.False(err); - } - - [Fact] - public void Catch5() - { - var ex = new InvalidOperationException("Bang!"); - var ex2 = new Exception("Oops!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = xs.Catch(ex_ => { if (ex_.Message == "Bang!") throw ex2; return ys; }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex2); - } - - [Fact] - public void Catch6() - { - var ex = new InvalidOperationException("Bang!"); - - var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - - var res = xs.Catch(ex_ => { err = true; return xs; }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - Assert.False(err); - - HasNext(e, 1); - - Assert.True(err); - - HasNext(e, 2); - HasNext(e, 3); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Catch7() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.Catch(xs, ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); - } - - [Fact] - public void Catch8() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.Catch(xs, ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void Catch9() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void Catch10() - { - var res = CatchXss().Catch(); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - } - - private IEnumerable> CatchXss() - { - yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(new Exception("!!!"))); - throw new Exception("Bang!"); - } - - [Fact] - public void Catch11() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - - var res = AsyncEnumerableEx.Catch(new[] { xs, xs }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Catch12() - { - var res = AsyncEnumerableEx.Catch(Enumerable.Empty>()); - - var e = res.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public async Task Catch13() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); - - await SequenceIdentity(res); - } - - [Fact] - public async Task Catch14() - { - var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = xs.Catch(ex_ => { err = true; return ys; }); - - await SequenceIdentity(res); - - Assert.False(err); - } - [Fact] public void Finally_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs new file mode 100644 index 0000000000..55c9186dde --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -0,0 +1,299 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Catch : AsyncEnumerableExTests + { + [Fact] + public void Catch_Null() + { + AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(Func>))); + + AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerableEx.Catch(default(IEnumerable>))); + } + + [Fact] + public void Catch1() + { + var err = false; + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = xs.Catch(ex_ => { err = true; return ys; }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + NoNext(e); + + Assert.False(err); + } + + [Fact] + public void Catch2() + { + var ex = new InvalidOperationException("Bang!"); + + var err = false; + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = xs.Catch(ex_ => { err = true; return ys; }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + Assert.False(err); + + HasNext(e, 4); + + Assert.True(err); + + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void Catch3() + { + var ex = new InvalidOperationException("Bang!"); + + var err = false; + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = xs.Catch(ex_ => { err = true; return ys; }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + Assert.False(err); + + HasNext(e, 4); + + Assert.True(err); + + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void Catch4() + { + var ex = new DivideByZeroException(); + + var err = false; + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = xs.Catch(ex_ => { err = true; return ys; }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + + Assert.False(err); + } + + [Fact] + public void Catch5() + { + var ex = new InvalidOperationException("Bang!"); + var ex2 = new Exception("Oops!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = xs.Catch(ex_ => { if (ex_.Message == "Bang!") throw ex2; return ys; }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex2); + } + + [Fact] + public void Catch6() + { + var ex = new InvalidOperationException("Bang!"); + + var err = false; + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + + var res = xs.Catch(ex_ => { err = true; return xs; }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + Assert.False(err); + + HasNext(e, 1); + + Assert.True(err); + + HasNext(e, 2); + HasNext(e, 3); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Catch7() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.Catch(xs, ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + NoNext(e); + } + + [Fact] + public void Catch8() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.Catch(xs, ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void Catch9() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void Catch10() + { + var res = CatchXss().Catch(); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + } + + private IEnumerable> CatchXss() + { + yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(new Exception("!!!"))); + throw new Exception("Bang!"); + } + + [Fact] + public void Catch11() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + + var res = AsyncEnumerableEx.Catch(new[] { xs, xs }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Catch12() + { + var res = AsyncEnumerableEx.Catch(Enumerable.Empty>()); + + var e = res.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public async Task Catch13() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); + + await SequenceIdentity(res); + } + + [Fact] + public async Task Catch14() + { + var err = false; + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = xs.Catch(ex_ => { err = true; return ys; }); + + await SequenceIdentity(res); + + Assert.False(err); + } + } +} From a5cca272d5e18c6e0251e880e45203111645d3ab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:15:59 -0700 Subject: [PATCH 225/862] Moving Finally tests. --- .../AsyncTests.Exceptions.cs | 106 ---------------- .../System/Linq/Operators/Finally.cs | 120 ++++++++++++++++++ 2 files changed, 120 insertions(+), 106 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index 0c535ee087..93c9700a6e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -12,112 +12,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void Finally_Null() - { - AssertThrows(() => AsyncEnumerableEx.Finally(default(IAsyncEnumerable), () => { })); - AssertThrows(() => AsyncEnumerableEx.Finally(AsyncEnumerable.Return(42), null)); - } - - [Fact] - public void Finally1() - { - var b = false; - - var xs = AsyncEnumerable.Empty().Finally(() => { b = true; }); - - var e = xs.GetAsyncEnumerator(); - - Assert.False(b); - NoNext(e); - - Assert.True(b); - } - - [Fact] - public void Finally2() - { - var b = false; - - var xs = AsyncEnumerable.Return(42).Finally(() => { b = true; }); - - var e = xs.GetAsyncEnumerator(); - - Assert.False(b); - HasNext(e, 42); - - Assert.False(b); - NoNext(e); - - Assert.True(b); - } - - [Fact] - public void Finally3() - { - var ex = new Exception("Bang!"); - - var b = false; - - var xs = AsyncEnumerable.Throw(ex).Finally(() => { b = true; }); - - var e = xs.GetAsyncEnumerator(); - - Assert.False(b); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - - Assert.True(b); - } - - [Fact] - public void Finally4() - { - var b = false; - - var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); - - var e = xs.GetAsyncEnumerator(); - - Assert.False(b); - HasNext(e, 1); - - Assert.False(b); - HasNext(e, 2); - - Assert.False(b); - NoNext(e); - - Assert.True(b); - } - - [Fact] - public async Task Finally5() - { - var b = false; - - var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); - - var e = xs.GetAsyncEnumerator(); - - Assert.False(b); - HasNext(e, 1); - - await e.DisposeAsync(); - - Assert.True(b); - } - - [Fact] - public async Task Finally7() - { - var i = 0; - var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { i++; }); - - await SequenceIdentity(xs); - Assert.Equal(2, i); - } - - [Fact] public void OnErrorResumeNext_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs new file mode 100644 index 0000000000..bee0ba2429 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -0,0 +1,120 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Finally : AsyncEnumerableExTests + { + [Fact] + public void Finally_Null() + { + AssertThrows(() => AsyncEnumerableEx.Finally(default(IAsyncEnumerable), () => { })); + AssertThrows(() => AsyncEnumerableEx.Finally(AsyncEnumerable.Return(42), null)); + } + + [Fact] + public void Finally1() + { + var b = false; + + var xs = AsyncEnumerable.Empty().Finally(() => { b = true; }); + + var e = xs.GetAsyncEnumerator(); + + Assert.False(b); + NoNext(e); + + Assert.True(b); + } + + [Fact] + public void Finally2() + { + var b = false; + + var xs = AsyncEnumerable.Return(42).Finally(() => { b = true; }); + + var e = xs.GetAsyncEnumerator(); + + Assert.False(b); + HasNext(e, 42); + + Assert.False(b); + NoNext(e); + + Assert.True(b); + } + + [Fact] + public void Finally3() + { + var ex = new Exception("Bang!"); + + var b = false; + + var xs = AsyncEnumerable.Throw(ex).Finally(() => { b = true; }); + + var e = xs.GetAsyncEnumerator(); + + Assert.False(b); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + + Assert.True(b); + } + + [Fact] + public void Finally4() + { + var b = false; + + var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); + + var e = xs.GetAsyncEnumerator(); + + Assert.False(b); + HasNext(e, 1); + + Assert.False(b); + HasNext(e, 2); + + Assert.False(b); + NoNext(e); + + Assert.True(b); + } + + [Fact] + public async Task Finally5() + { + var b = false; + + var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { b = true; }); + + var e = xs.GetAsyncEnumerator(); + + Assert.False(b); + HasNext(e, 1); + + await e.DisposeAsync(); + + Assert.True(b); + } + + [Fact] + public async Task Finally7() + { + var i = 0; + var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { i++; }); + + await SequenceIdentity(xs); + Assert.Equal(2, i); + } + } +} From df53ab24ed2a8f1ac805c197aaa0874910b1c469 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:17:10 -0700 Subject: [PATCH 226/862] Moving OnErrorResumeNext tests. --- .../AsyncTests.Exceptions.cs | 131 ---------------- .../Linq/Operators/OnErrorResumeNext.cs | 146 ++++++++++++++++++ 2 files changed, 146 insertions(+), 131 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index 93c9700a6e..f90e33ee35 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -12,137 +12,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void OnErrorResumeNext_Null() - { - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable[]))); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IEnumerable>))); - } - - [Fact] - public void OnErrorResumeNext7() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void OnErrorResumeNext8() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void OnErrorResumeNext9() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs, ys, ys }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void OnErrorResumeNext10() - { - var res = OnErrorResumeNextXss().OnErrorResumeNext(); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - } - - private IEnumerable> OnErrorResumeNextXss() - { - yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(new Exception("!!!"))); - throw new Exception("Bang!"); - } - - [Fact] - public void OnErrorResumeNext11() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - - var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); - } - - [Fact] - public void OnErrorResumeNext12() - { - var res = AsyncEnumerableEx.OnErrorResumeNext(Enumerable.Empty>()); - - var e = res.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public async Task OnErrorResumeNext13() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - - var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); - - await SequenceIdentity(res); - } - [Fact] public void Retry_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs new file mode 100644 index 0000000000..46b41ded6e --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -0,0 +1,146 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class OnErrorResumeNext : AsyncEnumerableExTests + { + [Fact] + public void OnErrorResumeNext_Null() + { + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IEnumerable>))); + } + + [Fact] + public void OnErrorResumeNext7() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void OnErrorResumeNext8() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void OnErrorResumeNext9() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs, ys, ys }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void OnErrorResumeNext10() + { + var res = OnErrorResumeNextXss().OnErrorResumeNext(); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + } + + private IEnumerable> OnErrorResumeNextXss() + { + yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(new Exception("!!!"))); + throw new Exception("Bang!"); + } + + [Fact] + public void OnErrorResumeNext11() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + + var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + NoNext(e); + } + + [Fact] + public void OnErrorResumeNext12() + { + var res = AsyncEnumerableEx.OnErrorResumeNext(Enumerable.Empty>()); + + var e = res.GetAsyncEnumerator(); + NoNext(e); + } + + [Fact] + public async Task OnErrorResumeNext13() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); + + await SequenceIdentity(res); + } + } +} From 5afbba5508365fb2f4fe3554ce2c594eb32f4bce Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:17:56 -0700 Subject: [PATCH 227/862] Moving Retry tests. --- .../AsyncTests.Exceptions.cs | 43 -------------- .../System/Linq/Operators/Retry.cs | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 43 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs index f90e33ee35..85b36014d9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs @@ -12,48 +12,5 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void Retry_Null() - { - AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable))); - - AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable), 1)); - AssertThrows(() => AsyncEnumerableEx.Retry(AsyncEnumerable.Return(42), -1)); - } - - [Fact] - public void Retry1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - - var res = xs.Retry(); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); - } - - [Fact] - public void Retry2() - { - var ex = new InvalidOperationException("Bang!"); - - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - - var res = xs.Retry(); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs new file mode 100644 index 0000000000..8563a80eda --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Retry : AsyncEnumerableExTests + { + [Fact] + public void Retry_Null() + { + AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable))); + + AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable), 1)); + AssertThrows(() => AsyncEnumerableEx.Retry(AsyncEnumerable.Return(42), -1)); + } + + [Fact] + public void Retry1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Retry(); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + NoNext(e); + } + + [Fact] + public void Retry2() + { + var ex = new InvalidOperationException("Bang!"); + + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + + var res = xs.Retry(); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + } + } +} From 86b533fb8290c5fcfcbb593bb84d68a7affef741 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:18:10 -0700 Subject: [PATCH 228/862] Removing unused tests file. --- .../AsyncTests.Exceptions.cs | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs deleted file mode 100644 index 85b36014d9..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Exceptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Xunit; - -namespace Tests -{ - public partial class AsyncTests - { - } -} From a6a731686700ac83a3a758ba1a23c8bc47d3e2d9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:19:50 -0700 Subject: [PATCH 229/862] Moving Zip tests. --- .../AsyncTests.Multiple.cs | 96 --------------- .../System/Linq/Operators/Zip.cs | 110 ++++++++++++++++++ 2 files changed, 110 insertions(+), 96 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index 1d795ac6e2..8242b07f6a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -210,102 +210,6 @@ static IEnumerable> ConcatXss() throw new Exception("Bang!"); } - [Fact] - public void Zip_Null() - { - AssertThrows(() => AsyncEnumerable.Zip(null, AsyncEnumerable.Return(42), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), null, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func))); - } - - [Fact] - public void Zip1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = xs.Zip(ys, (x, y) => x * y); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1 * 4); - HasNext(e, 2 * 5); - HasNext(e, 3 * 6); - NoNext(e); - } - - [Fact] - public void Zip2() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); - var res = xs.Zip(ys, (x, y) => x * y); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1 * 4); - HasNext(e, 2 * 5); - HasNext(e, 3 * 6); - NoNext(e); - } - - [Fact] - public void Zip3() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = xs.Zip(ys, (x, y) => x * y); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1 * 4); - HasNext(e, 2 * 5); - HasNext(e, 3 * 6); - NoNext(e); - } - - [Fact] - public void Zip4() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); - var res = xs.Zip(ys, (x, y) => x * y); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Zip5() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.Zip(ys, (x, y) => x * y); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Zip6() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; }); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Zip7() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); - var res = xs.Zip(ys, (x, y) => x * y); - - await SequenceIdentity(res); - } - [Fact] public void Union_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs new file mode 100644 index 0000000000..008825521c --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -0,0 +1,110 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Zip : AsyncEnumerableTests + { + [Fact] + public void Zip_Null() + { + AssertThrows(() => AsyncEnumerable.Zip(null, AsyncEnumerable.Return(42), (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), null, (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func))); + } + + [Fact] + public void Zip1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.Zip(ys, (x, y) => x * y); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1 * 4); + HasNext(e, 2 * 5); + HasNext(e, 3 * 6); + NoNext(e); + } + + [Fact] + public void Zip2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); + var res = xs.Zip(ys, (x, y) => x * y); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1 * 4); + HasNext(e, 2 * 5); + HasNext(e, 3 * 6); + NoNext(e); + } + + [Fact] + public void Zip3() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.Zip(ys, (x, y) => x * y); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1 * 4); + HasNext(e, 2 * 5); + HasNext(e, 3 * 6); + NoNext(e); + } + + [Fact] + public void Zip4() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = AsyncEnumerable.Throw(ex); + var res = xs.Zip(ys, (x, y) => x * y); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Zip5() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.Zip(ys, (x, y) => x * y); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Zip6() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; }); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task Zip7() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.Zip(ys, (x, y) => x * y); + + await SequenceIdentity(res); + } + } +} From c20d4c255735407e0f8246523f0adfddf06100cd Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:23:25 -0700 Subject: [PATCH 230/862] Moving Except, Intersect, and Union tests. --- .../AsyncTests.Multiple.cs | 136 ------------------ .../System/Linq/Operators/Except.cs | 73 ++++++++++ .../System/Linq/Operators/Intersect.cs | 75 ++++++++++ .../System/Linq/Operators/Union.cs | 70 +++++++++ 4 files changed, 218 insertions(+), 136 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index 8242b07f6a..0604c5b2c6 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -210,142 +210,6 @@ static IEnumerable> ConcatXss() throw new Exception("Bang!"); } - [Fact] - public void Union_Null() - { - AssertThrows(() => AsyncEnumerable.Union(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), null)); - - AssertThrows(() => AsyncEnumerable.Union(null, AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), null, new Eq())); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); - } - - [Fact] - public void Union1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); - var res = xs.Union(ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Union2() - { - var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); - var res = xs.Union(ys, new Eq()); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, -3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void Intersect_Null() - { - AssertThrows(() => AsyncEnumerable.Intersect(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), null)); - - AssertThrows(() => AsyncEnumerable.Intersect(null, AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), null, new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); - } - - [Fact] - public void Intersect1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); - var res = xs.Intersect(ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 3); - NoNext(e); - } - - [Fact] - public void Intersect2() - { - var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); - var res = xs.Intersect(ys, new Eq()); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, -3); - NoNext(e); - } - - [Fact] - public async Task Intersect3() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); - var res = xs.Intersect(ys); - - await SequenceIdentity(res); - } - - - [Fact] - public void Except_Null() - { - AssertThrows(() => AsyncEnumerable.Except(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), null)); - - AssertThrows(() => AsyncEnumerable.Except(null, AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), null, new Eq())); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); - } - - [Fact] - public void Except1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); - var res = xs.Except(ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void Except2() - { - var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); - var res = xs.Except(ys, new Eq()); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public async Task Except3() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); - var res = xs.Except(ys); - - await SequenceIdentity(res); - } - [Fact] public async Task SequenceEqual_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs new file mode 100644 index 0000000000..b6a314eb54 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Except : AsyncEnumerableTests + { + [Fact] + public void Except_Null() + { + AssertThrows(() => AsyncEnumerable.Except(null, AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), null)); + + AssertThrows(() => AsyncEnumerable.Except(null, AsyncEnumerable.Return(42), new Eq())); + AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), null, new Eq())); + AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + } + + [Fact] + public void Except1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); + var res = xs.Except(ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void Except2() + { + var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); + var res = xs.Except(ys, new Eq()); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public async Task Except3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); + var res = xs.Except(ys); + + await SequenceIdentity(res); + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs new file mode 100644 index 0000000000..7a4220e656 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Intersect : AsyncEnumerableTests + { + [Fact] + public void Intersect_Null() + { + AssertThrows(() => AsyncEnumerable.Intersect(null, AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), null)); + + AssertThrows(() => AsyncEnumerable.Intersect(null, AsyncEnumerable.Return(42), new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), null, new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + } + + [Fact] + public void Intersect1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); + var res = xs.Intersect(ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 3); + NoNext(e); + } + + [Fact] + public void Intersect2() + { + var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); + var res = xs.Intersect(ys, new Eq()); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, -3); + NoNext(e); + } + + [Fact] + public async Task Intersect3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); + var res = xs.Intersect(ys); + + await SequenceIdentity(res); + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs new file mode 100644 index 0000000000..b96c0fbcdc --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -0,0 +1,70 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Union : AsyncEnumerableTests + { + [Fact] + public void Union_Null() + { + AssertThrows(() => AsyncEnumerable.Union(null, AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), null)); + + AssertThrows(() => AsyncEnumerable.Union(null, AsyncEnumerable.Return(42), new Eq())); + AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), null, new Eq())); + AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + } + + [Fact] + public void Union1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); + var res = xs.Union(ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 5); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void Union2() + { + var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); + var res = xs.Union(ys, new Eq()); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, -3); + HasNext(e, 5); + HasNext(e, 4); + NoNext(e); + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} From cd324ece2dd4fb69e7b2fd394ab510017d070bc2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:25:33 -0700 Subject: [PATCH 231/862] Moving SequenceEqual tests. --- .../AsyncTests.Multiple.cs | 179 --------------- .../System/Linq/Operators/SequenceEqual.cs | 208 ++++++++++++++++++ 2 files changed, 208 insertions(+), 179 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index 0604c5b2c6..73cd7f19f3 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -210,185 +210,6 @@ static IEnumerable> ConcatXss() throw new Exception("Bang!"); } - [Fact] - public async Task SequenceEqual_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, CancellationToken.None)); - } - - [Fact] - public void SequenceEqual1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(xs); - Assert.True(res.Result); - } - - [Fact] - public void SequenceEqual2() - { - var xs = AsyncEnumerable.Empty(); - var res = xs.SequenceEqual(xs); - Assert.True(res.Result); - } - - [Fact] - public void SequenceEqual3() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); - Assert.False(res.Result); - } - - [Fact] - public void SequenceEqual4() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); - Assert.False(res.Result); - } - - [Fact] - public void SequenceEqual5() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); - Assert.False(res.Result); - } - - [Fact] - public void SequenceEqual6() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); - var res = xs.SequenceEqual(ys); - - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SequenceEqual7() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); - - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SequenceEqual8() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(xs, new Eq()); - Assert.True(res.Result); - } - - [Fact] - public void SequenceEqual9() - { - var xs = AsyncEnumerable.Empty(); - var res = xs.SequenceEqual(xs, new Eq()); - Assert.True(res.Result); - } - - [Fact] - public void SequenceEqual10() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); - Assert.False(res.Result); - } - - [Fact] - public void SequenceEqual11() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); - Assert.False(res.Result); - } - - [Fact] - public void SequenceEqual12() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); - Assert.False(res.Result); - } - - [Fact] - public void SequenceEqual13() - { - var ex = new Exception("Bang!"); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); - var res = xs.SequenceEqual(ys, new Eq()); - - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SequenceEqual14() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); - - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void SequenceEqual15() - { - var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); - var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); - Assert.True(res.Result); - } - - [Fact] - public void SequenceEqual16() - { - var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); - var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new EqEx()); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); - } - - class EqEx : IEqualityComparer - { - public bool Equals(int x, int y) - { - throw new NotImplementedException(); - } - - public int GetHashCode(int obj) - { - throw new NotImplementedException(); - } - } - [Fact] public void GroupJoin_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs new file mode 100644 index 0000000000..63f4ba2f2d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -0,0 +1,208 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class SequenceEqual : AsyncEnumerableTests + { + [Fact] + public async Task SequenceEqual_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, CancellationToken.None)); + } + + [Fact] + public void SequenceEqual1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(xs); + Assert.True(res.Result); + } + + [Fact] + public void SequenceEqual2() + { + var xs = AsyncEnumerable.Empty(); + var res = xs.SequenceEqual(xs); + Assert.True(res.Result); + } + + [Fact] + public void SequenceEqual3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys); + Assert.False(res.Result); + } + + [Fact] + public void SequenceEqual4() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys); + Assert.False(res.Result); + } + + [Fact] + public void SequenceEqual5() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys); + Assert.False(res.Result); + } + + [Fact] + public void SequenceEqual6() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = AsyncEnumerable.Throw(ex); + var res = xs.SequenceEqual(ys); + + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SequenceEqual7() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys); + + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SequenceEqual8() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(xs, new Eq()); + Assert.True(res.Result); + } + + [Fact] + public void SequenceEqual9() + { + var xs = AsyncEnumerable.Empty(); + var res = xs.SequenceEqual(xs, new Eq()); + Assert.True(res.Result); + } + + [Fact] + public void SequenceEqual10() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys, new Eq()); + Assert.False(res.Result); + } + + [Fact] + public void SequenceEqual11() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys, new Eq()); + Assert.False(res.Result); + } + + [Fact] + public void SequenceEqual12() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys, new Eq()); + Assert.False(res.Result); + } + + [Fact] + public void SequenceEqual13() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = AsyncEnumerable.Throw(ex); + var res = xs.SequenceEqual(ys, new Eq()); + + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SequenceEqual14() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys, new Eq()); + + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void SequenceEqual15() + { + var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys, new Eq()); + Assert.True(res.Result); + } + + [Fact] + public void SequenceEqual16() + { + var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.SequenceEqual(ys, new EqEx()); + AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + } + + private sealed class EqEx : IEqualityComparer + { + public bool Equals(int x, int y) + { + throw new NotImplementedException(); + } + + public int GetHashCode(int obj) + { + throw new NotImplementedException(); + } + } + + private sealed class Eq : IEqualityComparer + { + public bool Equals(int x, int y) + { + return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + } + } + } +} From 30ffc6c930653ef4ae68718d866ef2ed35d98f79 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:25:46 -0700 Subject: [PATCH 232/862] Removing dead test code. --- .../AsyncTests.Multiple.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index 73cd7f19f3..e1eb3abcec 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -623,18 +623,5 @@ public override int GetHashCode() public int OrderId { get; set; } public string CustomerId { get; set; } } - - private sealed class Eq : IEqualityComparer - { - public bool Equals(int x, int y) - { - return EqualityComparer.Default.Equals(Math.Abs(x), Math.Abs(y)); - } - - public int GetHashCode(int obj) - { - return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); - } - } } } From 81781316056fce451396de9d6268af5b4d96a162 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:26:57 -0700 Subject: [PATCH 233/862] Moving SelectMany tests. --- .../AsyncTests.Multiple.cs | 27 ------------- .../System/Linq/Operators/SelectMany.cs | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index e1eb3abcec..051efcb299 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -546,33 +546,6 @@ public void Join12() NoNext(e); } - - [Fact] - public void SelectManyMultiple_Null() - { - AssertThrows(() => AsyncEnumerableEx.SelectMany(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerableEx.SelectMany(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - } - - [Fact] - public void SelectManyMultiple1() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 4 }.ToAsyncEnumerable(); - - var res = xs.SelectMany(ys); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - public class Customer { public string CustomerId { get; set; } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs new file mode 100644 index 0000000000..449b925d07 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class SelectMany : AsyncEnumerableExTests + { + [Fact] + public void SelectMany_Null() + { + AssertThrows(() => AsyncEnumerableEx.SelectMany(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerableEx.SelectMany(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + } + + [Fact] + public void SelectMany1() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 4 }.ToAsyncEnumerable(); + + var res = xs.SelectMany(ys); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + } +} From fada7bbe58507321af4ccebf3b0c3e98b7ca8f84 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:31:10 -0700 Subject: [PATCH 234/862] Moving Concat tests. --- .../AsyncTests.Multiple.cs | 197 ---------------- .../System/Linq/Operators/Concat.cs | 211 ++++++++++++++++++ 2 files changed, 211 insertions(+), 197 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index 051efcb299..d311996dd9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Xunit; @@ -14,202 +13,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void Concat_Null() - { - AssertThrows(() => AsyncEnumerable.Concat(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Concat(AsyncEnumerable.Return(42), null)); - AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable[]))); - AssertThrows(() => AsyncEnumerable.Concat(default(IEnumerable>))); - } - - [Fact] - public void Concat1() - { - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void Concat2() - { - var ex = new Exception("Bang"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); - - var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Concat3() - { - var ex = new Exception("Bang"); - var ys = AsyncEnumerable.Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); - - var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Concat4() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - - var res = AsyncEnumerable.Concat(xs, ys, zs); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 8); - NoNext(e); - } - - [Fact] - public void Concat5() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = AsyncEnumerable.Throw(ex); - - var res = AsyncEnumerable.Concat(xs, ys, zs); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Concat6() - { - var res = AsyncEnumerable.Concat(ConcatXss()); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - } - - [Fact] - public void Concat7() - { - var ws = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var xs = new[] { 4, 5 }.ToAsyncEnumerable(); - var ys = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - var zs = new[] { 9, 10, 11 }.ToAsyncEnumerable(); - - var res = ws.Concat(xs).Concat(ys).Concat(zs); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 8); - HasNext(e, 9); - HasNext(e, 10); - HasNext(e, 11); - NoNext(e); - } - - [Fact] - public async Task Concat8() - { - var ws = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var xs = new[] { 4, 5 }.ToAsyncEnumerable(); - var ys = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - var zs = new[] { 9, 10, 11 }.ToAsyncEnumerable(); - - var res = ws.Concat(xs).Concat(ys).Concat(zs); - - await SequenceIdentity(res); - } - - [Fact] - public async Task Concat9() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - - var res = AsyncEnumerable.Concat(xs, ys, zs); - - await SequenceIdentity(res); - } - - [Fact] - public async Task Concat10() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - - var c = xs.Concat(ys).Concat(zs); - - var res = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; - Assert.True(res.SequenceEqual(await c.ToArray())); - } - - [Fact] - public async Task Concat11() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - - var c = xs.Concat(ys).Concat(zs); - - var res = new List { 1, 2, 3, 4, 5, 6, 7, 8 }; - Assert.True(res.SequenceEqual(await c.ToList())); - } - - [Fact] - public async Task Concat12() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - - var c = xs.Concat(ys).Concat(zs); - - Assert.Equal(8, await c.Count()); - } - - static IEnumerable> ConcatXss() - { - yield return new[] { 1, 2, 3 }.ToAsyncEnumerable(); - yield return new[] { 4, 5 }.ToAsyncEnumerable(); - throw new Exception("Bang!"); - } - [Fact] public void GroupJoin_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs new file mode 100644 index 0000000000..b50eca8175 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -0,0 +1,211 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Concat : AsyncEnumerableTests + { + [Fact] + public void Concat_Null() + { + AssertThrows(() => AsyncEnumerable.Concat(null, AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Concat(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerable.Concat(default(IEnumerable>))); + } + + [Fact] + public void Concat1() + { + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void Concat2() + { + var ex = new Exception("Bang"); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + + var e = ys.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Concat3() + { + var ex = new Exception("Bang"); + var ys = AsyncEnumerable.Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); + + var e = ys.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Concat4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + + var res = AsyncEnumerable.Concat(xs, ys, zs); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + HasNext(e, 7); + HasNext(e, 8); + NoNext(e); + } + + [Fact] + public void Concat5() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = AsyncEnumerable.Throw(ex); + + var res = AsyncEnumerable.Concat(xs, ys, zs); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Concat6() + { + var res = AsyncEnumerable.Concat(ConcatXss()); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + } + + [Fact] + public void Concat7() + { + var ws = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var xs = new[] { 4, 5 }.ToAsyncEnumerable(); + var ys = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + var zs = new[] { 9, 10, 11 }.ToAsyncEnumerable(); + + var res = ws.Concat(xs).Concat(ys).Concat(zs); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + HasNext(e, 7); + HasNext(e, 8); + HasNext(e, 9); + HasNext(e, 10); + HasNext(e, 11); + NoNext(e); + } + + [Fact] + public async Task Concat8() + { + var ws = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var xs = new[] { 4, 5 }.ToAsyncEnumerable(); + var ys = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + var zs = new[] { 9, 10, 11 }.ToAsyncEnumerable(); + + var res = ws.Concat(xs).Concat(ys).Concat(zs); + + await SequenceIdentity(res); + } + + [Fact] + public async Task Concat9() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + + var res = AsyncEnumerable.Concat(xs, ys, zs); + + await SequenceIdentity(res); + } + + [Fact] + public async Task Concat10() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + + var c = xs.Concat(ys).Concat(zs); + + var res = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; + Assert.True(res.SequenceEqual(await c.ToArray())); + } + + [Fact] + public async Task Concat11() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + + var c = xs.Concat(ys).Concat(zs); + + var res = new List { 1, 2, 3, 4, 5, 6, 7, 8 }; + Assert.True(res.SequenceEqual(await c.ToList())); + } + + [Fact] + public async Task Concat12() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + + var c = xs.Concat(ys).Concat(zs); + + Assert.Equal(8, await c.Count()); + } + + static IEnumerable> ConcatXss() + { + yield return new[] { 1, 2, 3 }.ToAsyncEnumerable(); + yield return new[] { 4, 5 }.ToAsyncEnumerable(); + throw new Exception("Bang!"); + } + } +} From 483e6120dbac4d1b2831388169ff16134645ee54 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:33:07 -0700 Subject: [PATCH 235/862] Moving GroupJoin tests. --- .../AsyncTests.Multiple.cs | 118 --------------- .../System/Linq/Operators/GroupJoin.cs | 134 ++++++++++++++++++ 2 files changed, 134 insertions(+), 118 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index d311996dd9..0e3c5b9db7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -13,124 +13,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void GroupJoin_Null() - { - AssertThrows(() => AsyncEnumerable.GroupJoin(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null)); - - AssertThrows(() => AsyncEnumerable.GroupJoin(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); - } - - [Fact] - public void GroupJoin1() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 4, 7, 6, 2, 3, 4, 8, 9 }.ToAsyncEnumerable(); - - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - - var e = res.GetAsyncEnumerator(); - HasNext(e, "0 - 639"); - HasNext(e, "1 - 474"); - HasNext(e, "2 - 28"); - NoNext(e); - } - - [Fact] - public void GroupJoin2() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - - var e = res.GetAsyncEnumerator(); - HasNext(e, "0 - 36"); - HasNext(e, "1 - 4"); - HasNext(e, "2 - "); - NoNext(e); - } - - [Fact] - public void GroupJoin3() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void GroupJoin4() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); - - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void GroupJoin5() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - - var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void GroupJoin6() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - - var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void GroupJoin7() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => - { - if (x == 1) - throw ex; - return x + " - " + i.Aggregate("", (s, j) => s + j).Result; - }); - - var e = res.GetAsyncEnumerator(); - HasNext(e, "0 - 36"); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - [Fact] public void Join_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs new file mode 100644 index 0000000000..ee67eb3cfa --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -0,0 +1,134 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class GroupJoin : AsyncEnumerableTests + { + [Fact] + public void GroupJoin_Null() + { + AssertThrows(() => AsyncEnumerable.GroupJoin(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null)); + + AssertThrows(() => AsyncEnumerable.GroupJoin(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); + } + + [Fact] + public void GroupJoin1() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 4, 7, 6, 2, 3, 4, 8, 9 }.ToAsyncEnumerable(); + + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + + var e = res.GetAsyncEnumerator(); + HasNext(e, "0 - 639"); + HasNext(e, "1 - 474"); + HasNext(e, "2 - 28"); + NoNext(e); + } + + [Fact] + public void GroupJoin2() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + + var e = res.GetAsyncEnumerator(); + HasNext(e, "0 - 36"); + HasNext(e, "1 - 4"); + HasNext(e, "2 - "); + NoNext(e); + } + + [Fact] + public void GroupJoin3() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void GroupJoin4() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = AsyncEnumerable.Throw(ex); + + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void GroupJoin5() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + + var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void GroupJoin6() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + + var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void GroupJoin7() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => + { + if (x == 1) + throw ex; + return x + " - " + i.Aggregate("", (s, j) => s + j).Result; + }); + + var e = res.GetAsyncEnumerator(); + HasNext(e, "0 - 36"); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + } +} From 88265ccee40f2f04896da816dd7e96ef1d90b3b8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:33:17 -0700 Subject: [PATCH 236/862] Cleaning up some usings. --- .../System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index ee67eb3cfa..5f9a050ecf 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -5,8 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Xunit; namespace Tests From 508487a58c52db698dbb76dddfe888fa87bddc73 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:34:46 -0700 Subject: [PATCH 237/862] Moving Join tests. --- .../AsyncTests.Multiple.cs | 268 ----------------- .../System/Linq/Operators/Join.cs | 282 ++++++++++++++++++ 2 files changed, 282 insertions(+), 268 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs index 0e3c5b9db7..dd8db02ea2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs @@ -13,273 +13,5 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void Join_Null() - { - AssertThrows(() => AsyncEnumerable.Join(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null)); - - AssertThrows(() => AsyncEnumerable.Join(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); - } - - [Fact] - public void Join1() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 0 + 3); - HasNext(e, 0 + 6); - HasNext(e, 1 + 4); - NoNext(e); - } - - [Fact] - public void Join2() - { - var xs = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 3 + 0); - HasNext(e, 6 + 0); - HasNext(e, 4 + 1); - NoNext(e); - } - - [Fact] - public void Join3() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 6 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 0 + 3); - HasNext(e, 0 + 6); - NoNext(e); - } - - [Fact] - public void Join4() - { - var xs = new[] { 3, 6 }.ToAsyncEnumerable(); - var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 3 + 0); - HasNext(e, 6 + 0); - NoNext(e); - } - - [Fact] - public void Join5() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); - var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Join6() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); - - var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Join7() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => { throw ex; }, y => y, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Join8() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x, y => { throw ex; }, (x, y) => x + y); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public void Join9() - { - var ex = new Exception("Bang!"); - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x, y => y, (x, y) => { throw ex; }); - - var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Join10() - { - var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - - var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); - - await SequenceIdentity(res); - } - - - [Fact] - public void Join11() - { - var customers = new List - { - new Customer {CustomerId = "ALFKI"}, - new Customer {CustomerId = "ANANT"}, - new Customer {CustomerId = "FISSA"} - }; - var orders = new List - { - new Order { OrderId = 1, CustomerId = "ALFKI"}, - new Order { OrderId = 2, CustomerId = "ALFKI"}, - new Order { OrderId = 3, CustomerId = "ALFKI"}, - new Order { OrderId = 4, CustomerId = "FISSA"}, - new Order { OrderId = 5, CustomerId = "FISSA"}, - new Order { OrderId = 6, CustomerId = "FISSA"}, - }; - - var asyncResult = customers.ToAsyncEnumerable() - .Join(orders.ToAsyncEnumerable(), c => c.CustomerId, o => o.CustomerId, - (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); - - var e = asyncResult.GetAsyncEnumerator(); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); - NoNext(e); - } - - [Fact] - public void Join12() - { - var customers = new List - { - new Customer {CustomerId = "ANANT"}, - new Customer {CustomerId = "ALFKI"}, - new Customer {CustomerId = "FISSA"} - }; - var orders = new List - { - new Order { OrderId = 1, CustomerId = "ALFKI"}, - new Order { OrderId = 2, CustomerId = "ALFKI"}, - new Order { OrderId = 3, CustomerId = "ALFKI"}, - new Order { OrderId = 4, CustomerId = "FISSA"}, - new Order { OrderId = 5, CustomerId = "FISSA"}, - new Order { OrderId = 6, CustomerId = "FISSA"}, - }; - - var asyncResult = customers.ToAsyncEnumerable() - .Join(orders.ToAsyncEnumerable(), c => c.CustomerId, o => o.CustomerId, - (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); - - var e = asyncResult.GetAsyncEnumerator(); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); - NoNext(e); - } - - public class Customer - { - public string CustomerId { get; set; } - } - - public class Order - { - public int OrderId { get; set; } - public string CustomerId { get; set; } - } - - [DebuggerDisplay("CustomerId = {CustomerId}, OrderId = {OrderId}")] - public class CustomerOrder : IEquatable - { - public bool Equals(CustomerOrder other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return OrderId == other.OrderId && string.Equals(CustomerId, other.CustomerId); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((CustomerOrder)obj); - } - - public override int GetHashCode() - { - unchecked - { - return (OrderId * 397) ^ (CustomerId != null ? CustomerId.GetHashCode() : 0); - } - } - - public static bool operator ==(CustomerOrder left, CustomerOrder right) - { - return Equals(left, right); - } - - public static bool operator !=(CustomerOrder left, CustomerOrder right) - { - return !Equals(left, right); - } - - public int OrderId { get; set; } - public string CustomerId { get; set; } - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs new file mode 100644 index 0000000000..ed278bcfb5 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -0,0 +1,282 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Join : AsyncEnumerableTests + { + [Fact] + public void Join_Null() + { + AssertThrows(() => AsyncEnumerable.Join(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null)); + + AssertThrows(() => AsyncEnumerable.Join(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); + } + + [Fact] + public void Join1() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 0 + 3); + HasNext(e, 0 + 6); + HasNext(e, 1 + 4); + NoNext(e); + } + + [Fact] + public void Join2() + { + var xs = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 3 + 0); + HasNext(e, 6 + 0); + HasNext(e, 4 + 1); + NoNext(e); + } + + [Fact] + public void Join3() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 6 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 0 + 3); + HasNext(e, 0 + 6); + NoNext(e); + } + + [Fact] + public void Join4() + { + var xs = new[] { 3, 6 }.ToAsyncEnumerable(); + var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 3 + 0); + HasNext(e, 6 + 0); + NoNext(e); + } + + [Fact] + public void Join5() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerable.Throw(ex); + var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Join6() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = AsyncEnumerable.Throw(ex); + + var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Join7() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => { throw ex; }, y => y, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Join8() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x, y => { throw ex; }, (x, y) => x + y); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public void Join9() + { + var ex = new Exception("Bang!"); + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x, y => y, (x, y) => { throw ex; }); + + var e = res.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + } + + [Fact] + public async Task Join10() + { + var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); + var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); + + var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); + + await SequenceIdentity(res); + } + + [Fact] + public void Join11() + { + var customers = new List + { + new Customer {CustomerId = "ALFKI"}, + new Customer {CustomerId = "ANANT"}, + new Customer {CustomerId = "FISSA"} + }; + var orders = new List + { + new Order { OrderId = 1, CustomerId = "ALFKI"}, + new Order { OrderId = 2, CustomerId = "ALFKI"}, + new Order { OrderId = 3, CustomerId = "ALFKI"}, + new Order { OrderId = 4, CustomerId = "FISSA"}, + new Order { OrderId = 5, CustomerId = "FISSA"}, + new Order { OrderId = 6, CustomerId = "FISSA"}, + }; + + var asyncResult = customers.ToAsyncEnumerable() + .Join(orders.ToAsyncEnumerable(), c => c.CustomerId, o => o.CustomerId, + (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); + + var e = asyncResult.GetAsyncEnumerator(); + HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); + HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); + HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); + HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); + HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); + HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); + NoNext(e); + } + + [Fact] + public void Join12() + { + var customers = new List + { + new Customer {CustomerId = "ANANT"}, + new Customer {CustomerId = "ALFKI"}, + new Customer {CustomerId = "FISSA"} + }; + var orders = new List + { + new Order { OrderId = 1, CustomerId = "ALFKI"}, + new Order { OrderId = 2, CustomerId = "ALFKI"}, + new Order { OrderId = 3, CustomerId = "ALFKI"}, + new Order { OrderId = 4, CustomerId = "FISSA"}, + new Order { OrderId = 5, CustomerId = "FISSA"}, + new Order { OrderId = 6, CustomerId = "FISSA"}, + }; + + var asyncResult = customers.ToAsyncEnumerable() + .Join(orders.ToAsyncEnumerable(), c => c.CustomerId, o => o.CustomerId, + (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); + + var e = asyncResult.GetAsyncEnumerator(); + HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); + HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); + HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); + HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); + HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); + HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); + NoNext(e); + } + + public class Customer + { + public string CustomerId { get; set; } + } + + public class Order + { + public int OrderId { get; set; } + public string CustomerId { get; set; } + } + + public class CustomerOrder : IEquatable + { + public bool Equals(CustomerOrder other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return OrderId == other.OrderId && string.Equals(CustomerId, other.CustomerId); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((CustomerOrder)obj); + } + + public override int GetHashCode() + { + unchecked + { + return (OrderId * 397) ^ (CustomerId != null ? CustomerId.GetHashCode() : 0); + } + } + + public static bool operator ==(CustomerOrder left, CustomerOrder right) + { + return Equals(left, right); + } + + public static bool operator !=(CustomerOrder left, CustomerOrder right) + { + return !Equals(left, right); + } + + public int OrderId { get; set; } + public string CustomerId { get; set; } + } + } +} From 79ea1559ec755f273c222400e09e546fc27086f1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:35:26 -0700 Subject: [PATCH 238/862] Some code cosmetics. --- .../System/Linq/Operators/Join.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index ed278bcfb5..0afb9c1fce 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -168,10 +168,11 @@ public void Join11() { var customers = new List { - new Customer {CustomerId = "ALFKI"}, - new Customer {CustomerId = "ANANT"}, - new Customer {CustomerId = "FISSA"} + new Customer { CustomerId = "ALFKI" }, + new Customer { CustomerId = "ANANT" }, + new Customer { CustomerId = "FISSA" }, }; + var orders = new List { new Order { OrderId = 1, CustomerId = "ALFKI"}, @@ -242,6 +243,9 @@ public class Order public class CustomerOrder : IEquatable { + public int OrderId { get; set; } + public string CustomerId { get; set; } + public bool Equals(CustomerOrder other) { if (ReferenceEquals(null, other)) return false; @@ -274,9 +278,6 @@ public override int GetHashCode() { return !Equals(left, right); } - - public int OrderId { get; set; } - public string CustomerId { get; set; } } } } From f272884d83575875f384c2c50b07533988c261fa Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:35:40 -0700 Subject: [PATCH 239/862] Removing an empty test file. --- .../AsyncTests.Multiple.cs | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs deleted file mode 100644 index dd8db02ea2..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Multiple.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using Xunit; - -namespace Tests -{ - public partial class AsyncTests - { - } -} From 05a42bd07a7f9e551471f3a0d0d5c6b554c19ff3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:37:23 -0700 Subject: [PATCH 240/862] Moving Repeat tests. --- .../AsyncTests.Single.cs | 119 ---------------- .../System/Linq/Operators/Repeat.cs | 134 ++++++++++++++++++ 2 files changed, 134 insertions(+), 119 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index d6a40430f9..2d14856d7f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -55,124 +55,5 @@ public void WhereSelect3() HasNext(e, 6); NoNext(e); } - - [Fact] - public void RepeatSeq_Null() - { - AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); - AssertThrows(() => AsyncEnumerableEx.Repeat(AsyncEnumerable.Return(42), -1)); - } - - [Fact] - public void RepeatSeq1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - } - - [Fact] - public void RepeatSeq2() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); - } - - [Fact] - public void RepeatSeq3() - { - var i = 0; - var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(3); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - - Assert.Equal(3, i); - } - - [Fact] - public void RepeatSeq0() - { - var i = 0; - var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(0); - - var e = xs.GetAsyncEnumerator(); - - NoNext(e); - } - - [Fact] - public async Task RepeatSeq6() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); - - await SequenceIdentity(xs); - } - - static IEnumerable RepeatXs(Action started) - { - started(); - - yield return 1; - yield return 2; - } - - [Fact] - public void RepeatSeq4() - { - var xs = new FailRepeat().ToAsyncEnumerable().Repeat(); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); - } - - [Fact] - public void RepeatSeq5() - { - var xs = new FailRepeat().ToAsyncEnumerable().Repeat(3); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); - } - - class FailRepeat : IEnumerable - { - public IEnumerator GetEnumerator() - { - throw new NotImplementedException(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); - } - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs new file mode 100644 index 0000000000..5b001f9453 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs @@ -0,0 +1,134 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Repeat : AsyncEnumerableExTests + { + [Fact] + public void Repeat_Null() + { + AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); + AssertThrows(() => AsyncEnumerableEx.Repeat(AsyncEnumerable.Return(42), -1)); + } + + [Fact] + public void Repeat1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + } + + [Fact] + public void Repeat2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + NoNext(e); + } + + [Fact] + public void Repeat3() + { + var i = 0; + var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(3); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + + Assert.Equal(3, i); + } + + [Fact] + public void Repeat0() + { + var i = 0; + var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(0); + + var e = xs.GetAsyncEnumerator(); + + NoNext(e); + } + + [Fact] + public async Task Repeat6() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); + + await SequenceIdentity(xs); + } + + static IEnumerable RepeatXs(Action started) + { + started(); + + yield return 1; + yield return 2; + } + + [Fact] + public void Repeat4() + { + var xs = new FailRepeat().ToAsyncEnumerable().Repeat(); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + } + + [Fact] + public void Repeat5() + { + var xs = new FailRepeat().ToAsyncEnumerable().Repeat(3); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + } + + private sealed class FailRepeat : IEnumerable + { + public IEnumerator GetEnumerator() + { + throw new NotImplementedException(); + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } + } + } +} From 55d3878950dbf33fdf44b2d7419f8a2b53c42937 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:39:06 -0700 Subject: [PATCH 241/862] Moving Using tests. --- .../AsyncTests.Creation.cs | 160 ---------------- .../AsyncTests.Single.cs | 1 - .../System/Linq/Operators/Using.cs | 175 ++++++++++++++++++ 3 files changed, 175 insertions(+), 161 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 958d52086b..0e4127eb5c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -238,165 +238,5 @@ public async Task Generate5() await SequenceIdentity(xs); } - - [Fact] - public void Using_Null() - { - AssertThrows(() => AsyncEnumerableEx.Using(null, _ => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Using(() => new MyD(null), default(Func>))); - } - - [Fact] - public void Using1() - { - var i = 0; - var d = 0; - - var xs = AsyncEnumerableEx.Using( - () => - { - i++; - return new MyD(() => { d++; }); - }, - _ => AsyncEnumerable.Return(42) - ); - - Assert.Equal(0, i); - - var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); - } - - [Fact] - public async Task Using2() - { - var i = 0; - var d = 0; - - var xs = AsyncEnumerableEx.Using( - () => - { - i++; - return new MyD(() => { d++; }); - }, - _ => AsyncEnumerable.Return(42) - ); - - Assert.Equal(0, i); - - var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); - - await e.DisposeAsync(); - Assert.Equal(1, d); - } - - [Fact] - public void Using3() - { - var ex = new Exception("Bang!"); - var i = 0; - var d = 0; - - var xs = AsyncEnumerableEx.Using( - () => - { - i++; - return new MyD(() => { d++; }); - }, - _ => { throw ex; } - ); - - Assert.Equal(0, i); - - AssertThrows(() => xs.GetAsyncEnumerator(), ex_ => ex_ == ex); - - Assert.Equal(1, d); - } - - [Fact] - public void Using4() - { - var i = 0; - var disposed = new TaskCompletionSource(); - - var xs = AsyncEnumerableEx.Using( - () => - { - i++; - return new MyD(() => { disposed.TrySetResult(true); }); - }, - _ => AsyncEnumerable.Return(42) - ); - - Assert.Equal(0, i); - - var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); - - HasNext(e, 42); - NoNext(e); - - Assert.True(disposed.Task.Result); - } - - [Fact] - public void Using5() - { - var ex = new Exception("Bang!"); - var i = 0; - var disposed = new TaskCompletionSource(); - - var xs = AsyncEnumerableEx.Using( - () => - { - i++; - return new MyD(() => { disposed.TrySetResult(true); }); - }, - _ => AsyncEnumerable.Throw(ex) - ); - - Assert.Equal(0, i); - - var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - - Assert.True(disposed.Task.Result); - } - - [Fact] - public async Task Using7() - { - var i = 0; - var d = 0; - - var xs = AsyncEnumerableEx.Using( - () => - { - i++; - return new MyD(() => { d++; }); - }, - _ => AsyncEnumerable.Return(42) - ); - - await SequenceIdentity(xs); - } - - class MyD : IDisposable - { - private readonly Action _dispose; - - public MyD(Action dispose) - { - _dispose = dispose; - } - - public void Dispose() - { - _dispose(); - } - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index 2d14856d7f..aeb5084f83 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Xunit; namespace Tests diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs new file mode 100644 index 0000000000..2b31e1a6df --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -0,0 +1,175 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Using : AsyncEnumerableExTests + { + [Fact] + public void Using_Null() + { + AssertThrows(() => AsyncEnumerableEx.Using(null, _ => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Using(() => new MyD(null), default(Func>))); + } + + [Fact] + public void Using1() + { + var i = 0; + var d = 0; + + var xs = AsyncEnumerableEx.Using( + () => + { + i++; + return new MyD(() => { d++; }); + }, + _ => AsyncEnumerable.Return(42) + ); + + Assert.Equal(0, i); + + var e = xs.GetAsyncEnumerator(); + Assert.Equal(1, i); + } + + [Fact] + public async Task Using2() + { + var i = 0; + var d = 0; + + var xs = AsyncEnumerableEx.Using( + () => + { + i++; + return new MyD(() => { d++; }); + }, + _ => AsyncEnumerable.Return(42) + ); + + Assert.Equal(0, i); + + var e = xs.GetAsyncEnumerator(); + Assert.Equal(1, i); + + await e.DisposeAsync(); + Assert.Equal(1, d); + } + + [Fact] + public void Using3() + { + var ex = new Exception("Bang!"); + var i = 0; + var d = 0; + + var xs = AsyncEnumerableEx.Using( + () => + { + i++; + return new MyD(() => { d++; }); + }, + _ => { throw ex; } + ); + + Assert.Equal(0, i); + + AssertThrows(() => xs.GetAsyncEnumerator(), ex_ => ex_ == ex); + + Assert.Equal(1, d); + } + + [Fact] + public void Using4() + { + var i = 0; + var disposed = new TaskCompletionSource(); + + var xs = AsyncEnumerableEx.Using( + () => + { + i++; + return new MyD(() => { disposed.TrySetResult(true); }); + }, + _ => AsyncEnumerable.Return(42) + ); + + Assert.Equal(0, i); + + var e = xs.GetAsyncEnumerator(); + Assert.Equal(1, i); + + HasNext(e, 42); + NoNext(e); + + Assert.True(disposed.Task.Result); + } + + [Fact] + public void Using5() + { + var ex = new Exception("Bang!"); + var i = 0; + var disposed = new TaskCompletionSource(); + + var xs = AsyncEnumerableEx.Using( + () => + { + i++; + return new MyD(() => { disposed.TrySetResult(true); }); + }, + _ => AsyncEnumerable.Throw(ex) + ); + + Assert.Equal(0, i); + + var e = xs.GetAsyncEnumerator(); + Assert.Equal(1, i); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + + Assert.True(disposed.Task.Result); + } + + [Fact] + public async Task Using7() + { + var i = 0; + var d = 0; + + var xs = AsyncEnumerableEx.Using( + () => + { + i++; + return new MyD(() => { d++; }); + }, + _ => AsyncEnumerable.Return(42) + ); + + await SequenceIdentity(xs); + } + + private sealed class MyD : IDisposable + { + private readonly Action _dispose; + + public MyD(Action dispose) + { + _dispose = dispose; + } + + public void Dispose() + { + _dispose(); + } + } + } +} From 307c4818ca527db3dcab08fa12e0be1d97b35f3c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:39:52 -0700 Subject: [PATCH 242/862] Moving Defer tests. --- .../AsyncTests.Creation.cs | 26 ------------ .../System/Linq/Operators/Defer.cs | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 0e4127eb5c..f20e6298b4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -150,32 +150,6 @@ public async Task Repeat4() await SequenceIdentity(xs); } - [Fact] - public void Defer_Null() - { - AssertThrows(() => AsyncEnumerableEx.Defer(default(Func>))); - } - - [Fact] - public void Defer1() - { - var x = 0; - var xs = AsyncEnumerableEx.Defer(() => new[] { x }.ToAsyncEnumerable()); - - { - var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - NoNext(e); - } - - { - x++; - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - NoNext(e); - } - } - [Fact] public void Generate_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs new file mode 100644 index 0000000000..8265d3e12f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Defer : AsyncEnumerableExTests + { + [Fact] + public void Defer_Null() + { + AssertThrows(() => AsyncEnumerableEx.Defer(default(Func>))); + } + + [Fact] + public void Defer1() + { + var x = 0; + var xs = AsyncEnumerableEx.Defer(() => new[] { x }.ToAsyncEnumerable()); + + { + var e = xs.GetAsyncEnumerator(); + HasNext(e, 0); + NoNext(e); + } + + { + x++; + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + NoNext(e); + } + } + } +} From f44aec2268aace3fe4481f87763f080013a1448e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:40:39 -0700 Subject: [PATCH 243/862] Moving Generate tests. --- .../AsyncTests.Creation.cs | 63 --------------- .../System/Linq/Operators/Generate.cs | 77 +++++++++++++++++++ 2 files changed, 77 insertions(+), 63 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index f20e6298b4..484b65a802 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -149,68 +149,5 @@ public async Task Repeat4() await SequenceIdentity(xs); } - - [Fact] - public void Generate_Null() - { - AssertThrows(() => AsyncEnumerableEx.Generate(0, null, x => x, x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, null, x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, null)); - } - - [Fact] - public async Task Generate1() - { - var xs = AsyncEnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 1); - HasNext(e, 4); - HasNext(e, 9); - HasNext(e, 16); - NoNext(e); - await e.DisposeAsync(); - } - - [Fact] - public void Generate2() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerableEx.Generate(0, x => { throw ex; }, x => x + 1, x => x * x); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - - [Fact] - public void Generate3() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerableEx.Generate(0, x => true, x => x + 1, x => { if (x == 1) throw ex; return x * x; }); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - - [Fact] - public void Generate4() - { - var ex = new Exception("Bang!"); - var xs = AsyncEnumerableEx.Generate(0, x => true, x => { throw ex; }, x => x * x); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - - [Fact] - public async Task Generate5() - { - var xs = AsyncEnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x); - - await SequenceIdentity(xs); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs new file mode 100644 index 0000000000..99a3fcf930 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Generate : AsyncEnumerableExTests + { + [Fact] + public void Generate_Null() + { + AssertThrows(() => AsyncEnumerableEx.Generate(0, null, x => x, x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, null, x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, null)); + } + + [Fact] + public async Task Generate1() + { + var xs = AsyncEnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 0); + HasNext(e, 1); + HasNext(e, 4); + HasNext(e, 9); + HasNext(e, 16); + NoNext(e); + await e.DisposeAsync(); + } + + [Fact] + public void Generate2() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerableEx.Generate(0, x => { throw ex; }, x => x + 1, x => x * x); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + } + + [Fact] + public void Generate3() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerableEx.Generate(0, x => true, x => x + 1, x => { if (x == 1) throw ex; return x * x; }); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 0); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + } + + [Fact] + public void Generate4() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerableEx.Generate(0, x => true, x => { throw ex; }, x => x * x); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 0); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + } + + [Fact] + public async Task Generate5() + { + var xs = AsyncEnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x); + + await SequenceIdentity(xs); + } + } +} From db01ff69e10bd00c700d6f89f36a55ac3502282c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:42:33 -0700 Subject: [PATCH 244/862] Moving Repeat tests. --- .../AsyncTests.Creation.cs | 51 ------------------- .../System/Linq/Operators/Repeat.cs | 22 ++++++++ .../System/Linq/Operators/Repeat.cs | 43 ++++++++++++++++ 3 files changed, 65 insertions(+), 51 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 484b65a802..e7f5f9d9d2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -98,56 +98,5 @@ public void Range2() var e = xs.GetAsyncEnumerator(); NoNext(e); } - - [Fact] - public void Repeat_Null() - { - AssertThrows(() => AsyncEnumerable.Repeat(0, -1)); - } - - [Fact] - public void Repeat1() - { - var xs = AsyncEnumerable.Repeat(2, 5); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - NoNext(e); - } - - [Fact] - public void Repeat2() - { - var xs = AsyncEnumerable.Repeat(2, 0); - - var e = xs.GetAsyncEnumerator(); - NoNext(e); - } - - [Fact] - public async Task Repeat3() - { - var xs = AsyncEnumerableEx.Repeat(2); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - await e.DisposeAsync(); - } - - [Fact] - public async Task Repeat4() - { - var xs = AsyncEnumerableEx.Repeat(2).Take(5); - - await SequenceIdentity(xs); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs index 5b001f9453..3a4abfbabd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs @@ -20,6 +20,28 @@ public void Repeat_Null() AssertThrows(() => AsyncEnumerableEx.Repeat(AsyncEnumerable.Return(42), -1)); } + [Fact] + public async Task RepeatA() + { + var xs = AsyncEnumerableEx.Repeat(2); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 2); + HasNext(e, 2); + HasNext(e, 2); + HasNext(e, 2); + HasNext(e, 2); + await e.DisposeAsync(); + } + + [Fact] + public async Task RepeatB() + { + var xs = AsyncEnumerableEx.Repeat(2).Take(5); + + await SequenceIdentity(xs); + } + [Fact] public void Repeat1() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs new file mode 100644 index 0000000000..ad72413daf --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Repeat : AsyncEnumerableTests + { + [Fact] + public void Repeat_Null() + { + AssertThrows(() => AsyncEnumerable.Repeat(0, -1)); + } + + [Fact] + public void Repeat1() + { + var xs = AsyncEnumerable.Repeat(2, 5); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 2); + HasNext(e, 2); + HasNext(e, 2); + HasNext(e, 2); + HasNext(e, 2); + NoNext(e); + } + + [Fact] + public void Repeat2() + { + var xs = AsyncEnumerable.Repeat(2, 0); + + var e = xs.GetAsyncEnumerator(); + NoNext(e); + } + } +} From 8a198ebcff738223522d9ae7b7281b378665c7e0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:43:50 -0700 Subject: [PATCH 245/862] Cleaning up some test code. --- .../System/Linq/Operators/Repeat.cs | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs index 3a4abfbabd..a848db09ba 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs @@ -13,15 +13,7 @@ namespace Tests public class Repeat : AsyncEnumerableExTests { [Fact] - public void Repeat_Null() - { - AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); - AssertThrows(() => AsyncEnumerableEx.Repeat(AsyncEnumerable.Return(42), -1)); - } - - [Fact] - public async Task RepeatA() + public async Task RepeatValue1() { var xs = AsyncEnumerableEx.Repeat(2); @@ -35,7 +27,7 @@ public async Task RepeatA() } [Fact] - public async Task RepeatB() + public async Task RepeatValue2() { var xs = AsyncEnumerableEx.Repeat(2).Take(5); @@ -43,7 +35,15 @@ public async Task RepeatB() } [Fact] - public void Repeat1() + public void RepeatSequence_Null() + { + AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); + AssertThrows(() => AsyncEnumerableEx.Repeat(AsyncEnumerable.Return(42), -1)); + } + + [Fact] + public void RepeatSequence1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(); @@ -60,7 +60,7 @@ public void Repeat1() } [Fact] - public void Repeat2() + public void RepeatSequence2() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); @@ -78,7 +78,7 @@ public void Repeat2() } [Fact] - public void Repeat3() + public void RepeatSequence3() { var i = 0; var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(3); @@ -96,7 +96,7 @@ public void Repeat3() } [Fact] - public void Repeat0() + public void RepeatSequence4() { var i = 0; var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(0); @@ -107,23 +107,15 @@ public void Repeat0() } [Fact] - public async Task Repeat6() + public async Task RepeatSequence5() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); await SequenceIdentity(xs); } - static IEnumerable RepeatXs(Action started) - { - started(); - - yield return 1; - yield return 2; - } - [Fact] - public void Repeat4() + public void RepeatSequence6() { var xs = new FailRepeat().ToAsyncEnumerable().Repeat(); @@ -132,7 +124,7 @@ public void Repeat4() } [Fact] - public void Repeat5() + public void RepeatSequence7() { var xs = new FailRepeat().ToAsyncEnumerable().Repeat(3); @@ -140,6 +132,14 @@ public void Repeat5() AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); } + private static IEnumerable RepeatXs(Action started) + { + started(); + + yield return 1; + yield return 2; + } + private sealed class FailRepeat : IEnumerable { public IEnumerator GetEnumerator() From ce8bf9907dc8f75b98c67957b27ca1f4685cbc5b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:47:05 -0700 Subject: [PATCH 246/862] Moving Range tests. --- .../AsyncTests.Creation.cs | 30 ------------- .../System/Linq/Operators/Range.cs | 42 +++++++++++++++++++ 2 files changed, 42 insertions(+), 30 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Range.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index e7f5f9d9d2..6eda2bd6f4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Xunit; @@ -69,34 +68,5 @@ public void Throw() private void Nop(object o) { } - - [Fact] - public void Range_Null() - { - AssertThrows(() => AsyncEnumerable.Range(0, -1)); - } - - [Fact] - public void Range1() - { - var xs = AsyncEnumerable.Range(2, 5); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); - } - - [Fact] - public void Range2() - { - var xs = AsyncEnumerable.Range(2, 0); - - var e = xs.GetAsyncEnumerator(); - NoNext(e); - } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Range.cs new file mode 100644 index 0000000000..e7d343c636 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Range.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Range : AsyncEnumerableExTests + { + [Fact] + public void Range_Null() + { + AssertThrows(() => AsyncEnumerable.Range(0, -1)); + } + + [Fact] + public void Range1() + { + var xs = AsyncEnumerable.Range(2, 5); + + var e = xs.GetAsyncEnumerator(); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + NoNext(e); + } + + [Fact] + public void Range2() + { + var xs = AsyncEnumerable.Range(2, 0); + + var e = xs.GetAsyncEnumerator(); + NoNext(e); + } + } +} From 31dd11d3f3722119100e494491f19bde328bf8ae Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:48:15 -0700 Subject: [PATCH 247/862] Moving Range tests to correct project. --- .../Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs | 1 - .../System/Linq/Operators/Range.cs | 0 2 files changed, 1 deletion(-) rename Ix.NET/Source/{System.Interactive.Async.Tests => System.Linq.Async.Tests}/System/Linq/Operators/Range.cs (100%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 6eda2bd6f4..eb42874dcf 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -12,7 +12,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] public void Create_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Range.cs rename to Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs From 9170c09017880513c4d31da577cbe3ea0b30df48 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:49:05 -0700 Subject: [PATCH 248/862] Moving Never tests. --- .../AsyncTests.Creation.cs | 11 ------- .../System/Linq/Operators/Never.cs | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index eb42874dcf..136a703dc2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -36,17 +36,6 @@ public void Return() HasNext(xs.GetAsyncEnumerator(), 42); } - [Fact] - public async Task Never() - { - var xs = AsyncEnumerableEx.Never(); - - var e = xs.GetAsyncEnumerator(); - Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check - AssertThrows(() => Nop(e.Current)); - await e.DisposeAsync(); - } - [Fact] public void Throw_Null() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs new file mode 100644 index 0000000000..0ac26f3cf4 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Never : AsyncEnumerableExTests + { + [Fact] + public async Task Never1() + { + var xs = AsyncEnumerableEx.Never(); + + var e = xs.GetAsyncEnumerator(); + Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check + AssertThrows(() => Nop(e.Current)); + await e.DisposeAsync(); + } + + private void Nop(object o) + { + } + } +} From 6945612327c097a8b811cf4958e0d44f70edf657 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:51:06 -0700 Subject: [PATCH 249/862] Moving AsyncEnumerator tests. --- .../AsyncTests.Single.cs | 8 ------- .../System/Linq/AsyncEnumeratorTests.cs | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs index aeb5084f83..83c41e8fa7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs @@ -11,14 +11,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void MoveNextExtension_Null() - { - var en = default(IAsyncEnumerator); - - Assert.ThrowsAsync(() => en.MoveNextAsync()); - } - [Fact] public void SelectWhere2() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs new file mode 100644 index 0000000000..b438507d75 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using Xunit; + +namespace Tests +{ + public class AsyncEnumeratorTests + { + [Fact] + public void MoveNextExtension_Null() + { + var en = default(IAsyncEnumerator); + + Assert.ThrowsAsync(() => en.MoveNextAsync()); + } + } +} From 6dce0f54bb8c8e1f9dc0a89746600aef3d5320ad Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:52:15 -0700 Subject: [PATCH 250/862] Adding some tests for optimizations. --- .../System/Linq/Optimizations.cs} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename Ix.NET/Source/{System.Interactive.Async.Tests/AsyncTests.Single.cs => System.Linq.Async.Tests/System/Linq/Optimizations.cs} (93%) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs similarity index 93% rename from Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs rename to Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs index 83c41e8fa7..694267292a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs @@ -2,14 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; using System.Linq; using Xunit; namespace Tests { - public partial class AsyncTests + public class Optimizations : AsyncEnumerableTests { [Fact] public void SelectWhere2() From ed3e36b79e915107723f060fe0a04b26086a8019 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:52:55 -0700 Subject: [PATCH 251/862] Moving some more optimization tests. --- .../AppendPrependTests.cs | 162 ----------------- .../System/Linq/Optimizations.cs | 166 ++++++++++++++++++ 2 files changed, 166 insertions(+), 162 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs index ece24f734a..8e73548436 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs @@ -11,168 +11,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void AppendPrepend1() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.Prepend(4) - .Append(5) - .Append(6) - .Prepend(7) - .Append(8) - .Prepend(9) - .Prepend(10); - - var e = res.GetAsyncEnumerator(); - - HasNext(e, 10); - HasNext(e, 9); - HasNext(e, 7); - HasNext(e, 4); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 8); - NoNext(e); - } - - [Fact] - public async Task AppendPrepend2() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - - var res = xs.Prepend(4) - .Append(5) - .Append(6) - .Prepend(7) - .Append(8) - .Prepend(9) - .Prepend(10); - - var a = new[] { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task AppendPrepend3() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.Prepend(4) - .Append(5) - .Append(6) - .Prepend(7) - .Append(8) - .Prepend(9) - .Prepend(10); - - var a = new List { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task AppendPrepend4() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - - var res = xs.Prepend(4) - .Append(5) - .Append(6) - .Prepend(7) - .Append(8) - .Prepend(9) - .Prepend(10); - - Assert.Equal(10, await res.Count()); - } - - [Fact] - public async Task AppendPrepend5() - { - var xs = AsyncEnumerable.Range(1, 3).Where(i => true); - - var res = xs.Prepend(4) - .Append(5) - .Append(6) - .Prepend(7) - .Append(8) - .Prepend(9) - .Prepend(10); - - var a = new[] { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - - var arr = await res.ToArray(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task AppendPrepend6() - { - var xs = AsyncEnumerable.Range(1, 3).Where(i => true); - - var res = xs.Prepend(4) - .Append(5) - .Append(6) - .Prepend(7) - .Append(8) - .Prepend(9) - .Prepend(10); - - var a = new List { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - - var arr = await res.ToList(); - Assert.Equal(a, arr); - } - - [Fact] - public async Task AppendPrepend7() - { - var xs = AsyncEnumerable.Range(1, 3).Where(i => true); - - var res = xs.Prepend(4) - .Append(5) - .Append(6) - .Prepend(7) - .Append(8) - .Prepend(9) - .Prepend(10); - - Assert.Equal(10, await res.Count()); - } - - [Fact] - public void AppendPrepend8() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - - var res = xs.Append(4) - .Prepend(5); - - var e = res.GetAsyncEnumerator(); - - HasNext(e, 5); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public async Task AppendPrepend9() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - - var res = xs.Append(4) - .Prepend(5); - - await SequenceIdentity(res); - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs index 694267292a..da027268d9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs @@ -2,7 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -44,5 +46,169 @@ public void WhereSelect3() HasNext(e, 6); NoNext(e); } + + [Fact] + public void AppendPrepend1() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4) + .Append(5) + .Append(6) + .Prepend(7) + .Append(8) + .Prepend(9) + .Prepend(10); + + var e = res.GetAsyncEnumerator(); + + HasNext(e, 10); + HasNext(e, 9); + HasNext(e, 7); + HasNext(e, 4); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 5); + HasNext(e, 6); + HasNext(e, 8); + NoNext(e); + } + + [Fact] + public async Task AppendPrepend2() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4) + .Append(5) + .Append(6) + .Prepend(7) + .Append(8) + .Prepend(9) + .Prepend(10); + + var a = new[] { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task AppendPrepend3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var res = xs.Prepend(4) + .Append(5) + .Append(6) + .Prepend(7) + .Append(8) + .Prepend(9) + .Prepend(10); + + var a = new List { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; + + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task AppendPrepend4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Prepend(4) + .Append(5) + .Append(6) + .Prepend(7) + .Append(8) + .Prepend(9) + .Prepend(10); + + Assert.Equal(10, await res.Count()); + } + + [Fact] + public async Task AppendPrepend5() + { + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + + var res = xs.Prepend(4) + .Append(5) + .Append(6) + .Prepend(7) + .Append(8) + .Prepend(9) + .Prepend(10); + + var a = new[] { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; + + var arr = await res.ToArray(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task AppendPrepend6() + { + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + + var res = xs.Prepend(4) + .Append(5) + .Append(6) + .Prepend(7) + .Append(8) + .Prepend(9) + .Prepend(10); + + var a = new List { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; + + var arr = await res.ToList(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task AppendPrepend7() + { + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + + var res = xs.Prepend(4) + .Append(5) + .Append(6) + .Prepend(7) + .Append(8) + .Prepend(9) + .Prepend(10); + + Assert.Equal(10, await res.Count()); + } + + [Fact] + public void AppendPrepend8() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4) + .Prepend(5); + + var e = res.GetAsyncEnumerator(); + + HasNext(e, 5); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public async Task AppendPrepend9() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + + var res = xs.Append(4) + .Prepend(5); + + await SequenceIdentity(res); + } } } From b0b4847e08c3ffb9d8578ff5ca09055e63427c81 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:53:11 -0700 Subject: [PATCH 252/862] Removing empty test file. --- .../AppendPrependTests.cs | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs deleted file mode 100644 index 8e73548436..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AppendPrependTests.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Xunit; - -namespace Tests -{ - public partial class AsyncTests - { - - } -} From e9e85e4af6eee7e555de61b723cc3ea8d1fb1027 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:53:42 -0700 Subject: [PATCH 253/862] Removing some obsolete code. --- .../Source/System.Interactive.Async.Tests/AsyncTests.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs index 72fac9befe..dbbf9c06ca 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs @@ -22,17 +22,9 @@ public void AssertThrows(Action a) Assert.Throws(a); } - [Obsolete("Don't use this, use Assert.ThrowsAsync and await it", true)] - public Task AssertThrows(Func func) - where E : Exception - { - return Assert.ThrowsAsync(func); - } - public void AssertThrows(Action a, Func assert) where E : Exception { - var hasFailed = false; try From 4590f25ab8a57d9fa07fecd0a10b5a0fd0222033 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:54:28 -0700 Subject: [PATCH 254/862] Removing more obsolete code. --- .../System/Linq/AsyncEnumerableExTests.cs | 7 ------- .../System/Linq/AsyncEnumerableTests.cs | 7 ------- 2 files changed, 14 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 57dd283126..f968f4f014 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -22,13 +22,6 @@ public void AssertThrows(Action a) Assert.Throws(a); } - [Obsolete("Don't use this, use Assert.ThrowsAsync and await it", true)] - public Task AssertThrows(Func func) - where E : Exception - { - return Assert.ThrowsAsync(func); - } - public void AssertThrows(Action a, Func assert) where E : Exception { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 39faf57c03..c6aaf41853 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -22,13 +22,6 @@ public void AssertThrows(Action a) Assert.Throws(a); } - [Obsolete("Don't use this, use Assert.ThrowsAsync and await it", true)] - public Task AssertThrows(Func func) - where E : Exception - { - return Assert.ThrowsAsync(func); - } - public void AssertThrows(Action a, Func assert) where E : Exception { From 90b3437e561c3a6a747846286e253fdea3dda93a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:54:55 -0700 Subject: [PATCH 255/862] Removing AssertEx.Throws. --- Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs index a76ba747ce..1c7c7d5d37 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs @@ -9,12 +9,6 @@ namespace Tests { internal class AssertEx { - internal static void Throws(Action action) - where T : Exception - { - Throws(action, _ => true); - } - internal static void Throws(Action action, Func assert) where T : Exception { From b286e44eb5ffc5fbff295f1edb8e2b8534a8244c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:56:33 -0700 Subject: [PATCH 256/862] Moving Return tests. --- .../AsyncTests.Creation.cs | 7 ------- .../System/Linq/Operators/Return.cs | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 136a703dc2..224db54673 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -29,13 +29,6 @@ public void Create_Iterator_Throws() AssertThrows(() => enu.GetAsyncEnumerator()); } - [Fact] - public void Return() - { - var xs = AsyncEnumerable.Return(42); - HasNext(xs.GetAsyncEnumerator(), 42); - } - [Fact] public void Throw_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs new file mode 100644 index 0000000000..8e837340bc --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Return : AsyncEnumerableTests + { + [Fact] + public void Return1() + { + var xs = AsyncEnumerable.Return(42); + HasNext(xs.GetAsyncEnumerator(), 42); + } + } +} From 7e1dde9b885b57597fcacf6c21538930921e9706 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:57:16 -0700 Subject: [PATCH 257/862] Moving Throw tests. --- .../AsyncTests.Creation.cs | 21 ------------ .../System/Linq/Operators/Throw.cs | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 224db54673..619625d4a2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -28,26 +28,5 @@ public void Create_Iterator_Throws() AssertThrows(() => enu.GetAsyncEnumerator()); } - - [Fact] - public void Throw_Null() - { - AssertThrows(() => AsyncEnumerable.Throw(null)); - } - - [Fact] - public void Throw() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); - - var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - AssertThrows(() => Nop(e.Current)); - } - - private void Nop(object o) - { - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs new file mode 100644 index 0000000000..bce59605e1 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Throw : AsyncEnumerableTests + { + [Fact] + public void Throw_Null() + { + AssertThrows(() => AsyncEnumerable.Throw(null)); + } + + [Fact] + public void Throw1() + { + var ex = new Exception("Bang"); + var xs = AsyncEnumerable.Throw(ex); + + var e = xs.GetAsyncEnumerator(); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrows(() => Nop(e.Current)); + } + + private void Nop(object o) + { + } + } +} From ac222910ce111148a80106e33609410589476f37 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:59:10 -0700 Subject: [PATCH 258/862] Moving CreateEnumerator tests. --- .../AsyncTests.Creation.cs | 11 ------- .../System/Linq/Operators/CreateEnumerator.cs | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 619625d4a2..e5bc44085c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -15,18 +15,7 @@ public partial class AsyncTests [Fact] public void Create_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); AssertThrows(() => AsyncEnumerable.CreateEnumerator(null, () => 3, () => Task.FromResult(true))); } - - [Fact] - public void Create_Iterator_Throws() - { - var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => Task.FromResult(true)); - - var enu = (IAsyncEnumerable)iter; - - AssertThrows(() => enu.GetAsyncEnumerator()); - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs new file mode 100644 index 0000000000..36eed74261 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class CreateEnumerator : AsyncEnumerableTests + { + [Fact] + public void CreateEnumerator_Null() + { + AssertThrows(() => AsyncEnumerable.CreateEnumerator(null, () => 3, () => Task.FromResult(true))); + } + + [Fact] + public void CreateEnumerator_Throws() + { + var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => Task.FromResult(true)); + + var enu = (IAsyncEnumerable)iter; + + AssertThrows(() => enu.GetAsyncEnumerator()); + } + } +} From e0fc5075ef6fac27653d8bb403ab32756c985488 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 22:59:31 -0700 Subject: [PATCH 259/862] Fixing a test. --- .../System.Interactive.Async.Tests/AsyncTests.Creation.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index e5bc44085c..41dab68c1e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using Xunit; namespace Tests @@ -15,7 +14,7 @@ public partial class AsyncTests [Fact] public void Create_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerator(null, () => 3, () => Task.FromResult(true))); + AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); } } } From 806e6da6a78e42ad0835e3e81eb215c092415781 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 23:00:10 -0700 Subject: [PATCH 260/862] Moving CreateEnumerable tests. --- .../AsyncTests.Creation.cs | 5 ----- .../System/Linq/Operators/CreateEnumerable.cs | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs index 41dab68c1e..69ee9dad49 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs @@ -11,10 +11,5 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void Create_Null() - { - AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs new file mode 100644 index 0000000000..4029a6af72 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class CreateEnumerable : AsyncEnumerableTests + { + [Fact] + public void CreateEnumerable_Null() + { + AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); + } + } +} From 9969a40d49408196b3db3c38647aeddebc785bbd Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 23:00:25 -0700 Subject: [PATCH 261/862] Removing an empty test file. --- .../AsyncTests.Creation.cs | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs deleted file mode 100644 index 69ee9dad49..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Creation.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; - -namespace Tests -{ - public partial class AsyncTests - { - } -} From cea1f5149112315877ed1813745657785dca1055 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 2 Sep 2017 23:01:56 -0700 Subject: [PATCH 262/862] Cleaning up some code. --- .../AsyncTests.Bugs.cs | 88 ++----------------- 1 file changed, 6 insertions(+), 82 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index abf6f57eec..89d81d6eaa 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -3,14 +3,12 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Text; -using Xunit; -using System.Collections; using System.Threading; using System.Threading.Tasks; -using System.Diagnostics; +using Xunit; namespace Tests { @@ -23,61 +21,6 @@ public AsyncTests() }; } - /* - [Fact] - public void TestPushPopAsync() - { - var stack = new Stack(); - var count = 10; - - var observable = Observable.Generate( - 0, - i => i < count, - i => i + 1, - i => i, - i => TimeSpan.FromMilliseconds(1), // change this to 0 to avoid the problem [1] - Scheduler.ThreadPool); - - var task = DoSomethingAsync(observable, stack); - - // we give it a timeout so the test can fail instead of hang - task.Wait(TimeSpan.FromSeconds(2)); - - Assert.Equal(10, stack.Count); - } - - private Task DoSomethingAsync(IObservable observable, Stack stack) - { - var ae = observable - .ToAsyncEnumerable() - //.Do(i => Debug.WriteLine("Bug-fixing side effect: " + i)) // [2] - .GetEnumerator(); - - var tcs = new TaskCompletionSource(); - - var a = default(Action); - a = new Action(() => - { - ae.MoveNext().ContinueWith(t => - { - if (t.Result) - { - var i = ae.Current; - Debug.WriteLine("Doing something with " + i); - Thread.Sleep(50); - stack.Push(i); - a(); - } - else - tcs.TrySetResult(null); - }); - }); - - a(); - - return tcs.Task; - } - */ #if !NO_THREAD static IEnumerable Xs(Action a) { @@ -239,16 +182,7 @@ public static IEnumerable WithDispose(this IEnumerable source, Action a }); } - public static IAsyncEnumerable WithDispose(this IAsyncEnumerable source, Action a) - { - return AsyncEnumerable.CreateEnumerable(() => - { - var e = source.GetAsyncEnumerator(); - return AsyncEnumerable.CreateEnumerator(e.MoveNextAsync, () => e.Current, async () => { await e.DisposeAsync(); a(); }); - }); - } - - class Enumerator : IEnumerator + private sealed class Enumerator : IEnumerator { private readonly Func _moveNext; private readonly Func _current; @@ -266,26 +200,16 @@ public T Current get { return _current(); } } - public void Dispose() - { - _dispose(); - } + public void Dispose() => _dispose(); - object IEnumerator.Current - { - get { return Current; } - } + object IEnumerator.Current => Current; - public bool MoveNext() - { - return _moveNext(); - } + public bool MoveNext() => _moveNext(); public void Reset() { throw new NotImplementedException(); } } - } } From aafd8f5718e48677c9517096c60ba7621d2df2a5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 10:29:06 -0700 Subject: [PATCH 263/862] Some cosmetics. --- .../System.Interactive.Async/System/Linq/Operators/Scan.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 47b55adade..4850d8ef38 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -181,7 +181,6 @@ protected override async Task MoveNextCore() } break; - } await DisposeAsync().ConfigureAwait(false); From 17bdfa793acc2667ac633e19c60844a613cb4a6e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 10:40:25 -0700 Subject: [PATCH 264/862] Initial implementation of Amb. --- .../System/Linq/Operators/Amb.cs | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs new file mode 100644 index 0000000000..9923429e4a --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -0,0 +1,121 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Amb(this IAsyncEnumerable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + + return new AmbAsyncIterator(first, second); + } + + private sealed class AmbAsyncIterator : AsyncIterator + { + private readonly IAsyncEnumerable first; + private readonly IAsyncEnumerable second; + + private IAsyncEnumerator enumerator; + + public AmbAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second) + { + Debug.Assert(first != null); + Debug.Assert(second != null); + + this.first = first; + this.second = second; + } + + public override AsyncIterator Clone() + { + return new AmbAsyncIterator(first, second); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + var firstEnumerator = first.GetAsyncEnumerator(); + var secondEnumerator = second.GetAsyncEnumerator(); + + var firstMoveNext = firstEnumerator.MoveNextAsync(); + var secondMoveNext = secondEnumerator.MoveNextAsync(); + + var winner = await Task.WhenAny(firstMoveNext, secondMoveNext).ConfigureAwait(false); + + // + // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: + // + // 1. Concurrent DisposeAsync while a MoveNextAsync is in flight. + // 2. The winner elected by Amb is blocked to yield results until the loser unblocks. + // + // The approach below has one drawback, namely that exceptions raised by loser are dropped on the floor. + // + + if (winner == firstMoveNext) + { + enumerator = firstEnumerator; + + var ignored = secondMoveNext.ContinueWith(_ => + { + secondEnumerator.DisposeAsync(); + }); + } + else + { + enumerator = secondEnumerator; + + var ignored = firstMoveNext.ContinueWith(_ => + { + firstEnumerator.DisposeAsync(); + }); + } + + state = AsyncIteratorState.Iterating; + + if (await winner.ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + break; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} From d3dca51ece4a7ec17c3d405065572808f412a946 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 10:47:39 -0700 Subject: [PATCH 265/862] Adding initial implementation of N-ary Amb overloads. --- .../System/Linq/Operators/Amb.cs | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 9923429e4a..ea49f55c79 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -20,6 +20,22 @@ public static IAsyncEnumerable Amb(this IAsyncEnumerable(first, second); } + public static IAsyncEnumerable Amb(params IAsyncEnumerable[] sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return new AmbAsyncIteratorN(sources); + } + + public static IAsyncEnumerable Amb(this IEnumerable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return new AmbAsyncIteratorN(sources.ToArray()); + } + private sealed class AmbAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable first; @@ -117,5 +133,103 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class AmbAsyncIteratorN : AsyncIterator + { + private readonly IAsyncEnumerable[] sources; + + private IAsyncEnumerator enumerator; + + public AmbAsyncIteratorN(IAsyncEnumerable[] sources) + { + Debug.Assert(sources != null); + + this.sources = sources; + } + + public override AsyncIterator Clone() + { + return new AmbAsyncIteratorN(sources); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + var n = sources.Length; + + var enumerators = new IAsyncEnumerator[n]; + var moveNexts = new Task[n]; + + for (var i = 0; i < n; i++) + { + var enumerator = sources[i].GetAsyncEnumerator(); + + enumerators[i] = enumerator; + moveNexts[i] = enumerator.MoveNextAsync(); + } + + var winner = await Task.WhenAny(moveNexts).ConfigureAwait(false); + + // + // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: + // + // 1. Concurrent DisposeAsync while a MoveNextAsync is in flight. + // 2. The winner elected by Amb is blocked to yield results until all losers unblocks. + // + // The approach below has one drawback, namely that exceptions raised by any loser are dropped on the floor. + // + + var winnerIndex = Array.IndexOf(moveNexts, winner); + + enumerator = enumerators[winnerIndex]; + + for (var i = 0; i < n; i++) + { + if (i != winnerIndex) + { + var ignored = moveNexts[i].ContinueWith(_ => + { + enumerators[i].DisposeAsync(); + }); + } + } + + state = AsyncIteratorState.Iterating; + + if (await winner.ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + break; + + case AsyncIteratorState.Iterating: + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } } } From 0a6b14c9d107e4ac9a63c4c515202bb4e09642c2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 13:29:24 -0700 Subject: [PATCH 266/862] Initial implementation of Timeout. --- .../System/Linq/Operators/Timeout.cs | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs new file mode 100644 index 0000000000..f2562b13f2 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Timeout(this IAsyncEnumerable source, TimeSpan timeout) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + var num = (long)timeout.TotalMilliseconds; + if (num < -1L || num > int.MaxValue) + throw new ArgumentOutOfRangeException(nameof(timeout)); + + return new TimeoutAsyncIterator(source, timeout); + } + + private sealed class TimeoutAsyncIterator : AsyncIterator + { + private readonly IAsyncEnumerable source; + private readonly TimeSpan timeout; + + private IAsyncEnumerator enumerator; + + public TimeoutAsyncIterator(IAsyncEnumerable source, TimeSpan timeout) + { + Debug.Assert(source != null); + + this.source = source; + this.timeout = timeout; + } + + public override AsyncIterator Clone() + { + return new TimeoutAsyncIterator(source, timeout); + } + + public override async Task DisposeAsync() + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + enumerator = source.GetAsyncEnumerator(); + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + var moveNext = enumerator.MoveNextAsync(); + + if (!moveNext.IsCompleted) + { + using (var delayCts = new CancellationTokenSource()) + { + var delay = Task.Delay(timeout, delayCts.Token); + + var winner = await Task.WhenAny(moveNext, delay).ConfigureAwait(false); + + if (winner == delay) + { + throw new TimeoutException(); + } + + delayCts.Cancel(); + } + } + + if (await moveNext.ConfigureAwait(false)) + { + current = enumerator.Current; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} From 37600837115102c2141b63ddabffca79a6efe3e0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 14:39:05 -0700 Subject: [PATCH 267/862] Initial implementation of Merge. --- Ix.NET/Source/Playground/Program.cs | 2 - .../System/Linq/Operators/Merge.cs | 134 ++++++++++++++++++ .../System.Interactive.Async/TaskExt.cs | 1 + 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs diff --git a/Ix.NET/Source/Playground/Program.cs b/Ix.NET/Source/Playground/Program.cs index e3bf7c26f2..66ca95dd94 100644 --- a/Ix.NET/Source/Playground/Program.cs +++ b/Ix.NET/Source/Playground/Program.cs @@ -21,8 +21,6 @@ static void Main() static async Task Experiment() { // Add test code here - - await Task.Yield(); } [Demo(11, "LINQ to Objects for IEnumerable")] diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs new file mode 100644 index 0000000000..a60c40c9ae --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -0,0 +1,134 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Merge(params IAsyncEnumerable[] sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return new MergeAsyncIterator(sources); + } + + public static IAsyncEnumerable Merge(this IEnumerable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return sources.ToAsyncEnumerable().SelectMany(source => source); + } + + public static IAsyncEnumerable Merge(this IAsyncEnumerable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return sources.SelectMany(source => source); + } + + private sealed class MergeAsyncIterator : AsyncIterator + { + private readonly IAsyncEnumerable[] sources; + + private IAsyncEnumerator[] enumerators; + private Task[] moveNexts; + private int active; + + public MergeAsyncIterator(IAsyncEnumerable[] sources) + { + Debug.Assert(sources != null); + + this.sources = sources; + } + + public override AsyncIterator Clone() + { + return new MergeAsyncIterator(sources); + } + + public override async Task DisposeAsync() + { + if (enumerators != null) + { + var n = enumerators.Length; + + var disposes = new Task[n]; + + for (var i = 0; i < n; i++) + { + var dispose = enumerators[i].DisposeAsync(); + disposes[i] = dispose; + } + + await Task.WhenAll(disposes).ConfigureAwait(false); + enumerators = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + var n = sources.Length; + + enumerators = new IAsyncEnumerator[n]; + moveNexts = new Task[n]; + active = n; + + for (var i = 0; i < n; i++) + { + var enumerator = sources[i].GetAsyncEnumerator(); + enumerators[i] = enumerator; + moveNexts[i] = enumerator.MoveNextAsync(); + } + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (active > 0) + { + // + // REVIEW: This approach does have a bias towards giving sources on the left + // priority over sources on the right when yielding values. We may + // want to consider a "prefer fairness" option. + // + + var moveNext = await Task.WhenAny(moveNexts).ConfigureAwait(false); + + var index = Array.IndexOf(moveNexts, moveNext); + + if (!await moveNext.ConfigureAwait(false)) + { + moveNexts[index] = TaskExt.Never; + active--; + } + else + { + var enumerator = enumerators[index]; + current = enumerator.Current; + moveNexts[index] = enumerator.MoveNextAsync(); + return true; + } + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index 0732f58206..d1a2917d35 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -8,6 +8,7 @@ internal static class TaskExt { public static readonly Task True = Task.FromResult(true); public static readonly Task False = Task.FromResult(false); + public static readonly Task Never = new TaskCompletionSource().Task; public static readonly Task CompletedTask = True; } } From 401bf16e60f7277697f1095bbdf1fa6abbab794c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 14:44:06 -0700 Subject: [PATCH 268/862] Adding ToHashSet. --- .../System/Linq/Operators/ToHashSet.cs | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs new file mode 100644 index 0000000000..ee23899192 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task> ToHashSet(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return ToHashSet(source, EqualityComparer.Default, CancellationToken.None); + } + + public static Task> ToHashSet(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return ToHashSet(source, EqualityComparer.Default, cancellationToken); + } + + public static Task> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return ToHashSet(source, comparer, CancellationToken.None); + } + + public static Task> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + + return source.Aggregate( + new HashSet(comparer), + (set, x) => + { + set.Add(x); + return set; + }, + cancellationToken + ); + } + } +} From f6a7b0bafaae56c6e6e99f86d988357729fe8b15 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 14:52:31 -0700 Subject: [PATCH 269/862] Whitelisting ToHashSet in API compare. --- Ix.NET/Source/ApiCompare/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ix.NET/Source/ApiCompare/Program.cs b/Ix.NET/Source/ApiCompare/Program.cs index a797f84ebe..67222c198b 100644 --- a/Ix.NET/Source/ApiCompare/Program.cs +++ b/Ix.NET/Source/ApiCompare/Program.cs @@ -26,6 +26,8 @@ class Program "SkipLast", // In .NET Core 2.0 "TakeLast", // In .NET Core 2.0 + "ToHashSet", // In .NET Core 2.0 + "Cast", // Non-generic methods "OfType", // Non-generic methods From 8baab59431e7128fe08768edb920e6b6d160bcd3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 14:59:50 -0700 Subject: [PATCH 270/862] Fixing a test. --- .../Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index ac01b1a196..0ccdaca623 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -4,6 +4,7 @@ using System; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests From a92138455e8742434aa45dbad876ffade57000ae Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:00:09 -0700 Subject: [PATCH 271/862] Fixing another test. --- .../System.Linq.Async.Tests/System/Linq/Operators/Range.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs index e7d343c636..832f8b6f55 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs @@ -8,7 +8,7 @@ namespace Tests { - public class Range : AsyncEnumerableExTests + public class Range : AsyncEnumerableTests { [Fact] public void Range_Null() From 456a82086bf6e05c079a6a6b50d38bce0166c4e5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:01:52 -0700 Subject: [PATCH 272/862] Adding ToHashSet tests. --- .../System/Linq/Operators/ToHashSet.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs new file mode 100644 index 0000000000..d1d388c65c --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ToHashSet : AsyncEnumerableTests + { + [Fact] + public async Task ToHashSet_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(AsyncEnumerable.Return(42), default(IEqualityComparer), CancellationToken.None)); + } + + [Fact] + public void ToHashSet1() + { + var xs = new[] { 1, 2, 1, 2, 3, 4, 1, 2, 3, 4 }; + var res = xs.ToAsyncEnumerable().ToHashSet(); + Assert.True(res.Result.OrderBy(x => x).SequenceEqual(new[] { 1, 2, 3, 4 })); + } + } +} From f8bab3912a73526e9ec09c7c68123c20d4a63a2c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:18:01 -0700 Subject: [PATCH 273/862] Using default expressions in tests. --- .../System/Linq/Operators/Distinct.cs | 4 ++-- .../System/Linq/Operators/Do.cs | 11 +++++----- .../System/Linq/Operators/Finally.cs | 2 +- .../System/Linq/Operators/Generate.cs | 6 ++--- .../System/Linq/Operators/IsEmpty.cs | 5 +++-- .../System/Linq/Operators/StartWith.cs | 2 +- .../System/Linq/Operators/Using.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 13 ++++++----- .../System/Linq/Operators/All.cs | 5 +++-- .../System/Linq/Operators/Any.cs | 9 ++++---- .../System/Linq/Operators/Append.cs | 2 +- .../Linq/Operators/AsAsyncEnumerable.cs | 2 +- .../System/Linq/Operators/Cast.cs | 3 ++- .../System/Linq/Operators/Concat.cs | 4 ++-- .../System/Linq/Operators/Contains.cs | 8 +++---- .../System/Linq/Operators/Count.cs | 9 ++++---- .../System/Linq/Operators/CreateEnumerator.cs | 2 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 ++-- .../System/Linq/Operators/Distinct.cs | 6 ++--- .../System/Linq/Operators/ElementAt.cs | 5 +++-- .../Linq/Operators/ElementAtOrDefault.cs | 5 +++-- .../System/Linq/Operators/Except.cs | 8 +++---- .../System/Linq/Operators/First.cs | 9 ++++---- .../System/Linq/Operators/FirstOrDefault.cs | 9 ++++---- .../System/Linq/Operators/ForEachAsync.cs | 9 ++++---- .../System/Linq/Operators/GroupBy.cs | 17 +++++++------- .../System/Linq/Operators/GroupJoin.cs | 22 +++++++++---------- .../System/Linq/Operators/Intersect.cs | 10 ++++----- .../System/Linq/Operators/Join.cs | 22 +++++++++---------- .../System/Linq/Operators/Last.cs | 9 ++++---- .../System/Linq/Operators/LastOrDefault.cs | 9 ++++---- .../System/Linq/Operators/LongCount.cs | 9 ++++---- .../System/Linq/Operators/OfType.cs | 3 ++- .../System/Linq/Operators/Prepend.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 3 ++- .../System/Linq/Operators/Select.cs | 5 +++-- .../System/Linq/Operators/SelectMany.cs | 12 +++++----- .../System/Linq/Operators/SequenceEqual.cs | 20 ++++++++--------- .../System/Linq/Operators/Single.cs | 9 ++++---- .../System/Linq/Operators/SingleOrDefault.cs | 9 ++++---- .../System/Linq/Operators/Skip.cs | 3 ++- .../System/Linq/Operators/SkipWhile.cs | 5 +++-- .../System/Linq/Operators/Take.cs | 3 ++- .../System/Linq/Operators/TakeWhile.cs | 5 +++-- .../System/Linq/Operators/Throw.cs | 2 +- .../System/Linq/Operators/ToArray.cs | 4 ++-- .../System/Linq/Operators/ToList.cs | 5 +++-- .../System/Linq/Operators/Union.cs | 10 ++++----- .../System/Linq/Operators/Where.cs | 5 +++-- .../System/Linq/Operators/Zip.cs | 5 +++-- 50 files changed, 189 insertions(+), 163 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index 97393486c7..4185be535d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -15,14 +15,14 @@ public class Distinct : AsyncEnumerableExTests [Fact] public void Distinct_Null() { - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), (Func)null)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func))); AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x)); AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func))); AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), x => x, null)); + AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index 21cfba9e16..b245d8aa5f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,23 +15,23 @@ public class Do : AsyncEnumerableExTests [Fact] public void Do_Null() { - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { })); + AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, () => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), () => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, ex => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(null, x => { }, ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, ex => { }, () => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { }, () => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action), () => { })); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, ex => { }, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(null, new MyObs())); + AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), new MyObs())); AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(IObserver))); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index bee0ba2429..e08b01f9dd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -16,7 +16,7 @@ public class Finally : AsyncEnumerableExTests public void Finally_Null() { AssertThrows(() => AsyncEnumerableEx.Finally(default(IAsyncEnumerable), () => { })); - AssertThrows(() => AsyncEnumerableEx.Finally(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerableEx.Finally(AsyncEnumerable.Return(42), default(Action))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs index 99a3fcf930..751f45065e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs @@ -14,9 +14,9 @@ public class Generate : AsyncEnumerableExTests [Fact] public void Generate_Null() { - AssertThrows(() => AsyncEnumerableEx.Generate(0, null, x => x, x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, null, x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, null)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, default(Func), x => x, x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, default(Func), x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs index a5e955cb72..1b3cc968f4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,8 +16,8 @@ public class IsEmpty : AsyncEnumerableExTests [Fact] public async Task IsEmpty_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default(IAsyncEnumerable), CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index 6fdb0b79ff..0bfe03d318 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -15,7 +15,7 @@ public class StartWith : AsyncEnumerableExTests public void StartWith_Null() { AssertThrows(() => AsyncEnumerableEx.StartWith(default(IAsyncEnumerable), new[] { 1 })); - AssertThrows(() => AsyncEnumerableEx.StartWith(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerableEx.StartWith(AsyncEnumerable.Return(42), default(int[]))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index 2b31e1a6df..88f5cc08c2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -15,7 +15,7 @@ public class Using : AsyncEnumerableExTests [Fact] public void Using_Null() { - AssertThrows(() => AsyncEnumerableEx.Using(null, _ => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Using(default(Func), _ => default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.Using(() => new MyD(null), default(Func>))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index d38bf1d0c6..8f0f41c3fa 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,23 +16,23 @@ public class Aggregate : AsyncEnumerableTests [Fact] public async Task Aggregate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), (x, y) => x + y)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, z => z)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), (x, y) => x + y, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(null, 0, (x, y) => x + y, z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, z => z, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index a84e2b9a2e..80eb990ee4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,10 +16,10 @@ public class All : AsyncEnumerableTests [Fact] public async Task All_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 5a9f42ce32..0f73e26b3a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class Any : AsyncEnumerableTests [Fact] public async Task Any_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs index e61f88e1ea..76be4296d5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs @@ -15,7 +15,7 @@ public class Append : AsyncEnumerableTests [Fact] public void Append_Null() { - AssertThrows(() => AsyncEnumerable.Append(null, 42)); + AssertThrows(() => AsyncEnumerable.Append(default(IAsyncEnumerable), 42)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs index 8342d8d1da..30971d8452 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs @@ -14,7 +14,7 @@ public class AsAsyncEnumerable : AsyncEnumerableTests [Fact] public void AsAsyncEnumerable_Null() { - AssertThrows(() => AsyncEnumerable.AsAsyncEnumerable((IAsyncEnumerable)null)); + AssertThrows(() => AsyncEnumerable.AsAsyncEnumerable(default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs index 72ac62a9f7..67e069d086 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using Xunit; @@ -13,7 +14,7 @@ public class Cast : AsyncEnumerableTests [Fact] public void Cast_Null() { - AssertThrows(() => AsyncEnumerable.Cast(null)); + AssertThrows(() => AsyncEnumerable.Cast(default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index b50eca8175..82557afafa 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -15,8 +15,8 @@ public class Concat : AsyncEnumerableTests [Fact] public void Concat_Null() { - AssertThrows(() => AsyncEnumerable.Concat(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Concat(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Concat(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable[]))); AssertThrows(() => AsyncEnumerable.Concat(default(IEnumerable>))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index de17c51980..aba68b8011 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -16,12 +16,12 @@ public class Contains : AsyncEnumerableTests [Fact] public async Task Contains_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(null, 42, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index fb9e5d565d..99b8fe5f79 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class Count : AsyncEnumerableTests [Fact] public async Task Count_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index 36eed74261..6ef0ae3e0c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -15,7 +15,7 @@ public class CreateEnumerator : AsyncEnumerableTests [Fact] public void CreateEnumerator_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerator(null, () => 3, () => Task.FromResult(true))); + AssertThrows(() => AsyncEnumerable.CreateEnumerator(default(Func>), () => 3, () => Task.FromResult(true))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index 2312fb6b41..adba0b4b17 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -15,8 +15,8 @@ public class DefaultIfEmpty : AsyncEnumerableTests [Fact] public void DefaultIfEmpty_Null() { - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(null)); - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(null, 42)); + AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default(IAsyncEnumerable), 42)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index 9827cf7168..116d1339a9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -15,9 +15,9 @@ public class Distinct : AsyncEnumerableTests [Fact] public void Distinct_Null() { - AssertThrows(() => AsyncEnumerable.Distinct(null)); - AssertThrows(() => AsyncEnumerable.Distinct(null, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index 5fb6d6599d..6439065ee1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,10 +16,10 @@ public class ElementAt : AsyncEnumerableTests [Fact] public async Task ElementAt_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(null, 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default(IAsyncEnumerable), 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(null, 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default(IAsyncEnumerable), 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index e093f39537..a0e839f92e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,10 +16,10 @@ public class ElementAtOrDefault : AsyncEnumerableTests [Fact] public async Task ElementAtOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(null, 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default(IAsyncEnumerable), 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(null, 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default(IAsyncEnumerable), 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs index b6a314eb54..2f28e1bcb8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs @@ -15,12 +15,12 @@ public class Except : AsyncEnumerableTests [Fact] public void Except_Null() { - AssertThrows(() => AsyncEnumerable.Except(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Except(null, AsyncEnumerable.Return(42), new Eq())); + AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), null, new Eq())); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index c5e2debcc0..97c4d401b9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class First : AsyncEnumerableTests [Fact] public async Task First_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index b5e7f66e23..4110faa426 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class FirstOrDefault : AsyncEnumerableTests [Fact] public async Task FirstOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 5446233a12..10ca1fce0c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,14 +16,14 @@ public class ForEachAsync : AsyncEnumerableTests [Fact] public async Task ForEachAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, x => { })); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), x => { })); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, (x, i) => { })); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), (x, i) => { })); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, x => { }, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), x => { }, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(null, (x, i) => { }, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), (x, i) => { }, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index c2febbbdb6..e62bf628f0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Xunit; @@ -16,37 +15,37 @@ public class GroupBy : AsyncEnumerableTests [Fact] public void GroupBy_Null() { - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func))); - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(IEqualityComparer))); - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>))); - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, (x, ys) => x, default(IEqualityComparer))); - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>))); - AssertThrows(() => AsyncEnumerable.GroupBy(null, x => x, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>), EqualityComparer.Default)); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index 5f9a050ecf..d3047e7abb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -14,17 +14,17 @@ public class GroupJoin : AsyncEnumerableTests [Fact] public void GroupJoin_Null() { - AssertThrows(() => AsyncEnumerable.GroupJoin(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null)); - - AssertThrows(() => AsyncEnumerable.GroupJoin(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>))); + + AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs index 7a4220e656..0245744a68 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs @@ -15,12 +15,12 @@ public class Intersect : AsyncEnumerableTests [Fact] public void Intersect_Null() { - AssertThrows(() => AsyncEnumerable.Intersect(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Intersect(null, AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), null, new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index 0afb9c1fce..d262053dd1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -15,17 +15,17 @@ public class Join : AsyncEnumerableTests [Fact] public void Join_Null() { - AssertThrows(() => AsyncEnumerable.Join(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null)); - - AssertThrows(() => AsyncEnumerable.Join(null, AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), null, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, null, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, null, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func))); + + AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 27594aa294..951e081d0f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class Last : AsyncEnumerableTests [Fact] public async Task Last_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 282b8aca95..47c401e85c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class LastOrDefault : AsyncEnumerableTests [Fact] public async Task LastOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index b6c3f460d9..6e9fd2c8fa 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class LongCount : AsyncEnumerableTests [Fact] public async Task LongCount_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs index faaabe7290..fcd682aacd 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using Xunit; @@ -13,7 +14,7 @@ public class OfType : AsyncEnumerableTests [Fact] public void OfType_Null() { - AssertThrows(() => AsyncEnumerable.OfType(null)); + AssertThrows(() => AsyncEnumerable.OfType(default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs index a4f1556772..dd827a262a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs @@ -15,7 +15,7 @@ public class Prepend : AsyncEnumerableTests [Fact] public void Prepend_Null() { - AssertThrows(() => AsyncEnumerable.Prepend(null, 42)); + AssertThrows(() => AsyncEnumerable.Prepend(default(IAsyncEnumerable), 42)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index 76f35bd61a..039b8de1b4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,7 +15,7 @@ public class Reverse : AsyncEnumerableTests [Fact] public void Reverse_Null() { - AssertThrows(() => AsyncEnumerable.Reverse(null)); + AssertThrows(() => AsyncEnumerable.Reverse(default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index f3e05bca59..29ab9e5b75 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,8 +15,8 @@ public class Select : AsyncEnumerableTests [Fact] public void Select_Null() { - AssertThrows(() => AsyncEnumerable.Select(null, x => x)); - AssertThrows(() => AsyncEnumerable.Select(null, (x, i) => x)); + AssertThrows(() => AsyncEnumerable.Select(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.Select(default(IAsyncEnumerable), (x, i) => x)); AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index 6f6c2d036e..f2505bd76a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -15,17 +15,17 @@ public class SelectMany : AsyncEnumerableTests [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(null, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), x => null, default(Func))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), (x, i) => null, default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), x => default(IAsyncEnumerable), default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), (x, i) => default(IAsyncEnumerable), default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 63f4ba2f2d..37a803f7bc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -16,19 +16,19 @@ public class SequenceEqual : AsyncEnumerableTests [Fact] public async Task SequenceEqual_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(null, AsyncEnumerable.Return(42), new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), null, new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index b2c1ccf760..8444c40420 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class Single : AsyncEnumerableTests [Fact] public async Task Single_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 4eb9f2ee6e..e301814f00 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,12 +16,12 @@ public class SingleOrDefault : AsyncEnumerableTests [Fact] public async Task SingleOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(null, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index 165d837fb9..56b5bfc30d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,7 +15,7 @@ public class Skip : AsyncEnumerableTests [Fact] public void Skip_Null() { - AssertThrows(() => AsyncEnumerable.Skip(null, 5)); + AssertThrows(() => AsyncEnumerable.Skip(default(IAsyncEnumerable), 5)); } //[Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index 4e5fd20dd5..46ca743d9c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,8 +15,8 @@ public class SkipWhile : AsyncEnumerableTests [Fact] public void SkipWhile_Null() { - AssertThrows(() => AsyncEnumerable.SkipWhile(null, x => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(null, (x, i) => true)); + AssertThrows(() => AsyncEnumerable.SkipWhile(default(IAsyncEnumerable), x => true)); + AssertThrows(() => AsyncEnumerable.SkipWhile(default(IAsyncEnumerable), (x, i) => true)); AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index 0ccdaca623..1fb4b1ae19 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,7 +15,7 @@ public class Take : AsyncEnumerableTests [Fact] public void Take_Null() { - AssertThrows(() => AsyncEnumerable.Take(null, 5)); + AssertThrows(() => AsyncEnumerable.Take(default(IAsyncEnumerable), 5)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index a6ed27e715..7d88180d5e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,8 +15,8 @@ public class TakeWhile : AsyncEnumerableTests [Fact] public void TakeWhile_Null() { - AssertThrows(() => AsyncEnumerable.TakeWhile(null, x => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(null, (x, i) => true)); + AssertThrows(() => AsyncEnumerable.TakeWhile(default(IAsyncEnumerable), x => true)); + AssertThrows(() => AsyncEnumerable.TakeWhile(default(IAsyncEnumerable), (x, i) => true)); AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index bce59605e1..cc73e5fa81 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -13,7 +13,7 @@ public class Throw : AsyncEnumerableTests [Fact] public void Throw_Null() { - AssertThrows(() => AsyncEnumerable.Throw(null)); + AssertThrows(() => AsyncEnumerable.Throw(default(Exception))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 1b3504b3f8..4330334277 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -16,8 +16,8 @@ public class ToArray : AsyncEnumerableTests [Fact] public async Task ToArray_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default(IAsyncEnumerable), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index 6fdbe5c228..e8a494e39b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,8 +16,8 @@ public class ToList : AsyncEnumerableTests [Fact] public async Task ToList_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default(IAsyncEnumerable), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs index b96c0fbcdc..220b23d875 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -14,12 +14,12 @@ public class Union : AsyncEnumerableTests [Fact] public void Union_Null() { - AssertThrows(() => AsyncEnumerable.Union(null, AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); + AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Union(null, AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), null, new Eq())); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), null)); + AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); + AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq())); + AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index 098e651b35..d32ef9b1fa 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,8 +15,8 @@ public class Where : AsyncEnumerableTests [Fact] public void Where_Null() { - AssertThrows(() => AsyncEnumerable.Where(null, x => true)); - AssertThrows(() => AsyncEnumerable.Where(null, (x, i) => true)); + AssertThrows(() => AsyncEnumerable.Where(default(IAsyncEnumerable), x => true)); + AssertThrows(() => AsyncEnumerable.Where(default(IAsyncEnumerable), (x, i) => true)); AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index 008825521c..9da620971b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -14,8 +15,8 @@ public class Zip : AsyncEnumerableTests [Fact] public void Zip_Null() { - AssertThrows(() => AsyncEnumerable.Zip(null, AsyncEnumerable.Return(42), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), null, (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(default(IAsyncEnumerable), AsyncEnumerable.Return(42), (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), default(IAsyncEnumerable), (x, y) => x + y)); AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func))); } From 82dd7bd43b84c2cb8ae9ee33efd1c0e94417eeab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:21:03 -0700 Subject: [PATCH 274/862] Moving ToAsyncEnumerable tests. --- .../AsyncTests.Conversions.cs | 278 ----------------- .../Linq/Operators/ToAsyncEnumerable.cs | 293 ++++++++++++++++++ 2 files changed, 293 insertions(+), 278 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs index 17ca19ad18..03791f0820 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs @@ -13,284 +13,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void ToAsyncEnumerable_Null() - { - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IEnumerable))); - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); - } - - [Fact] - public void ToAsyncEnumerable1() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public void ToAsyncEnumerable2() - { - var ex = new Exception("Bang"); - var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - - private IEnumerable ToAsyncEnumerable_Sequence(Exception e) - { - yield return 42; - throw e; - } - - [Fact] - public void ToAsyncEnumerable3() - { - var subscribed = false; - - var xs = new MyObservable(obs => - { - subscribed = true; - - obs.OnNext(42); - obs.OnCompleted(); - - return new MyDisposable(() => { }); - }).ToAsyncEnumerable(); - - Assert.False(subscribed); - - var e = xs.GetAsyncEnumerator(); - - Assert.True(subscribed); - - HasNext(e, 42); - NoNext(e); - } - - [Fact] - public void ToAsyncEnumerable4() - { - var ex = new Exception("Bang!"); - var subscribed = false; - - var xs = new MyObservable(obs => - { - subscribed = true; - - obs.OnError(ex); - - return new MyDisposable(() => { }); - }).ToAsyncEnumerable(); - - Assert.False(subscribed); - - var e = xs.GetAsyncEnumerator(); - - Assert.True(subscribed); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - - [Fact] - public void ToAsyncEnumerable5() - { - var set = new HashSet(new[] { 1, 2, 3, 4 }); - - var xs = set.ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); - } - - [Fact] - public async Task ToAsyncEnumerable6() - { - var set = new HashSet(new[] { 1, 2, 3, 4, 5, 6, 7, 8 }); - - var xs = set.ToAsyncEnumerable(); - - var arr = await xs.ToArray(); - - Assert.True(set.SetEquals(arr)); - } - - [Fact] - public async Task ToAsyncEnumerable7() - { - var set = new HashSet(new[] { 1, 2, 3, 4 }); - var xs = set.ToAsyncEnumerable(); - - var arr = await xs.ToList(); - - Assert.True(set.SetEquals(arr)); - } - - [Fact] - public async Task ToAsyncEnumerable8() - { - var set = new HashSet(new[] { 1, 2, 3, 4 }); - var xs = set.ToAsyncEnumerable(); - - var c = await xs.Count(); - - Assert.Equal(set.Count, c); - } - - [Fact] - public async Task ToAsyncEnumerable9() - { - var set = new HashSet(new[] { 1, 2, 3, 4 }); - var xs = set.ToAsyncEnumerable(); - - await SequenceIdentity(xs); - } - - [Fact] - public async Task ToAsyncEnumerable10() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - await SequenceIdentity(xs); - } - - [Fact] - public void ToAsyncEnumerable11() - { - var set = new HashSet(new[] { 1, 2, 3, 4 }); - var xs = set.ToAsyncEnumerable(); - - var xc = xs as ICollection; - - Assert.NotNull(xc); - - Assert.False(xc.IsReadOnly); - - xc.Add(5); - - - Assert.True(xc.Contains(5)); - - Assert.True(xc.Remove(5)); - - var arr = new int[4]; - xc.CopyTo(arr, 0); - Assert.True(arr.SequenceEqual(xc)); - xc.Clear(); - Assert.Equal(0, xc.Count); - } - - [Fact] - public void ToAsyncEnumerable12() - { - var set = new List { 1, 2, 3, 4 }; - var xs = set.ToAsyncEnumerable(); - - var xl = xs as IList; - - Assert.NotNull(xl); - - Assert.False(xl.IsReadOnly); - - xl.Add(5); - - - Assert.True(xl.Contains(5)); - - Assert.True(xl.Remove(5)); - - xl.Insert(2, 10); - - Assert.Equal(2, xl.IndexOf(10)); - xl.RemoveAt(2); - - xl[0] = 7; - Assert.Equal(7, xl[0]); - - var arr = new int[4]; - xl.CopyTo(arr, 0); - Assert.True(arr.SequenceEqual(xl)); - xl.Clear(); - Assert.Equal(0, xl.Count); - - } - - [Fact] - public void ToAsyncEnumerable_With_Completed_Task() - { - var task = Task.Factory.StartNew(() => 36); - - var xs = task.ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - - Assert.True(e.MoveNextAsync().Result); - Assert.Equal(36, e.Current); - Assert.False(e.MoveNextAsync().Result); - } - - [Fact] - public void ToAsyncEnumerable_With_Faulted_Task() - { - var ex = new InvalidOperationException(); - var tcs = new TaskCompletionSource(); - tcs.SetException(ex); - - var xs = tcs.Task.ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - - [Fact] - public void ToAsyncEnumerable_With_Canceled_Task() - { - var tcs = new TaskCompletionSource(); - tcs.SetCanceled(); - - var xs = tcs.Task.ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() is TaskCanceledException); - } - - class MyObservable : IObservable - { - private Func, IDisposable> _subscribe; - - public MyObservable(Func, IDisposable> subscribe) - { - _subscribe = subscribe; - } - - public IDisposable Subscribe(IObserver observer) - { - return _subscribe(observer); - } - } - - class MyDisposable : IDisposable - { - private Action _dispose; - - public MyDisposable(Action dispose) - { - _dispose = dispose; - } - - public void Dispose() - { - _dispose(); - } - } - [Fact] public void ToEnumerable_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs new file mode 100644 index 0000000000..e7a41ae964 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -0,0 +1,293 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ToAsyncEnumerable : AsyncEnumerableTests + { + [Fact] + public void ToAsyncEnumerable_Null() + { + AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IEnumerable))); + AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); + AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); + } + + [Fact] + public void ToAsyncEnumerable1() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public void ToAsyncEnumerable2() + { + var ex = new Exception("Bang"); + var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + HasNext(e, 42); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + } + + private IEnumerable ToAsyncEnumerable_Sequence(Exception e) + { + yield return 42; + throw e; + } + + [Fact] + public void ToAsyncEnumerable3() + { + var subscribed = false; + + var xs = new MyObservable(obs => + { + subscribed = true; + + obs.OnNext(42); + obs.OnCompleted(); + + return new MyDisposable(() => { }); + }).ToAsyncEnumerable(); + + Assert.False(subscribed); + + var e = xs.GetAsyncEnumerator(); + + Assert.True(subscribed); + + HasNext(e, 42); + NoNext(e); + } + + [Fact] + public void ToAsyncEnumerable4() + { + var ex = new Exception("Bang!"); + var subscribed = false; + + var xs = new MyObservable(obs => + { + subscribed = true; + + obs.OnError(ex); + + return new MyDisposable(() => { }); + }).ToAsyncEnumerable(); + + Assert.False(subscribed); + + var e = xs.GetAsyncEnumerator(); + + Assert.True(subscribed); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + } + + [Fact] + public void ToAsyncEnumerable5() + { + var set = new HashSet(new[] { 1, 2, 3, 4 }); + + var xs = set.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + NoNext(e); + } + + [Fact] + public async Task ToAsyncEnumerable6() + { + var set = new HashSet(new[] { 1, 2, 3, 4, 5, 6, 7, 8 }); + + var xs = set.ToAsyncEnumerable(); + + var arr = await xs.ToArray(); + + Assert.True(set.SetEquals(arr)); + } + + [Fact] + public async Task ToAsyncEnumerable7() + { + var set = new HashSet(new[] { 1, 2, 3, 4 }); + var xs = set.ToAsyncEnumerable(); + + var arr = await xs.ToList(); + + Assert.True(set.SetEquals(arr)); + } + + [Fact] + public async Task ToAsyncEnumerable8() + { + var set = new HashSet(new[] { 1, 2, 3, 4 }); + var xs = set.ToAsyncEnumerable(); + + var c = await xs.Count(); + + Assert.Equal(set.Count, c); + } + + [Fact] + public async Task ToAsyncEnumerable9() + { + var set = new HashSet(new[] { 1, 2, 3, 4 }); + var xs = set.ToAsyncEnumerable(); + + await SequenceIdentity(xs); + } + + [Fact] + public async Task ToAsyncEnumerable10() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + await SequenceIdentity(xs); + } + + [Fact] + public void ToAsyncEnumerable11() + { + var set = new HashSet(new[] { 1, 2, 3, 4 }); + var xs = set.ToAsyncEnumerable(); + + var xc = xs as ICollection; + + Assert.NotNull(xc); + + Assert.False(xc.IsReadOnly); + + xc.Add(5); + + + Assert.True(xc.Contains(5)); + + Assert.True(xc.Remove(5)); + + var arr = new int[4]; + xc.CopyTo(arr, 0); + Assert.True(arr.SequenceEqual(xc)); + xc.Clear(); + Assert.Equal(0, xc.Count); + } + + [Fact] + public void ToAsyncEnumerable12() + { + var set = new List { 1, 2, 3, 4 }; + var xs = set.ToAsyncEnumerable(); + + var xl = xs as IList; + + Assert.NotNull(xl); + + Assert.False(xl.IsReadOnly); + + xl.Add(5); + + + Assert.True(xl.Contains(5)); + + Assert.True(xl.Remove(5)); + + xl.Insert(2, 10); + + Assert.Equal(2, xl.IndexOf(10)); + xl.RemoveAt(2); + + xl[0] = 7; + Assert.Equal(7, xl[0]); + + var arr = new int[4]; + xl.CopyTo(arr, 0); + Assert.True(arr.SequenceEqual(xl)); + xl.Clear(); + Assert.Equal(0, xl.Count); + + } + + [Fact] + public void ToAsyncEnumerable_With_Completed_Task() + { + var task = Task.Factory.StartNew(() => 36); + + var xs = task.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + + Assert.True(e.MoveNextAsync().Result); + Assert.Equal(36, e.Current); + Assert.False(e.MoveNextAsync().Result); + } + + [Fact] + public void ToAsyncEnumerable_With_Faulted_Task() + { + var ex = new InvalidOperationException(); + var tcs = new TaskCompletionSource(); + tcs.SetException(ex); + + var xs = tcs.Task.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + } + + [Fact] + public void ToAsyncEnumerable_With_Canceled_Task() + { + var tcs = new TaskCompletionSource(); + tcs.SetCanceled(); + + var xs = tcs.Task.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() is TaskCanceledException); + } + + private sealed class MyObservable : IObservable + { + private Func, IDisposable> _subscribe; + + public MyObservable(Func, IDisposable> subscribe) + { + _subscribe = subscribe; + } + + public IDisposable Subscribe(IObserver observer) + { + return _subscribe(observer); + } + } + + private sealed class MyDisposable : IDisposable + { + private Action _dispose; + + public MyDisposable(Action dispose) + { + _dispose = dispose; + } + + public void Dispose() + { + _dispose(); + } + } + } +} From 1cad8bc5b1aa23bcfb8883cc7e1d5eda475638dd Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:25:43 -0700 Subject: [PATCH 275/862] Adding package build for System.Linq.Async and System.Linq.Async.Queryable. --- Ix.NET/Source/build-new.ps1 | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/build-new.ps1 b/Ix.NET/Source/build-new.ps1 index 95c9d387dc..d7f3868d09 100644 --- a/Ix.NET/Source/build-new.ps1 +++ b/Ix.NET/Source/build-new.ps1 @@ -68,7 +68,7 @@ if ($LastExitCode -ne 0) { } } -dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true +dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true if ($LastExitCode -ne 0) { Write-Host "Error with build" -Foreground Red if($isAppVeyor) { @@ -77,7 +77,7 @@ if ($LastExitCode -ne 0) { } } -dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true +dotnet pack "$scriptPath\System.Linq.Async\System.Linq.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true if ($LastExitCode -ne 0) { Write-Host "Error with build" -Foreground Red if($isAppVeyor) { @@ -86,7 +86,25 @@ if ($LastExitCode -ne 0) { } } -dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true +dotnet pack "$scriptPath\System.Linq.Async.Queryable\System.Linq.Async.Queryable.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true +if ($LastExitCode -ne 0) { + Write-Host "Error with build" -Foreground Red + if($isAppVeyor) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode + } +} + +dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true +if ($LastExitCode -ne 0) { + Write-Host "Error with build" -Foreground Red + if($isAppVeyor) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode + } +} + +dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true if ($LastExitCode -ne 0) { Write-Host "Error with build" -Foreground Red if($isAppVeyor) { From 6c22e1abf3a1e4c50531a8664bef6a0cc3830bfa Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:27:44 -0700 Subject: [PATCH 276/862] Regenerating AsyncQueryable operators. --- .../System/Linq/AsyncQueryableEx.Generated.cs | 68 ++++++++++++++---- .../AsyncQueryableExTests.Generated.cs | 69 ++++++++++++++----- .../AsyncQueryableTests.Generated.cs | 38 ++++++++++ .../System/Linq/AsyncQueryable.Generated.cs | 52 ++++++++++++++ 4 files changed, 193 insertions(+), 34 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index a7bb567b96..9e2e81e5c7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -12,6 +12,20 @@ namespace System.Linq { public static partial class AsyncQueryableEx { + public static IAsyncQueryable Amb(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Amb(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); +#endif + } + public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count) { if (source == null) @@ -486,6 +500,20 @@ public static Task Max(this IAsyncQueryable source, I #endif } + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -500,17 +528,19 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } @@ -558,7 +588,7 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -568,9 +598,9 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -590,19 +620,15 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static IAsyncQueryable Merge(this IAsyncQueryable> sources) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (sources == null) + throw new ArgumentNullException(nameof(sources)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return sources.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Merge(default(IAsyncQueryable>))), sources.Expression)); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return sources.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), sources.Expression)); #endif } @@ -900,5 +926,17 @@ public static IAsyncQueryable StartWith(this IAsyncQueryable Timeout(this IAsyncQueryable source, TimeSpan timeout) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Timeout(default(IAsyncQueryable), default(TimeSpan))), source.Expression, Expression.Constant(timeout, typeof(TimeSpan)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(timeout, typeof(TimeSpan)))); +#endif + } + } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs index d42e7fac07..6c3347872c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs @@ -14,6 +14,17 @@ namespace Tests { public class AsyncQueryableTests { + [Fact] + public void Amb1() + { + AssertEx.Throws(() => AsyncQueryableEx.Amb(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryableEx.Amb(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + + var res = AsyncQueryableEx.Amb(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Buffer1() { @@ -383,6 +394,16 @@ public void Max2() [Fact] public void MaxBy1() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy2() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); @@ -392,17 +413,18 @@ public void MaxBy1() } [Fact] - public void MaxBy2() + public void MaxBy3() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy3() + public void MaxBy4() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -412,7 +434,7 @@ public void MaxBy3() } [Fact] - public void MaxBy4() + public void MaxBy5() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -423,7 +445,7 @@ public void MaxBy4() } [Fact] - public void MaxBy5() + public void MaxBy6() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -433,18 +455,18 @@ public void MaxBy5() } [Fact] - public void MaxBy6() + public void MaxBy7() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy7() + public void MaxBy8() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -455,14 +477,13 @@ public void MaxBy7() } [Fact] - public void MaxBy8() + public void Merge1() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.Merge(default(IAsyncQueryable>)), ane => ane.ParamName == "sources"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryableEx.Merge(new IAsyncEnumerable[] { default(IAsyncEnumerable) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] @@ -688,5 +709,15 @@ public void StartWith1() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Timeout1() + { + AssertEx.Throws(() => AsyncQueryableEx.Timeout(default(IAsyncQueryable), default(TimeSpan)), ane => ane.ParamName == "source"); + + var res = AsyncQueryableEx.Timeout(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(TimeSpan)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs index aafb9a9650..096b7dca39 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs @@ -4325,6 +4325,44 @@ public void ToDictionary16() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void ToHashSet1() + { + AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToHashSet2() + { + AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToHashSet3() + { + AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToHashSet4() + { + AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void ToList1() { diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 8d1c3d1f29..f21aaa9930 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -5964,6 +5964,58 @@ public static Task> ToDictionary> ToHashSet(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + + public static Task> ToHashSet(this IAsyncQueryable source, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); +#endif + } + + public static Task> ToHashSet(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task> ToHashSet(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToList(this IAsyncQueryable source) { if (source == null) From dc027a1ad5d5c360f220acfa91a1dae9cc647bc6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:41:12 -0700 Subject: [PATCH 277/862] Adding ConfigureAwait. --- .../Tasks/AsyncEnumerableExtensions.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs new file mode 100644 index 0000000000..6e46ae231b --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +namespace System.Threading.Tasks +{ + namespace System.Threading.Tasks + { + public static class AsyncEnumerableExtensions + { + public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerable enumerable, bool continueOnCapturedContext) + { + if (enumerable == null) + throw new ArgumentNullException(nameof(enumerable)); + + return new ConfiguredAsyncEnumerable(enumerable, continueOnCapturedContext); + } + + public struct ConfiguredAsyncEnumerable + { + private readonly IAsyncEnumerable _enumerable; + private readonly bool _continueOnCapturedContext; + + internal ConfiguredAsyncEnumerable(IAsyncEnumerable enumerable, bool continueOnCapturedContext) + { + _enumerable = enumerable; + _continueOnCapturedContext = continueOnCapturedContext; + } + + public ConfiguredAsyncEnumerator GetAsyncEnumerator() => + new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(), _continueOnCapturedContext); + + public struct ConfiguredAsyncEnumerator + { + private readonly IAsyncEnumerator _enumerator; + private readonly bool _continueOnCapturedContext; + + internal ConfiguredAsyncEnumerator(IAsyncEnumerator enumerator, bool continueOnCapturedContext) + { + _enumerator = enumerator; + _continueOnCapturedContext = continueOnCapturedContext; + } + + public ConfiguredTaskAwaitable MoveNextAsync() => + _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); + + public T Current => _enumerator.Current; + + public ConfiguredTaskAwaitable DisposeAsync() => + _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); + } + } + } + } +} From a4f3f17770b19a2e26ed38d768ea1fb7faedd70c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:46:11 -0700 Subject: [PATCH 278/862] Fixing build script. --- Ix.NET/Source/build-new.ps1 | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/build-new.ps1 b/Ix.NET/Source/build-new.ps1 index d7f3868d09..c9f96228ca 100644 --- a/Ix.NET/Source/build-new.ps1 +++ b/Ix.NET/Source/build-new.ps1 @@ -65,7 +65,7 @@ if ($LastExitCode -ne 0) { if($isAppVeyor) { $host.SetShouldExit($LastExitCode) exit $LastExitCode - } + } } dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true @@ -74,7 +74,7 @@ if ($LastExitCode -ne 0) { if($isAppVeyor) { $host.SetShouldExit($LastExitCode) exit $LastExitCode - } + } } dotnet pack "$scriptPath\System.Linq.Async\System.Linq.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true @@ -83,7 +83,7 @@ if ($LastExitCode -ne 0) { if($isAppVeyor) { $host.SetShouldExit($LastExitCode) exit $LastExitCode - } + } } dotnet pack "$scriptPath\System.Linq.Async.Queryable\System.Linq.Async.Queryable.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true @@ -92,7 +92,7 @@ if ($LastExitCode -ne 0) { if($isAppVeyor) { $host.SetShouldExit($LastExitCode) exit $LastExitCode - } + } } dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true @@ -101,7 +101,7 @@ if ($LastExitCode -ne 0) { if($isAppVeyor) { $host.SetShouldExit($LastExitCode) exit $LastExitCode - } + } } dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true @@ -110,7 +110,7 @@ if ($LastExitCode -ne 0) { if($isAppVeyor) { $host.SetShouldExit($LastExitCode) exit $LastExitCode - } + } } if($hasSignClientSecret) { @@ -143,25 +143,25 @@ $testDirectory = Join-Path $scriptPath "System.Interactive.Tests" # Use xUnit CLI as it's significantly faster than vstest (dotnet test) $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe" -.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1" +.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1" if ($LastExitCode -ne 0) { - Write-Host "Error with tests" -Foreground Red - if($isAppVeyor) { - $host.SetShouldExit($LastExitCode) - exit $LastExitCode - } + Write-Host "Error with tests" -Foreground Red + if($isAppVeyor) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode + } } $testDirectory = Join-Path $scriptPath "System.Interactive.Async.Tests" -.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2" +.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2" if ($LastExitCode -ne 0) { - Write-Host "Error with tests" -Foreground Red - if($isAppVeyor) { - $host.SetShouldExit($LastExitCode) - exit $LastExitCode - } + Write-Host "Error with tests" -Foreground Red + if($isAppVeyor) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode + } } .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover" From 37c8ee5ceec0bfefbf75b89c1d333e475528a89c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:49:15 -0700 Subject: [PATCH 279/862] Removing dead code. --- .../AsyncTests.cs | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs index dbbf9c06ca..5fa0d0268b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs @@ -3,10 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using FluentAssertions; using Xunit; namespace Tests @@ -42,39 +38,6 @@ public void AssertThrows(Action a, Func assert) Assert.True(false); } } - - public void NoNext(IAsyncEnumerator e) - { - Assert.False(e.MoveNextAsync().Result); - } - - public void HasNext(IAsyncEnumerator e, T value) - { - Assert.True(e.MoveNextAsync().Result); - Assert.Equal(value, e.Current); - } - - public async Task SequenceIdentity(IAsyncEnumerable enumerable) - { - var en1 = enumerable.GetAsyncEnumerator(); - var en2 = enumerable.GetAsyncEnumerator(); - - Assert.Equal(en1.GetType(), en2.GetType()); - - await en1.DisposeAsync(); - await en2.DisposeAsync(); - - var e1t = enumerable.ToList(); - var e2t = enumerable.ToList(); - - await Task.WhenAll(e1t, e2t); - - - var e1Result = e1t.Result; - var e2Result = e2t.Result; - - e1Result.ShouldAllBeEquivalentTo(e2Result); - } #pragma warning restore xUnit1013 // Public method should be marked as test } } From 215dbd25d688aa874b9fd16109bdb0f059343666 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sun, 3 Sep 2017 15:52:58 -0700 Subject: [PATCH 280/862] Removing more dead code. --- .../AsyncTests.Bugs.cs | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 89d81d6eaa..4d5e7252ab 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -21,26 +21,6 @@ public AsyncTests() }; } -#if !NO_THREAD - static IEnumerable Xs(Action a) - { - try - { - var rnd = new Random(); - - while (true) - { - yield return rnd.Next(0, 43); - Thread.Sleep(rnd.Next(0, 500)); - } - } - finally - { - a(); - } - } -#endif - [Fact] public async void CorrectDispose() { @@ -195,10 +175,7 @@ public Enumerator(Func moveNext, Func current, Action dispose) _dispose = dispose; } - public T Current - { - get { return _current(); } - } + public T Current => _current(); public void Dispose() => _dispose(); From eef69d99b9b9b2ac6371979a6a76c94931971595 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 10:24:02 -0700 Subject: [PATCH 281/862] Cleaning up some XML docs. --- .../System.Interactive/System/Linq/IAwaitable.cs | 7 +++++++ .../System.Interactive/System/Linq/IAwaiter.cs | 14 ++++++++++++++ .../System.Interactive/System/Linq/IYielder.cs | 8 +++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs b/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs index 8b061fa0fd..3737a44a17 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/IAwaitable.cs @@ -4,8 +4,15 @@ namespace System.Linq { + /// + /// Interface for objects that can be awaited for the completion of an asynchronous operation. + /// public interface IAwaitable { + /// + /// Gets an awaiter object. + /// + /// Awaiter object. IAwaiter GetAwaiter(); } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs b/Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs index 9b22236d2b..b7ba2f552b 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/IAwaiter.cs @@ -6,9 +6,23 @@ namespace System.Linq { + /// + /// Interface for an awaiter of an asynchronous operation. + /// public interface IAwaiter : ICriticalNotifyCompletion { + /// + /// Gets a Boolean value indicating whether the asynchronous operation has completed. + /// bool IsCompleted { get; } + + /// + /// Gets the result of the asynchronous operation. + /// + /// + /// This method may cause blocking if invoked prior to returning true. + /// Completion of the asynchronous operation can be observed using . + /// void GetResult(); } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs b/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs index d927b78304..0759a8878a 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/IYielder.cs @@ -2,24 +2,22 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Security; - namespace System.Linq { /// - /// Interface for yielding elements to enumerator. + /// Interface for yielding elements to enumerator. /// /// Type of the elements yielded to an enumerator. public interface IYielder { /// - /// Stops the enumeration. + /// Stops the enumeration. /// /// Awaitable object for use in an asynchronous method. IAwaitable Break(); /// - /// Yields a value to the enumerator. + /// Yields a value to the enumerator. /// /// Value to yield return. /// Awaitable object for use in an asynchronous method. From 8c66936475bdd478d04573dc1607196d68f957ef Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 10:25:15 -0700 Subject: [PATCH 282/862] Putting IBuffer in its own file. --- .../System.Interactive/System/Linq/IBuffer.cs | 16 ++++++++++++++++ .../System/Linq/Operators/Buffer.cs | 8 -------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/IBuffer.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IBuffer.cs b/Ix.NET/Source/System.Interactive/System/Linq/IBuffer.cs new file mode 100644 index 0000000000..3428d41044 --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/IBuffer.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + /// + /// Represents a buffer exposing a shared view over an underlying enumerable sequence. + /// + /// Element type. + public interface IBuffer : IEnumerable, IDisposable + { + } +} diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs index 9d8334fa8e..2b6d292b15 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs @@ -69,12 +69,4 @@ private static IEnumerable> Buffer_(this IEnumerable - /// Represents a buffer exposing a shared view over an underlying enumerable sequence. - /// - /// Element type. - public interface IBuffer : IEnumerable, IDisposable - { - } } From 0e3519071489b2c28b9fe4c8f8342746072676f8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 10:25:53 -0700 Subject: [PATCH 283/862] Fixing XML doc style. --- .../System/Linq/Operators/Buffer.cs | 4 +- .../System/Linq/Operators/Case.cs | 10 ++-- .../System/Linq/Operators/Catch.cs | 10 ++-- .../System/Linq/Operators/Concat.cs | 4 +- .../System/Linq/Operators/Create.cs | 8 +-- .../System/Linq/Operators/Defer.cs | 2 +- .../System/Linq/Operators/Do.cs | 14 ++--- .../System/Linq/Operators/Expand.cs | 2 +- .../System/Linq/Operators/Finally.cs | 2 +- .../System/Linq/Operators/For.cs | 8 +-- .../System/Linq/Operators/ForEach.cs | 4 +- .../System/Linq/Operators/Generate.cs | 2 +- .../System/Linq/Operators/Hide.cs | 6 +- .../System/Linq/Operators/If.cs | 6 +- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../System/Linq/Operators/IsEmpty.cs | 2 +- .../System/Linq/Operators/Max.cs | 2 +- .../System/Linq/Operators/MaxBy.cs | 4 +- .../System/Linq/Operators/Memoize.cs | 58 +++++++++---------- .../System/Linq/Operators/Min.cs | 2 +- .../System/Linq/Operators/MinBy.cs | 4 +- .../Linq/Operators/OnErrorResumeNext.cs | 10 ++-- .../System/Linq/Operators/Publish.cs | 34 +++++------ .../System/Linq/Operators/Repeat.cs | 8 +-- .../System/Linq/Operators/Retry.cs | 6 +- .../System/Linq/Operators/Return.cs | 2 +- .../System/Linq/Operators/Scan.cs | 12 ++-- .../System/Linq/Operators/SelectMany.cs | 2 +- .../System/Linq/Operators/Share.cs | 30 +++++----- .../System/Linq/Operators/SkipLast.cs | 6 +- .../System/Linq/Operators/StartsWith.cs | 2 +- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/Throw.cs | 2 +- .../System/Linq/Operators/Using.cs | 4 +- .../System/Linq/Operators/While.cs | 2 +- 35 files changed, 139 insertions(+), 139 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs index 2b6d292b15..b9071f5f13 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Generates a sequence of non-overlapping adjacent buffers over the source sequence. + /// Generates a sequence of non-overlapping adjacent buffers over the source sequence. /// /// Source sequence element type. /// Source sequence. @@ -26,7 +26,7 @@ public static IEnumerable> Buffer(this IEnumerable - /// Generates a sequence of buffers over the source sequence, with specified length and possible overlap. + /// Generates a sequence of buffers over the source sequence, with specified length and possible overlap. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs index be55b6af5c..894d1de8d7 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs @@ -12,7 +12,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns a sequence from a dictionary based on the result of evaluating a selector function. + /// Returns a sequence from a dictionary based on the result of evaluating a selector function. /// /// Type of the selector value. /// Result sequence element type. @@ -30,16 +30,16 @@ public static IEnumerable Case(Func selector, } /// - /// Returns a sequence from a dictionary based on the result of evaluating a selector function, also specifying a - /// default sequence. + /// Returns a sequence from a dictionary based on the result of evaluating a selector function, also specifying a + /// default sequence. /// /// Type of the selector value. /// Result sequence element type. /// Selector function used to pick a sequence from the given sources. /// Dictionary mapping selector values onto resulting sequences. /// - /// Default sequence to return in case there's no corresponding source for the computed - /// selector value. + /// Default sequence to return in case there's no corresponding source for the computed + /// selector value. /// /// The source sequence corresponding with the evaluated selector value; otherwise, the default source. public static IEnumerable Case(Func selector, IDictionary> sources, IEnumerable defaultSource) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs index df4c671d54..9ec678ee7e 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs @@ -9,8 +9,8 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates a sequence that corresponds to the source sequence, concatenating it with the sequence resulting from - /// calling an exception handler function in case of an error. + /// Creates a sequence that corresponds to the source sequence, concatenating it with the sequence resulting from + /// calling an exception handler function in case of an error. /// /// Source sequence element type. /// Exception type to catch. @@ -29,7 +29,7 @@ public static IEnumerable Catch(this IEnumerable - /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. + /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. /// /// Source sequence element type. /// Source sequences. @@ -43,7 +43,7 @@ public static IEnumerable Catch(this IEnumerable - /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. + /// Creates a sequence by concatenating source sequences until a source sequence completes successfully. /// /// Source sequence element type. /// Source sequences. @@ -57,7 +57,7 @@ public static IEnumerable Catch(params IEnumerable[] } /// - /// Creates a sequence that returns the elements of the first sequence, switching to the second in case of an error. + /// Creates a sequence that returns the elements of the first sequence, switching to the second in case of an error. /// /// Source sequence element type. /// First sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs index adab68131c..527d007164 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Concatenates the input sequences. + /// Concatenates the input sequences. /// /// Source sequence element type. /// Source sequences. @@ -23,7 +23,7 @@ public static IEnumerable Concat(this IEnumerable - /// Concatenates the input sequences. + /// Concatenates the input sequences. /// /// Source sequence element type. /// Source sequences. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs index 2b63c07a20..1adc78a5b9 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs @@ -10,7 +10,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates an enumerable sequence based on an enumerator factory function. + /// Creates an enumerable sequence based on an enumerator factory function. /// /// Result sequence element type. /// Enumerator factory function. @@ -24,12 +24,12 @@ public static IEnumerable Create(Func> ge } /// - /// Creates an enumerable sequence based on an asynchronous method that provides a yielder. + /// Creates an enumerable sequence based on an asynchronous method that provides a yielder. /// /// Result sequence element type. /// - /// Delegate implementing an asynchronous method that can use the specified yielder to yield return - /// values. + /// Delegate implementing an asynchronous method that can use the specified yielder to yield return + /// values. /// /// Sequence that will use the asynchronous method to obtain its elements. public static IEnumerable Create(Action> create) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs index b3f5e83a47..0c0f9bee43 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates an enumerable sequence based on an enumerable factory function. + /// Creates an enumerable sequence based on an enumerable factory function. /// /// Result sequence element type. /// Enumerable factory function. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs index c3acff9519..f6d0331442 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Lazily invokes an action for each value in the sequence. + /// Lazily invokes an action for each value in the sequence. /// /// Source sequence element type. /// Source sequence. @@ -26,7 +26,7 @@ public static IEnumerable Do(this IEnumerable source, } /// - /// Lazily invokes an action for each value in the sequence, and executes an action for successful termination. + /// Lazily invokes an action for each value in the sequence, and executes an action for successful termination. /// /// Source sequence element type. /// Source sequence. @@ -46,7 +46,7 @@ public static IEnumerable Do(this IEnumerable source, } /// - /// Lazily invokes an action for each value in the sequence, and executes an action upon exceptional termination. + /// Lazily invokes an action for each value in the sequence, and executes an action upon exceptional termination. /// /// Source sequence element type. /// Source sequence. @@ -66,8 +66,8 @@ public static IEnumerable Do(this IEnumerable source, } /// - /// Lazily invokes an action for each value in the sequence, and executes an action upon successful or exceptional - /// termination. + /// Lazily invokes an action for each value in the sequence, and executes an action upon successful or exceptional + /// termination. /// /// Source sequence element type. /// Source sequence. @@ -90,7 +90,7 @@ public static IEnumerable Do(this IEnumerable source, } /// - /// Lazily invokes observer methods for each value in the sequence, and upon successful or exceptional termination. + /// Lazily invokes observer methods for each value in the sequence, and upon successful or exceptional termination. /// /// Source sequence element type. /// Source sequence. @@ -107,7 +107,7 @@ public static IEnumerable Do(this IEnumerable source, } /// - /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds. + /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds. /// /// Result sequence element type. /// Source sequence to repeat while the condition evaluates true. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs index 66494ed7fa..888fa7cbef 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Expands the sequence by recursively applying a selector function. + /// Expands the sequence by recursively applying a selector function. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs index 797a3a418a..71265692f4 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed. + /// Creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs index d0c2798d06..b3daa9859f 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs @@ -9,16 +9,16 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Generates a sequence by enumerating a source sequence, mapping its elements on result sequences, and concatenating - /// those sequences. + /// Generates a sequence by enumerating a source sequence, mapping its elements on result sequences, and concatenating + /// those sequences. /// /// Source sequence element type. /// Result sequence element type. /// Source sequence. /// Result selector to evaluate for each iteration over the source. /// - /// Sequence concatenating the inner sequences that result from evaluating the result selector on elements from - /// the source. + /// Sequence concatenating the inner sequences that result from evaluating the result selector on elements from + /// the source. /// public static IEnumerable For(IEnumerable source, Func> resultSelector) { diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs index 39b885b435..7f256a42cc 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Enumerates the sequence and invokes the given action for each value in the sequence. + /// Enumerates the sequence and invokes the given action for each value in the sequence. /// /// Source sequence element type. /// Source sequence. @@ -26,7 +26,7 @@ public static void ForEach(this IEnumerable source, Action - /// Enumerates the sequence and invokes the given action for each value in the sequence. + /// Enumerates the sequence and invokes the given action for each value in the sequence. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs index c7c104bb94..5c1b1c723b 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Generate.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Generates a sequence by mimicking a for loop. + /// Generates a sequence by mimicking a for loop. /// /// State type. /// Result sequence element type. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs index a27f356889..978e6e484f 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs @@ -9,14 +9,14 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Hides the enumerable sequence object identity. + /// Hides the enumerable sequence object identity. /// /// Source sequence element type. /// Source sequence. /// Enumerable sequence with the same behavior as the original, but hiding the source object identity. /// - /// AsEnumerable doesn't hide the object identity, and simply acts as a cast to the IEnumerable<TSource> - /// interface. + /// AsEnumerable doesn't hide the object identity, and simply acts as a cast to the IEnumerable<TSource> + /// interface. /// public static IEnumerable Hide(this IEnumerable source) { diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/If.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/If.cs index 885325c970..bf1a28ae1e 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/If.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/If.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns an enumerable sequence based on the evaluation result of the given condition. + /// Returns an enumerable sequence based on the evaluation result of the given condition. /// /// Result sequence element type. /// Condition to evaluate. @@ -29,8 +29,8 @@ public static IEnumerable If(Func condition, IEnumerable } /// - /// Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty - /// sequence. + /// Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty + /// sequence. /// /// Result sequence element type. /// Condition to evaluate. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs index 62e29d4851..9ece9b290a 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Ignores all elements in the source sequence. + /// Ignores all elements in the source sequence. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IsEmpty.cs index 7d2747d2e7..c4c0ce5921 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IsEmpty.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Determines whether an enumerable sequence is empty. + /// Determines whether an enumerable sequence is empty. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs index ba796b5785..154ebaa4dd 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Max.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns the maximum value in the enumerable sequence by using the specified comparer to compare values. + /// Returns the maximum value in the enumerable sequence by using the specified comparer to compare values. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs index d1dc988852..c0b6de6ac9 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns the elements with the maximum key value by using the default comparer to compare key values. + /// Returns the elements with the maximum key value by using the default comparer to compare key values. /// /// Source sequence element type. /// Key type. @@ -27,7 +27,7 @@ public static IList MaxBy(this IEnumerable sour } /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. + /// Returns the elements with the minimum key value by using the specified comparer to compare key values. /// /// Source sequence element type. /// Key type. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs index 3683732515..6c322cb89b 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs @@ -11,27 +11,27 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates a buffer with a view over the source sequence, causing each enumerator to obtain access to all of the - /// sequence's elements without causing multiple enumerations over the source. + /// Creates a buffer with a view over the source sequence, causing each enumerator to obtain access to all of the + /// sequence's elements without causing multiple enumerations over the source. /// /// Source sequence element type. /// Source sequence. /// - /// Buffer enabling each enumerator to retrieve all elements from the shared source sequence, without duplicating - /// source enumeration side-effects. + /// Buffer enabling each enumerator to retrieve all elements from the shared source sequence, without duplicating + /// source enumeration side-effects. /// /// - /// var rng = Enumerable.Range(0, 10).Do(x => Console.WriteLine(x)).Memoize(); - /// var e1 = rng.GetEnumerator(); - /// Assert.IsTrue(e1.MoveNext()); // Prints 0 - /// Assert.AreEqual(0, e1.Current); - /// Assert.IsTrue(e1.MoveNext()); // Prints 1 - /// Assert.AreEqual(1, e1.Current); - /// var e2 = rng.GetEnumerator(); - /// Assert.IsTrue(e2.MoveNext()); // Doesn't print anything; the side-effect of Do - /// Assert.AreEqual(0, e2.Current); // has already taken place during e1's iteration. - /// Assert.IsTrue(e1.MoveNext()); // Prints 2 - /// Assert.AreEqual(2, e1.Current); + /// var rng = Enumerable.Range(0, 10).Do(x => Console.WriteLine(x)).Memoize(); + /// var e1 = rng.GetEnumerator(); + /// Assert.IsTrue(e1.MoveNext()); // Prints 0 + /// Assert.AreEqual(0, e1.Current); + /// Assert.IsTrue(e1.MoveNext()); // Prints 1 + /// Assert.AreEqual(1, e1.Current); + /// var e2 = rng.GetEnumerator(); + /// Assert.IsTrue(e2.MoveNext()); // Doesn't print anything; the side-effect of Do + /// Assert.AreEqual(0, e2.Current); // has already taken place during e1's iteration. + /// Assert.IsTrue(e1.MoveNext()); // Prints 2 + /// Assert.AreEqual(2, e1.Current); /// public static IBuffer Memoize(this IEnumerable source) { @@ -42,8 +42,8 @@ public static IBuffer Memoize(this IEnumerable source } /// - /// Memoizes the source sequence within a selector function where each enumerator can get access to all of the - /// sequence's elements without causing multiple enumerations over the source. + /// Memoizes the source sequence within a selector function where each enumerator can get access to all of the + /// sequence's elements without causing multiple enumerations over the source. /// /// Source sequence element type. /// Result sequence element type. @@ -61,18 +61,18 @@ public static IEnumerable Memoize(this IEnumerable - /// Creates a buffer with a view over the source sequence, causing a specified number of enumerators to obtain access - /// to all of the sequence's elements without causing multiple enumerations over the source. + /// Creates a buffer with a view over the source sequence, causing a specified number of enumerators to obtain access + /// to all of the sequence's elements without causing multiple enumerations over the source. /// /// Source sequence element type. /// Source sequence. /// - /// Number of enumerators that can access the underlying buffer. Once every enumerator has - /// obtained an element from the buffer, the element is removed from the buffer. + /// Number of enumerators that can access the underlying buffer. Once every enumerator has + /// obtained an element from the buffer, the element is removed from the buffer. /// /// - /// Buffer enabling a specified number of enumerators to retrieve all elements from the shared source sequence, - /// without duplicating source enumeration side-effects. + /// Buffer enabling a specified number of enumerators to retrieve all elements from the shared source sequence, + /// without duplicating source enumeration side-effects. /// public static IBuffer Memoize(this IEnumerable source, int readerCount) { @@ -85,19 +85,19 @@ public static IBuffer Memoize(this IEnumerable source } /// - /// Memoizes the source sequence within a selector function where a specified number of enumerators can get access to - /// all of the sequence's elements without causing multiple enumerations over the source. + /// Memoizes the source sequence within a selector function where a specified number of enumerators can get access to + /// all of the sequence's elements without causing multiple enumerations over the source. /// /// Source sequence element type. /// Result sequence element type. /// Source sequence. /// - /// Number of enumerators that can access the underlying buffer. Once every enumerator has - /// obtained an element from the buffer, the element is removed from the buffer. + /// Number of enumerators that can access the underlying buffer. Once every enumerator has + /// obtained an element from the buffer, the element is removed from the buffer. /// /// - /// Selector function with memoized access to the source sequence for a specified number of - /// enumerators. + /// Selector function with memoized access to the source sequence for a specified number of + /// enumerators. /// /// Sequence resulting from applying the selector function to the memoized view over the source sequence. public static IEnumerable Memoize(this IEnumerable source, int readerCount, Func, IEnumerable> selector) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs index 4904538a70..3659714db0 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Min.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns the minimum value in the enumerable sequence by using the specified comparer to compare values. + /// Returns the minimum value in the enumerable sequence by using the specified comparer to compare values. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs index 8406f74284..4dbf9100e8 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MinBy.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns the elements with the minimum key value by using the default comparer to compare key values. + /// Returns the elements with the minimum key value by using the default comparer to compare key values. /// /// Source sequence element type. /// Key type. @@ -27,7 +27,7 @@ public static IList MinBy(this IEnumerable sour } /// - /// Returns the elements with the minimum key value by using the specified comparer to compare key values. + /// Returns the elements with the minimum key value by using the specified comparer to compare key values. /// /// Source sequence element type. /// Key type. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs index f063232d7f..425da3207c 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates a sequence that concatenates both given sequences, regardless of whether an error occurs. + /// Creates a sequence that concatenates both given sequences, regardless of whether an error occurs. /// /// Source sequence element type. /// First sequence. @@ -26,8 +26,8 @@ public static IEnumerable OnErrorResumeNext(this IEnumerable - /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the - /// sequences. + /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the + /// sequences. /// /// Source sequence element type. /// Source sequences. @@ -41,8 +41,8 @@ public static IEnumerable OnErrorResumeNext(params IEnumerable } /// - /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the - /// sequences. + /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the + /// sequences. /// /// Source sequence element type. /// Source sequences. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs index 1a3ed9a88b..a301ec2fa5 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Publish.cs @@ -10,27 +10,27 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates a buffer with a view over the source sequence, causing each enumerator to obtain access to the remainder of - /// the sequence from the current index in the buffer. + /// Creates a buffer with a view over the source sequence, causing each enumerator to obtain access to the remainder of + /// the sequence from the current index in the buffer. /// /// Source sequence element type. /// Source sequence. /// - /// Buffer enabling each enumerator to retrieve elements from the shared source sequence, starting from the index - /// at the point of obtaining the enumerator. + /// Buffer enabling each enumerator to retrieve elements from the shared source sequence, starting from the index + /// at the point of obtaining the enumerator. /// /// - /// var rng = Enumerable.Range(0, 10).Publish(); - /// var e1 = rng.GetEnumerator(); // e1 has a view on the source starting from element 0 - /// Assert.IsTrue(e1.MoveNext()); - /// Assert.AreEqual(0, e1.Current); - /// Assert.IsTrue(e1.MoveNext()); - /// Assert.AreEqual(1, e1.Current); - /// var e2 = rng.GetEnumerator(); - /// Assert.IsTrue(e2.MoveNext()); // e2 has a view on the source starting from element 2 - /// Assert.AreEqual(2, e2.Current); - /// Assert.IsTrue(e1.MoveNext()); // e1 continues to enumerate over its view - /// Assert.AreEqual(2, e1.Current); + /// var rng = Enumerable.Range(0, 10).Publish(); + /// var e1 = rng.GetEnumerator(); // e1 has a view on the source starting from element 0 + /// Assert.IsTrue(e1.MoveNext()); + /// Assert.AreEqual(0, e1.Current); + /// Assert.IsTrue(e1.MoveNext()); + /// Assert.AreEqual(1, e1.Current); + /// var e2 = rng.GetEnumerator(); + /// Assert.IsTrue(e2.MoveNext()); // e2 has a view on the source starting from element 2 + /// Assert.AreEqual(2, e2.Current); + /// Assert.IsTrue(e1.MoveNext()); // e1 continues to enumerate over its view + /// Assert.AreEqual(2, e1.Current); /// public static IBuffer Publish(this IEnumerable source) { @@ -41,8 +41,8 @@ public static IBuffer Publish(this IEnumerable source } /// - /// Publishes the source sequence within a selector function where each enumerator can obtain a view over a tail of the - /// source sequence. + /// Publishes the source sequence within a selector function where each enumerator can obtain a view over a tail of the + /// source sequence. /// /// Source sequence element type. /// Result sequence element type. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs index e007c0fb80..ef311bbfd1 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Generates a sequence by repeating the given value infinitely. + /// Generates a sequence by repeating the given value infinitely. /// /// Result sequence element type. /// Value to repreat in the resulting sequence. @@ -21,7 +21,7 @@ public static IEnumerable Repeat(TResult value) } /// - /// Generates a sequence that contains one repeated value. + /// Generates a sequence that contains one repeated value. /// /// Result sequence element type. /// The value to be repeated. @@ -33,7 +33,7 @@ public static IEnumerable Repeat(TResult element, int count) } /// - /// Repeats and concatenates the source sequence infinitely. + /// Repeats and concatenates the source sequence infinitely. /// /// Source sequence element type. /// Source sequence. @@ -47,7 +47,7 @@ public static IEnumerable Repeat(this IEnumerable sou } /// - /// Repeats and concatenates the source sequence the given number of times. + /// Repeats and concatenates the source sequence the given number of times. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Retry.cs index 548418d92b..7600cbb312 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Retry.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates a sequence that retries enumerating the source sequence as long as an error occurs. + /// Creates a sequence that retries enumerating the source sequence as long as an error occurs. /// /// Source sequence element type. /// Source sequence. @@ -23,8 +23,8 @@ public static IEnumerable Retry(this IEnumerable sour } /// - /// Creates a sequence that retries enumerating the source sequence as long as an error occurs, with the specified - /// maximum number of retries. + /// Creates a sequence that retries enumerating the source sequence as long as an error occurs, with the specified + /// maximum number of retries. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Return.cs index b07bd7b8e5..a09cf4e6de 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Return.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns a sequence with a single element. + /// Returns a sequence with a single element. /// /// Result sequence element type. /// Single element of the resulting sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs index 39b8c12eaa..98e6583362 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs @@ -9,15 +9,15 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. + /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. /// /// Source sequence element type. /// Accumulation type. /// Source sequence. /// Accumulator seed value. /// - /// Accumulation function to apply to the current accumulation value and each element of the - /// sequence. + /// Accumulation function to apply to the current accumulation value and each element of the + /// sequence. /// /// Sequence with all intermediate accumulation values resulting from scanning the sequence. public static IEnumerable Scan(this IEnumerable source, TAccumulate seed, Func accumulator) @@ -31,13 +31,13 @@ public static IEnumerable Scan(this IEnumerab } /// - /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. + /// Generates a sequence of accumulated values by scanning the source sequence and applying an accumulator function. /// /// Source sequence element type. /// Source sequence. /// - /// Accumulation function to apply to the current accumulation value and each element of the - /// sequence. + /// Accumulation function to apply to the current accumulation value and each element of the + /// sequence. /// /// Sequence with all intermediate accumulation values resulting from scanning the sequence. public static IEnumerable Scan(this IEnumerable source, Func accumulator) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SelectMany.cs index 61e1fd9099..db8a35a5ff 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SelectMany.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Projects each element of a sequence to an given sequence and flattens the resulting sequences into one sequence. + /// Projects each element of a sequence to an given sequence and flattens the resulting sequences into one sequence. /// /// First source sequence element type. /// Second source sequence element type. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs index 4dc8345234..61d58d8ac0 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs @@ -10,24 +10,24 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Creates a buffer with a shared view over the source sequence, causing each enumerator to fetch the next element - /// from the source sequence. + /// Creates a buffer with a shared view over the source sequence, causing each enumerator to fetch the next element + /// from the source sequence. /// /// Source sequence element type. /// Source sequence. /// Buffer enabling each enumerator to retrieve elements from the shared source sequence. /// - /// var rng = Enumerable.Range(0, 10).Share(); - /// var e1 = rng.GetEnumerator(); // Both e1 and e2 will consume elements from - /// var e2 = rng.GetEnumerator(); // the source sequence. - /// Assert.IsTrue(e1.MoveNext()); - /// Assert.AreEqual(0, e1.Current); - /// Assert.IsTrue(e1.MoveNext()); - /// Assert.AreEqual(1, e1.Current); - /// Assert.IsTrue(e2.MoveNext()); // e2 "steals" element 2 - /// Assert.AreEqual(2, e2.Current); - /// Assert.IsTrue(e1.MoveNext()); // e1 can't see element 2 - /// Assert.AreEqual(3, e1.Current); + /// var rng = Enumerable.Range(0, 10).Share(); + /// var e1 = rng.GetEnumerator(); // Both e1 and e2 will consume elements from + /// var e2 = rng.GetEnumerator(); // the source sequence. + /// Assert.IsTrue(e1.MoveNext()); + /// Assert.AreEqual(0, e1.Current); + /// Assert.IsTrue(e1.MoveNext()); + /// Assert.AreEqual(1, e1.Current); + /// Assert.IsTrue(e2.MoveNext()); // e2 "steals" element 2 + /// Assert.AreEqual(2, e2.Current); + /// Assert.IsTrue(e1.MoveNext()); // e1 can't see element 2 + /// Assert.AreEqual(3, e1.Current); /// public static IBuffer Share(this IEnumerable source) { @@ -38,8 +38,8 @@ public static IBuffer Share(this IEnumerable source) } /// - /// Shares the source sequence within a selector function where each enumerator can fetch the next element from the - /// source sequence. + /// Shares the source sequence within a selector function where each enumerator can fetch the next element from the + /// source sequence. /// /// Source sequence element type. /// Result sequence element type. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs index 0fb3691bca..f87a9c91b3 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs @@ -9,13 +9,13 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Bypasses a specified number of contiguous elements from the end of the sequence and returns the remaining elements. + /// Bypasses a specified number of contiguous elements from the end of the sequence and returns the remaining elements. /// /// Source sequence element type. /// Source sequence. /// - /// The number of elements to skip from the end of the sequence before returning the remaining - /// elements. + /// The number of elements to skip from the end of the sequence before returning the remaining + /// elements. /// /// Sequence bypassing the specified number of elements counting from the end of the source sequence. public static IEnumerable SkipLast(this IEnumerable source, int count) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs index 9d4d6c57c7..ee0989d1c0 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns the source sequence prefixed with the specified value. + /// Returns the source sequence prefixed with the specified value. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs index be92d2a6cf..3e0ed1d835 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns a specified number of contiguous elements from the end of the sequence. + /// Returns a specified number of contiguous elements from the end of the sequence. /// /// Source sequence element type. /// Source sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs index e5da8eb7fb..0bf9f04e70 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Returns a sequence that throws an exception upon enumeration. + /// Returns a sequence that throws an exception upon enumeration. /// /// Result sequence element type. /// Exception to throw upon enumerating the resulting sequence. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs index 86482ab63c..f0cf0e81b6 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs @@ -9,8 +9,8 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Generates a sequence that's dependent on a resource object whose lifetime is determined by the sequence usage - /// duration. + /// Generates a sequence that's dependent on a resource object whose lifetime is determined by the sequence usage + /// duration. /// /// Source element type. /// Resource type. diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs index 10128c0187..6aa43bd0bf 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs @@ -9,7 +9,7 @@ namespace System.Linq public static partial class EnumerableEx { /// - /// Generates an enumerable sequence by repeating a source sequence as long as the given loop condition holds. + /// Generates an enumerable sequence by repeating a source sequence as long as the given loop condition holds. /// /// Result sequence element type. /// Loop condition. From 94924c06c33804fc9a233f90990463506f6ff616 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 10:43:11 -0700 Subject: [PATCH 284/862] Cleaning up Ix code. --- .../System/Linq/Operators/Buffer.cs | 19 ++++++++---- .../System/Linq/Operators/Case.cs | 16 +++++----- .../System/Linq/Operators/Catch.cs | 14 +++++---- .../System/Linq/Operators/Concat.cs | 10 +++++-- .../System/Linq/Operators/Create.cs | 2 ++ .../System/Linq/Operators/Defer.cs | 6 ++-- .../System/Linq/Operators/Distinct.cs | 9 ++++-- .../Linq/Operators/DistinctUntilChanged.cs | 11 +++---- .../System/Linq/Operators/Do.cs | 30 +++++-------------- .../System/Linq/Operators/DoWhile.cs | 28 +++++++++++++++++ .../System/Linq/Operators/Expand.cs | 4 +-- .../System/Linq/Operators/Finally.cs | 6 ++-- .../System/Linq/Operators/For.cs | 3 +- .../System/Linq/Operators/ForEach.cs | 4 +++ .../System/Linq/Operators/Generate.cs | 6 ++-- .../System/Linq/Operators/Hide.cs | 10 ++++--- .../System/Linq/Operators/IgnoreElements.cs | 6 ++-- .../System/Linq/Operators/MaxBy.cs | 5 +--- .../Linq/Operators/OnErrorResumeNext.cs | 9 +++--- .../System/Linq/Operators/Publish.cs | 22 ++++++++++---- .../System/Linq/Operators/Repeat.cs | 18 ++++++++--- .../System/Linq/Operators/Scan.cs | 10 ++++--- .../System/Linq/Operators/Share.cs | 11 +++++-- .../System/Linq/Operators/SkipLast.cs | 7 +++-- .../System/Linq/Operators/StartsWith.cs | 8 +++-- .../System/Linq/Operators/TakeLast.cs | 9 ++++-- .../System/Linq/Operators/Throw.cs | 4 +-- .../System/Linq/Operators/Using.cs | 8 +++-- .../System/Linq/Operators/While.cs | 5 ++-- 29 files changed, 194 insertions(+), 106 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/Operators/DoWhile.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs index b9071f5f13..dd6df4f0a4 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Buffer.cs @@ -22,7 +22,7 @@ public static IEnumerable> Buffer(this IEnumerable @@ -42,31 +42,38 @@ public static IEnumerable> Buffer(this IEnumerable> Buffer_(this IEnumerable source, int count, int skip) + private static IEnumerable> BufferCore(IEnumerable source, int count, int skip) { var buffers = new Queue>(); var i = 0; foreach (var item in source) { - if (i%skip == 0) + if (i % skip == 0) + { buffers.Enqueue(new List(count)); + } foreach (var buffer in buffers) + { buffer.Add(item); + } - if (buffers.Count > 0 && buffers.Peek() - .Count == count) + if (buffers.Count > 0 && buffers.Peek().Count == count) + { yield return buffers.Dequeue(); + } i++; } while (buffers.Count > 0) + { yield return buffers.Dequeue(); + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs index 894d1de8d7..65194383ce 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Case.cs @@ -2,10 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace System.Linq { @@ -52,11 +49,14 @@ public static IEnumerable Case(Func selector, throw new ArgumentNullException(nameof(defaultSource)); return Defer(() => - { - if (!sources.TryGetValue(selector(), out var result)) - result = defaultSource; - return result; - }); + { + if (!sources.TryGetValue(selector(), out var result)) + { + result = defaultSource; + } + + return result; + }); } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs index 9ec678ee7e..528f06e53b 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Catch.cs @@ -25,7 +25,7 @@ public static IEnumerable Catch(this IEnumerable @@ -39,7 +39,7 @@ public static IEnumerable Catch(this IEnumerable @@ -53,7 +53,7 @@ public static IEnumerable Catch(params IEnumerable[] if (sources == null) throw new ArgumentNullException(nameof(sources)); - return sources.Catch_(); + return CatchCore(sources); } /// @@ -70,10 +70,10 @@ public static IEnumerable Catch(this IEnumerable firs if (second == null) throw new ArgumentNullException(nameof(second)); - return new[] {first, second}.Catch_(); + return CatchCore(new[] { first, second }); } - private static IEnumerable Catch_(this IEnumerable source, Func> handler) + private static IEnumerable CatchCore(IEnumerable source, Func> handler) where TException : Exception { var err = default(IEnumerable); @@ -104,11 +104,13 @@ private static IEnumerable Catch_(this IEnumerable if (err != null) { foreach (var item in err) + { yield return item; + } } } - private static IEnumerable Catch_(this IEnumerable> sources) + private static IEnumerable CatchCore(IEnumerable> sources) { var error = default(Exception); diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs index 527d007164..ad24663f25 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs @@ -19,7 +19,7 @@ public static IEnumerable Concat(this IEnumerable @@ -33,14 +33,18 @@ public static IEnumerable Concat(params IEnumerable[] if (sources == null) throw new ArgumentNullException(nameof(sources)); - return sources.Concat_(); + return ConcatCore(sources); } - private static IEnumerable Concat_(this IEnumerable> sources) + private static IEnumerable ConcatCore(IEnumerable> sources) { foreach (var source in sources) + { foreach (var item in source) + { yield return item; + } + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs index 1adc78a5b9..b3763ebb01 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Create.cs @@ -38,7 +38,9 @@ public static IEnumerable Create(Action> create) throw new ArgumentNullException(nameof(create)); foreach (var x in new Yielder(create)) + { yield return x; + } } private sealed class AnonymousEnumerable : IEnumerable diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs index 0c0f9bee43..829f1fe76b 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Defer.cs @@ -19,13 +19,15 @@ public static IEnumerable Defer(Func> enu if (enumerableFactory == null) throw new ArgumentNullException(nameof(enumerableFactory)); - return Defer_(enumerableFactory); + return DeferCore(enumerableFactory); } - private static IEnumerable Defer_(Func> enumerableFactory) + private static IEnumerable DeferCore(Func> enumerableFactory) { foreach (var item in enumerableFactory()) + { yield return item; + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs index 881b4d9702..febff27cd4 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Distinct.cs @@ -23,7 +23,7 @@ public static IEnumerable Distinct(this IEnumerable.Default); + return DistinctCore(source, keySelector, EqualityComparer.Default); } /// @@ -44,18 +44,21 @@ public static IEnumerable Distinct(this IEnumerable Distinct_(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + private static IEnumerable DistinctCore(IEnumerable source, Func keySelector, IEqualityComparer comparer) { var set = new HashSet(comparer); foreach (var item in source) { var key = keySelector(item); + if (set.Add(key)) + { yield return item; + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs index 0ebad8d138..ffdac09cb8 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/DistinctUntilChanged.cs @@ -19,7 +19,7 @@ public static IEnumerable DistinctUntilChanged(this IEnumerabl if (source == null) throw new ArgumentNullException(nameof(source)); - return source.DistinctUntilChanged_(x => x, EqualityComparer.Default); + return DistinctUntilChangedCore(source, x => x, EqualityComparer.Default); } /// @@ -36,7 +36,7 @@ public static IEnumerable DistinctUntilChanged(this IEnumerabl if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.DistinctUntilChanged_(x => x, comparer); + return DistinctUntilChangedCore(source, x => x, comparer); } /// @@ -54,7 +54,7 @@ public static IEnumerable DistinctUntilChanged(this IEnu if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); + return DistinctUntilChangedCore(source, keySelector, EqualityComparer.Default); } /// @@ -75,10 +75,10 @@ public static IEnumerable DistinctUntilChanged(this IEnu if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.DistinctUntilChanged_(keySelector, comparer); + return DistinctUntilChangedCore(source, keySelector, comparer); } - private static IEnumerable DistinctUntilChanged_(this IEnumerable source, Func keySelector, IEqualityComparer comparer) + private static IEnumerable DistinctUntilChangedCore(IEnumerable source, Func keySelector, IEqualityComparer comparer) { var currentKey = default(TKey); var hasCurrentKey = false; @@ -97,6 +97,7 @@ private static IEnumerable DistinctUntilChanged_(this IE { hasCurrentKey = true; currentKey = key; + yield return item; } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs index f6d0331442..8d269ad7c0 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Do.cs @@ -22,7 +22,7 @@ public static IEnumerable Do(this IEnumerable source, if (onNext == null) throw new ArgumentNullException(nameof(onNext)); - return DoHelper(source, onNext, _ => { }, () => { }); + return DoCore(source, onNext, _ => { }, () => { }); } /// @@ -42,7 +42,7 @@ public static IEnumerable Do(this IEnumerable source, if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); - return DoHelper(source, onNext, _ => { }, onCompleted); + return DoCore(source, onNext, _ => { }, onCompleted); } /// @@ -62,7 +62,7 @@ public static IEnumerable Do(this IEnumerable source, if (onError == null) throw new ArgumentNullException(nameof(onError)); - return DoHelper(source, onNext, onError, () => { }); + return DoCore(source, onNext, onError, () => { }); } /// @@ -86,7 +86,7 @@ public static IEnumerable Do(this IEnumerable source, if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); - return DoHelper(source, onNext, onError, onCompleted); + return DoCore(source, onNext, onError, onCompleted); } /// @@ -103,27 +103,10 @@ public static IEnumerable Do(this IEnumerable source, if (observer == null) throw new ArgumentNullException(nameof(observer)); - return DoHelper(source, observer.OnNext, observer.OnError, observer.OnCompleted); + return DoCore(source, observer.OnNext, observer.OnError, observer.OnCompleted); } - /// - /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds. - /// - /// Result sequence element type. - /// Source sequence to repeat while the condition evaluates true. - /// Loop condition. - /// Sequence generated by repeating the given sequence until the condition evaluates to false. - public static IEnumerable DoWhile(this IEnumerable source, Func condition) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (condition == null) - throw new ArgumentNullException(nameof(condition)); - - return source.Concat(While(condition, source)); - } - - private static IEnumerable DoHelper(this IEnumerable source, Action onNext, Action onError, Action onCompleted) + private static IEnumerable DoCore(IEnumerable source, Action onNext, Action onError, Action onCompleted) { using (var e = source.GetEnumerator()) { @@ -144,6 +127,7 @@ private static IEnumerable DoHelper(this IEnumerable } onNext(current); + yield return current; } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/DoWhile.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/DoWhile.cs new file mode 100644 index 0000000000..b1808060da --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/DoWhile.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class EnumerableEx + { + /// + /// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds. + /// + /// Result sequence element type. + /// Source sequence to repeat while the condition evaluates true. + /// Loop condition. + /// Sequence generated by repeating the given sequence until the condition evaluates to false. + public static IEnumerable DoWhile(this IEnumerable source, Func condition) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (condition == null) + throw new ArgumentNullException(nameof(condition)); + + return source.Concat(While(condition, source)); + } + } +} diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs index 888fa7cbef..fc25b5b98a 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Expand.cs @@ -22,10 +22,10 @@ public static IEnumerable Expand(this IEnumerable sou if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Expand_(selector); + return ExpandCore(source, selector); } - private static IEnumerable Expand_(this IEnumerable source, Func> selector) + private static IEnumerable ExpandCore(IEnumerable source, Func> selector) { var queue = new Queue>(); queue.Enqueue(source); diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs index 71265692f4..f3518cc992 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Finally.cs @@ -22,15 +22,17 @@ public static IEnumerable Finally(this IEnumerable so if (finallyAction == null) throw new ArgumentNullException(nameof(finallyAction)); - return source.Finally_(finallyAction); + return FinallyCore(source, finallyAction); } - private static IEnumerable Finally_(this IEnumerable source, Action finallyAction) + private static IEnumerable FinallyCore(IEnumerable source, Action finallyAction) { try { foreach (var item in source) + { yield return item; + } } finally { diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs index b3daa9859f..56af715d73 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/For.cs @@ -27,8 +27,7 @@ public static IEnumerable For(IEnumerable so if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - return ForCore(source, resultSelector) - .Concat(); + return ForCore(source, resultSelector).Concat(); } private static IEnumerable> ForCore(IEnumerable source, Func> resultSelector) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs index 7f256a42cc..45fa73f71d 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/ForEach.cs @@ -22,7 +22,9 @@ public static void ForEach(this IEnumerable source, Action @@ -40,7 +42,9 @@ public static void ForEach(this IEnumerable source, Action Generate(TState initialState if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - return Generate_(initialState, condition, iterate, resultSelector); + return GenerateCore(initialState, condition, iterate, resultSelector); } - private static IEnumerable Generate_(TState initialState, Func condition, Func iterate, Func resultSelector) + private static IEnumerable GenerateCore(TState initialState, Func condition, Func iterate, Func resultSelector) { for (var i = initialState; condition(i); i = iterate(i)) + { yield return resultSelector(i); + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs index 978e6e484f..214595bf20 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Hide.cs @@ -15,21 +15,23 @@ public static partial class EnumerableEx /// Source sequence. /// Enumerable sequence with the same behavior as the original, but hiding the source object identity. /// - /// AsEnumerable doesn't hide the object identity, and simply acts as a cast to the IEnumerable<TSource> - /// interface. + /// doesn't hide the object identity, and simply acts as a cast + /// to the interface type. /// public static IEnumerable Hide(this IEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Hide_(); + return HideCore(source); } - private static IEnumerable Hide_(this IEnumerable source) + private static IEnumerable HideCore(this IEnumerable source) { foreach (var item in source) + { yield return item; + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs index 9ece9b290a..7b5016c455 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs @@ -19,13 +19,13 @@ public static IEnumerable IgnoreElements(this IEnumerable IgnoreElements_(this IEnumerable source) + private static IEnumerable IgnoreElementsCore(IEnumerable source) { foreach (var item in source) - ; + ; yield break; } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs index c0b6de6ac9..e570c8dcf8 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/MaxBy.cs @@ -72,10 +72,7 @@ private static IList ExtremaBy(IEnumerable sour } else if (cmp > 0) { - result = new List - { - cur - }; + result = new List { cur }; resKey = key; } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs index 425da3207c..fa8ab10db7 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs @@ -22,7 +22,7 @@ public static IEnumerable OnErrorResumeNext(this IEnumerable @@ -37,7 +37,7 @@ public static IEnumerable OnErrorResumeNext(params IEnumerable if (sources == null) throw new ArgumentNullException(nameof(sources)); - return OnErrorResumeNext_(sources); + return OnErrorResumeNextCore(sources); } /// @@ -52,10 +52,10 @@ public static IEnumerable OnErrorResumeNext(this IEnumerable OnErrorResumeNext_(IEnumerable> sources) + private static IEnumerable OnErrorResumeNextCore(IEnumerable> sources) { foreach (var source in sources) { @@ -68,6 +68,7 @@ private static IEnumerable OnErrorResumeNext_(IEnumerable Publish(this IEnumerable selector(source.Publish()) - .GetEnumerator()); + return Create(() => selector(source.Publish()).GetEnumerator()); } - private class PublishedBuffer : IBuffer + private sealed class PublishedBuffer : IBuffer { private RefCountList _buffer; private bool _disposed; @@ -86,7 +85,7 @@ public IEnumerator GetEnumerator() _buffer.ReaderCount++; } - return GetEnumerator_(i); + return GetEnumeratorCore(i); } IEnumerator IEnumerable.GetEnumerator() @@ -114,7 +113,7 @@ public void Dispose() } } - private IEnumerator GetEnumerator_(int i) + private IEnumerator GetEnumeratorCore(int i) { try { @@ -135,8 +134,11 @@ private IEnumerator GetEnumerator_(int i) try { hasValue = _source.MoveNext(); + if (hasValue) + { current = _source.Current; + } } catch (Exception ex) { @@ -150,9 +152,13 @@ private IEnumerator GetEnumerator_(int i) if (_stopped) { if (_error != null) + { throw _error; + } else + { break; + } } if (hasValue) @@ -167,9 +173,13 @@ private IEnumerator GetEnumerator_(int i) } if (hasValue) + { yield return _buffer[i]; + } else + { break; + } i++; } @@ -177,7 +187,9 @@ private IEnumerator GetEnumerator_(int i) finally { if (_buffer != null) + { _buffer.Done(i + 1); + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs index ef311bbfd1..5cf06e5470 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs @@ -17,7 +17,9 @@ public static partial class EnumerableEx public static IEnumerable Repeat(TResult value) { while (true) + { yield return value; + } } /// @@ -43,7 +45,7 @@ public static IEnumerable Repeat(this IEnumerable sou if (source == null) throw new ArgumentNullException(nameof(source)); - return Repeat_(source); + return RepeatCore(source); } /// @@ -60,21 +62,29 @@ public static IEnumerable Repeat(this IEnumerable sou if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - return Repeat_(source, count); + return RepeatCore(source, count); } - private static IEnumerable Repeat_(IEnumerable source) + private static IEnumerable RepeatCore(IEnumerable source) { while (true) + { foreach (var item in source) + { yield return item; + } + } } - private static IEnumerable Repeat_(IEnumerable source, int count) + private static IEnumerable RepeatCore(IEnumerable source, int count) { for (var i = 0; i < count; i++) + { foreach (var item in source) + { yield return item; + } + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs index 98e6583362..e0b77a6e7a 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Scan.cs @@ -27,7 +27,7 @@ public static IEnumerable Scan(this IEnumerab if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return source.Scan_(seed, accumulator); + return ScanCore(source, seed, accumulator); } /// @@ -47,21 +47,22 @@ public static IEnumerable Scan(this IEnumerable sourc if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return source.Scan_(accumulator); + return ScanCore(source, accumulator); } - private static IEnumerable Scan_(this IEnumerable source, TAccumulate seed, Func accumulator) + private static IEnumerable ScanCore(IEnumerable source, TAccumulate seed, Func accumulator) { var acc = seed; foreach (var item in source) { acc = accumulator(acc, item); + yield return acc; } } - private static IEnumerable Scan_(this IEnumerable source, Func accumulator) + private static IEnumerable ScanCore(IEnumerable source, Func accumulator) { var hasSeed = false; var acc = default(TSource); @@ -76,6 +77,7 @@ private static IEnumerable Scan_(this IEnumerable sou } acc = accumulator(acc, item); + yield return acc; } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs index 61d58d8ac0..27fa31931f 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs @@ -71,7 +71,7 @@ public IEnumerator GetEnumerator() if (_disposed) throw new ObjectDisposedException(""); - return GetEnumerator_(); + return GetEnumeratorCore(); } IEnumerator IEnumerable.GetEnumerator() @@ -96,7 +96,7 @@ public void Dispose() } } - private IEnumerator GetEnumerator_() + private IEnumerator GetEnumeratorCore() { while (true) { @@ -109,14 +109,21 @@ private IEnumerator GetEnumerator_() lock (_source) { hasValue = _source.MoveNext(); + if (hasValue) + { current = _source.Current; + } } if (hasValue) + { yield return current; + } else + { break; + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs index f87a9c91b3..b571c7001a 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs @@ -25,18 +25,21 @@ public static IEnumerable SkipLast(this IEnumerable s if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - return source.SkipLast_(count); + return SkipLastCore(source, count); } - private static IEnumerable SkipLast_(this IEnumerable source, int count) + private static IEnumerable SkipLastCore(this IEnumerable source, int count) { var q = new Queue(); foreach (var x in source) { q.Enqueue(x); + if (q.Count > count) + { yield return q.Dequeue(); + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs index ee0989d1c0..efa4e680af 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/StartsWith.cs @@ -20,16 +20,20 @@ public static IEnumerable StartWith(this IEnumerable if (source == null) throw new ArgumentNullException(nameof(source)); - return source.StartWith_(values); + return StartWithCore(source, values); } - private static IEnumerable StartWith_(this IEnumerable source, params TSource[] values) + private static IEnumerable StartWithCore(IEnumerable source, params TSource[] values) { foreach (var x in values) + { yield return x; + } foreach (var item in source) + { yield return item; + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs index 3e0ed1d835..6ebfeeb880 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/TakeLast.cs @@ -22,10 +22,10 @@ public static IEnumerable TakeLast(this IEnumerable s if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - return source.TakeLast_(count); + return TakeLastCore(source, count); } - private static IEnumerable TakeLast_(this IEnumerable source, int count) + private static IEnumerable TakeLastCore(IEnumerable source, int count) { if (count == 0) { @@ -37,12 +37,17 @@ private static IEnumerable TakeLast_(this IEnumerable foreach (var item in source) { if (q.Count >= count) + { q.Dequeue(); + } + q.Enqueue(item); } while (q.Count > 0) + { yield return q.Dequeue(); + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs index 0bf9f04e70..4f60f549f3 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Throw.cs @@ -19,10 +19,10 @@ public static IEnumerable Throw(Exception exception) if (exception == null) throw new ArgumentNullException(nameof(exception)); - return Throw_(exception); + return ThrowCore(exception); } - private static IEnumerable Throw_(Exception exception) + private static IEnumerable ThrowCore(Exception exception) { throw exception; #pragma warning disable 0162 diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs index f0cf0e81b6..24c618fe74 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Using.cs @@ -24,14 +24,18 @@ public static IEnumerable Using(Func res if (enumerableFactory == null) throw new ArgumentNullException(nameof(enumerableFactory)); - return Using_(resourceFactory, enumerableFactory); + return UsingCore(resourceFactory, enumerableFactory); } - private static IEnumerable Using_(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable + private static IEnumerable UsingCore(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable { using (var res = resourceFactory()) + { foreach (var item in enumerableFactory(res)) + { yield return item; + } + } } } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs index 6aa43bd0bf..8fdaa43a42 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/While.cs @@ -22,14 +22,15 @@ public static IEnumerable While(Func condition, IEnumera if (source == null) throw new ArgumentNullException(nameof(source)); - return WhileCore(condition, source) - .Concat(); + return WhileCore(condition, source).Concat(); } private static IEnumerable> WhileCore(Func condition, IEnumerable source) { while (condition()) + { yield return source; + } } } } From 95546a52727f51416236333122e3d3fbebfd7d1d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 10:44:43 -0700 Subject: [PATCH 285/862] Moving IRefCountList to its own file. --- .../System/Linq/IRefCountList.cs | 19 +++++++++++++++++++ .../System/Linq/Operators/Memoize.cs | 16 ---------------- 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/IRefCountList.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/IRefCountList.cs b/Ix.NET/Source/System.Interactive/System/Linq/IRefCountList.cs new file mode 100644 index 0000000000..df173e384b --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/IRefCountList.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +namespace System.Linq +{ + internal interface IRefCountList + { + void Clear(); + + int Count { get; } + + T this[int i] { get; } + + void Add(T item); + + void Done(int index); + } +} diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs index 6c322cb89b..f51b3d440f 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs @@ -240,22 +240,6 @@ private IEnumerator GetEnumerator_() } } - internal interface IRefCountList - { - void Clear(); - - int Count { get; } - - T this[int i] - { - get; - } - - void Add(T item); - - void Done(int index); - } - internal sealed class MaxRefCountList : IRefCountList { private IList _list = new List(); From 8cf5616928f6db4882340bdc52cd801e14e72020 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 10:47:14 -0700 Subject: [PATCH 286/862] Modernizing some code. --- .../System/Linq/Operators/Memoize.cs | 53 ++++++------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs index f51b3d440f..2965c5198d 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs @@ -242,31 +242,17 @@ private IEnumerator GetEnumerator_() internal sealed class MaxRefCountList : IRefCountList { - private IList _list = new List(); + private readonly IList _list = new List(); - public void Clear() - { - _list.Clear(); - } + public void Clear() => _list.Clear(); - public int Count - { - get { return _list.Count; } - } + public int Count => _list.Count; - public T this[int i] - { - get { return _list[i]; } - } + public T this[int i] => _list[i]; - public void Add(T item) - { - _list.Add(item); - } + public void Add(T item) => _list.Add(item); - public void Done(int index) - { - } + public void Done(int index) { } } internal sealed class RefCountList : IRefCountList @@ -283,26 +269,13 @@ public RefCountList(int readerCount) public int ReaderCount { - get - { - return _readerCount; - } - - set - { - _readerCount = value; - } + get => _readerCount; + set => _readerCount = value; } - public void Clear() - { - _list.Clear(); - } + public void Clear() => _list.Clear(); - public int Count - { - get { return _count; } - } + public int Count => _count; public T this[int i] { @@ -314,8 +287,11 @@ public T this[int i] throw new InvalidOperationException("Element no longer available in the buffer."); var val = res.Value; + if (--res.Count == 0) + { _list.Remove(i); + } return val; } @@ -324,12 +300,13 @@ public T this[int i] public void Add(T item) { _list[_count] = new RefCount { Value = item, Count = _readerCount }; + _count++; } public void Done(int index) { - for (int i = index; i < _count; i++) + for (var i = index; i < _count; i++) { var ignore = this[i]; } From 1c3382c776ff2abed628010bbd6a97f6c8fa3600 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 10:48:52 -0700 Subject: [PATCH 287/862] Refactoring some files. --- .../System/Linq/MaxRefCountList.cs | 24 ++++++ .../System/Linq/Operators/Memoize.cs | 82 ------------------- .../System/Linq/RefCountList.cs | 75 +++++++++++++++++ 3 files changed, 99 insertions(+), 82 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/MaxRefCountList.cs create mode 100644 Ix.NET/Source/System.Interactive/System/Linq/RefCountList.cs diff --git a/Ix.NET/Source/System.Interactive/System/Linq/MaxRefCountList.cs b/Ix.NET/Source/System.Interactive/System/Linq/MaxRefCountList.cs new file mode 100644 index 0000000000..9d23331f6d --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/MaxRefCountList.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Linq; + +namespace System.Linq +{ + internal sealed class MaxRefCountList : IRefCountList + { + private readonly IList _list = new List(); + + public void Clear() => _list.Clear(); + + public int Count => _list.Count; + + public T this[int i] => _list[i]; + + public void Add(T item) => _list.Add(item); + + public void Done(int index) { } + } +} diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs index 2965c5198d..abd565e781 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Memoize.cs @@ -4,7 +4,6 @@ using System.Collections; using System.Collections.Generic; -using System.Diagnostics; namespace System.Linq { @@ -239,85 +238,4 @@ private IEnumerator GetEnumerator_() } } } - - internal sealed class MaxRefCountList : IRefCountList - { - private readonly IList _list = new List(); - - public void Clear() => _list.Clear(); - - public int Count => _list.Count; - - public T this[int i] => _list[i]; - - public void Add(T item) => _list.Add(item); - - public void Done(int index) { } - } - - internal sealed class RefCountList : IRefCountList - { - private int _readerCount; - private readonly IDictionary _list; - private int _count; - - public RefCountList(int readerCount) - { - _readerCount = readerCount; - _list = new Dictionary(); - } - - public int ReaderCount - { - get => _readerCount; - set => _readerCount = value; - } - - public void Clear() => _list.Clear(); - - public int Count => _count; - - public T this[int i] - { - get - { - Debug.Assert(i < _count); - - if (!_list.TryGetValue(i, out var res)) - throw new InvalidOperationException("Element no longer available in the buffer."); - - var val = res.Value; - - if (--res.Count == 0) - { - _list.Remove(i); - } - - return val; - } - } - - public void Add(T item) - { - _list[_count] = new RefCount { Value = item, Count = _readerCount }; - - _count++; - } - - public void Done(int index) - { - for (var i = index; i < _count; i++) - { - var ignore = this[i]; - } - - _readerCount--; - } - - private sealed class RefCount - { - public int Count; - public T Value; - } - } } diff --git a/Ix.NET/Source/System.Interactive/System/Linq/RefCountList.cs b/Ix.NET/Source/System.Interactive/System/Linq/RefCountList.cs new file mode 100644 index 0000000000..c574a88872 --- /dev/null +++ b/Ix.NET/Source/System.Interactive/System/Linq/RefCountList.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace System.Linq +{ + internal sealed class RefCountList : IRefCountList + { + private int _readerCount; + private readonly IDictionary _list; + private int _count; + + public RefCountList(int readerCount) + { + _readerCount = readerCount; + _list = new Dictionary(); + } + + public int ReaderCount + { + get => _readerCount; + set => _readerCount = value; + } + + public void Clear() => _list.Clear(); + + public int Count => _count; + + public T this[int i] + { + get + { + Debug.Assert(i < _count); + + if (!_list.TryGetValue(i, out var res)) + throw new InvalidOperationException("Element no longer available in the buffer."); + + var val = res.Value; + + if (--res.Count == 0) + { + _list.Remove(i); + } + + return val; + } + } + + public void Add(T item) + { + _list[_count] = new RefCount { Value = item, Count = _readerCount }; + + _count++; + } + + public void Done(int index) + { + for (var i = index; i < _count; i++) + { + var ignore = this[i]; + } + + _readerCount--; + } + + private sealed class RefCount + { + public int Count; + public T Value; + } + } +} From a91adf1420eda146bad0a3eef701e2bfd1424d9f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 11:04:42 -0700 Subject: [PATCH 288/862] Cleaning up some AssemblyInfo files. --- .../Properties/AssemblyInfo.cs | 9 ++++++--- .../System.Interactive.Async/Properties/AssemblyInfo.cs | 8 +++++--- .../Properties/AssemblyInfo.cs | 8 +++++--- .../Source/System.Interactive/Properties/AssemblyInfo.cs | 9 +++++---- .../Properties/AssemblyInfo.cs | 8 +++++--- .../Source/System.Linq.Async/Properties/AssemblyInfo.cs | 8 +++++--- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Interactive.Async.Providers/Properties/AssemblyInfo.cs index c8d837b731..640bf10dbe 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/Properties/AssemblyInfo.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/Properties/AssemblyInfo.cs @@ -1,5 +1,8 @@ -using System; -using System.Reflection; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Resources; using System.Runtime.InteropServices; using System.Security; @@ -14,4 +17,4 @@ #if HAS_APTCA && NO_CODECOVERAGE [assembly: AllowPartiallyTrustedCallers] -#endif \ No newline at end of file +#endif diff --git a/Ix.NET/Source/System.Interactive.Async/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Interactive.Async/Properties/AssemblyInfo.cs index 6c2beda1e6..640bf10dbe 100644 --- a/Ix.NET/Source/System.Interactive.Async/Properties/AssemblyInfo.cs +++ b/Ix.NET/Source/System.Interactive.Async/Properties/AssemblyInfo.cs @@ -1,5 +1,8 @@ -using System; -using System.Reflection; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Resources; using System.Runtime.InteropServices; using System.Security; @@ -15,4 +18,3 @@ #if HAS_APTCA && NO_CODECOVERAGE [assembly: AllowPartiallyTrustedCallers] #endif - diff --git a/Ix.NET/Source/System.Interactive.Providers/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Interactive.Providers/Properties/AssemblyInfo.cs index d2a0c3b7be..640bf10dbe 100644 --- a/Ix.NET/Source/System.Interactive.Providers/Properties/AssemblyInfo.cs +++ b/Ix.NET/Source/System.Interactive.Providers/Properties/AssemblyInfo.cs @@ -1,10 +1,12 @@ -using System; -using System.Reflection; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Resources; using System.Runtime.InteropServices; using System.Security; - [assembly: NeutralResourcesLanguage("en-US")] #if !PLIB diff --git a/Ix.NET/Source/System.Interactive/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Interactive/Properties/AssemblyInfo.cs index 0bb318ea67..640bf10dbe 100644 --- a/Ix.NET/Source/System.Interactive/Properties/AssemblyInfo.cs +++ b/Ix.NET/Source/System.Interactive/Properties/AssemblyInfo.cs @@ -1,10 +1,12 @@ -using System; -using System.Reflection; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Resources; using System.Runtime.InteropServices; using System.Security; - [assembly: NeutralResourcesLanguage("en-US")] #if !PLIB @@ -16,4 +18,3 @@ #if HAS_APTCA && NO_CODECOVERAGE [assembly: AllowPartiallyTrustedCallers] #endif - diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs index 6c2beda1e6..640bf10dbe 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/Properties/AssemblyInfo.cs @@ -1,5 +1,8 @@ -using System; -using System.Reflection; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Resources; using System.Runtime.InteropServices; using System.Security; @@ -15,4 +18,3 @@ #if HAS_APTCA && NO_CODECOVERAGE [assembly: AllowPartiallyTrustedCallers] #endif - diff --git a/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs index 6c2beda1e6..640bf10dbe 100644 --- a/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs +++ b/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs @@ -1,5 +1,8 @@ -using System; -using System.Reflection; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; using System.Resources; using System.Runtime.InteropServices; using System.Security; @@ -15,4 +18,3 @@ #if HAS_APTCA && NO_CODECOVERAGE [assembly: AllowPartiallyTrustedCallers] #endif - From ba2b26c1a42ae2574e3ed6f7efeb131640bef407 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 11:06:12 -0700 Subject: [PATCH 289/862] Moving some dead code. --- .../System.Interactive.Async/AsyncIterator.cs | 2 +- .../System/Linq/Set.cs | 61 ------------------- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 2edde69963..5cbe6d327e 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -115,6 +115,6 @@ internal enum AsyncIteratorState New = 0, Allocated = 1, Iterating = 2, - Disposed = -1 + Disposed = -1, } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs index 0c28569f4a..60f488cfeb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs @@ -58,73 +58,12 @@ public bool Add(TElement value) return true; } - // If value is in set, remove it and return true; otherwise return false - public bool Remove(TElement value) - { -#if DEBUG - _haveRemoved = true; -#endif - var hashCode = InternalGetHashCode(value); - var bucket = hashCode%_buckets.Length; - var last = -1; - for (var i = _buckets[bucket] - 1; i >= 0; last = i, i = _slots[i]._next) - { - if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) - { - if (last < 0) - { - _buckets[bucket] = _slots[i]._next + 1; - } - else - { - _slots[last]._next = _slots[i]._next; - } - - _slots[i]._hashCode = -1; - _slots[i]._value = default(TElement); - _slots[i]._next = -1; - return true; - } - } - - return false; - } - internal int InternalGetHashCode(TElement value) { // Handle comparer implementations that throw when passed null return (value == null) ? 0 : _comparer.GetHashCode(value) & 0x7FFFFFFF; } - internal TElement[] ToArray() - { -#if DEBUG - Debug.Assert(!_haveRemoved, "Optimised ToArray cannot be called if Remove has been called."); -#endif - var array = new TElement[Count]; - for (var i = 0; i != array.Length; ++i) - { - array[i] = _slots[i]._value; - } - - return array; - } - - internal List ToList() - { -#if DEBUG - Debug.Assert(!_haveRemoved, "Optimised ToList cannot be called if Remove has been called."); -#endif - var count = Count; - var list = new List(count); - for (var i = 0; i != count; ++i) - { - list.Add(_slots[i]._value); - } - - return list; - } - private void Resize() { var newSize = checked((Count*2) + 1); From 25888d7f63bccf97b2091a757b0156f95240ae69 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 11:25:26 -0700 Subject: [PATCH 290/862] Cleaning up Ix-Async. --- .../System/Linq/AsyncEnumerableEx.cs | 2 -- .../System/Linq/Operators/Buffer.cs | 1 + .../System/Linq/Operators/Catch.cs | 8 +++---- .../System/Linq/Operators/Distinct.cs | 16 ++++++++++--- .../Linq/Operators/DistinctUntilChanged.cs | 22 ++++++++++------- .../System/Linq/Operators/Do.cs | 22 ++++++++--------- .../System/Linq/Operators/IgnoreElements.cs | 1 - .../System/Linq/Operators/IsEmpty.cs | 6 ++--- .../System/Linq/Operators/Max.cs | 6 ++--- .../System/Linq/Operators/MaxBy.cs | 24 +++++++++++++------ .../System/Linq/Operators/Min.cs | 6 ++--- .../System/Linq/Operators/MinBy.cs | 24 +++++++++++++------ .../System/Linq/Operators/Never.cs | 3 +-- .../Linq/Operators/OnErrorResumeNext.cs | 8 +++---- .../System/Linq/Operators/Retry.cs | 8 +++++++ 15 files changed, 98 insertions(+), 59 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs index 5f037f2c79..f47320abc5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs @@ -17,8 +17,6 @@ private static IAsyncEnumerator CreateEnumerator(Func(); - var stop = new Action(() => tcs.TrySetCanceled()); - return await moveNext(tcs).ConfigureAwait(false); }, current, diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 20154f4c70..8c65afe207 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -109,6 +109,7 @@ protected override async Task MoveNextCore() continue; // loop } + stopped = true; await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index a617fe0665..37f6682b3d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -38,7 +38,7 @@ public static IAsyncEnumerable Catch(this IEnumerable Catch(params IAsyncEnumerable[] sources) @@ -46,7 +46,7 @@ public static IAsyncEnumerable Catch(params IAsyncEnumerable Catch(this IAsyncEnumerable first, IAsyncEnumerable second) @@ -56,10 +56,10 @@ public static IAsyncEnumerable Catch(this IAsyncEnumerable Catch_(this IEnumerable> sources) + private static IAsyncEnumerable CatchCore(IEnumerable> sources) { return new CatchAsyncIterator(sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index cd115b935a..4990047ed1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.Distinct(keySelector, EqualityComparer.Default); + return DistinctCore(source, keySelector, EqualityComparer.Default); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -30,7 +30,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new DistinctAsyncIterator(source, keySelector, comparer); + return DistinctCore(source, keySelector, comparer); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) @@ -40,7 +40,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.Distinct(keySelector, EqualityComparer.Default); + return DistinctCore(source, keySelector, EqualityComparer.Default); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -52,6 +52,16 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume if (comparer == null) throw new ArgumentNullException(nameof(comparer)); + return DistinctCore(source, keySelector, comparer); + } + + private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + { + return new DistinctAsyncIterator(source, keySelector, comparer); + } + + private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index aa8f017da8..ff6443e79f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -16,7 +15,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this IAsyn if (source == null) throw new ArgumentNullException(nameof(source)); - return source.DistinctUntilChanged(EqualityComparer.Default); + return DistinctUntilChangedCore(source, EqualityComparer.Default); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, IEqualityComparer comparer) @@ -26,7 +25,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this IAsyn if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return new DistinctUntilChangedAsyncIterator(source, comparer); + return DistinctUntilChangedCore(source, comparer); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector) @@ -36,7 +35,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); + return DistinctUntilChangedCore(source, keySelector, EqualityComparer.Default); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -48,7 +47,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.DistinctUntilChanged_(keySelector, comparer); + return DistinctUntilChangedCore(source, keySelector, comparer); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) @@ -58,7 +57,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.DistinctUntilChanged_(keySelector, EqualityComparer.Default); + return DistinctUntilChangedCore(source, keySelector, EqualityComparer.Default); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -70,15 +69,20 @@ public static IAsyncEnumerable DistinctUntilChanged(this if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.DistinctUntilChanged_(keySelector, comparer); + return DistinctUntilChangedCore(source, keySelector, comparer); + } + + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, IEqualityComparer comparer) + { + return new DistinctUntilChangedAsyncIterator(source, comparer); } - private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); } - private static IAsyncEnumerable DistinctUntilChanged_(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index c69659e388..a751eef49a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -17,7 +17,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext, Action onCompleted) @@ -29,7 +29,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext, Action onError) @@ -41,7 +41,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext, Action onError, Action onCompleted) @@ -55,7 +55,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext) @@ -65,7 +65,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onCompleted) @@ -77,7 +77,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError) @@ -89,7 +89,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) @@ -103,7 +103,7 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, IObserver observer) @@ -113,15 +113,15 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable(observer.OnNext), new Action(observer.OnError), new Action(observer.OnCompleted)); + return DoCore(source, new Action(observer.OnNext), new Action(observer.OnError), new Action(observer.OnCompleted)); } - private static IAsyncEnumerable DoHelper(this IAsyncEnumerable source, Action onNext, Action onError, Action onCompleted) + private static IAsyncEnumerable DoCore(IAsyncEnumerable source, Action onNext, Action onError, Action onCompleted) { return new DoAsyncIterator(source, onNext, onError, onCompleted); } - private static IAsyncEnumerable DoHelper(this IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + private static IAsyncEnumerable DoCore(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) { return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index d862afd427..a75348fba7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -58,7 +58,6 @@ protected override async Task MoveNextCore() case AsyncIteratorState.Iterating: while (await enumerator.MoveNextAsync().ConfigureAwait(false)) { - // Do nothing, we're ignoring these elements } break; // case diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index 7ae5379a3b..daa5ca23d4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -15,7 +15,7 @@ public static Task IsEmpty(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.IsEmpty(CancellationToken.None); + return IsEmptyCore(source, CancellationToken.None); } public static Task IsEmpty(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,10 +23,10 @@ public static Task IsEmpty(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return IsEmpty_(source, cancellationToken); + return IsEmptyCore(source, cancellationToken); } - private static async Task IsEmpty_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task IsEmptyCore(IAsyncEnumerable source, CancellationToken cancellationToken) { return !await source.Any(cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index a18417dacb..dd786f1a10 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -17,7 +17,7 @@ public static Task Max(this IAsyncEnumerable source, if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.Max(comparer, CancellationToken.None); + return MaxCore(source, comparer, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) @@ -27,10 +27,10 @@ public static Task Max(this IAsyncEnumerable source, if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return Max_(source, comparer, cancellationToken); + return MaxCore(source, comparer, cancellationToken); } - private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index 61a40095a8..1193abbf6f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -17,7 +17,7 @@ public static Task> MaxBy(this IAsyncEnumerable.Default, CancellationToken.None); } public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) @@ -27,7 +27,7 @@ public static Task> MaxBy(this IAsyncEnumerable.Default, cancellationToken); + return MaxByCore(source, keySelector, Comparer.Default, cancellationToken); } public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) @@ -39,7 +39,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) @@ -51,7 +51,7 @@ public static Task> MaxBy(this IAsyncEnumerable comparer.Compare(key, minValue), cancellationToken); + return MaxByCore(source, keySelector, comparer, cancellationToken); } public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector) @@ -61,7 +61,7 @@ public static Task> MaxBy(this IAsyncEnumerable.Default, CancellationToken.None); } public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) @@ -71,7 +71,7 @@ public static Task> MaxBy(this IAsyncEnumerable.Default, cancellationToken); + return MaxByCore(source, keySelector, Comparer.Default, cancellationToken); } public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) @@ -83,7 +83,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) @@ -95,6 +95,16 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + { + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); + } + + private static Task> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 24b7382d91..c0485f2297 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -17,7 +17,7 @@ public static Task Min(this IAsyncEnumerable source, if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.Min(comparer, CancellationToken.None); + return MinCore(source, comparer, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) @@ -27,10 +27,10 @@ public static Task Min(this IAsyncEnumerable source, if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return Min_(source, comparer, cancellationToken); + return MinCore(source, comparer, cancellationToken); } - private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 39b83bcb6d..83fef303de 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -17,7 +17,7 @@ public static Task> MinBy(this IAsyncEnumerable.Default, CancellationToken.None); } public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) @@ -27,7 +27,7 @@ public static Task> MinBy(this IAsyncEnumerable.Default, cancellationToken); + return MinByCore(source, keySelector, Comparer.Default, cancellationToken); } public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) @@ -39,7 +39,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) @@ -51,7 +51,7 @@ public static Task> MinBy(this IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); + return MinByCore(source, keySelector, comparer, cancellationToken); } public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector) @@ -61,7 +61,7 @@ public static Task> MinBy(this IAsyncEnumerable.Default, CancellationToken.None); } public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) @@ -71,7 +71,7 @@ public static Task> MinBy(this IAsyncEnumerable.Default, cancellationToken); + return MinByCore(source, keySelector, Comparer.Default, cancellationToken); } public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) @@ -83,7 +83,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) @@ -95,6 +95,16 @@ public static Task> MinBy(this IAsyncEnumerable> MinByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + { + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); + } + + private static Task> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index d4ea53c51f..a7a516a8b9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using static System.Linq.AsyncEnumerable; namespace System.Linq { @@ -11,7 +10,7 @@ public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Never() { - return CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); + return AsyncEnumerable.CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index 65720eab88..805285ce3d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -17,7 +17,7 @@ public static IAsyncEnumerable OnErrorResumeNext(this IAsyncEn if (second == null) throw new ArgumentNullException(nameof(second)); - return OnErrorResumeNext_(new[] { first, second }); + return OnErrorResumeNextCore(new[] { first, second }); } public static IAsyncEnumerable OnErrorResumeNext(params IAsyncEnumerable[] sources) @@ -25,7 +25,7 @@ public static IAsyncEnumerable OnErrorResumeNext(params IAsync if (sources == null) throw new ArgumentNullException(nameof(sources)); - return OnErrorResumeNext_(sources); + return OnErrorResumeNextCore(sources); } public static IAsyncEnumerable OnErrorResumeNext(this IEnumerable> sources) @@ -33,10 +33,10 @@ public static IAsyncEnumerable OnErrorResumeNext(this IEnumera if (sources == null) throw new ArgumentNullException(nameof(sources)); - return OnErrorResumeNext_(sources); + return OnErrorResumeNextCore(sources); } - private static IAsyncEnumerable OnErrorResumeNext_(IEnumerable> sources) + private static IAsyncEnumerable OnErrorResumeNextCore(IEnumerable> sources) { return new OnErrorResumeNextAsyncIterator(sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs index e1029ce693..35c3a5b35e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs @@ -29,15 +29,23 @@ public static IAsyncEnumerable Retry(this IAsyncEnumerable Repeat(this IEnumerable source) { while (true) + { foreach (var item in source) + { yield return item; + } + } } private static IEnumerable Repeat(this IEnumerable source, int count) { for (var i = 0; i < count; i++) + { foreach (var item in source) + { yield return item; + } + } } } } From 925216010a04609da97150814ac457a21c8e32ef Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 11:29:17 -0700 Subject: [PATCH 291/862] Removing unused code. --- .../System/Linq/AsyncEnumerableEx.cs | 75 ------------------- .../System/Linq/Operators/Never.cs | 12 ++- 2 files changed, 11 insertions(+), 76 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs index f47320abc5..91355fcaec 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs @@ -2,84 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading.Tasks; - namespace System.Linq { public static partial class AsyncEnumerableEx { - private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Func dispose) - { - var self = new AnonymousAsyncIterator( - async () => - { - var tcs = new TaskCompletionSource(); - - return await moveNext(tcs).ConfigureAwait(false); - }, - current, - dispose - ); - - return self; - } - - private sealed class AnonymousAsyncIterator : AsyncIterator - { - private readonly Func currentFunc; - private readonly Func dispose; - private readonly Func> moveNext; - - public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) - { - Debug.Assert(moveNext != null); - - this.moveNext = moveNext; - this.currentFunc = currentFunc; - this.dispose = dispose; - - // Explicit call to initialize enumerator mode - GetAsyncEnumerator(); - } - - public override AsyncIterator Clone() - { - throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator."); - } - - public override async Task DisposeAsync() - { - if (dispose != null) - { - await dispose().ConfigureAwait(false); - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (await moveNext().ConfigureAwait(false)) - { - current = currentFunc(); - return true; - } - - await DisposeAsync().ConfigureAwait(false); - break; - } - - return false; - } - } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index a7a516a8b9..d112aae7af 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading.Tasks; namespace System.Linq { @@ -10,7 +11,16 @@ public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Never() { - return AsyncEnumerable.CreateEnumerable(() => CreateEnumerator(tcs => tcs.Task, current: null, dispose: null)); + // + // REVIEW: The C# 8.0 proposed interfaces don't allow for cancellation, so this "Never" is + // as never as never can be; it can't be interrupted *at all*, similar to the sync + // variant in Ix. Passing a *hot* CancellationToken to the Never operator doesn't + // seem correct either, given that we return a *cold* sequence. + // + + var tcs = new TaskCompletionSource(); + + return AsyncEnumerable.CreateEnumerable(() => AsyncEnumerable.CreateEnumerator(() => tcs.Task, current: null, dispose: null)); } } } From 1a607efcb8392fa5466e7b36acfecbafa10c7d7d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 11:32:16 -0700 Subject: [PATCH 292/862] Fixing XML doc comment style. --- .../Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index a5d919dff3..3f5540915a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -13,13 +13,13 @@ namespace System.Collections.Generic public static class AsyncEnumerator { /// - /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. + /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. /// /// The enumerator to advance. /// Cancellation token that can be used to cancel the operation. /// - /// Task containing the result of the operation: true if the enumerator was successfully advanced - /// to the next element; false if the enumerator has passed the end of the sequence. + /// Task containing the result of the operation: true if the enumerator was successfully advanced + /// to the next element; false if the enumerator has passed the end of the sequence. /// public static Task MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) { From 1d2540d64464e6e16c60ec1346516b8a94ebe591 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 11:33:07 -0700 Subject: [PATCH 293/862] More stylistic stuff. --- Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs | 6 +++--- .../Source/System.Linq.Async/System/Linq/AsyncIterator.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 5cbe6d327e..6e1871d1e6 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -25,9 +25,9 @@ protected AsyncIterator() public IAsyncEnumerator GetAsyncEnumerator() { - var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? - this : - Clone(); + var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId + ? this + : Clone(); enumerator.state = AsyncIteratorState.Allocated; enumerator.cancellationTokenSource = new CancellationTokenSource(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 0981243e9d..59d6bad366 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -25,9 +25,9 @@ protected AsyncIterator() public IAsyncEnumerator GetAsyncEnumerator() { - var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? - this : - Clone(); + var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId + ? this + : Clone(); enumerator.state = AsyncIteratorState.Allocated; enumerator.cancellationTokenSource = new CancellationTokenSource(); @@ -135,6 +135,6 @@ internal enum AsyncIteratorState New = 0, Allocated = 1, Iterating = 2, - Disposed = -1 + Disposed = -1, } } From 8316c1e12fee0e8fa02e80e8a9fd6d2de951641d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 14:55:56 -0700 Subject: [PATCH 294/862] Moving Queryable tests to their own projects. --- Ix.NET/Source/Ix.NET.sln | 19 +++++++ .../AssertEx.cs | 45 +++++++++++++++++ .../AsyncQueryableExTests.Generated.cs | 34 ++++++------- .../AsyncQueryableExTests.Generated.tt | 0 .../NopObserver.cs | 0 ...m.Interactive.Async.Providers.Tests.csproj | 50 +++++++++++++++++++ .../xunit.runner.json | 5 ++ .../AssertEx.cs | 45 +++++++++++++++++ .../AsyncEnumerableQueryTest.cs | 0 .../AsyncQueryableTests.Generated.cs | 0 .../AsyncQueryableTests.Generated.tt | 0 .../System.Linq.Async.Queryable.Tests.csproj | 19 +++++++ 12 files changed, 200 insertions(+), 17 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Providers.Test/AssertEx.cs rename Ix.NET/Source/{System.Interactive.Async.Tests => System.Interactive.Async.Providers.Test}/AsyncQueryableExTests.Generated.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Tests => System.Interactive.Async.Providers.Test}/AsyncQueryableExTests.Generated.tt (100%) rename Ix.NET/Source/{System.Interactive.Async.Tests => System.Interactive.Async.Providers.Test}/NopObserver.cs (100%) create mode 100644 Ix.NET/Source/System.Interactive.Async.Providers.Test/System.Interactive.Async.Providers.Tests.csproj create mode 100644 Ix.NET/Source/System.Interactive.Async.Providers.Test/xunit.runner.json create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable.Tests/AssertEx.cs rename Ix.NET/Source/{System.Interactive.Async.Tests => System.Linq.Async.Queryable.Tests}/AsyncEnumerableQueryTest.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Tests => System.Linq.Async.Queryable.Tests}/AsyncQueryableTests.Generated.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Tests => System.Linq.Async.Queryable.Tests}/AsyncQueryableTests.Generated.tt (100%) diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index e91e01fdba..036c081c30 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Tests", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable.Tests", "System.Linq.Async.Queryable.Tests\System.Linq.Async.Queryable.Tests.csproj", "{134E9066-6217-4AF0-B408-47D92AB595BD}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers.Tests", "System.Interactive.Async.Providers.Test\System.Interactive.Async.Providers.Tests.csproj", "{974056C0-91BD-4EB6-8431-E30A614FD1D4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -277,6 +279,22 @@ Global {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x64.Build.0 = Release|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.ActiveCfg = Release|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.Build.0 = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|ARM.ActiveCfg = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|ARM.Build.0 = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x64.ActiveCfg = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x64.Build.0 = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x86.ActiveCfg = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x86.Build.0 = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.Build.0 = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|ARM.ActiveCfg = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|ARM.Build.0 = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x64.ActiveCfg = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x64.Build.0 = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.ActiveCfg = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -295,6 +313,7 @@ Global {792093F9-83E4-4630-9652-4328FDAED15F} = {61683064-A120-44A7-A174-E19154F6D84F} {2E23D7AD-0B21-4725-87C4-BD43271260A1} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {134E9066-6217-4AF0-B408-47D92AB595BD} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} + {974056C0-91BD-4EB6-8431-E30A614FD1D4} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AssertEx.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AssertEx.cs new file mode 100644 index 0000000000..1c7c7d5d37 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AssertEx.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using Xunit; +using System; + +namespace Tests +{ + internal class AssertEx + { + internal static void Throws(Action action, Func assert) + where T : Exception + { + var failed = false; + + try + { + action(); + } + catch (T ex) + { + Assert.True(assert(ex)); + + failed = true; + } + + Assert.True(failed); + } + + internal static void SucceedOrFailProper(Action action) + { + try + { + action(); + } + catch (AggregateException ex) + { + var inner = ex.Flatten().InnerException; + + // TODO: proper assert; unfortunately there's not always a good call stack + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs rename to Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs index 6c3347872c..86ef2a65e8 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs @@ -394,6 +394,16 @@ public void Max2() [Fact] public void MaxBy1() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxBy2() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); @@ -403,17 +413,17 @@ public void MaxBy1() } [Fact] - public void MaxBy2() + public void MaxBy3() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy3() + public void MaxBy4() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -424,7 +434,7 @@ public void MaxBy3() } [Fact] - public void MaxBy4() + public void MaxBy5() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -434,7 +444,7 @@ public void MaxBy4() } [Fact] - public void MaxBy5() + public void MaxBy6() { AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -444,16 +454,6 @@ public void MaxBy5() AssertEx.SucceedOrFailProper(() => res.Wait()); } - [Fact] - public void MaxBy6() - { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - [Fact] public void MaxBy7() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableExTests.Generated.tt rename to Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/NopObserver.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Test/NopObserver.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Tests/NopObserver.cs rename to Ix.NET/Source/System.Interactive.Async.Providers.Test/NopObserver.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Test/System.Interactive.Async.Providers.Tests.csproj new file mode 100644 index 0000000000..ad450d908b --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Test/System.Interactive.Async.Providers.Tests.csproj @@ -0,0 +1,50 @@ + + + + netcoreapp1.1;net461 + $(NoWarn);CS0618 + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + AsyncQueryableExTests.Generated.cs + TextTemplatingFileGenerator + + + + + + + + + + True + True + AsyncQueryableExTests.Generated.tt + + + + diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/xunit.runner.json b/Ix.NET/Source/System.Interactive.Async.Providers.Test/xunit.runner.json new file mode 100644 index 0000000000..0a67ebc934 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Test/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "diagnosticMessages": true, + "methodDisplay": "classAndMethod", + "longRunningTestSeconds": 30 +} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AssertEx.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AssertEx.cs new file mode 100644 index 0000000000..1c7c7d5d37 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AssertEx.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using Xunit; +using System; + +namespace Tests +{ + internal class AssertEx + { + internal static void Throws(Action action, Func assert) + where T : Exception + { + var failed = false; + + try + { + action(); + } + catch (T ex) + { + Assert.True(assert(ex)); + + failed = true; + } + + Assert.True(failed); + } + + internal static void SucceedOrFailProper(Action action) + { + try + { + action(); + } + catch (AggregateException ex) + { + var inner = ex.Flatten().InnerException; + + // TODO: proper assert; unfortunately there's not always a good call stack + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncEnumerableQueryTest.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncEnumerableQueryTest.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Tests/AsyncEnumerableQueryTest.cs rename to Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncEnumerableQueryTest.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.cs rename to Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Tests/AsyncQueryableTests.Generated.tt rename to Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj index 9be91e5813..476bc1779b 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -27,4 +27,23 @@ + + + AsyncQueryableTests.Generated.cs + TextTemplatingFileGenerator + + + + + + + + + + True + True + AsyncQueryableTests.Generated.tt + + + From be1ed6c74f9aa2f45194eced338b49c64d31e54d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 14:56:37 -0700 Subject: [PATCH 295/862] Removing dead code. --- .../AssertEx.cs | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs deleted file mode 100644 index 1c7c7d5d37..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AssertEx.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using Xunit; -using System; - -namespace Tests -{ - internal class AssertEx - { - internal static void Throws(Action action, Func assert) - where T : Exception - { - var failed = false; - - try - { - action(); - } - catch (T ex) - { - Assert.True(assert(ex)); - - failed = true; - } - - Assert.True(failed); - } - - internal static void SucceedOrFailProper(Action action) - { - try - { - action(); - } - catch (AggregateException ex) - { - var inner = ex.Flatten().InnerException; - - // TODO: proper assert; unfortunately there's not always a good call stack - } - } - } -} From 8bd3495132f457473b8fd0441646619066c13747 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:04:46 -0700 Subject: [PATCH 296/862] Using Task.FromException in Throw. --- .../System/Linq/AsyncEnumerable.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 90af7a4ad8..1c7b85d689 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -27,14 +27,17 @@ public static IAsyncEnumerable Throw(Exception exception) if (exception == null) throw new ArgumentNullException(nameof(exception)); +#if NO_TASK_FROMEXCEPTION + var tcs = new TaskCompletionSource(); + tcs.TrySetException(exception); + var moveNextThrows = tcs.Task; +#else + var moveNextThrows = Task.FromException(exception); +#endif + return CreateEnumerable( () => CreateEnumerator( - ct => - { - var tcs = new TaskCompletionSource(); - tcs.TrySetException(exception); - return tcs.Task; - }, + () => moveNextThrows, current: null, dispose: null) ); From 7be8459f41668a3bd57665852a77d882fd396e4f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:07:20 -0700 Subject: [PATCH 297/862] Using shared instance for the Never task. --- .../System.Interactive.Async/System/Linq/Operators/Never.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index d112aae7af..c7a81fd21d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -18,9 +18,7 @@ public static IAsyncEnumerable Never() // seem correct either, given that we return a *cold* sequence. // - var tcs = new TaskCompletionSource(); - - return AsyncEnumerable.CreateEnumerable(() => AsyncEnumerable.CreateEnumerator(() => tcs.Task, current: null, dispose: null)); + return AsyncEnumerable.CreateEnumerable(() => AsyncEnumerable.CreateEnumerator(() => TaskExt.Never, current: null, dispose: null)); } } } From e7250662512e295dd66950697952fee7f6a1e058 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:08:13 -0700 Subject: [PATCH 298/862] Removing some dead code. --- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index c0dbaac1af..df0203ef1e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -44,8 +44,6 @@ private static IAsyncEnumerator CreateEnumerator(Func(); - var stop = new Action(() => tcs.TrySetCanceled()); - return await moveNext(tcs).ConfigureAwait(false); }, current, From b47922968281854a02e7ea1284fbac05ac0f1873 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:13:58 -0700 Subject: [PATCH 299/862] Moving some Create methods to AsyncEnumerator. --- .../System/Linq/AsyncEnumerator.cs | 82 +++++++++++++++++++ .../System/Linq/Operators/Create.cs | 76 +---------------- 2 files changed, 84 insertions(+), 74 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 3f5540915a..14f7a2a106 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Diagnostics; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -12,6 +14,30 @@ namespace System.Collections.Generic /// public static class AsyncEnumerator { + public static IAsyncEnumerator Create(Func> moveNext, Func current, Func dispose) + { + if (moveNext == null) + throw new ArgumentNullException(nameof(moveNext)); + + // Note: Many methods pass null in for the second two params. We're assuming + // That the caller is responsible and knows what they're doing + return new AnonymousAsyncIterator(moveNext, current, dispose); + } + + internal static IAsyncEnumerator Create(Func, Task> moveNext, Func current, Func dispose) + { + return new AnonymousAsyncIterator( + async () => + { + var tcs = new TaskCompletionSource(); + + return await moveNext(tcs).ConfigureAwait(false); + }, + current, + dispose + ); + } + /// /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. /// @@ -30,5 +56,61 @@ public static Task MoveNextAsync(this IAsyncEnumerator source, Cance return source.MoveNextAsync(); } + + private sealed class AnonymousAsyncIterator : AsyncIterator + { + private readonly Func currentFunc; + private readonly Func dispose; + private readonly Func> moveNext; + + public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) + { + Debug.Assert(moveNext != null); + + this.moveNext = moveNext; + this.currentFunc = currentFunc; + this.dispose = dispose; + + // Explicit call to initialize enumerator mode + GetAsyncEnumerator(); + } + + public override AsyncIterator Clone() + { + throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator."); + } + + public override async Task DisposeAsync() + { + if (dispose != null) + { + await dispose().ConfigureAwait(false); + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await moveNext().ConfigureAwait(false)) + { + current = currentFunc(); + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index df0203ef1e..3785786bd9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -29,28 +29,12 @@ public static IAsyncEnumerable CreateEnumerable(Func CreateEnumerator(Func> moveNext, Func current, Func dispose) { - if (moveNext == null) - throw new ArgumentNullException(nameof(moveNext)); - - // Note: Many methods pass null in for the second two params. We're assuming - // That the caller is responsible and knows what they're doing - return new AnonymousAsyncIterator(moveNext, current, dispose); + return AsyncEnumerator.Create(moveNext, current, dispose); } private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Func dispose) { - var self = new AnonymousAsyncIterator( - async () => - { - var tcs = new TaskCompletionSource(); - - return await moveNext(tcs).ConfigureAwait(false); - }, - current, - dispose - ); - - return self; + return AsyncEnumerator.Create(moveNext, current, dispose); } private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable @@ -154,61 +138,5 @@ private sealed class DisposedEnumerator : IAsyncEnumerator } } } - - private sealed class AnonymousAsyncIterator : AsyncIterator - { - private readonly Func currentFunc; - private readonly Func dispose; - private readonly Func> moveNext; - - public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) - { - Debug.Assert(moveNext != null); - - this.moveNext = moveNext; - this.currentFunc = currentFunc; - this.dispose = dispose; - - // Explicit call to initialize enumerator mode - GetAsyncEnumerator(); - } - - public override AsyncIterator Clone() - { - throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator."); - } - - public override async Task DisposeAsync() - { - if (dispose != null) - { - await dispose().ConfigureAwait(false); - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (await moveNext().ConfigureAwait(false)) - { - current = currentFunc(); - return true; - } - - await DisposeAsync().ConfigureAwait(false); - break; - } - - return false; - } - } } } From a9c9afdcd9262d893c84053f4c140f162f2646ff Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:21:53 -0700 Subject: [PATCH 300/862] Removing a lot of references to Return. --- .../AsyncTests.Conversions.cs | 4 +- .../System/Linq/AsyncEnumerableExTests.cs | 2 + .../System/Linq/Operators/Buffer.cs | 6 +-- .../System/Linq/Operators/Catch.cs | 6 +-- .../System/Linq/Operators/Distinct.cs | 8 ++-- .../Linq/Operators/DistinctUntilChanged.cs | 8 ++-- .../System/Linq/Operators/Do.cs | 18 ++++---- .../System/Linq/Operators/Expand.cs | 2 +- .../System/Linq/Operators/Finally.cs | 4 +- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../System/Linq/Operators/MaxBy.cs | 12 +++--- .../System/Linq/Operators/MinBy.cs | 12 +++--- .../Linq/Operators/OnErrorResumeNext.cs | 4 +- .../System/Linq/Operators/Repeat.cs | 2 +- .../System/Linq/Operators/Retry.cs | 2 +- .../System/Linq/Operators/Scan.cs | 4 +- .../System/Linq/Operators/SelectMany.cs | 4 +- .../System/Linq/Operators/StartWith.cs | 2 +- .../System/Linq/Operators/Using.cs | 8 ++-- .../System/Linq/AsyncEnumerableTests.cs | 2 + .../System/Linq/Operators/Aggregate.cs | 16 +++---- .../System/Linq/Operators/All.cs | 4 +- .../System/Linq/Operators/Any.cs | 4 +- .../Linq/Operators/AsAsyncEnumerable.cs | 2 +- .../System/Linq/Operators/Concat.cs | 4 +- .../System/Linq/Operators/Contains.cs | 4 +- .../System/Linq/Operators/Count.cs | 4 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 2 +- .../System/Linq/Operators/ElementAt.cs | 8 ++-- .../Linq/Operators/ElementAtOrDefault.cs | 8 ++-- .../System/Linq/Operators/Except.cs | 10 ++--- .../System/Linq/Operators/First.cs | 10 ++--- .../System/Linq/Operators/FirstOrDefault.cs | 10 ++--- .../System/Linq/Operators/ForEachAsync.cs | 8 ++-- .../System/Linq/Operators/GroupBy.cs | 42 +++++++++---------- .../System/Linq/Operators/GroupJoin.cs | 24 +++++------ .../System/Linq/Operators/Intersect.cs | 10 ++--- .../System/Linq/Operators/Join.cs | 24 +++++------ .../System/Linq/Operators/Last.cs | 10 ++--- .../System/Linq/Operators/LastOrDefault.cs | 10 ++--- .../System/Linq/Operators/LongCount.cs | 4 +- .../System/Linq/Operators/OrderBy.cs | 14 +++---- .../System/Linq/Operators/Return.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/Select.cs | 4 +- .../System/Linq/Operators/SelectMany.cs | 12 +++--- .../System/Linq/Operators/SequenceEqual.cs | 20 ++++----- .../System/Linq/Operators/Single.cs | 10 ++--- .../System/Linq/Operators/SingleOrDefault.cs | 10 ++--- .../System/Linq/Operators/SkipWhile.cs | 4 +- .../System/Linq/Operators/TakeWhile.cs | 4 +- .../System/Linq/Operators/ToDictionary.cs | 32 +++++++------- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToLookup.cs | 32 +++++++------- .../System/Linq/Operators/Union.cs | 10 ++--- .../System/Linq/Operators/Where.cs | 4 +- .../System/Linq/Operators/Zip.cs | 6 +-- 58 files changed, 253 insertions(+), 249 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs index 03791f0820..e03f693ea9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs @@ -22,7 +22,7 @@ public void ToEnumerable_Null() [Fact] public void ToEnumerable1() { - var xs = AsyncEnumerable.Return(42).ToEnumerable(); + var xs = AsyncEnumerable.Range(42, 1).ToEnumerable(); Assert.True(xs.SequenceEqual(new[] { 42 })); } @@ -81,7 +81,7 @@ public void ToObservable2() var fail = false; var evt = new ManualResetEvent(false); - var xs = AsyncEnumerable.Return(42).ToObservable(); + var xs = AsyncEnumerable.Range(42, 1).ToObservable(); xs.Subscribe(new MyObserver( x => { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index f968f4f014..752730a9d0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -13,6 +13,8 @@ namespace Tests { public class AsyncEnumerableExTests { + protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); + protected const int WaitTimeoutMs = 5000; #pragma warning disable xUnit1013 // Public method should be marked as test diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs index 9726424be9..c202579461 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs @@ -18,9 +18,9 @@ public void Buffer_Null() AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1)); AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1, 1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1, 1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), 1, -1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(Return42, -1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(Return42, -1, 1)); + AssertThrows(() => AsyncEnumerableEx.Buffer(Return42, 1, -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs index 55c9186dde..cf9a9071a7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -16,10 +16,10 @@ public class Catch : AsyncEnumerableExTests public void Catch_Null() { AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(Func>))); + AssertThrows(() => AsyncEnumerableEx.Catch(Return42, default(Func>))); - AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerableEx.Catch(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), Return42)); + AssertThrows(() => AsyncEnumerableEx.Catch(Return42, default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable[]))); AssertThrows(() => AsyncEnumerableEx.Catch(default(IEnumerable>))); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index 4185be535d..319296439b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -15,14 +15,14 @@ public class Distinct : AsyncEnumerableExTests [Fact] public void Distinct_Null() { - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func))); AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func))); AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, x => x, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs index 2558f48ad3..e4fab00fce 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -18,14 +18,14 @@ public void DistinctUntilChanged_Null() AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(IEqualityComparer))); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func))); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, x => x, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index b245d8aa5f..a68d902ca9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -16,23 +16,23 @@ public class Do : AsyncEnumerableExTests public void Do_Null() { AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action))); AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action), () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, ex => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action), ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(Action), ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, default(Action), () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), x => { }, ex => { }, default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action), ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action), () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, ex => { }, default(Action))); AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), new MyObs())); - AssertThrows(() => AsyncEnumerableEx.Do(AsyncEnumerable.Return(42), default(IObserver))); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(IObserver))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs index 66b1963a2d..e97956d3d6 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs @@ -16,7 +16,7 @@ public class Expand : AsyncEnumerableExTests public void Expand_Null() { AssertThrows(() => AsyncEnumerableEx.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Expand(AsyncEnumerable.Return(42), default(Func>))); + AssertThrows(() => AsyncEnumerableEx.Expand(Return42, default(Func>))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index e08b01f9dd..3305224d05 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -16,7 +16,7 @@ public class Finally : AsyncEnumerableExTests public void Finally_Null() { AssertThrows(() => AsyncEnumerableEx.Finally(default(IAsyncEnumerable), () => { })); - AssertThrows(() => AsyncEnumerableEx.Finally(AsyncEnumerable.Return(42), default(Action))); + AssertThrows(() => AsyncEnumerableEx.Finally(Return42, default(Action))); } [Fact] @@ -39,7 +39,7 @@ public void Finally2() { var b = false; - var xs = AsyncEnumerable.Return(42).Finally(() => { b = true; }); + var xs = Return42.Finally(() => { b = true; }); var e = xs.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs index 2ef60a4b05..ff5555924d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -32,7 +32,7 @@ public void IgnoreElements1() [Fact] public void IgnoreElements2() { - var xs = AsyncEnumerable.Return(42).IgnoreElements(); + var xs = Return42.IgnoreElements(); var e = xs.GetAsyncEnumerator(); NoNext(e); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index c1fa62b02e..2d2527693c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -17,18 +17,18 @@ public class MaxBy : AsyncEnumerableExTests public async Task MaxBy_Null() { await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, x => x, default(IComparer))); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, x => x, default(IComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index 61fb60a6e2..71be8dfe52 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -17,18 +17,18 @@ public class MinBy : AsyncEnumerableExTests public async Task MinBy_Null() { await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, x => x, default(IComparer))); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(AsyncEnumerable.Return(42), x => x, default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, x => x, default(IComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs index 46b41ded6e..0c92b9210a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -15,8 +15,8 @@ public class OnErrorResumeNext : AsyncEnumerableExTests [Fact] public void OnErrorResumeNext_Null() { - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable), Return42)); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(Return42, default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable[]))); AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IEnumerable>))); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs index a848db09ba..0fc089e5bd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs @@ -39,7 +39,7 @@ public void RepeatSequence_Null() { AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); - AssertThrows(() => AsyncEnumerableEx.Repeat(AsyncEnumerable.Return(42), -1)); + AssertThrows(() => AsyncEnumerableEx.Repeat(Return42, -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs index 8563a80eda..a389104abf 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs @@ -17,7 +17,7 @@ public void Retry_Null() AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable), 1)); - AssertThrows(() => AsyncEnumerableEx.Retry(AsyncEnumerable.Return(42), -1)); + AssertThrows(() => AsyncEnumerableEx.Retry(Return42, -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs index c328ad60d0..378ad9e8c5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs @@ -16,10 +16,10 @@ public class Scan : AsyncEnumerableExTests public void Scan_Null() { AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), 3, default(Func))); + AssertThrows(() => AsyncEnumerableEx.Scan(Return42, 3, default(Func))); AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerableEx.Scan(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerableEx.Scan(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs index 449b925d07..d4d5c1e58b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -14,8 +14,8 @@ public class SelectMany : AsyncEnumerableExTests [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerableEx.SelectMany(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerableEx.SelectMany(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.SelectMany(default(IAsyncEnumerable), Return42)); + AssertThrows(() => AsyncEnumerableEx.SelectMany(Return42, default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index 0bfe03d318..32f5ec9012 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -15,7 +15,7 @@ public class StartWith : AsyncEnumerableExTests public void StartWith_Null() { AssertThrows(() => AsyncEnumerableEx.StartWith(default(IAsyncEnumerable), new[] { 1 })); - AssertThrows(() => AsyncEnumerableEx.StartWith(AsyncEnumerable.Return(42), default(int[]))); + AssertThrows(() => AsyncEnumerableEx.StartWith(Return42, default(int[]))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index 88f5cc08c2..af7ea8509c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -31,7 +31,7 @@ public void Using1() i++; return new MyD(() => { d++; }); }, - _ => AsyncEnumerable.Return(42) + _ => Return42 ); Assert.Equal(0, i); @@ -52,7 +52,7 @@ public async Task Using2() i++; return new MyD(() => { d++; }); }, - _ => AsyncEnumerable.Return(42) + _ => Return42 ); Assert.Equal(0, i); @@ -99,7 +99,7 @@ public void Using4() i++; return new MyD(() => { disposed.TrySetResult(true); }); }, - _ => AsyncEnumerable.Return(42) + _ => Return42 ); Assert.Equal(0, i); @@ -151,7 +151,7 @@ public async Task Using7() i++; return new MyD(() => { d++; }); }, - _ => AsyncEnumerable.Return(42) + _ => Return42 ); await SequenceIdentity(xs); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index c6aaf41853..29f1f31472 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -13,6 +13,8 @@ namespace Tests { public class AsyncEnumerableTests { + protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); + protected const int WaitTimeoutMs = 5000; #pragma warning disable xUnit1013 // Public method should be marked as test diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 8f0f41c3fa..584006f244 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -17,24 +17,24 @@ public class Aggregate : AsyncEnumerableTests public async Task Aggregate_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, default(Func), z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(AsyncEnumerable.Return(42), 0, (x, y) => x + y, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default(Func), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 80eb990ee4..aa170e748d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -17,10 +17,10 @@ public class All : AsyncEnumerableTests public async Task All_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.All(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.All(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 0f73e26b3a..ed478970c7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -18,11 +18,11 @@ public async Task Any_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs index 30971d8452..6c0203d231 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs @@ -20,7 +20,7 @@ public void AsAsyncEnumerable_Null() [Fact] public void AsAsyncEnumerable1() { - var xs = AsyncEnumerable.Return(42); + var xs = Return42; var ys = xs.AsAsyncEnumerable(); Assert.NotSame(xs, ys); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 82557afafa..a207e99077 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -15,8 +15,8 @@ public class Concat : AsyncEnumerableTests [Fact] public void Concat_Null() { - AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Concat(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable), Return42)); + AssertThrows(() => AsyncEnumerable.Concat(Return42, default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable[]))); AssertThrows(() => AsyncEnumerable.Concat(default(IEnumerable>))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index aba68b8011..c03eed5193 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -18,11 +18,11 @@ public async Task Contains_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(Return42, 42, null)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(AsyncEnumerable.Return(42), 42, null, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(Return42, 42, null, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 99b8fe5f79..6f35aa30da 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -18,11 +18,11 @@ public async Task Count_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index adba0b4b17..e95e8b4451 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -42,7 +42,7 @@ public void DefaultIfEmpty2() [Fact] public void DefaultIfEmpty3() { - var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(); + var xs = Return42.DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); HasNext(e, 42); @@ -52,7 +52,7 @@ public void DefaultIfEmpty3() [Fact] public void DefaultIfEmpty4() { - var xs = AsyncEnumerable.Return(42).DefaultIfEmpty(24); + var xs = Return42.DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); HasNext(e, 42); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index 116d1339a9..9726089f0e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -17,7 +17,7 @@ public void Distinct_Null() { AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Distinct(AsyncEnumerable.Return(42), default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Distinct(Return42, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index 6439065ee1..6ef7771a94 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -17,10 +17,10 @@ public class ElementAt : AsyncEnumerableTests public async Task ElementAt_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default(IAsyncEnumerable), 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default(IAsyncEnumerable), 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(AsyncEnumerable.Return(42), -1, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1, CancellationToken.None)); } [Fact] @@ -33,14 +33,14 @@ public void ElementAt1() [Fact] public void ElementAt2() { - var res = AsyncEnumerable.Return(42).ElementAt(0); + var res = Return42.ElementAt(0); Assert.Equal(42, res.Result); } [Fact] public void ElementAt3() { - var res = AsyncEnumerable.Return(42).ElementAt(1); + var res = Return42.ElementAt(1); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index a0e839f92e..9d4af5f948 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -17,10 +17,10 @@ public class ElementAtOrDefault : AsyncEnumerableTests public async Task ElementAtOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default(IAsyncEnumerable), 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(Return42, -1)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default(IAsyncEnumerable), 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(AsyncEnumerable.Return(42), -1, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(Return42, -1, CancellationToken.None)); } [Fact] @@ -33,14 +33,14 @@ public void ElementAtOrDefault1() [Fact] public void ElementAtOrDefault2() { - var res = AsyncEnumerable.Return(42).ElementAtOrDefault(0); + var res = Return42.ElementAtOrDefault(0); Assert.Equal(42, res.Result); } [Fact] public void ElementAtOrDefault3() { - var res = AsyncEnumerable.Return(42).ElementAtOrDefault(1); + var res = Return42.ElementAtOrDefault(1); Assert.Equal(0, res.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs index 2f28e1bcb8..cce6bb310c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs @@ -15,12 +15,12 @@ public class Except : AsyncEnumerableTests [Fact] public void Except_Null() { - AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), Return42)); + AssertThrows(() => AsyncEnumerable.Except(Return42, default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), null, new Eq())); - AssertThrows(() => AsyncEnumerable.Except(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Except(Return42, null, new Eq())); + AssertThrows(() => AsyncEnumerable.Except(Return42, Return42, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 97c4d401b9..f870125667 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -18,11 +18,11 @@ public async Task First_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -42,21 +42,21 @@ public void First2() [Fact] public void First3() { - var res = AsyncEnumerable.Return(42).First(x => x % 2 != 0); + var res = Return42.First(x => x % 2 != 0); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); } [Fact] public void First4() { - var res = AsyncEnumerable.Return(42).First(); + var res = Return42.First(); Assert.Equal(42, res.Result); } [Fact] public void First5() { - var res = AsyncEnumerable.Return(42).First(x => x % 2 == 0); + var res = Return42.First(x => x % 2 == 0); Assert.Equal(42, res.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 4110faa426..0ef196cbe1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -18,11 +18,11 @@ public async Task FirstOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -42,21 +42,21 @@ public void FirstOrDefault2() [Fact] public void FirstOrDefault3() { - var res = AsyncEnumerable.Return(42).FirstOrDefault(x => x % 2 != 0); + var res = Return42.FirstOrDefault(x => x % 2 != 0); Assert.Equal(0, res.Result); } [Fact] public void FirstOrDefault4() { - var res = AsyncEnumerable.Return(42).FirstOrDefault(); + var res = Return42.FirstOrDefault(); Assert.Equal(42, res.Result); } [Fact] public void FirstOrDefault5() { - var res = AsyncEnumerable.Return(42).FirstOrDefault(x => x % 2 == 0); + var res = Return42.FirstOrDefault(x => x % 2 == 0); Assert.Equal(42, res.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 10ca1fce0c..76b67fc78b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -17,14 +17,14 @@ public class ForEachAsync : AsyncEnumerableTests public async Task ForEachAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), x => { })); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), (x, i) => { })); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), x => { }, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), (x, i) => { }, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(AsyncEnumerable.Return(42), default(Action), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index e62bf628f0..ed3e2cfb22 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -16,40 +16,40 @@ public class GroupBy : AsyncEnumerableTests public void GroupBy_Null() { AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(IEqualityComparer))); AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func))); AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default(IEqualityComparer))); AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>))); AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, (x, ys) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, (x, ys) => x, default(IEqualityComparer))); AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default(Func, int>))); AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), default(Func), x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, default(Func), (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(AsyncEnumerable.Return(42), x => x, x => x, (x, ys) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default(Func, int>), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, (x, ys) => x, default(IEqualityComparer))); } [Fact] @@ -237,7 +237,7 @@ static IEnumerable GetXs() public void GroupBy7() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Return(42); + var xs = Return42; var ys = xs.GroupBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index d3047e7abb..37a596331a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -14,18 +14,18 @@ public class GroupJoin : AsyncEnumerableTests [Fact] public void GroupJoin_Null() { - AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>))); - - AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default(Func), x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default(Func), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default(Func, int>))); + + AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default(Func), x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default(Func), (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default(Func, int>), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, (x, y) => x, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs index 0245744a68..95bdaeecda 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs @@ -15,12 +15,12 @@ public class Intersect : AsyncEnumerableTests [Fact] public void Intersect_Null() { - AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), Return42)); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, default(IAsyncEnumerable), new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, Return42, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index d262053dd1..c4c3f3bca0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -15,18 +15,18 @@ public class Join : AsyncEnumerableTests [Fact] public void Join_Null() { - AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func))); - - AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func), x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, default(Func), (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), x => x, x => x, (x, y) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default(Func), x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default(Func), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default(Func))); + + AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default(Func), x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default(Func), (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, (x, y) => x, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 951e081d0f..5ebe3d43c5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -18,11 +18,11 @@ public async Task Last_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -42,21 +42,21 @@ public void Last2() [Fact] public void Last3() { - var res = AsyncEnumerable.Return(42).Last(x => x % 2 != 0); + var res = Return42.Last(x => x % 2 != 0); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); } [Fact] public void Last4() { - var res = AsyncEnumerable.Return(42).Last(); + var res = Return42.Last(); Assert.Equal(42, res.Result); } [Fact] public void Last5() { - var res = AsyncEnumerable.Return(42).Last(x => x % 2 == 0); + var res = Return42.Last(x => x % 2 == 0); Assert.Equal(42, res.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 47c401e85c..619edb492d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -18,11 +18,11 @@ public async Task LastOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -42,21 +42,21 @@ public void LastOrDefault2() [Fact] public void LastOrDefault3() { - var res = AsyncEnumerable.Return(42).LastOrDefault(x => x % 2 != 0); + var res = Return42.LastOrDefault(x => x % 2 != 0); Assert.Equal(0, res.Result); } [Fact] public void LastOrDefault4() { - var res = AsyncEnumerable.Return(42).LastOrDefault(); + var res = Return42.LastOrDefault(); Assert.Equal(42, res.Result); } [Fact] public void LastOrDefault5() { - var res = AsyncEnumerable.Return(42).LastOrDefault(x => x % 2 == 0); + var res = Return42.LastOrDefault(x => x % 2 == 0); Assert.Equal(42, res.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 6e9fd2c8fa..366c3336d5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -18,11 +18,11 @@ public async Task LongCount_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index 21d08af186..b37c8978c0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -16,20 +16,20 @@ public class OrderBy : AsyncEnumerableTests public void OrderBy_Null() { AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(AsyncEnumerable.Return(42), x => x, default(IComparer))); + AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderBy(Return42, x => x, default(IComparer))); AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(AsyncEnumerable.Return(42), x => x, default(IComparer))); + AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, x => x, default(IComparer))); - var xs = AsyncEnumerable.Return(42).OrderBy(x => x); + var xs = Return42.OrderBy(x => x); AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x)); AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs index 8e837340bc..93f333f5af 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs @@ -12,7 +12,7 @@ public class Return : AsyncEnumerableTests [Fact] public void Return1() { - var xs = AsyncEnumerable.Return(42); + var xs = Return42; HasNext(xs.GetAsyncEnumerator(), 42); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index 039b8de1b4..c1afa72d9c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -31,7 +31,7 @@ public void Reverse1() [Fact] public void Reverse2() { - var xs = AsyncEnumerable.Return(42); + var xs = Return42; var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index 29ab9e5b75..eaf5d72f6c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -17,8 +17,8 @@ public void Select_Null() { AssertThrows(() => AsyncEnumerable.Select(default(IAsyncEnumerable), x => x)); AssertThrows(() => AsyncEnumerable.Select(default(IAsyncEnumerable), (x, i) => x)); - AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.Select(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index f2505bd76a..c1549d9a1c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -17,15 +17,15 @@ public void SelectMany_Null() { AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), x => default(IAsyncEnumerable), default(Func))); - AssertThrows(() => AsyncEnumerable.SelectMany(AsyncEnumerable.Return(42), (x, i) => default(IAsyncEnumerable), default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, x => default(IAsyncEnumerable), default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, (x, i) => default(IAsyncEnumerable), default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 37a803f7bc..3db096e9b9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -16,19 +16,19 @@ public class SequenceEqual : AsyncEnumerableTests [Fact] public async Task SequenceEqual_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable), new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, Return42, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable), new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, Return42, default(IEqualityComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 8444c40420..9c998c77f5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -18,11 +18,11 @@ public async Task Single_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -42,21 +42,21 @@ public void Single2() [Fact] public void Single3() { - var res = AsyncEnumerable.Return(42).Single(x => x % 2 != 0); + var res = Return42.Single(x => x % 2 != 0); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); } [Fact] public void Single4() { - var res = AsyncEnumerable.Return(42).Single(); + var res = Return42.Single(); Assert.Equal(42, res.Result); } [Fact] public void Single5() { - var res = AsyncEnumerable.Return(42).Single(x => x % 2 == 0); + var res = Return42.Single(x => x % 2 == 0); Assert.Equal(42, res.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index e301814f00..4a24736539 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -18,11 +18,11 @@ public async Task SingleOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -42,21 +42,21 @@ public void SingleOrDefault2() [Fact] public void SingleOrDefault3() { - var res = AsyncEnumerable.Return(42).SingleOrDefault(x => x % 2 != 0); + var res = Return42.SingleOrDefault(x => x % 2 != 0); Assert.Equal(0, res.Result); } [Fact] public void SingleOrDefault4() { - var res = AsyncEnumerable.Return(42).SingleOrDefault(); + var res = Return42.SingleOrDefault(); Assert.Equal(42, res.Result); } [Fact] public void SingleOrDefault5() { - var res = AsyncEnumerable.Return(42).SingleOrDefault(x => x % 2 == 0); + var res = Return42.SingleOrDefault(x => x % 2 == 0); Assert.Equal(42, res.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index 46ca743d9c..69016ea417 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -17,8 +17,8 @@ public void SkipWhile_Null() { AssertThrows(() => AsyncEnumerable.SkipWhile(default(IAsyncEnumerable), x => true)); AssertThrows(() => AsyncEnumerable.SkipWhile(default(IAsyncEnumerable), (x, i) => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.SkipWhile(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index 7d88180d5e..cb6d66fdae 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -17,8 +17,8 @@ public void TakeWhile_Null() { AssertThrows(() => AsyncEnumerable.TakeWhile(default(IAsyncEnumerable), x => true)); AssertThrows(() => AsyncEnumerable.TakeWhile(default(IAsyncEnumerable), (x, i) => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.TakeWhile(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index dd00c58d98..7850236075 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -17,36 +17,36 @@ public class ToDictionary : AsyncEnumerableTests public async Task ToDictionary_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(IEqualityComparer), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index d1d388c65c..cb60af8342 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -20,7 +20,7 @@ public async Task ToHashSet_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(AsyncEnumerable.Return(42), default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(Return42, default(IEqualityComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index ca93f05912..ddba84bbf9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -18,36 +18,36 @@ public class ToLookup : AsyncEnumerableTests public async Task ToLookup_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(IEqualityComparer), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(AsyncEnumerable.Return(42), x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs index 220b23d875..cf1664c403 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -14,12 +14,12 @@ public class Union : AsyncEnumerableTests [Fact] public void Union_Null() { - AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), AsyncEnumerable.Return(42))); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), Return42)); + AssertThrows(() => AsyncEnumerable.Union(Return42, default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), AsyncEnumerable.Return(42), new Eq())); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), default(IAsyncEnumerable), new Eq())); - AssertThrows(() => AsyncEnumerable.Union(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Union(Return42, default(IAsyncEnumerable), new Eq())); + AssertThrows(() => AsyncEnumerable.Union(Return42, Return42, default(IEqualityComparer))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index d32ef9b1fa..37db6739bf 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -17,8 +17,8 @@ public void Where_Null() { AssertThrows(() => AsyncEnumerable.Where(default(IAsyncEnumerable), x => true)); AssertThrows(() => AsyncEnumerable.Where(default(IAsyncEnumerable), (x, i) => true)); - AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); - AssertThrows(() => AsyncEnumerable.Where(AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index 9da620971b..4a08812871 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -15,9 +15,9 @@ public class Zip : AsyncEnumerableTests [Fact] public void Zip_Null() { - AssertThrows(() => AsyncEnumerable.Zip(default(IAsyncEnumerable), AsyncEnumerable.Return(42), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), default(IAsyncEnumerable), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(AsyncEnumerable.Return(42), AsyncEnumerable.Return(42), default(Func))); + AssertThrows(() => AsyncEnumerable.Zip(default(IAsyncEnumerable), Return42, (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(Return42, default(IAsyncEnumerable), (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(Return42, Return42, default(Func))); } [Fact] From e430df5c58a1369d5bf6fd12636b7fd698f7d05a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:43:48 -0700 Subject: [PATCH 301/862] Reducing the number of references to Throw. --- .../System/Linq/AsyncEnumerableExTests.cs | 1 + .../System/Linq/Operators/Catch.cs | 20 +++++++++---------- .../System/Linq/Operators/Do.cs | 4 ++-- .../System/Linq/Operators/Finally.cs | 2 +- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../System/Linq/Operators/MaxBy.cs | 2 +- .../System/Linq/Operators/MinBy.cs | 2 +- .../Linq/Operators/OnErrorResumeNext.cs | 8 ++++---- .../System/Linq/Operators/Retry.cs | 2 +- .../System/Linq/Operators/StartWith.cs | 2 +- .../System/Linq/Operators/Using.cs | 2 +- .../System/Linq/AsyncEnumerableTests.cs | 1 + .../System/Linq/Operators/Aggregate.cs | 6 +++--- .../System/Linq/Operators/All.cs | 2 +- .../System/Linq/Operators/Any.cs | 2 +- .../System/Linq/Operators/Concat.cs | 6 +++--- .../System/Linq/Operators/Count.cs | 4 ++-- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 ++-- .../System/Linq/Operators/ElementAt.cs | 2 +- .../Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/First.cs | 4 ++-- .../System/Linq/Operators/FirstOrDefault.cs | 4 ++-- .../System/Linq/Operators/ForEachAsync.cs | 4 ++-- .../System/Linq/Operators/GroupBy.cs | 2 +- .../System/Linq/Operators/GroupJoin.cs | 4 ++-- .../System/Linq/Operators/Join.cs | 4 ++-- .../System/Linq/Operators/Last.cs | 4 ++-- .../System/Linq/Operators/LastOrDefault.cs | 4 ++-- .../System/Linq/Operators/LongCount.cs | 4 ++-- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/SelectMany.cs | 8 ++++---- .../System/Linq/Operators/SequenceEqual.cs | 8 ++++---- .../System/Linq/Operators/Single.cs | 4 ++-- .../System/Linq/Operators/SingleOrDefault.cs | 4 ++-- .../System/Linq/Operators/Skip.cs | 2 +- .../System/Linq/Operators/Take.cs | 2 +- .../System/Linq/Operators/Throw.cs | 4 ++-- .../System/Linq/Operators/ToArray.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/Where.cs | 4 ++-- .../System/Linq/Operators/Zip.cs | 4 ++-- 41 files changed, 79 insertions(+), 77 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 752730a9d0..a3423eba30 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -14,6 +14,7 @@ namespace Tests public class AsyncEnumerableExTests { protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); + protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); protected const int WaitTimeoutMs = 5000; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs index cf9a9071a7..fe9a645b59 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -48,7 +48,7 @@ public void Catch2() var ex = new InvalidOperationException("Bang!"); var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Catch(ex_ => { err = true; return ys; }); @@ -75,7 +75,7 @@ public void Catch3() var ex = new InvalidOperationException("Bang!"); var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Catch(ex_ => { err = true; return ys; }); @@ -102,7 +102,7 @@ public void Catch4() var ex = new DivideByZeroException(); var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Catch(ex_ => { err = true; return ys; }); @@ -123,7 +123,7 @@ public void Catch5() var ex = new InvalidOperationException("Bang!"); var ex2 = new Exception("Oops!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Catch(ex_ => { if (ex_.Message == "Bang!") throw ex2; return ys; }); @@ -142,7 +142,7 @@ public void Catch6() var ex = new InvalidOperationException("Bang!"); var err = false; - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var res = xs.Catch(ex_ => { err = true; return xs; }); @@ -183,7 +183,7 @@ public void Catch8() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = AsyncEnumerableEx.Catch(xs, ys); @@ -203,7 +203,7 @@ public void Catch9() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); @@ -236,7 +236,7 @@ public void Catch10() private IEnumerable> CatchXss() { - yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(new Exception("!!!"))); + yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(new Exception("!!!"))); throw new Exception("Bang!"); } @@ -245,7 +245,7 @@ public void Catch11() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var res = AsyncEnumerableEx.Catch(new[] { xs, xs }); @@ -274,7 +274,7 @@ public async Task Catch13() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index a68d902ca9..3abd74caf9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -118,7 +118,7 @@ public void Do5() var exa = default(Exception); var done = false; var hasv = false; - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }, () => { done = true; }); var e = ys.GetAsyncEnumerator(); @@ -135,7 +135,7 @@ public void Do6() var ex = new Exception("Bang"); var exa = default(Exception); var hasv = false; - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index 3305224d05..7a879e0777 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -59,7 +59,7 @@ public void Finally3() var b = false; - var xs = AsyncEnumerable.Throw(ex).Finally(() => { b = true; }); + var xs = Throw(ex).Finally(() => { b = true; }); var e = xs.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs index ff5555924d..e23e35f780 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -55,7 +55,7 @@ public void IgnoreElements3() public void IgnoreElements4() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).IgnoreElements(); + var xs = Throw(ex).IgnoreElements(); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index 2d2527693c..9dd9c9f641 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -70,7 +70,7 @@ public void MaxBy4() public void MaxBy5() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)).MaxBy(x => x, Comparer.Default); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MaxBy(x => x, Comparer.Default); AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index 71be8dfe52..bd38ccddfd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -70,7 +70,7 @@ public void MinBy4() public void MinBy5() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)).MinBy(x => x, Comparer.Default); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MinBy(x => x, Comparer.Default); AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs index 0c92b9210a..8127c41759 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -44,7 +44,7 @@ public void OnErrorResumeNext8() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); @@ -64,7 +64,7 @@ public void OnErrorResumeNext9() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs, ys, ys }); @@ -100,7 +100,7 @@ public void OnErrorResumeNext10() private IEnumerable> OnErrorResumeNextXss() { - yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(new Exception("!!!"))); + yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(new Exception("!!!"))); throw new Exception("Bang!"); } @@ -109,7 +109,7 @@ public void OnErrorResumeNext11() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs }); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs index a389104abf..4dd420cdab 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs @@ -39,7 +39,7 @@ public void Retry2() { var ex = new InvalidOperationException("Bang!"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var res = xs.Retry(); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index 32f5ec9012..b90bb31f3c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -45,7 +45,7 @@ public void StartWith2() public void StartWith3() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).StartWith(1, 2); + var xs = Throw(ex).StartWith(1, 2); var e = xs.GetAsyncEnumerator(); HasNext(e, 1); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index af7ea8509c..f9bd10c433 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -126,7 +126,7 @@ public void Using5() i++; return new MyD(() => { disposed.TrySetResult(true); }); }, - _ => AsyncEnumerable.Throw(ex) + _ => Throw(ex) ); Assert.Equal(0, i); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 29f1f31472..553c6d51e3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -14,6 +14,7 @@ namespace Tests public class AsyncEnumerableTests { protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); + protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); protected const int WaitTimeoutMs = 5000; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 584006f244..fe1a6a143f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -57,7 +57,7 @@ public void Aggregate2() public void Aggregate3() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Aggregate((x, y) => x * y); AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -91,7 +91,7 @@ public void Aggregate6() public void Aggregate7() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y); AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -125,7 +125,7 @@ public void Aggregate10() public void Aggregate11() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index aa170e748d..05e48666d1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -41,7 +41,7 @@ public void All2() public void All3() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).All(x => x % 2 == 0); + var res = Throw(ex).All(x => x % 2 == 0); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index ed478970c7..1c9770c8f2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -43,7 +43,7 @@ public void Any2() public void Any3() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Any(x => x % 2 == 0); + var res = Throw(ex).Any(x => x % 2 == 0); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index a207e99077..e422d527f2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -40,7 +40,7 @@ public void Concat1() public void Concat2() { var ex = new Exception("Bang"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(AsyncEnumerable.Throw(ex)); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var e = ys.GetAsyncEnumerator(); HasNext(e, 1); @@ -53,7 +53,7 @@ public void Concat2() public void Concat3() { var ex = new Exception("Bang"); - var ys = AsyncEnumerable.Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); + var ys = Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -86,7 +86,7 @@ public void Concat5() var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = AsyncEnumerable.Throw(ex); + var zs = Throw(ex); var res = AsyncEnumerable.Concat(xs, ys, zs); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 6f35aa30da..60f167d2e6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -30,7 +30,7 @@ public void Count1() { Assert.Equal(0, new int[0].ToAsyncEnumerable().Count().Result); Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count().Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).Count().Wait(WaitTimeoutMs)); + AssertThrows(() => Throw(new Exception("Bang!")).Count().Wait(WaitTimeoutMs)); } [Fact] @@ -38,7 +38,7 @@ public void Count2() { Assert.Equal(0, new int[0].ToAsyncEnumerable().Count(x => x < 3).Result); Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3).Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).Count(x => x < 3).Wait(WaitTimeoutMs)); + AssertThrows(() => Throw(new Exception("Bang!")).Count(x => x < 3).Wait(WaitTimeoutMs)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index e95e8b4451..56a6594021 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -89,7 +89,7 @@ public void DefaultIfEmpty6() public void DefaultIfEmpty7() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(); + var xs = Throw(ex).DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -99,7 +99,7 @@ public void DefaultIfEmpty7() public void DefaultIfEmpty8() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex).DefaultIfEmpty(24); + var xs = Throw(ex).DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index 6ef7771a94..22dd661321 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -62,7 +62,7 @@ public void ElementAt5() public void ElementAt6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ElementAt(15); + var res = Throw(ex).ElementAt(15); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index 9d4af5f948..21a7f0df37 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -62,7 +62,7 @@ public void ElementAtOrDefault5() public void ElementAtOrDefault6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ElementAtOrDefault(15); + var res = Throw(ex).ElementAtOrDefault(15); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index f870125667..8e1bf08b90 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -64,7 +64,7 @@ public void First5() public void First6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).First(); + var res = Throw(ex).First(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -72,7 +72,7 @@ public void First6() public void First7() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).First(x => true); + var res = Throw(ex).First(x => true); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 0ef196cbe1..f031ad73b2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -64,7 +64,7 @@ public void FirstOrDefault5() public void FirstOrDefault6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).FirstOrDefault(); + var res = Throw(ex).FirstOrDefault(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -72,7 +72,7 @@ public void FirstOrDefault6() public void FirstOrDefault7() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).FirstOrDefault(x => true); + var res = Throw(ex).FirstOrDefault(x => true); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 76b67fc78b..36338c293a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -69,7 +69,7 @@ public void ForEachAsync4() public void ForEachAsync5() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -78,7 +78,7 @@ public void ForEachAsync5() public void ForEachAsync6() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index ed3e2cfb22..e90ec487c7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -172,7 +172,7 @@ public void GroupBy3() public void GroupBy4() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index 37a596331a..cc4cd50935 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -62,7 +62,7 @@ public void GroupJoin2() public void GroupJoin3() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); @@ -76,7 +76,7 @@ public void GroupJoin4() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); + var ys = Throw(ex); var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index c4c3f3bca0..825e3cad26 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -91,7 +91,7 @@ public void Join4() public void Join5() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); @@ -105,7 +105,7 @@ public void Join6() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); + var ys = Throw(ex); var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 5ebe3d43c5..e99cdc1d68 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -64,7 +64,7 @@ public void Last5() public void Last6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Last(); + var res = Throw(ex).Last(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -72,7 +72,7 @@ public void Last6() public void Last7() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Last(x => true); + var res = Throw(ex).Last(x => true); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 619edb492d..daaa15f0d9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -64,7 +64,7 @@ public void LastOrDefault5() public void LastOrDefault6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).LastOrDefault(); + var res = Throw(ex).LastOrDefault(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -72,7 +72,7 @@ public void LastOrDefault6() public void LastOrDefault7() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).LastOrDefault(x => true); + var res = Throw(ex).LastOrDefault(x => true); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 366c3336d5..455b06c162 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -30,7 +30,7 @@ public void LongCount1() { Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount().Result); Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount().Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).LongCount().Wait(WaitTimeoutMs)); + AssertThrows(() => Throw(new Exception("Bang!")).LongCount().Wait(WaitTimeoutMs)); } [Fact] @@ -38,7 +38,7 @@ public void LongCount2() { Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount(x => x < 3).Result); Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3).Result); - AssertThrows(() => AsyncEnumerable.Throw(new Exception("Bang!")).LongCount(x => x < 3).Wait(WaitTimeoutMs)); + AssertThrows(() => Throw(new Exception("Bang!")).LongCount(x => x < 3).Wait(WaitTimeoutMs)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index c1afa72d9c..2e9f94c98a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -56,7 +56,7 @@ public void Reverse3() public void Reverse4() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index c1549d9a1c..f22cc0c81f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -54,7 +54,7 @@ public void SelectMany2() if (x < 3) return Enumerable.Range(0, x).ToAsyncEnumerable(); else - return AsyncEnumerable.Throw(ex); + return Throw(ex); }); var e = ys.GetAsyncEnumerator(); @@ -68,7 +68,7 @@ public void SelectMany2() public void SelectMany3() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); @@ -121,7 +121,7 @@ public void SelectMany6() if (i < 2) return Enumerable.Range(0, x).ToAsyncEnumerable(); else - return AsyncEnumerable.Throw(ex); + return Throw(ex); }); var e = ys.GetAsyncEnumerator(); @@ -135,7 +135,7 @@ public void SelectMany6() public void SelectMany7() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 3db096e9b9..69bae9c9fd 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -79,7 +79,7 @@ public void SequenceEqual6() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); + var ys = Throw(ex); var res = xs.SequenceEqual(ys); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -89,7 +89,7 @@ public void SequenceEqual6() public void SequenceEqual7() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); @@ -144,7 +144,7 @@ public void SequenceEqual13() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); + var ys = Throw(ex); var res = xs.SequenceEqual(ys, new Eq()); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); @@ -154,7 +154,7 @@ public void SequenceEqual13() public void SequenceEqual14() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 9c998c77f5..c80b9d8c73 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -64,7 +64,7 @@ public void Single5() public void Single6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Single(); + var res = Throw(ex).Single(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -72,7 +72,7 @@ public void Single6() public void Single7() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).Single(x => true); + var res = Throw(ex).Single(x => true); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 4a24736539..bab4add363 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -64,7 +64,7 @@ public void SingleOrDefault5() public void SingleOrDefault6() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).SingleOrDefault(); + var res = Throw(ex).SingleOrDefault(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } @@ -72,7 +72,7 @@ public void SingleOrDefault6() public void SingleOrDefault7() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).SingleOrDefault(x => true); + var res = Throw(ex).SingleOrDefault(x => true); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index 56b5bfc30d..6504be2ade 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -68,7 +68,7 @@ public void Skip3() public void Skip4() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Skip(2); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index 1fb4b1ae19..e114ab3685 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -68,7 +68,7 @@ public void Take3() public void Take4() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Take(2); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index cc73e5fa81..20f719056d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -13,14 +13,14 @@ public class Throw : AsyncEnumerableTests [Fact] public void Throw_Null() { - AssertThrows(() => AsyncEnumerable.Throw(default(Exception))); + AssertThrows(() => Throw(default(Exception))); } [Fact] public void Throw1() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 4330334277..bb96b50106 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -40,7 +40,7 @@ public void ToArray2() public void ToArray3() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ToArray(); + var res = Throw(ex).ToArray(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index e8a494e39b..5ac4482740 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -40,7 +40,7 @@ public void ToList2() public void ToList3() { var ex = new Exception("Bang!"); - var res = AsyncEnumerable.Throw(ex).ToList(); + var res = Throw(ex).ToList(); AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index 37db6739bf..89aa0ad184 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -82,7 +82,7 @@ public void Where4() public void Where5() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Where(x => true); var e = ys.GetAsyncEnumerator(); @@ -93,7 +93,7 @@ public void Where5() public void Where6() { var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = xs.Where((x, i) => true); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index 4a08812871..01fe7d6eb2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -67,7 +67,7 @@ public void Zip4() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = AsyncEnumerable.Throw(ex); + var ys = Throw(ex); var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); @@ -78,7 +78,7 @@ public void Zip4() public void Zip5() { var ex = new Exception("Bang!"); - var xs = AsyncEnumerable.Throw(ex); + var xs = Throw(ex); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); From 7e97ecfbb5ca62fae1e50635f52250be8b7af443 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:47:00 -0700 Subject: [PATCH 302/862] Adding some XML doc comments. --- .../System/Linq/AsyncEnumerator.cs | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 14f7a2a106..f8d088358e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -14,6 +14,14 @@ namespace System.Collections.Generic /// public static class AsyncEnumerator { + /// + /// Creates a new enumerator using the specified delegates implementing the members of . + /// + /// The type of the elements returned by the enumerator. + /// The delegate implementing the method. + /// The delegate implementing the property getter. + /// The delegate implementing the method. + /// A new enumerator instance. public static IAsyncEnumerator Create(Func> moveNext, Func current, Func dispose) { if (moveNext == null) @@ -24,23 +32,10 @@ public static IAsyncEnumerator Create(Func> moveNext, Func c return new AnonymousAsyncIterator(moveNext, current, dispose); } - internal static IAsyncEnumerator Create(Func, Task> moveNext, Func current, Func dispose) - { - return new AnonymousAsyncIterator( - async () => - { - var tcs = new TaskCompletionSource(); - - return await moveNext(tcs).ConfigureAwait(false); - }, - current, - dispose - ); - } - /// /// Advances the enumerator to the next element in the sequence, returning the result asynchronously. /// + /// The type of the elements returned by the enumerator. /// The enumerator to advance. /// Cancellation token that can be used to cancel the operation. /// @@ -57,6 +52,20 @@ public static Task MoveNextAsync(this IAsyncEnumerator source, Cance return source.MoveNextAsync(); } + internal static IAsyncEnumerator Create(Func, Task> moveNext, Func current, Func dispose) + { + return new AnonymousAsyncIterator( + async () => + { + var tcs = new TaskCompletionSource(); + + return await moveNext(tcs).ConfigureAwait(false); + }, + current, + dispose + ); + } + private sealed class AnonymousAsyncIterator : AsyncIterator { private readonly Func currentFunc; From 41b86f838e95cc3be0843fe264d2d3ff7b4a2c93 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:50:17 -0700 Subject: [PATCH 303/862] Removing some more dead code. --- .../Source/System.Interactive.Async/AsyncIterator.cs | 12 ------------ .../System.Linq.Async/System/Linq/AsyncIterator.cs | 12 ------------ 2 files changed, 24 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 6e1871d1e6..b8e0bbd014 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -12,7 +12,6 @@ internal abstract class AsyncIterator : IAsyncEnumerable, IAsy { private readonly int threadId; - private CancellationTokenSource cancellationTokenSource; private bool currentIsInvalid = true; internal TSource current; @@ -30,7 +29,6 @@ public IAsyncEnumerator GetAsyncEnumerator() : Clone(); enumerator.state = AsyncIteratorState.Allocated; - enumerator.cancellationTokenSource = new CancellationTokenSource(); try { @@ -47,16 +45,6 @@ public IAsyncEnumerator GetAsyncEnumerator() public virtual Task DisposeAsync() { - if (cancellationTokenSource != null) - { - if (!cancellationTokenSource.IsCancellationRequested) - { - cancellationTokenSource.Cancel(); - } - - cancellationTokenSource.Dispose(); - } - current = default(TSource); state = AsyncIteratorState.Disposed; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 59d6bad366..9269a24a71 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -12,7 +12,6 @@ internal abstract class AsyncIterator : IAsyncEnumerable, IAsy { private readonly int threadId; - private CancellationTokenSource cancellationTokenSource; private bool currentIsInvalid = true; internal TSource current; @@ -30,7 +29,6 @@ public IAsyncEnumerator GetAsyncEnumerator() : Clone(); enumerator.state = AsyncIteratorState.Allocated; - enumerator.cancellationTokenSource = new CancellationTokenSource(); try { @@ -47,16 +45,6 @@ public IAsyncEnumerator GetAsyncEnumerator() public virtual Task DisposeAsync() { - if (cancellationTokenSource != null) - { - if (!cancellationTokenSource.IsCancellationRequested) - { - cancellationTokenSource.Cancel(); - } - - cancellationTokenSource.Dispose(); - } - current = default(TSource); state = AsyncIteratorState.Disposed; From a653d5fe59bc1b79c8c2ed409357d2c0b559e391 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 15:51:20 -0700 Subject: [PATCH 304/862] Ensure idempotency of dispose. --- .../Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index f8d088358e..d7d7ffa560 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -69,8 +69,8 @@ internal static IAsyncEnumerator Create(Func, T private sealed class AnonymousAsyncIterator : AsyncIterator { private readonly Func currentFunc; - private readonly Func dispose; private readonly Func> moveNext; + private Func dispose; public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) { @@ -91,6 +91,8 @@ public override AsyncIterator Clone() public override async Task DisposeAsync() { + var dispose = Interlocked.Exchange(ref this.dispose, null); + if (dispose != null) { await dispose().ConfigureAwait(false); From 5ebc829b41253d5f2fce42431693d2a1ff5e6170 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:00:00 -0700 Subject: [PATCH 305/862] Adding WithCancellation and AsEnumerable for async enumerators. --- .../System/Linq/AsyncEnumerator.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index d7d7ffa560..a386de8abe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -52,6 +52,44 @@ public static Task MoveNextAsync(this IAsyncEnumerator source, Cance return source.MoveNextAsync(); } + /// + /// Wraps the specified enumerator with an enumerator that checks for cancellation upon every invocation + /// of the method. + /// + /// The type of the elements returned by the enumerator. + /// The enumerator to augment with cancellation support. + /// The cancellation token to observe. + /// An enumerator that honors cancellation requests. + public static IAsyncEnumerator WithCancellation(this IAsyncEnumerator source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return new AnonymousAsyncIterator( + moveNext: () => + { + cancellationToken.ThrowIfCancellationRequested(); + return source.MoveNextAsync(); + }, + currentFunc: () => source.Current, + dispose: source.DisposeAsync + ); + } + + /// + /// Wraps the specified enumerator in an enumerable. + /// + /// The type of the elements returned by the enumerator. + /// The enumerator to wrap. + /// An enumerable wrapping the specified enumerator. + public static IAsyncEnumerable AsEnumerable(this IAsyncEnumerator source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return AsyncEnumerable.CreateEnumerable(() => source); + } + internal static IAsyncEnumerator Create(Func, Task> moveNext, Func current, Func dispose) { return new AnonymousAsyncIterator( From 13e8b16ffffdd4de869b8de24abc7cf29e4cd865 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:05:50 -0700 Subject: [PATCH 306/862] Remove some code duplication. --- .../System/Linq/AsyncEnumerableExTests.cs | 1 + .../System/Linq/Operators/Catch.cs | 8 ++++---- .../Linq/Operators/DistinctUntilChanged.cs | 2 +- .../System/Linq/Operators/Do.cs | 2 +- .../System/Linq/Operators/Expand.cs | 2 +- .../System/Linq/Operators/Finally.cs | 2 +- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../System/Linq/Operators/Scan.cs | 4 ++-- .../System/Linq/Operators/StartWith.cs | 10 +++++----- .../System/Linq/Operators/Using.cs | 2 +- .../System/Linq/AsyncEnumerableTests.cs | 1 + .../System/Linq/Operators/Concat.cs | 6 +++--- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 ++-- .../System/Linq/Operators/GroupBy.cs | 6 +++--- .../System/Linq/Operators/GroupJoin.cs | 10 +++++----- .../System/Linq/Operators/Join.cs | 10 +++++----- .../System/Linq/Operators/OrderBy.cs | 8 ++++---- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/SelectMany.cs | 16 ++++++++-------- .../System/Linq/Operators/Skip.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 4 ++-- .../System/Linq/Operators/Take.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 4 ++-- .../System/Linq/Operators/Where.cs | 8 ++++---- .../System/Linq/Operators/Zip.cs | 6 +++--- 25 files changed, 63 insertions(+), 61 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index a3423eba30..4c17264beb 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -15,6 +15,7 @@ public class AsyncEnumerableExTests { protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); + protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; protected const int WaitTimeoutMs = 5000; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs index fe9a645b59..6e66600a8d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -112,7 +112,7 @@ public void Catch4() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); Assert.False(err); } @@ -133,7 +133,7 @@ public void Catch5() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex2); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex2)); } [Fact] @@ -160,7 +160,7 @@ public void Catch6() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -257,7 +257,7 @@ public void Catch11() HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs index e4fab00fce..154285224c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -70,7 +70,7 @@ public void DistinctUntilChanged3() HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index 3abd74caf9..3e1aef2311 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -62,7 +62,7 @@ public void Do2() var ys = xs.Do(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs index e97956d3d6..10584b1c72 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs @@ -42,7 +42,7 @@ public void Expand2() var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(new Func>(x => { throw ex; })); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index 7a879e0777..d0cf28e577 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -64,7 +64,7 @@ public void Finally3() var e = xs.GetAsyncEnumerator(); Assert.False(b); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); Assert.True(b); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs index e23e35f780..6a3ea2ffea 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -58,7 +58,7 @@ public void IgnoreElements4() var xs = Throw(ex).IgnoreElements(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs index 378ad9e8c5..c692239009 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs @@ -52,7 +52,7 @@ public void Scan3() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, new Func((x, y) => { throw ex; })); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -62,7 +62,7 @@ public void Scan4() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(new Func((x, y) => { throw ex; })); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index b90bb31f3c..51ee32d6d5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -32,12 +32,12 @@ public void StartWith1() [Fact] public void StartWith2() { - var xs = AsyncEnumerable.Return(0).StartWith(1, 2); + var xs = Return42.StartWith(40, 41); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 0); + HasNext(e, 40); + HasNext(e, 41); + HasNext(e, 42); NoNext(e); } @@ -50,7 +50,7 @@ public void StartWith3() var e = xs.GetAsyncEnumerator(); HasNext(e, 1); HasNext(e, 2); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index f9bd10c433..fbcac3a17d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -134,7 +134,7 @@ public void Using5() var e = xs.GetAsyncEnumerator(); Assert.Equal(1, i); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); Assert.True(disposed.Task.Result); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 553c6d51e3..b814186c3b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -15,6 +15,7 @@ public class AsyncEnumerableTests { protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); + protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; protected const int WaitTimeoutMs = 5000; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index e422d527f2..11dc16ee55 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -46,7 +46,7 @@ public void Concat2() HasNext(e, 1); HasNext(e, 2); HasNext(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -56,7 +56,7 @@ public void Concat3() var ys = Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -96,7 +96,7 @@ public void Concat5() HasNext(e, 3); HasNext(e, 4); HasNext(e, 5); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index 56a6594021..fbd2a99749 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -92,7 +92,7 @@ public void DefaultIfEmpty7() var xs = Throw(ex).DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -102,7 +102,7 @@ public void DefaultIfEmpty8() var xs = Throw(ex).DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index e90ec487c7..4b880e0fd7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -176,7 +176,7 @@ public void GroupBy4() var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -241,7 +241,7 @@ public void GroupBy7() var ys = xs.GroupBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -253,7 +253,7 @@ public void GroupBy8() var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); //Assert.True(e.MoveNext().Result); //var g1 = e.Current; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index cc4cd50935..3f83b4f673 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -68,7 +68,7 @@ public void GroupJoin3() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -81,7 +81,7 @@ public void GroupJoin4() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -94,7 +94,7 @@ public void GroupJoin5() var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -107,7 +107,7 @@ public void GroupJoin6() var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -126,7 +126,7 @@ public void GroupJoin7() var e = res.GetAsyncEnumerator(); HasNext(e, "0 - 36"); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index 825e3cad26..cc0eca6334 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -97,7 +97,7 @@ public void Join5() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -110,7 +110,7 @@ public void Join6() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -123,7 +123,7 @@ public void Join7() var res = xs.Join(ys, x => { throw ex; }, y => y, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -136,7 +136,7 @@ public void Join8() var res = xs.Join(ys, x => x, y => { throw ex; }, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -149,7 +149,7 @@ public void Join9() var res = xs.Join(ys, x => x, y => y, (x, y) => { throw ex; }); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index b37c8978c0..c4dd1d9f6d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -66,7 +66,7 @@ public void OrderBy2() var ys = xs.OrderBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -86,7 +86,7 @@ public void ThenBy2() var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -109,7 +109,7 @@ public void OrderByDescending2() var ys = xs.OrderByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -129,7 +129,7 @@ public void ThenByDescending2() var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index 2e9f94c98a..a6d3f75970 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -60,7 +60,7 @@ public void Reverse4() var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index f22cc0c81f..df45777bed 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -61,7 +61,7 @@ public void SelectMany2() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -72,7 +72,7 @@ public void SelectMany3() var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -92,7 +92,7 @@ public void SelectMany4() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -128,7 +128,7 @@ public void SelectMany6() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -139,7 +139,7 @@ public void SelectMany7() var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -159,7 +159,7 @@ public void SelectMany8() HasNext(e, 0); HasNext(e, 0); HasNext(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -211,7 +211,7 @@ public void SelectMany11() HasNext(e, 6); HasNext(e, 8); HasNext(e, 9); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -230,7 +230,7 @@ public void SelectMany12() HasNext(e, 3); HasNext(e, 8); HasNext(e, 10); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index 6504be2ade..db7f44383b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -72,7 +72,7 @@ public void Skip4() var ys = xs.Skip(2); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index 69016ea417..9725a3fd46 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -80,7 +80,7 @@ public void SkipWhile5() var ys = xs.SkipWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -127,7 +127,7 @@ public void SkipWhile9() var ys = xs.SkipWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index e114ab3685..35b86faf9a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -72,7 +72,7 @@ public void Take4() var ys = xs.Take(2); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index cb6d66fdae..4ec8dd7ffc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -77,7 +77,7 @@ public void TakeWhile5() var ys = xs.TakeWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -124,7 +124,7 @@ public void TakeWhile9() var ys = xs.TakeWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index 89aa0ad184..c74fadecee 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -61,7 +61,7 @@ public void Where3() HasNext(e, 8); HasNext(e, 5); HasNext(e, 7); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -75,7 +75,7 @@ public void Where4() HasNext(e, 8); HasNext(e, 5); HasNext(e, 7); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -86,7 +86,7 @@ public void Where5() var ys = xs.Where(x => true); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -97,7 +97,7 @@ public void Where6() var ys = xs.Where((x, i) => true); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index 01fe7d6eb2..98e7bcff32 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -71,7 +71,7 @@ public void Zip4() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -83,7 +83,7 @@ public void Zip5() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -95,7 +95,7 @@ public void Zip6() var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; }); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] From 38c9f3c972310578c259b676210f333becd07de4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:19:36 -0700 Subject: [PATCH 307/862] Moving Return to AsyncEnumerableEx. --- .../AsyncTests.Bugs.cs | 13 ++++++++----- .../System/Linq/AsyncEnumerableExTests.cs | 2 +- .../System/Linq/Operators/Expand.cs | 4 ++-- .../System/Linq/Operators/Return.cs | 4 ++-- .../System/Linq/Operators/Return.cs | 16 ++++++++++++++++ .../System/Linq/AsyncEnumerableTests.cs | 2 +- .../System/Linq/AsyncEnumerable.cs | 5 ----- 7 files changed, 30 insertions(+), 16 deletions(-) rename Ix.NET/Source/{System.Linq.Async.Tests => System.Interactive.Async.Tests}/System/Linq/Operators/Return.cs (79%) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 4d5e7252ab..4006b3dad0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -79,9 +79,12 @@ static IEnumerable Blocking(ManualResetEvent evt, ManualResetEvent blocking [Fact] public async Task TakeOneFromSelectMany() { - var enumerable = AsyncEnumerable - .Return(0) - .SelectMany(_ => AsyncEnumerable.Return("Check")) + var ret0 = new[] { 0 }.ToAsyncEnumerable(); + var retCheck = new[] { "Check" }.ToAsyncEnumerable(); + + var enumerable = + ret0 + .SelectMany(_ => retCheck) .Take(1) .Do(_ => { }); @@ -93,7 +96,7 @@ public void SelectManyDisposeInvokedOnlyOnce() { var disposeCounter = new DisposeCounter(); - var result = AsyncEnumerable.Return(1).SelectMany(i => disposeCounter).Select(i => i).ToList().Result; + var result = new[] { 1 }.ToAsyncEnumerable().SelectMany(i => disposeCounter).Select(i => i).ToList().Result; Assert.Equal(0, result.Count); Assert.Equal(1, disposeCounter.DisposeCount); @@ -113,7 +116,7 @@ public void SelectManyInnerDispose() [Fact] public void DisposeAfterCreation() { - var enumerable = AsyncEnumerable.Return(0) as IDisposable; + var enumerable = new[] { 1 }.ToAsyncEnumerable() as IDisposable; enumerable?.Dispose(); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 4c17264beb..92fb064d48 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -13,7 +13,7 @@ namespace Tests { public class AsyncEnumerableExTests { - protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); + protected static readonly IAsyncEnumerable Return42 = AsyncEnumerableEx.Return(42); protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs index 10584b1c72..c611698bbb 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs @@ -22,7 +22,7 @@ public void Expand_Null() [Fact] public void Expand1() { - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerable.Return(x - 1).Repeat(x - 1)); + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerableEx.Return(x - 1).Repeat(x - 1)); var e = xs.GetAsyncEnumerator(); HasNext(e, 2); @@ -59,7 +59,7 @@ public void Expand3() [Fact] public async Task Expand4() { - var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerable.Return(x - 1).Repeat(x - 1)); + var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerableEx.Return(x - 1).Repeat(x - 1)); await SequenceIdentity(xs); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs similarity index 79% rename from Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs rename to Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs index 93f333f5af..e55b35c728 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs @@ -7,12 +7,12 @@ namespace Tests { - public class Return : AsyncEnumerableTests + public class Return : AsyncEnumerableExTests { [Fact] public void Return1() { - var xs = Return42; + var xs = AsyncEnumerableEx.Return(42); HasNext(xs.GetAsyncEnumerator(), 42); } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs new file mode 100644 index 0000000000..c7b70b6d47 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Return(TValue value) + { + return new[] { value }.ToAsyncEnumerable(); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index b814186c3b..4593e45ce8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -13,7 +13,7 @@ namespace Tests { public class AsyncEnumerableTests { - protected static readonly IAsyncEnumerable Return42 = AsyncEnumerable.Return(42); + protected static readonly IAsyncEnumerable Return42 = new[] { 42 }.ToAsyncEnumerable(); protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 1c7b85d689..55aa52b24f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -17,11 +17,6 @@ public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEn return source.Select(x => x); } - public static IAsyncEnumerable Return(TValue value) - { - return new[] { value }.ToAsyncEnumerable(); - } - public static IAsyncEnumerable Throw(Exception exception) { if (exception == null) From a21cdeae03640a92a8a03bbb9a58de8e1b5af6ef Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:24:17 -0700 Subject: [PATCH 308/862] Moving ToEnumerable tests. --- .../AsyncTests.Conversions.cs | 28 ------------- .../System/Linq/Operators/ToEnumerable.cs | 41 +++++++++++++++++++ 2 files changed, 41 insertions(+), 28 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs index e03f693ea9..b6c7f6f677 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs @@ -13,34 +13,6 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void ToEnumerable_Null() - { - AssertThrows(() => AsyncEnumerable.ToEnumerable(null)); - } - - [Fact] - public void ToEnumerable1() - { - var xs = AsyncEnumerable.Range(42, 1).ToEnumerable(); - Assert.True(xs.SequenceEqual(new[] { 42 })); - } - - [Fact] - public void ToEnumerable2() - { - var xs = AsyncEnumerable.Empty().ToEnumerable(); - Assert.True(xs.SequenceEqual(new int[0])); - } - - [Fact] - public void ToEnumerable3() - { - var ex = new Exception("Bang"); - var xs = AsyncEnumerable.Throw(ex).ToEnumerable(); - AssertThrows(() => xs.GetEnumerator().MoveNext(), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - [Fact] public void ToObservable_Null() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs new file mode 100644 index 0000000000..b90f9a9ded --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class ToEnumerable : AsyncEnumerableTests + { + [Fact] + public void ToEnumerable_Null() + { + AssertThrows(() => AsyncEnumerable.ToEnumerable(null)); + } + + [Fact] + public void ToEnumerable1() + { + var xs = AsyncEnumerable.Range(42, 1).ToEnumerable(); + Assert.True(xs.SequenceEqual(new[] { 42 })); + } + + [Fact] + public void ToEnumerable2() + { + var xs = AsyncEnumerable.Empty().ToEnumerable(); + Assert.True(xs.SequenceEqual(new int[0])); + } + + [Fact] + public void ToEnumerable3() + { + var ex = new Exception("Bang"); + var xs = Throw(ex).ToEnumerable(); + AssertThrows(() => xs.GetEnumerator().MoveNext(), SingleInnerExceptionMatches(ex)); + } + } +} From b47c1ab9ce46583f12bf23b1984bc5b0d41bf3e6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:26:02 -0700 Subject: [PATCH 309/862] Minor tweak to ToEnumerable test. --- .../System/Linq/Operators/ToEnumerable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs index b90f9a9ded..0e1f0250d6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs @@ -19,7 +19,7 @@ public void ToEnumerable_Null() [Fact] public void ToEnumerable1() { - var xs = AsyncEnumerable.Range(42, 1).ToEnumerable(); + var xs = Return42.ToEnumerable(); Assert.True(xs.SequenceEqual(new[] { 42 })); } From f1fe24eb551c63db68e90624dd2bc0adbf1ceb79 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:28:02 -0700 Subject: [PATCH 310/862] Moving ToObservable tests. --- .../AsyncTests.Conversions.cs | 268 ---------------- .../System/Linq/Operators/ToObservable.cs | 285 ++++++++++++++++++ 2 files changed, 285 insertions(+), 268 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs index b6c7f6f677..4f4ac7a156 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs @@ -13,273 +13,5 @@ namespace Tests { public partial class AsyncTests { - [Fact] - public void ToObservable_Null() - { - AssertThrows(() => AsyncEnumerable.ToObservable(null)); - } - - [Fact] - public void ToObservable1() - { - var fail = false; - var evt = new ManualResetEvent(false); - - var xs = AsyncEnumerable.Empty().ToObservable(); - xs.Subscribe(new MyObserver( - x => - { - fail = true; - }, - ex => - { - fail = true; - evt.Set(); - }, - () => - { - evt.Set(); - } - )); - - evt.WaitOne(); - Assert.False(fail); - } - - [Fact] - public void ToObservable2() - { - var lst = new List(); - var fail = false; - var evt = new ManualResetEvent(false); - - var xs = AsyncEnumerable.Range(42, 1).ToObservable(); - xs.Subscribe(new MyObserver( - x => - { - lst.Add(x); - }, - ex => - { - fail = true; - evt.Set(); - }, - () => - { - evt.Set(); - } - )); - - evt.WaitOne(); - Assert.False(fail); - Assert.True(lst.SequenceEqual(new[] { 42 })); - } - - [Fact] - public void ToObservable3() - { - var lst = new List(); - var fail = false; - var evt = new ManualResetEvent(false); - - var xs = AsyncEnumerable.Range(0, 10).ToObservable(); - xs.Subscribe(new MyObserver( - x => - { - lst.Add(x); - }, - ex => - { - fail = true; - evt.Set(); - }, - () => - { - evt.Set(); - } - )); - - evt.WaitOne(); - Assert.False(fail); - Assert.True(lst.SequenceEqual(Enumerable.Range(0, 10))); - } - - [Fact] - public void ToObservable4() - { - var ex1 = new Exception("Bang!"); - var ex_ = default(Exception); - var fail = false; - var evt = new ManualResetEvent(false); - - var xs = AsyncEnumerable.Throw(ex1).ToObservable(); - xs.Subscribe(new MyObserver( - x => - { - fail = true; - }, - ex => - { - ex_ = ex; - evt.Set(); - }, - () => - { - fail = true; - evt.Set(); - } - )); - - evt.WaitOne(); - Assert.False(fail); - Assert.Equal(ex1, ((AggregateException)ex_).InnerExceptions.Single()); - } - - [Fact] - public void ToObservable_disposes_enumerator_on_completion() - { - var fail = false; - var evt = new ManualResetEvent(false); - - var ae = AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( - () => Task.FromResult(false), - () => { throw new InvalidOperationException(); }, - () => { evt.Set(); return Task.FromResult(true); })); - - ae - .ToObservable() - .Subscribe(new MyObserver( - x => - { - fail = true; - }, - ex => - { - fail = true; - }, - () => - { - } - )); - - evt.WaitOne(); - Assert.False(fail); - } - - [Fact] - public void ToObservable_disposes_enumerator_when_subscription_is_disposed() - { - var fail = false; - var evt = new ManualResetEvent(false); - var subscription = default(IDisposable); - var subscriptionAssignedTcs = new TaskCompletionSource(); - - var ae = AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( - async () => - { - await subscriptionAssignedTcs.Task; - return true; - }, - () => 1, - () => { evt.Set(); return Task.FromResult(true); })); - - subscription = ae - .ToObservable() - .Subscribe(new MyObserver( - x => - { - subscription.Dispose(); - }, - ex => - { - fail = true; - }, - () => - { - fail = true; - } - )); - - subscriptionAssignedTcs.SetResult(null); - evt.WaitOne(); - - Assert.False(fail); - } - - [Fact] - public void ToObservable_does_not_call_MoveNext_again_when_subscription_is_disposed() - { - var fail = false; - var moveNextCount = 0; - var evt = new ManualResetEvent(false); - var subscription = default(IDisposable); - var subscriptionAssignedTcs = new TaskCompletionSource(); - - var ae = AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( - async () => - { - await subscriptionAssignedTcs.Task; - - moveNextCount++; - return true; - }, - () => 1, - () => { evt.Set(); return Task.FromResult(true); })); - - subscription = ae - .ToObservable() - .Subscribe(new MyObserver( - x => - { - subscription.Dispose(); - }, - ex => - { - fail = true; - }, - () => - { - fail = true; - } - )); - - subscriptionAssignedTcs.SetResult(null); - evt.WaitOne(); - - Assert.Equal(1, moveNextCount); - Assert.False(fail); - } - - class MyObserver : IObserver - { - private Action _onNext; - private Action _onError; - private Action _onCompleted; - - public MyObserver(Action onNext, Action onError, Action onCompleted) - { - _onNext = onNext; - _onError = onError; - _onCompleted = onCompleted; - } - - public void OnCompleted() - { - _onCompleted(); - } - - public void OnError(Exception error) - { - _onError(error); - } - - public void OnNext(T value) - { - _onNext(value); - } - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs new file mode 100644 index 0000000000..ff03689214 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -0,0 +1,285 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class ToObservable : AsyncEnumerableTests + { + [Fact] + public void ToObservable_Null() + { + AssertThrows(() => AsyncEnumerable.ToObservable(null)); + } + + [Fact] + public void ToObservable1() + { + var fail = false; + var evt = new ManualResetEvent(false); + + var xs = AsyncEnumerable.Empty().ToObservable(); + xs.Subscribe(new MyObserver( + x => + { + fail = true; + }, + ex => + { + fail = true; + evt.Set(); + }, + () => + { + evt.Set(); + } + )); + + evt.WaitOne(); + Assert.False(fail); + } + + [Fact] + public void ToObservable2() + { + var lst = new List(); + var fail = false; + var evt = new ManualResetEvent(false); + + var xs = Return42.ToObservable(); + xs.Subscribe(new MyObserver( + x => + { + lst.Add(x); + }, + ex => + { + fail = true; + evt.Set(); + }, + () => + { + evt.Set(); + } + )); + + evt.WaitOne(); + Assert.False(fail); + Assert.True(lst.SequenceEqual(new[] { 42 })); + } + + [Fact] + public void ToObservable3() + { + var lst = new List(); + var fail = false; + var evt = new ManualResetEvent(false); + + var xs = AsyncEnumerable.Range(0, 10).ToObservable(); + xs.Subscribe(new MyObserver( + x => + { + lst.Add(x); + }, + ex => + { + fail = true; + evt.Set(); + }, + () => + { + evt.Set(); + } + )); + + evt.WaitOne(); + Assert.False(fail); + Assert.True(lst.SequenceEqual(Enumerable.Range(0, 10))); + } + + [Fact] + public void ToObservable4() + { + var ex1 = new Exception("Bang!"); + var ex_ = default(Exception); + var fail = false; + var evt = new ManualResetEvent(false); + + var xs = Throw(ex1).ToObservable(); + xs.Subscribe(new MyObserver( + x => + { + fail = true; + }, + ex => + { + ex_ = ex; + evt.Set(); + }, + () => + { + fail = true; + evt.Set(); + } + )); + + evt.WaitOne(); + Assert.False(fail); + Assert.Equal(ex1, ((AggregateException)ex_).InnerExceptions.Single()); + } + + [Fact] + public void ToObservable_disposes_enumerator_on_completion() + { + var fail = false; + var evt = new ManualResetEvent(false); + + var ae = AsyncEnumerable.CreateEnumerable( + () => AsyncEnumerable.CreateEnumerator( + () => Task.FromResult(false), + () => { throw new InvalidOperationException(); }, + () => { evt.Set(); return Task.FromResult(true); })); + + ae + .ToObservable() + .Subscribe(new MyObserver( + x => + { + fail = true; + }, + ex => + { + fail = true; + }, + () => + { + } + )); + + evt.WaitOne(); + Assert.False(fail); + } + + [Fact] + public void ToObservable_disposes_enumerator_when_subscription_is_disposed() + { + var fail = false; + var evt = new ManualResetEvent(false); + var subscription = default(IDisposable); + var subscriptionAssignedTcs = new TaskCompletionSource(); + + var ae = AsyncEnumerable.CreateEnumerable( + () => AsyncEnumerable.CreateEnumerator( + async () => + { + await subscriptionAssignedTcs.Task; + return true; + }, + () => 1, + () => { evt.Set(); return Task.FromResult(true); })); + + subscription = ae + .ToObservable() + .Subscribe(new MyObserver( + x => + { + subscription.Dispose(); + }, + ex => + { + fail = true; + }, + () => + { + fail = true; + } + )); + + subscriptionAssignedTcs.SetResult(null); + evt.WaitOne(); + + Assert.False(fail); + } + + [Fact] + public void ToObservable_does_not_call_MoveNext_again_when_subscription_is_disposed() + { + var fail = false; + var moveNextCount = 0; + var evt = new ManualResetEvent(false); + var subscription = default(IDisposable); + var subscriptionAssignedTcs = new TaskCompletionSource(); + + var ae = AsyncEnumerable.CreateEnumerable( + () => AsyncEnumerable.CreateEnumerator( + async () => + { + await subscriptionAssignedTcs.Task; + + moveNextCount++; + return true; + }, + () => 1, + () => { evt.Set(); return Task.FromResult(true); })); + + subscription = ae + .ToObservable() + .Subscribe(new MyObserver( + x => + { + subscription.Dispose(); + }, + ex => + { + fail = true; + }, + () => + { + fail = true; + } + )); + + subscriptionAssignedTcs.SetResult(null); + evt.WaitOne(); + + Assert.Equal(1, moveNextCount); + Assert.False(fail); + } + + class MyObserver : IObserver + { + private Action _onNext; + private Action _onError; + private Action _onCompleted; + + public MyObserver(Action onNext, Action onError, Action onCompleted) + { + _onNext = onNext; + _onError = onError; + _onCompleted = onCompleted; + } + + public void OnCompleted() + { + _onCompleted(); + } + + public void OnError(Exception error) + { + _onError(error); + } + + public void OnNext(T value) + { + _onNext(value); + } + } + } +} From 94ed26a50ee551056cf05a727e460e83ce59e24b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:28:25 -0700 Subject: [PATCH 311/862] Removing empty test file. --- .../AsyncTests.Conversions.cs | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs deleted file mode 100644 index 4f4ac7a156..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Conversions.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Tests -{ - public partial class AsyncTests - { - } -} From 740d2ac2b834a722b977554aaf047250e5d5ff7c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:30:20 -0700 Subject: [PATCH 312/862] Cleaning up some test code. --- .../System/Linq/Operators/ToObservable.cs | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index ff03689214..d46e08c1b0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -136,7 +136,7 @@ public void ToObservable4() } [Fact] - public void ToObservable_disposes_enumerator_on_completion() + public void ToObservable_DisposesEnumeratorOnCompletion() { var fail = false; var evt = new ManualResetEvent(false); @@ -168,7 +168,7 @@ public void ToObservable_disposes_enumerator_on_completion() } [Fact] - public void ToObservable_disposes_enumerator_when_subscription_is_disposed() + public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed() { var fail = false; var evt = new ManualResetEvent(false); @@ -183,7 +183,11 @@ public void ToObservable_disposes_enumerator_when_subscription_is_disposed() return true; }, () => 1, - () => { evt.Set(); return Task.FromResult(true); })); + () => + { + evt.Set(); + return Task.FromResult(true); + })); subscription = ae .ToObservable() @@ -209,7 +213,7 @@ public void ToObservable_disposes_enumerator_when_subscription_is_disposed() } [Fact] - public void ToObservable_does_not_call_MoveNext_again_when_subscription_is_disposed() + public void ToObservable_DesNotCallMoveNextAgainWhenSubscriptionIsDisposed() { var fail = false; var moveNextCount = 0; @@ -227,7 +231,11 @@ public void ToObservable_does_not_call_MoveNext_again_when_subscription_is_dispo return true; }, () => 1, - () => { evt.Set(); return Task.FromResult(true); })); + () => + { + evt.Set(); + return Task.FromResult(true); + })); subscription = ae .ToObservable() @@ -253,11 +261,11 @@ public void ToObservable_does_not_call_MoveNext_again_when_subscription_is_dispo Assert.False(fail); } - class MyObserver : IObserver + private sealed class MyObserver : IObserver { - private Action _onNext; - private Action _onError; - private Action _onCompleted; + private readonly Action _onNext; + private readonly Action _onError; + private readonly Action _onCompleted; public MyObserver(Action onNext, Action onError, Action onCompleted) { @@ -266,20 +274,11 @@ public MyObserver(Action onNext, Action onError, Action onComplete _onCompleted = onCompleted; } - public void OnCompleted() - { - _onCompleted(); - } + public void OnCompleted() => _onCompleted(); - public void OnError(Exception error) - { - _onError(error); - } + public void OnError(Exception error) => _onError(error); - public void OnNext(T value) - { - _onNext(value); - } + public void OnNext(T value) => _onNext(value); } } } From 49c49e96ab0e34de2825f8b4e1383b004925d09f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:35:22 -0700 Subject: [PATCH 313/862] Moving Throw to AsyncEnumerableEx. --- .../System/Linq/AsyncEnumerableExTests.cs | 2 +- .../System/Linq/Operators/Throw.cs | 33 +++++++++++++++++++ .../System/Linq/AsyncEnumerableTests.cs | 22 ++++++++++++- .../System/Linq/AsyncEnumerable.cs | 2 +- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 92fb064d48..b866cd5f1a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -14,7 +14,7 @@ namespace Tests public class AsyncEnumerableExTests { protected static readonly IAsyncEnumerable Return42 = AsyncEnumerableEx.Return(42); - protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); + protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerableEx.Throw(exception); protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; protected const int WaitTimeoutMs = 5000; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs new file mode 100644 index 0000000000..c54e7bb90e --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Throw(Exception exception) + { + if (exception == null) + throw new ArgumentNullException(nameof(exception)); + +#if NO_TASK_FROMEXCEPTION + var tcs = new TaskCompletionSource(); + tcs.TrySetException(exception); + var moveNextThrows = tcs.Task; +#else + var moveNextThrows = Task.FromException(exception); +#endif + + return AsyncEnumerable.CreateEnumerable( + () => AsyncEnumerable.CreateEnumerator( + () => moveNextThrows, + current: null, + dispose: null) + ); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 4593e45ce8..c7e32eaba0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -14,7 +14,6 @@ namespace Tests public class AsyncEnumerableTests { protected static readonly IAsyncEnumerable Return42 = new[] { 42 }.ToAsyncEnumerable(); - protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerable.Throw(exception); protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; protected const int WaitTimeoutMs = 5000; @@ -80,5 +79,26 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) e1Result.ShouldAllBeEquivalentTo(e2Result); } #pragma warning restore xUnit1013 // Public method should be marked as test + + protected static IAsyncEnumerable Throw(Exception exception) + { + if (exception == null) + throw new ArgumentNullException(nameof(exception)); + +#if NO_TASK_FROMEXCEPTION + var tcs = new TaskCompletionSource(); + tcs.TrySetException(exception); + var moveNextThrows = tcs.Task; +#else + var moveNextThrows = Task.FromException(exception); +#endif + + return AsyncEnumerable.CreateEnumerable( + () => AsyncEnumerable.CreateEnumerator( + () => moveNextThrows, + current: null, + dispose: null) + ); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 55aa52b24f..f1e22bd0f1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -17,7 +17,7 @@ public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEn return source.Select(x => x); } - public static IAsyncEnumerable Throw(Exception exception) + private static IAsyncEnumerable Throw(Exception exception) { if (exception == null) throw new ArgumentNullException(nameof(exception)); From bb1d59e35d828e00de872c712b03d6eda64fd7ed Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:37:11 -0700 Subject: [PATCH 314/862] Whitelisting conversions in API compare. --- Ix.NET/Source/ApiCompare/Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/ApiCompare/Program.cs b/Ix.NET/Source/ApiCompare/Program.cs index 67222c198b..689084710a 100644 --- a/Ix.NET/Source/ApiCompare/Program.cs +++ b/Ix.NET/Source/ApiCompare/Program.cs @@ -35,6 +35,10 @@ class Program "AsAsyncEnumerable", // Trivially renamed "ForEachAsync", // "foreach await" language substitute for the time being + + "ToAsyncEnumerable", // First-class conversions + "ToEnumerable", // First-class conversions + "ToObservable", // First-class conversions }; private static readonly TypeSubstitutor subst = new TypeSubstitutor(new Dictionary @@ -54,7 +58,7 @@ static void Main() static void Compare(Type syncOperatorsType, Type asyncOperatorsType) { - var syncOperators = GetQueryOperators(new[] { syncInterfaceType, syncOrderedInterfaceType}, syncOperatorsType, exceptions); + var syncOperators = GetQueryOperators(new[] { syncInterfaceType, syncOrderedInterfaceType }, syncOperatorsType, exceptions); var asyncOperators = GetQueryOperators(new[] { asyncInterfaceType, asyncOrderedInterfaceType }, asyncOperatorsType, exceptions); CompareFactories(syncOperators.Factories, asyncOperators.Factories); From 3708663b471f83cd2deda6a214ca09dec776b705 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:40:37 -0700 Subject: [PATCH 315/862] Some code cleanup. --- .../System.Linq.Async/System/Linq/Operators/Concat.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index b08ba4d049..5c5ea361ed 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -110,7 +110,7 @@ protected override async Task MoveNextCore() } currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); - + mode = State_While; goto case State_While; } @@ -125,7 +125,6 @@ protected override async Task MoveNextCore() // No more on the inner enumerator, move to the next outer goto case State_OuterNext; - } await DisposeAsync().ConfigureAwait(false); @@ -187,7 +186,7 @@ public Task ToArrayAsync(CancellationToken cancellationToken) public async Task> ToListAsync(CancellationToken cancellationToken) { var list = new List(); - for (var i = 0;; i++) + for (var i = 0; ; i++) { var source = GetAsyncEnumerable(i); if (source == null) @@ -221,7 +220,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } var count = 0; - for (var i = 0;; i++) + for (var i = 0; ; i++) { var source = GetAsyncEnumerable(i); if (source == null) From 8c0f8ae39dd37395dc30b93877dc9725e6bbd2a0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:52:13 -0700 Subject: [PATCH 316/862] Moving non-standard Concat overloads to AsyncEnumerableEx. --- .../System/Linq/Operators/Concat.cs | 95 ++++++++++++++ .../System/Linq/Operators/Concat.cs | 124 ++++++++++++++++++ .../System/Linq/Operators/Concat.cs | 75 ----------- .../System/Linq/Operators/Concat.cs | 111 ---------------- 4 files changed, 219 insertions(+), 186 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs create mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs new file mode 100644 index 0000000000..d0f063c603 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs @@ -0,0 +1,95 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Concat : AsyncEnumerableExTests + { + [Fact] + public void Concat_Null() + { + AssertThrows(() => AsyncEnumerableEx.Concat(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerableEx.Concat(default(IEnumerable>))); + } + + [Fact] + public void Concat4() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.Concat(xs, ys, zs); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + HasNext(e, 6); + HasNext(e, 7); + HasNext(e, 8); + NoNext(e); + } + + [Fact] + public void Concat5() + { + var ex = new Exception("Bang"); + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = Throw(ex); + + var res = AsyncEnumerableEx.Concat(xs, ys, zs); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + } + + [Fact] + public void Concat6() + { + var res = AsyncEnumerableEx.Concat(ConcatXss()); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 4); + HasNext(e, 5); + AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + } + + [Fact] + public async Task Concat9() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5 }.ToAsyncEnumerable(); + var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); + + var res = AsyncEnumerableEx.Concat(xs, ys, zs); + + await SequenceIdentity(res); + } + + private static IEnumerable> ConcatXss() + { + yield return new[] { 1, 2, 3 }.ToAsyncEnumerable(); + yield return new[] { 4, 5 }.ToAsyncEnumerable(); + throw new Exception("Bang!"); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs new file mode 100644 index 0000000000..05183e1c10 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -0,0 +1,124 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerableEx + { + public static IAsyncEnumerable Concat(this IEnumerable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return ConcatCore(sources); + } + + public static IAsyncEnumerable Concat(params IAsyncEnumerable[] sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return ConcatCore(sources); + } + + private static IAsyncEnumerable ConcatCore(IEnumerable> sources) + { + return new ConcatEnumerableAsyncIterator(sources); + } + + private sealed class ConcatEnumerableAsyncIterator : AsyncIterator + { + private readonly IEnumerable> source; + + public ConcatEnumerableAsyncIterator(IEnumerable> source) + { + Debug.Assert(source != null); + + this.source = source; + } + + public override AsyncIterator Clone() + { + return new ConcatEnumerableAsyncIterator(source); + } + + public override async Task DisposeAsync() + { + if (outerEnumerator != null) + { + outerEnumerator.Dispose(); + outerEnumerator = null; + } + + if (currentEnumerator != null) + { + await currentEnumerator.DisposeAsync().ConfigureAwait(false); + currentEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + // State machine vars + private IEnumerator> outerEnumerator; + private IAsyncEnumerator currentEnumerator; + private int mode; + + private const int State_OuterNext = 1; + private const int State_While = 4; + + protected override async Task MoveNextCore() + { + + switch (state) + { + case AsyncIteratorState.Allocated: + outerEnumerator = source.GetEnumerator(); + mode = State_OuterNext; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (mode) + { + case State_OuterNext: + if (outerEnumerator.MoveNext()) + { + // make sure we dispose the previous one if we're about to replace it + if (currentEnumerator != null) + { + await currentEnumerator.DisposeAsync().ConfigureAwait(false); + } + + currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); + + mode = State_While; + goto case State_While; + } + + break; + case State_While: + if (await currentEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = currentEnumerator.Current; + return true; + } + + // No more on the inner enumerator, move to the next outer + goto case State_OuterNext; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 11dc16ee55..11d0cb90e4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -17,8 +17,6 @@ public void Concat_Null() { AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable), Return42)); AssertThrows(() => AsyncEnumerable.Concat(Return42, default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable[]))); - AssertThrows(() => AsyncEnumerable.Concat(default(IEnumerable>))); } [Fact] @@ -59,60 +57,6 @@ public void Concat3() AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } - [Fact] - public void Concat4() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - - var res = AsyncEnumerable.Concat(xs, ys, zs); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 8); - NoNext(e); - } - - [Fact] - public void Concat5() - { - var ex = new Exception("Bang"); - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = Throw(ex); - - var res = AsyncEnumerable.Concat(xs, ys, zs); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); - } - - [Fact] - public void Concat6() - { - var res = AsyncEnumerable.Concat(ConcatXss()); - - var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - } - [Fact] public void Concat7() { @@ -151,18 +95,6 @@ public async Task Concat8() await SequenceIdentity(res); } - [Fact] - public async Task Concat9() - { - var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = new[] { 4, 5 }.ToAsyncEnumerable(); - var zs = new[] { 6, 7, 8 }.ToAsyncEnumerable(); - - var res = AsyncEnumerable.Concat(xs, ys, zs); - - await SequenceIdentity(res); - } - [Fact] public async Task Concat10() { @@ -200,12 +132,5 @@ public async Task Concat12() Assert.Equal(8, await c.Count()); } - - static IEnumerable> ConcatXss() - { - yield return new[] { 1, 2, 3 }.ToAsyncEnumerable(); - yield return new[] { 4, 5 }.ToAsyncEnumerable(); - throw new Exception("Bang!"); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 5c5ea361ed..0548762fb4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -24,117 +24,6 @@ public static IAsyncEnumerable Concat(this IAsyncEnumerable(first, second); } - public static IAsyncEnumerable Concat(this IEnumerable> sources) - { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return sources.Concat_(); - } - - public static IAsyncEnumerable Concat(params IAsyncEnumerable[] sources) - { - if (sources == null) - throw new ArgumentNullException(nameof(sources)); - - return sources.Concat_(); - } - - private static IAsyncEnumerable Concat_(this IEnumerable> sources) - { - return new ConcatEnumerableAsyncIterator(sources); - } - - private sealed class ConcatEnumerableAsyncIterator : AsyncIterator - { - private readonly IEnumerable> source; - - public ConcatEnumerableAsyncIterator(IEnumerable> source) - { - Debug.Assert(source != null); - - this.source = source; - } - - public override AsyncIterator Clone() - { - return new ConcatEnumerableAsyncIterator(source); - } - - public override async Task DisposeAsync() - { - if (outerEnumerator != null) - { - outerEnumerator.Dispose(); - outerEnumerator = null; - } - - if (currentEnumerator != null) - { - await currentEnumerator.DisposeAsync().ConfigureAwait(false); - currentEnumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - // State machine vars - private IEnumerator> outerEnumerator; - private IAsyncEnumerator currentEnumerator; - private int mode; - - private const int State_OuterNext = 1; - private const int State_While = 4; - - protected override async Task MoveNextCore() - { - - switch (state) - { - case AsyncIteratorState.Allocated: - outerEnumerator = source.GetEnumerator(); - mode = State_OuterNext; - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - switch (mode) - { - case State_OuterNext: - if (outerEnumerator.MoveNext()) - { - // make sure we dispose the previous one if we're about to replace it - if (currentEnumerator != null) - { - await currentEnumerator.DisposeAsync().ConfigureAwait(false); - } - - currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); - - mode = State_While; - goto case State_While; - } - - break; - case State_While: - if (await currentEnumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = currentEnumerator.Current; - return true; - } - - // No more on the inner enumerator, move to the next outer - goto case State_OuterNext; - } - - await DisposeAsync().ConfigureAwait(false); - break; - } - - return false; - } - } - private sealed class Concat2AsyncIterator : ConcatAsyncIterator { private readonly IAsyncEnumerable first; From 7b2f9300131e22c70de0822ee711def7d98bc6cc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 16:54:45 -0700 Subject: [PATCH 317/862] Adding one more overload for Concat. --- .../System/Linq/Operators/Concat.cs | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index 05183e1c10..8a33974be1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -10,6 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + public static IAsyncEnumerable Concat(this IAsyncEnumerable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + + return new ConcatAsyncEnumerableAsyncIterator(sources); + } + public static IAsyncEnumerable Concat(this IEnumerable> sources) { if (sources == null) @@ -120,5 +128,95 @@ protected override async Task MoveNextCore() return false; } } + + private sealed class ConcatAsyncEnumerableAsyncIterator : AsyncIterator + { + private readonly IAsyncEnumerable> source; + + public ConcatAsyncEnumerableAsyncIterator(IAsyncEnumerable> source) + { + Debug.Assert(source != null); + + this.source = source; + } + + public override AsyncIterator Clone() + { + return new ConcatAsyncEnumerableAsyncIterator(source); + } + + public override async Task DisposeAsync() + { + if (outerEnumerator != null) + { + await outerEnumerator.DisposeAsync().ConfigureAwait(false); + outerEnumerator = null; + } + + if (currentEnumerator != null) + { + await currentEnumerator.DisposeAsync().ConfigureAwait(false); + currentEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + // State machine vars + private IAsyncEnumerator> outerEnumerator; + private IAsyncEnumerator currentEnumerator; + private int mode; + + private const int State_OuterNext = 1; + private const int State_While = 4; + + protected override async Task MoveNextCore() + { + + switch (state) + { + case AsyncIteratorState.Allocated: + outerEnumerator = source.GetAsyncEnumerator(); + mode = State_OuterNext; + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (mode) + { + case State_OuterNext: + if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + // make sure we dispose the previous one if we're about to replace it + if (currentEnumerator != null) + { + await currentEnumerator.DisposeAsync().ConfigureAwait(false); + } + + currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); + + mode = State_While; + goto case State_While; + } + + break; + case State_While: + if (await currentEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = currentEnumerator.Current; + return true; + } + + // No more on the inner enumerator, move to the next outer + goto case State_OuterNext; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } } } From bf3adad9bb6039271a2b273ba50d319344f3e153 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 17:59:37 -0700 Subject: [PATCH 318/862] Reshuffling some files. --- .../Linq/Operators/ToAsyncEnumerable.cs | 153 +++++++++++-- .../System/Linq/Operators/ToEnumerable.cs | 41 ++++ .../System/Linq/Operators/ToObservable.cs | 208 +++--------------- 3 files changed, 207 insertions(+), 195 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 31ee6a34e6..1accb3091e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -53,34 +53,69 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task ToEnumerable(this IAsyncEnumerable source) + public static IAsyncEnumerable ToAsyncEnumerable(this IObservable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return ToEnumerable_(source); - } + return CreateEnumerable( + () => + { + var observer = new ToAsyncEnumerableObserver(); - private static IEnumerable ToEnumerable_(IAsyncEnumerable source) - { - var e = source.GetAsyncEnumerator(); + var subscription = source.Subscribe(observer); - try - { - while (true) - { - if (!e.MoveNextAsync().Result) - break; + return CreateEnumerator( + tcs => + { + var hasValue = false; + var hasCompleted = false; + var error = default(Exception); - var c = e.Current; + lock (observer.SyncRoot) + { + if (observer.Values.Count > 0) + { + hasValue = true; + observer.Current = observer.Values.Dequeue(); + } + else if (observer.HasCompleted) + { + hasCompleted = true; + } + else if (observer.Error != null) + { + error = observer.Error; + } + else + { + observer.TaskCompletionSource = tcs; + } + } - yield return c; - } - } - finally - { - e.DisposeAsync().Wait(); - } + if (hasValue) + { + tcs.TrySetResult(true); + } + else if (hasCompleted) + { + tcs.TrySetResult(false); + } + else if (error != null) + { + tcs.TrySetException(error); + } + + return tcs.Task; + }, + () => observer.Current, + () => + { + subscription.Dispose(); + // Should we cancel in-flight operations somehow? + return TaskExt.True; + }); + }); } internal sealed class AsyncEnumerableAdapter : AsyncIterator, IIListProvider @@ -342,5 +377,83 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT bool ICollection.IsReadOnly => source.IsReadOnly; } + + private sealed class ToAsyncEnumerableObserver : IObserver + { + public readonly Queue Values; + + public T Current; + public Exception Error; + public bool HasCompleted; + public TaskCompletionSource TaskCompletionSource; + + public ToAsyncEnumerableObserver() + { + Values = new Queue(); + } + + public object SyncRoot + { + get { return Values; } + } + + public void OnCompleted() + { + var tcs = default(TaskCompletionSource); + + lock (SyncRoot) + { + HasCompleted = true; + + if (TaskCompletionSource != null) + { + tcs = TaskCompletionSource; + TaskCompletionSource = null; + } + } + + tcs?.TrySetResult(false); + } + + public void OnError(Exception error) + { + var tcs = default(TaskCompletionSource); + + lock (SyncRoot) + { + Error = error; + + if (TaskCompletionSource != null) + { + tcs = TaskCompletionSource; + TaskCompletionSource = null; + } + } + + tcs?.TrySetException(error); + } + + public void OnNext(T value) + { + var tcs = default(TaskCompletionSource); + + lock (SyncRoot) + { + if (TaskCompletionSource == null) + { + Values.Enqueue(value); + } + else + { + Current = value; + + tcs = TaskCompletionSource; + TaskCompletionSource = null; + } + } + + tcs?.TrySetResult(true); + } + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs new file mode 100644 index 0000000000..df392cee80 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IEnumerable ToEnumerable(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return ToEnumerableCore(source); + } + + private static IEnumerable ToEnumerableCore(IAsyncEnumerable source) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (true) + { + if (!e.MoveNextAsync().Result) + break; + + var c = e.Current; + + yield return c; + } + } + finally + { + e.DisposeAsync().Wait(); + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index a2302aca7e..ecf8420779 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -3,77 +3,11 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable ToAsyncEnumerable(this IObservable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return CreateEnumerable( - () => - { - var observer = new ToAsyncEnumerableObserver(); - - var subscription = source.Subscribe(observer); - - return CreateEnumerator( - tcs => - { - var hasValue = false; - var hasCompleted = false; - var error = default(Exception); - - lock (observer.SyncRoot) - { - if (observer.Values.Count > 0) - { - hasValue = true; - observer.Current = observer.Values.Dequeue(); - } - else if (observer.HasCompleted) - { - hasCompleted = true; - } - else if (observer.Error != null) - { - error = observer.Error; - } - else - { - observer.TaskCompletionSource = tcs; - } - } - - if (hasValue) - { - tcs.TrySetResult(true); - } - else if (hasCompleted) - { - tcs.TrySetResult(false); - } - else if (error != null) - { - tcs.TrySetException(error); - } - - return tcs.Task; - }, - () => observer.Current, - () => - { - subscription.Dispose(); - // Should we cancel in-flight operations somehow? - return TaskExt.True; - }); - }); - } - public static IObservable ToObservable(this IAsyncEnumerable source) { if (source == null) @@ -82,84 +16,6 @@ public static IObservable ToObservable(this IAsyncEnumerable(source); } - private sealed class ToAsyncEnumerableObserver : IObserver - { - public readonly Queue Values; - - public T Current; - public Exception Error; - public bool HasCompleted; - public TaskCompletionSource TaskCompletionSource; - - public ToAsyncEnumerableObserver() - { - Values = new Queue(); - } - - public object SyncRoot - { - get { return Values; } - } - - public void OnCompleted() - { - var tcs = default(TaskCompletionSource); - - lock (SyncRoot) - { - HasCompleted = true; - - if (TaskCompletionSource != null) - { - tcs = TaskCompletionSource; - TaskCompletionSource = null; - } - } - - tcs?.TrySetResult(false); - } - - public void OnError(Exception error) - { - var tcs = default(TaskCompletionSource); - - lock (SyncRoot) - { - Error = error; - - if (TaskCompletionSource != null) - { - tcs = TaskCompletionSource; - TaskCompletionSource = null; - } - } - - tcs?.TrySetException(error); - } - - public void OnNext(T value) - { - var tcs = default(TaskCompletionSource); - - lock (SyncRoot) - { - if (TaskCompletionSource == null) - { - Values.Enqueue(value); - } - else - { - Current = value; - - tcs = TaskCompletionSource; - TaskCompletionSource = null; - } - } - - tcs?.TrySetResult(true); - } - } - private sealed class ToObservableObservable : IObservable { private readonly IAsyncEnumerable source; @@ -175,38 +31,40 @@ public IDisposable Subscribe(IObserver observer) var e = source.GetAsyncEnumerator(); var f = default(Action); - f = () => e.MoveNextAsync() - .ContinueWith(async t => - { - if (t.IsFaulted) - { - observer.OnError(t.Exception); - await e.DisposeAsync().ConfigureAwait(false); - } - else if (t.IsCanceled) - { - await e.DisposeAsync().ConfigureAwait(false); - } - else if (t.IsCompleted) - { - if (t.Result) - { - observer.OnNext(e.Current); + f = () => e.MoveNextAsync().ContinueWith( + async t => + { + if (t.IsFaulted) + { + observer.OnError(t.Exception); + await e.DisposeAsync().ConfigureAwait(false); + } + else if (t.IsCanceled) + { + await e.DisposeAsync().ConfigureAwait(false); + } + else if (t.IsCompleted) + { + if (t.Result) + { + observer.OnNext(e.Current); - if (!ctd.Token.IsCancellationRequested) - f(); - - //In case cancellation is requested, this could only have happened - //by disposing the returned composite disposable (see below). - //In that case, e will be disposed too, so there is no need to dispose e here. - } - else - { - observer.OnCompleted(); - await e.DisposeAsync().ConfigureAwait(false); - } - } - }, ctd.Token); + if (!ctd.Token.IsCancellationRequested) + { + f(); + } + + // In case cancellation is requested, this could only have happened + // by disposing the returned composite disposable (see below). + // In that case, e will be disposed too, so there is no need to dispose e here. + } + else + { + observer.OnCompleted(); + await e.DisposeAsync().ConfigureAwait(false); + } + } + }, ctd.Token); f(); From edbebdb7ff1c0f6b03c7ac3d34118983418735fb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 18:02:45 -0700 Subject: [PATCH 319/862] Updating AsyncQueryable surface. --- .../AsyncQueryableExTests.Generated.cs | 10 + .../System/Linq/AsyncQueryableEx.Generated.cs | 46 +- .../AsyncQueryableTests.Generated.cs | 856 +++++++++--------- .../System/Linq/AsyncQueryable.Generated.cs | 554 ++++++------ 4 files changed, 744 insertions(+), 722 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs index 86ef2a65e8..1295ee0e20 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs @@ -78,6 +78,16 @@ public void Catch3() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Concat1() + { + AssertEx.Throws(() => AsyncQueryableEx.Concat(default(IAsyncQueryable>)), ane => ane.ParamName == "sources"); + + var res = AsyncQueryableEx.Concat(new IAsyncEnumerable[] { default(IAsyncEnumerable) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Distinct1() { diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 9e2e81e5c7..69a5a4be35 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -92,6 +92,18 @@ public static IAsyncQueryable Catch(this IAsyncQueryable Concat(this IAsyncQueryable> sources) + { + if (sources == null) + throw new ArgumentNullException(nameof(sources)); + +#if CRIPPLED_REFLECTION + return sources.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Concat(default(IAsyncQueryable>))), sources.Expression)); +#else + return sources.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), sources.Expression)); +#endif + } + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -500,6 +512,20 @@ public static Task Max(this IAsyncQueryable source, I #endif } + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); +#endif + } + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -514,7 +540,7 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -522,9 +548,9 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -574,20 +600,6 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index 096b7dca39..d8c1e3f5dc 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -248,15 +248,6 @@ public void Append1() [Fact] public void Average1() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average2() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -265,7 +256,7 @@ public void Average2() } [Fact] - public void Average3() + public void Average2() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -274,7 +265,7 @@ public void Average3() } [Fact] - public void Average4() + public void Average3() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -283,7 +274,7 @@ public void Average4() } [Fact] - public void Average5() + public void Average4() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -292,7 +283,7 @@ public void Average5() } [Fact] - public void Average6() + public void Average5() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -301,7 +292,7 @@ public void Average6() } [Fact] - public void Average7() + public void Average6() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -310,7 +301,7 @@ public void Average7() } [Fact] - public void Average8() + public void Average7() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -319,7 +310,7 @@ public void Average8() } [Fact] - public void Average9() + public void Average8() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -328,7 +319,7 @@ public void Average9() } [Fact] - public void Average10() + public void Average9() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -336,6 +327,15 @@ public void Average10() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Average10() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Average11() { @@ -628,16 +628,6 @@ public void Average40() [Fact] public void Average41() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Average42() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -647,7 +637,7 @@ public void Average42() } [Fact] - public void Average43() + public void Average42() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -657,7 +647,7 @@ public void Average43() } [Fact] - public void Average44() + public void Average43() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -667,7 +657,7 @@ public void Average44() } [Fact] - public void Average45() + public void Average44() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -677,7 +667,7 @@ public void Average45() } [Fact] - public void Average46() + public void Average45() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -687,7 +677,7 @@ public void Average46() } [Fact] - public void Average47() + public void Average46() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -697,7 +687,7 @@ public void Average47() } [Fact] - public void Average48() + public void Average47() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -707,7 +697,7 @@ public void Average48() } [Fact] - public void Average49() + public void Average48() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -717,7 +707,7 @@ public void Average49() } [Fact] - public void Average50() + public void Average49() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -727,7 +717,7 @@ public void Average50() } [Fact] - public void Average51() + public void Average50() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -737,7 +727,7 @@ public void Average51() } [Fact] - public void Average52() + public void Average51() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -747,7 +737,7 @@ public void Average52() } [Fact] - public void Average53() + public void Average52() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -757,7 +747,7 @@ public void Average53() } [Fact] - public void Average54() + public void Average53() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -767,7 +757,7 @@ public void Average54() } [Fact] - public void Average55() + public void Average54() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -777,7 +767,7 @@ public void Average55() } [Fact] - public void Average56() + public void Average55() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -787,7 +777,7 @@ public void Average56() } [Fact] - public void Average57() + public void Average56() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -797,7 +787,7 @@ public void Average57() } [Fact] - public void Average58() + public void Average57() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -807,7 +797,7 @@ public void Average58() } [Fact] - public void Average59() + public void Average58() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -817,7 +807,7 @@ public void Average59() } [Fact] - public void Average60() + public void Average59() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -826,6 +816,16 @@ public void Average60() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Average60() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Cast1() { @@ -859,19 +859,19 @@ public void Contains1() [Fact] public void Contains2() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Contains3() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -897,29 +897,29 @@ public void Count1() [Fact] public void Count2() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Count3() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Count4() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1162,10 +1162,10 @@ public void FirstOrDefault6() [Fact] public void GroupBy1() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1173,10 +1173,10 @@ public void GroupBy1() [Fact] public void GroupBy2() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1184,11 +1184,11 @@ public void GroupBy2() [Fact] public void GroupBy3() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1196,11 +1196,11 @@ public void GroupBy3() [Fact] public void GroupBy4() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1208,11 +1208,11 @@ public void GroupBy4() [Fact] public void GroupBy5() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1220,11 +1220,11 @@ public void GroupBy5() [Fact] public void GroupBy6() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1232,11 +1232,11 @@ public void GroupBy6() [Fact] public void GroupBy7() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1244,30 +1244,17 @@ public void GroupBy7() [Fact] public void GroupBy8() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] public void GroupBy9() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy10() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1280,7 +1267,7 @@ public void GroupBy10() } [Fact] - public void GroupBy11() + public void GroupBy10() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1293,7 +1280,7 @@ public void GroupBy11() } [Fact] - public void GroupBy12() + public void GroupBy11() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1306,7 +1293,7 @@ public void GroupBy12() } [Fact] - public void GroupBy13() + public void GroupBy12() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); @@ -1319,7 +1306,7 @@ public void GroupBy13() } [Fact] - public void GroupBy14() + public void GroupBy13() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); @@ -1331,6 +1318,19 @@ public void GroupBy14() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void GroupBy14() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void GroupBy15() { @@ -1674,15 +1674,6 @@ public void LongCount6() [Fact] public void Max1() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max2() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1691,7 +1682,7 @@ public void Max2() } [Fact] - public void Max3() + public void Max2() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1700,7 +1691,7 @@ public void Max3() } [Fact] - public void Max4() + public void Max3() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1709,7 +1700,7 @@ public void Max4() } [Fact] - public void Max5() + public void Max4() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1718,7 +1709,7 @@ public void Max5() } [Fact] - public void Max6() + public void Max5() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1727,7 +1718,7 @@ public void Max6() } [Fact] - public void Max7() + public void Max6() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1736,7 +1727,7 @@ public void Max7() } [Fact] - public void Max8() + public void Max7() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1745,7 +1736,7 @@ public void Max8() } [Fact] - public void Max9() + public void Max8() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1754,7 +1745,7 @@ public void Max9() } [Fact] - public void Max10() + public void Max9() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -1762,6 +1753,15 @@ public void Max10() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Max10() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Max11() { @@ -1774,54 +1774,25 @@ public void Max11() [Fact] public void Max12() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max13() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max14() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max15() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max16() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max17() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1830,7 +1801,7 @@ public void Max17() } [Fact] - public void Max18() + public void Max15() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1840,7 +1811,7 @@ public void Max18() } [Fact] - public void Max19() + public void Max16() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1850,7 +1821,7 @@ public void Max19() } [Fact] - public void Max20() + public void Max17() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1859,7 +1830,7 @@ public void Max20() } [Fact] - public void Max21() + public void Max18() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1869,7 +1840,7 @@ public void Max21() } [Fact] - public void Max22() + public void Max19() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1879,7 +1850,7 @@ public void Max22() } [Fact] - public void Max23() + public void Max20() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1888,7 +1859,7 @@ public void Max23() } [Fact] - public void Max24() + public void Max21() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1898,7 +1869,7 @@ public void Max24() } [Fact] - public void Max25() + public void Max22() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1908,7 +1879,7 @@ public void Max25() } [Fact] - public void Max26() + public void Max23() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1917,7 +1888,7 @@ public void Max26() } [Fact] - public void Max27() + public void Max24() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1927,7 +1898,7 @@ public void Max27() } [Fact] - public void Max28() + public void Max25() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1937,7 +1908,7 @@ public void Max28() } [Fact] - public void Max29() + public void Max26() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1946,7 +1917,7 @@ public void Max29() } [Fact] - public void Max30() + public void Max27() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1956,7 +1927,7 @@ public void Max30() } [Fact] - public void Max31() + public void Max28() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1966,7 +1937,7 @@ public void Max31() } [Fact] - public void Max32() + public void Max29() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1975,7 +1946,7 @@ public void Max32() } [Fact] - public void Max33() + public void Max30() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1985,7 +1956,7 @@ public void Max33() } [Fact] - public void Max34() + public void Max31() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1995,7 +1966,7 @@ public void Max34() } [Fact] - public void Max35() + public void Max32() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2004,7 +1975,7 @@ public void Max35() } [Fact] - public void Max36() + public void Max33() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2014,7 +1985,7 @@ public void Max36() } [Fact] - public void Max37() + public void Max34() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2024,7 +1995,7 @@ public void Max37() } [Fact] - public void Max38() + public void Max35() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2033,7 +2004,7 @@ public void Max38() } [Fact] - public void Max39() + public void Max36() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2043,7 +2014,7 @@ public void Max39() } [Fact] - public void Max40() + public void Max37() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2053,7 +2024,7 @@ public void Max40() } [Fact] - public void Max41() + public void Max38() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2062,56 +2033,65 @@ public void Max41() } [Fact] - public void Max42() + public void Max39() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max43() + public void Max40() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max44() + public void Max41() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max45() + public void Max42() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max46() + public void Max43() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max47() + public void Max44() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max45() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2121,7 +2101,7 @@ public void Max47() } [Fact] - public void Max48() + public void Max46() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2131,7 +2111,7 @@ public void Max48() } [Fact] - public void Max49() + public void Max47() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2141,7 +2121,7 @@ public void Max49() } [Fact] - public void Max50() + public void Max48() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2151,7 +2131,7 @@ public void Max50() } [Fact] - public void Max51() + public void Max49() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2161,7 +2141,7 @@ public void Max51() } [Fact] - public void Max52() + public void Max50() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2171,7 +2151,7 @@ public void Max52() } [Fact] - public void Max53() + public void Max51() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2181,7 +2161,7 @@ public void Max53() } [Fact] - public void Max54() + public void Max52() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2191,7 +2171,7 @@ public void Max54() } [Fact] - public void Max55() + public void Max53() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2201,7 +2181,7 @@ public void Max55() } [Fact] - public void Max56() + public void Max54() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2211,7 +2191,7 @@ public void Max56() } [Fact] - public void Max57() + public void Max55() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2221,7 +2201,7 @@ public void Max57() } [Fact] - public void Max58() + public void Max56() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2231,7 +2211,7 @@ public void Max58() } [Fact] - public void Max59() + public void Max57() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2241,7 +2221,7 @@ public void Max59() } [Fact] - public void Max60() + public void Max58() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2251,7 +2231,7 @@ public void Max60() } [Fact] - public void Max61() + public void Max59() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2261,7 +2241,7 @@ public void Max61() } [Fact] - public void Max62() + public void Max60() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2271,7 +2251,7 @@ public void Max62() } [Fact] - public void Max63() + public void Max61() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2281,7 +2261,7 @@ public void Max63() } [Fact] - public void Max64() + public void Max62() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2290,6 +2270,26 @@ public void Max64() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Max63() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max64() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Max65() { @@ -2312,15 +2312,6 @@ public void Max66() [Fact] public void Min1() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min2() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2329,7 +2320,7 @@ public void Min2() } [Fact] - public void Min3() + public void Min2() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2338,7 +2329,7 @@ public void Min3() } [Fact] - public void Min4() + public void Min3() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2347,7 +2338,7 @@ public void Min4() } [Fact] - public void Min5() + public void Min4() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2356,7 +2347,7 @@ public void Min5() } [Fact] - public void Min6() + public void Min5() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2365,7 +2356,7 @@ public void Min6() } [Fact] - public void Min7() + public void Min6() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2374,7 +2365,7 @@ public void Min7() } [Fact] - public void Min8() + public void Min7() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2383,7 +2374,7 @@ public void Min8() } [Fact] - public void Min9() + public void Min8() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2392,7 +2383,7 @@ public void Min9() } [Fact] - public void Min10() + public void Min9() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2401,45 +2392,25 @@ public void Min10() } [Fact] - public void Min11() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min12() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min13() + public void Min10() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min14() + public void Min11() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min15() + public void Min12() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2448,7 +2419,7 @@ public void Min15() } [Fact] - public void Min16() + public void Min13() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2458,7 +2429,7 @@ public void Min16() } [Fact] - public void Min17() + public void Min14() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2468,7 +2439,7 @@ public void Min17() } [Fact] - public void Min18() + public void Min15() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2477,7 +2448,7 @@ public void Min18() } [Fact] - public void Min19() + public void Min16() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2487,7 +2458,7 @@ public void Min19() } [Fact] - public void Min20() + public void Min17() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2497,7 +2468,7 @@ public void Min20() } [Fact] - public void Min21() + public void Min18() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2506,7 +2477,7 @@ public void Min21() } [Fact] - public void Min22() + public void Min19() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2516,7 +2487,7 @@ public void Min22() } [Fact] - public void Min23() + public void Min20() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2526,7 +2497,7 @@ public void Min23() } [Fact] - public void Min24() + public void Min21() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2535,7 +2506,7 @@ public void Min24() } [Fact] - public void Min25() + public void Min22() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2545,7 +2516,7 @@ public void Min25() } [Fact] - public void Min26() + public void Min23() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2555,7 +2526,7 @@ public void Min26() } [Fact] - public void Min27() + public void Min24() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2564,7 +2535,7 @@ public void Min27() } [Fact] - public void Min28() + public void Min25() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2574,7 +2545,7 @@ public void Min28() } [Fact] - public void Min29() + public void Min26() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2584,7 +2555,7 @@ public void Min29() } [Fact] - public void Min30() + public void Min27() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2593,7 +2564,7 @@ public void Min30() } [Fact] - public void Min31() + public void Min28() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2603,7 +2574,7 @@ public void Min31() } [Fact] - public void Min32() + public void Min29() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2613,7 +2584,7 @@ public void Min32() } [Fact] - public void Min33() + public void Min30() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2622,7 +2593,7 @@ public void Min33() } [Fact] - public void Min34() + public void Min31() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2632,7 +2603,7 @@ public void Min34() } [Fact] - public void Min35() + public void Min32() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2642,7 +2613,7 @@ public void Min35() } [Fact] - public void Min36() + public void Min33() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2651,7 +2622,7 @@ public void Min36() } [Fact] - public void Min37() + public void Min34() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2661,7 +2632,7 @@ public void Min37() } [Fact] - public void Min38() + public void Min35() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2671,7 +2642,7 @@ public void Min38() } [Fact] - public void Min39() + public void Min36() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2680,7 +2651,7 @@ public void Min39() } [Fact] - public void Min40() + public void Min37() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2690,7 +2661,7 @@ public void Min40() } [Fact] - public void Min41() + public void Min38() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2700,26 +2671,36 @@ public void Min41() } [Fact] - public void Min42() + public void Min39() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min43() + public void Min40() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min44() + public void Min41() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min42() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2729,27 +2710,26 @@ public void Min44() } [Fact] - public void Min45() + public void Min43() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min46() + public void Min44() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min47() + public void Min45() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2759,7 +2739,7 @@ public void Min47() } [Fact] - public void Min48() + public void Min46() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2769,7 +2749,7 @@ public void Min48() } [Fact] - public void Min49() + public void Min47() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2779,7 +2759,7 @@ public void Min49() } [Fact] - public void Min50() + public void Min48() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2789,7 +2769,7 @@ public void Min50() } [Fact] - public void Min51() + public void Min49() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2799,7 +2779,7 @@ public void Min51() } [Fact] - public void Min52() + public void Min50() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2809,7 +2789,7 @@ public void Min52() } [Fact] - public void Min53() + public void Min51() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2819,7 +2799,7 @@ public void Min53() } [Fact] - public void Min54() + public void Min52() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2829,7 +2809,7 @@ public void Min54() } [Fact] - public void Min55() + public void Min53() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2839,7 +2819,7 @@ public void Min55() } [Fact] - public void Min56() + public void Min54() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2849,7 +2829,7 @@ public void Min56() } [Fact] - public void Min57() + public void Min55() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2859,7 +2839,7 @@ public void Min57() } [Fact] - public void Min58() + public void Min56() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2869,7 +2849,7 @@ public void Min58() } [Fact] - public void Min59() + public void Min57() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2879,7 +2859,7 @@ public void Min59() } [Fact] - public void Min60() + public void Min58() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2889,7 +2869,7 @@ public void Min60() } [Fact] - public void Min61() + public void Min59() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2899,7 +2879,7 @@ public void Min61() } [Fact] - public void Min62() + public void Min60() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2909,7 +2889,7 @@ public void Min62() } [Fact] - public void Min63() + public void Min61() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2919,7 +2899,7 @@ public void Min63() } [Fact] - public void Min64() + public void Min62() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2929,17 +2909,27 @@ public void Min64() } [Fact] - public void Min65() + public void Min63() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min66() + public void Min64() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min65() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2948,6 +2938,16 @@ public void Min66() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Min66() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void OfType1() { @@ -3273,20 +3273,20 @@ public void Single4() [Fact] public void Single5() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Single6() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3414,15 +3414,6 @@ public void SkipWhile4() [Fact] public void Sum1() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum2() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3431,7 +3422,7 @@ public void Sum2() } [Fact] - public void Sum3() + public void Sum2() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3440,7 +3431,7 @@ public void Sum3() } [Fact] - public void Sum4() + public void Sum3() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3449,7 +3440,7 @@ public void Sum4() } [Fact] - public void Sum5() + public void Sum4() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3458,7 +3449,7 @@ public void Sum5() } [Fact] - public void Sum6() + public void Sum5() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3467,7 +3458,7 @@ public void Sum6() } [Fact] - public void Sum7() + public void Sum6() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3476,7 +3467,7 @@ public void Sum7() } [Fact] - public void Sum8() + public void Sum7() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3485,7 +3476,7 @@ public void Sum8() } [Fact] - public void Sum9() + public void Sum8() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3494,7 +3485,7 @@ public void Sum9() } [Fact] - public void Sum10() + public void Sum9() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -3503,36 +3494,16 @@ public void Sum10() } [Fact] - public void Sum11() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum12() - { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Sum13() + public void Sum10() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum14() + public void Sum11() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3541,7 +3512,7 @@ public void Sum14() } [Fact] - public void Sum15() + public void Sum12() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3551,7 +3522,7 @@ public void Sum15() } [Fact] - public void Sum16() + public void Sum13() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3561,7 +3532,7 @@ public void Sum16() } [Fact] - public void Sum17() + public void Sum14() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3570,7 +3541,7 @@ public void Sum17() } [Fact] - public void Sum18() + public void Sum15() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3580,7 +3551,7 @@ public void Sum18() } [Fact] - public void Sum19() + public void Sum16() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3590,7 +3561,7 @@ public void Sum19() } [Fact] - public void Sum20() + public void Sum17() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3599,7 +3570,7 @@ public void Sum20() } [Fact] - public void Sum21() + public void Sum18() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3609,7 +3580,7 @@ public void Sum21() } [Fact] - public void Sum22() + public void Sum19() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3619,7 +3590,7 @@ public void Sum22() } [Fact] - public void Sum23() + public void Sum20() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3628,7 +3599,7 @@ public void Sum23() } [Fact] - public void Sum24() + public void Sum21() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3638,7 +3609,7 @@ public void Sum24() } [Fact] - public void Sum25() + public void Sum22() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3648,7 +3619,7 @@ public void Sum25() } [Fact] - public void Sum26() + public void Sum23() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3657,7 +3628,7 @@ public void Sum26() } [Fact] - public void Sum27() + public void Sum24() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3667,7 +3638,7 @@ public void Sum27() } [Fact] - public void Sum28() + public void Sum25() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3677,7 +3648,7 @@ public void Sum28() } [Fact] - public void Sum29() + public void Sum26() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3686,7 +3657,7 @@ public void Sum29() } [Fact] - public void Sum30() + public void Sum27() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3696,7 +3667,7 @@ public void Sum30() } [Fact] - public void Sum31() + public void Sum28() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3706,7 +3677,7 @@ public void Sum31() } [Fact] - public void Sum32() + public void Sum29() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3715,7 +3686,7 @@ public void Sum32() } [Fact] - public void Sum33() + public void Sum30() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3725,7 +3696,7 @@ public void Sum33() } [Fact] - public void Sum34() + public void Sum31() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3735,7 +3706,7 @@ public void Sum34() } [Fact] - public void Sum35() + public void Sum32() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3744,7 +3715,7 @@ public void Sum35() } [Fact] - public void Sum36() + public void Sum33() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3754,7 +3725,7 @@ public void Sum36() } [Fact] - public void Sum37() + public void Sum34() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3764,7 +3735,7 @@ public void Sum37() } [Fact] - public void Sum38() + public void Sum35() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -3773,7 +3744,7 @@ public void Sum38() } [Fact] - public void Sum39() + public void Sum36() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3783,7 +3754,7 @@ public void Sum39() } [Fact] - public void Sum40() + public void Sum37() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3793,17 +3764,36 @@ public void Sum40() } [Fact] - public void Sum41() + public void Sum38() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum42() + public void Sum39() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum40() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Sum41() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3813,7 +3803,7 @@ public void Sum42() } [Fact] - public void Sum43() + public void Sum42() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3823,7 +3813,7 @@ public void Sum43() } [Fact] - public void Sum44() + public void Sum43() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3833,7 +3823,7 @@ public void Sum44() } [Fact] - public void Sum45() + public void Sum44() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3843,7 +3833,7 @@ public void Sum45() } [Fact] - public void Sum46() + public void Sum45() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3853,7 +3843,7 @@ public void Sum46() } [Fact] - public void Sum47() + public void Sum46() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3863,7 +3853,7 @@ public void Sum47() } [Fact] - public void Sum48() + public void Sum47() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3873,7 +3863,7 @@ public void Sum48() } [Fact] - public void Sum49() + public void Sum48() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3883,7 +3873,7 @@ public void Sum49() } [Fact] - public void Sum50() + public void Sum49() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3893,7 +3883,7 @@ public void Sum50() } [Fact] - public void Sum51() + public void Sum50() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3903,7 +3893,7 @@ public void Sum51() } [Fact] - public void Sum52() + public void Sum51() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3913,7 +3903,7 @@ public void Sum52() } [Fact] - public void Sum53() + public void Sum52() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3923,7 +3913,7 @@ public void Sum53() } [Fact] - public void Sum54() + public void Sum53() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3933,7 +3923,7 @@ public void Sum54() } [Fact] - public void Sum55() + public void Sum54() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3943,7 +3933,7 @@ public void Sum55() } [Fact] - public void Sum56() + public void Sum55() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3953,7 +3943,7 @@ public void Sum56() } [Fact] - public void Sum57() + public void Sum56() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3963,7 +3953,7 @@ public void Sum57() } [Fact] - public void Sum58() + public void Sum57() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3973,7 +3963,7 @@ public void Sum58() } [Fact] - public void Sum59() + public void Sum58() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3983,7 +3973,7 @@ public void Sum59() } [Fact] - public void Sum60() + public void Sum59() { AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3992,6 +3982,16 @@ public void Sum60() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Sum60() + { + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Take1() { @@ -4337,19 +4337,19 @@ public void ToHashSet1() [Fact] public void ToHashSet2() { - AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); + var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToHashSet3() { - AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index f21aaa9930..bf0456f379 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -336,18 +336,6 @@ public static IAsyncQueryable Append(this IAsyncQueryable Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - public static Task Average(this IAsyncQueryable source) { if (source == null) @@ -456,6 +444,18 @@ public static Task Average(this IAsyncQueryable source) #endif } + public static Task Average(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -856,20 +856,6 @@ public static Task Average(this IAsyncQueryable source #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) @@ -1136,6 +1122,20 @@ public static Task Average(this IAsyncQueryable source #endif } + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static IAsyncQueryable Cast(this IAsyncQueryable source) { if (source == null) @@ -1174,29 +1174,29 @@ public static Task Contains(this IAsyncQueryable source, #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) + public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) + public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -1226,19 +1226,21 @@ public static Task Count(this IAsyncQueryable source) #endif } - public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Count(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Count(this IAsyncQueryable source, Expression> predicate) + public static Task Count(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1246,23 +1248,21 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Count(this IAsyncQueryable source, Expression>> predicate) + public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -1582,20 +1582,6 @@ public static Task FirstOrDefault(this IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -1610,103 +1596,101 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1714,13 +1698,11 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } @@ -1814,6 +1796,24 @@ public static IAsyncQueryable GroupBy #endif } + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -2292,18 +2292,6 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - public static Task Max(this IAsyncQueryable source) { if (source == null) @@ -2412,55 +2400,27 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } @@ -2824,19 +2784,21 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2844,27 +2806,37 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2872,13 +2844,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2886,9 +2858,9 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } @@ -3124,13 +3096,27 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3138,13 +3124,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3152,13 +3138,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3166,21 +3152,23 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3292,55 +3280,27 @@ public static Task Min(this IAsyncQueryable source) #endif } - public static Task Min(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } @@ -3704,19 +3664,19 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3724,9 +3684,23 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -3744,21 +3718,19 @@ public static Task Min(this IAsyncQueryable #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3766,9 +3738,9 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } @@ -4024,7 +3996,7 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4032,9 +4004,23 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -4052,6 +4038,20 @@ public static Task Min(this IAsyncQueryable #endif } + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static IAsyncQueryable OfType(this IAsyncQueryable source) { if (source == null) @@ -4496,7 +4496,7 @@ public static Task Single(this IAsyncQueryable source #endif } - public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4504,13 +4504,13 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4518,7 +4518,7 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4684,18 +4684,6 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable Sum(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - public static Task Sum(this IAsyncQueryable source) { if (source == null) @@ -4804,43 +4792,15 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -5204,7 +5164,19 @@ public static Task Sum(this IAsyncQueryable source, E #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5212,9 +5184,23 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -5484,6 +5470,20 @@ public static Task Sum(this IAsyncQueryable source, E #endif } + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static IAsyncQueryable Take(this IAsyncQueryable source, int count) { if (source == null) @@ -5976,29 +5976,29 @@ public static Task> ToHashSet(this IAsyncQueryable> ToHashSet(this IAsyncQueryable source, IEqualityComparer comparer) + public static Task> ToHashSet(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToHashSet(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task> ToHashSet(this IAsyncQueryable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } From 707e6e9dabda162747b8be1faa71a24c3ddc8a19 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 18:06:03 -0700 Subject: [PATCH 320/862] Improving AsyncQueryable codegen stability. --- .../AsyncQueryableExTests.Generated.cs | 80 +- .../AsyncQueryableExTests.Generated.tt | 4 +- .../System/Linq/AsyncQueryableEx.Generated.cs | 104 +- .../System/Linq/AsyncQueryableEx.Generated.tt | 4 +- .../AsyncQueryableTests.Generated.cs | 982 ++++++------- .../AsyncQueryableTests.Generated.tt | 4 +- .../System/Linq/AsyncQueryable.Generated.cs | 1280 ++++++++--------- .../System/Linq/AsyncQueryable.Generated.tt | 4 +- 8 files changed, 1235 insertions(+), 1227 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs index 1295ee0e20..13b31d3491 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs @@ -48,10 +48,10 @@ public void Buffer2() [Fact] public void Catch1() { - AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "handler"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -59,10 +59,10 @@ public void Catch1() [Fact] public void Catch2() { - AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "handler"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "handler"); - var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => default(Task>)); + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -70,10 +70,10 @@ public void Catch2() [Fact] public void Catch3() { - AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => default(Task>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "handler"); - var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => default(Task>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -204,10 +204,10 @@ public void DistinctUntilChanged6() [Fact] public void Do1() { - AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), new NopObserver()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IObserver)), ane => ane.ParamName == "observer"); - var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine()); + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new NopObserver()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -215,10 +215,10 @@ public void Do1() [Fact] public void Do2() { - AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); - var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -226,10 +226,10 @@ public void Do2() [Fact] public void Do3() { - AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), new NopObserver()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IObserver)), ane => ane.ParamName == "observer"); + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); - var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new NopObserver()); + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -249,11 +249,11 @@ public void Do4() [Fact] public void Do5() { - AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "onNext"); - AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Expression>)), ane => ane.ParamName == "onError"); + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), () => default(Task)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>)), ane => ane.ParamName == "onCompleted"); - var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()); + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), () => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -261,11 +261,11 @@ public void Do5() [Fact] public void Do6() { - AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), () => default(Task)), ane => ane.ParamName == "onNext"); - AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>)), ane => ane.ParamName == "onCompleted"); + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), default(Expression>)), ane => ane.ParamName == "onError"); - var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), () => default(Task)); + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -435,21 +435,21 @@ public void MaxBy3() [Fact] public void MaxBy4() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxBy5() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -549,21 +549,21 @@ public void MinBy3() [Fact] public void MinBy4() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinBy5() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt index 3a9f87da18..7b43d2d153 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt @@ -133,7 +133,9 @@ foreach (var m in typeof(AsyncEnumerableEx).GetMethods() return false; }) .OrderBy(m => m.Name) - .ThenBy(m => m.GetParameters().Length)) + .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) + .ThenBy(m => m.GetParameters().Length) + .ThenBy(m => string.Join(", ", m.GetParameters().Select(p => p.Name)))) { var genArgs = m.GetGenericArguments(); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 69a5a4be35..e1f22ad846 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -50,6 +50,20 @@ public static IAsyncQueryable> Buffer(this IAsyncQueryab #endif } + public static IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); +#endif + } + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) { if (source == null) @@ -78,20 +92,6 @@ public static IAsyncQueryable Catch(this IAsyncQue #endif } - public static IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif - } - public static IAsyncQueryable Concat(this IAsyncQueryable> sources) { if (sources == null) @@ -250,21 +250,21 @@ public static IAsyncQueryable DistinctUntilChanged(this #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + if (observer == null) + throw new ArgumentNullException(nameof(observer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -272,23 +272,23 @@ public static IAsyncQueryable Do(this IAsyncQueryable throw new ArgumentNullException(nameof(onNext)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (observer == null) - throw new ArgumentNullException(nameof(observer)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); #endif } @@ -308,35 +308,35 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) { if (source == null) throw new ArgumentNullException(nameof(source)); if (onNext == null) throw new ArgumentNullException(nameof(onNext)); - if (onError == null) - throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) throw new ArgumentNullException(nameof(source)); if (onNext == null) throw new ArgumentNullException(nameof(onNext)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); #endif } @@ -554,33 +554,33 @@ public static Task> MaxBy(this IAsyncQueryable> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } @@ -714,33 +714,33 @@ public static Task> MinBy(this IAsyncQueryable> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt index e853b1f311..efc034b348 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -128,7 +128,9 @@ foreach (var m in typeof(AsyncEnumerableEx).GetMethods() return false; }) .OrderBy(m => m.Name) - .ThenBy(m => m.GetParameters().Length)) + .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) + .ThenBy(m => m.GetParameters().Length) + .ThenBy(m => string.Join(", ", m.GetParameters().Select(p => p.Name)))) { var genArgs = m.GetGenericArguments(); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index d8c1e3f5dc..fe99079374 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -190,29 +190,29 @@ public void Any1() [Fact] public void Any2() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Any3() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Any4() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -348,261 +348,261 @@ public void Average11() [Fact] public void Average12() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average13() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average14() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average15() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average16() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average17() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average18() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average19() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average20() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average21() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average22() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average23() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average24() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average25() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average26() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average27() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average28() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average29() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average30() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average31() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average32() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average33() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average34() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average35() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average36() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average37() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Average38() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -859,19 +859,19 @@ public void Contains1() [Fact] public void Contains2() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Contains3() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -897,29 +897,29 @@ public void Count1() [Fact] public void Count2() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Count3() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Count4() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1184,11 +1184,11 @@ public void GroupBy2() [Fact] public void GroupBy3() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1196,11 +1196,11 @@ public void GroupBy3() [Fact] public void GroupBy4() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1208,11 +1208,11 @@ public void GroupBy4() [Fact] public void GroupBy5() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1220,11 +1220,11 @@ public void GroupBy5() [Fact] public void GroupBy6() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1232,11 +1232,11 @@ public void GroupBy6() [Fact] public void GroupBy7() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1244,11 +1244,11 @@ public void GroupBy7() [Fact] public void GroupBy8() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1268,6 +1268,19 @@ public void GroupBy9() [Fact] public void GroupBy10() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy11() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1280,7 +1293,7 @@ public void GroupBy10() } [Fact] - public void GroupBy11() + public void GroupBy12() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1293,7 +1306,7 @@ public void GroupBy11() } [Fact] - public void GroupBy12() + public void GroupBy13() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); @@ -1306,7 +1319,7 @@ public void GroupBy12() } [Fact] - public void GroupBy13() + public void GroupBy14() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); @@ -1319,20 +1332,7 @@ public void GroupBy13() } [Fact] - public void GroupBy14() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy15() + public void GroupBy15() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1765,333 +1765,313 @@ public void Max10() [Fact] public void Max11() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max12() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max13() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max14() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max15() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max16() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max17() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max18() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max19() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max20() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max21() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max22() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max23() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max24() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max25() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max26() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max27() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max28() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max29() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max30() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max31() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max32() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max33() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max34() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max35() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max36() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max37() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max38() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max39() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max40() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max41() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max42() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max43() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max44() - { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Max45() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2101,7 +2081,7 @@ public void Max45() } [Fact] - public void Max46() + public void Max44() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2111,7 +2091,7 @@ public void Max46() } [Fact] - public void Max47() + public void Max45() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2121,7 +2101,7 @@ public void Max47() } [Fact] - public void Max48() + public void Max46() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2131,7 +2111,7 @@ public void Max48() } [Fact] - public void Max49() + public void Max47() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2141,7 +2121,7 @@ public void Max49() } [Fact] - public void Max50() + public void Max48() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2151,7 +2131,7 @@ public void Max50() } [Fact] - public void Max51() + public void Max49() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2161,7 +2141,7 @@ public void Max51() } [Fact] - public void Max52() + public void Max50() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2171,7 +2151,7 @@ public void Max52() } [Fact] - public void Max53() + public void Max51() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2181,7 +2161,7 @@ public void Max53() } [Fact] - public void Max54() + public void Max52() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2191,7 +2171,7 @@ public void Max54() } [Fact] - public void Max55() + public void Max53() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2201,7 +2181,7 @@ public void Max55() } [Fact] - public void Max56() + public void Max54() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2211,7 +2191,7 @@ public void Max56() } [Fact] - public void Max57() + public void Max55() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2221,7 +2201,7 @@ public void Max57() } [Fact] - public void Max58() + public void Max56() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2231,7 +2211,7 @@ public void Max58() } [Fact] - public void Max59() + public void Max57() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2241,7 +2221,7 @@ public void Max59() } [Fact] - public void Max60() + public void Max58() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2251,7 +2231,7 @@ public void Max60() } [Fact] - public void Max61() + public void Max59() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2261,7 +2241,7 @@ public void Max61() } [Fact] - public void Max62() + public void Max60() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2271,7 +2251,7 @@ public void Max62() } [Fact] - public void Max63() + public void Max61() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2281,7 +2261,7 @@ public void Max63() } [Fact] - public void Max64() + public void Max62() { AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2290,6 +2270,26 @@ public void Max64() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Max63() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Max64() + { + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Max65() { @@ -2403,333 +2403,313 @@ public void Min10() [Fact] public void Min11() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min12() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min13() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min14() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min15() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min16() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min17() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min18() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min19() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min20() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min21() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min22() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min23() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min24() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min25() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min26() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min27() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min28() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min29() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min30() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min31() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min32() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min33() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min34() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min35() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min36() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min37() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min38() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min39() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min40() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min41() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min42() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min43() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min44() - { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void Min45() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2739,7 +2719,7 @@ public void Min45() } [Fact] - public void Min46() + public void Min44() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2749,7 +2729,7 @@ public void Min46() } [Fact] - public void Min47() + public void Min45() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2759,7 +2739,7 @@ public void Min47() } [Fact] - public void Min48() + public void Min46() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2769,7 +2749,7 @@ public void Min48() } [Fact] - public void Min49() + public void Min47() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2779,7 +2759,7 @@ public void Min49() } [Fact] - public void Min50() + public void Min48() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2789,7 +2769,7 @@ public void Min50() } [Fact] - public void Min51() + public void Min49() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2799,7 +2779,7 @@ public void Min51() } [Fact] - public void Min52() + public void Min50() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2809,7 +2789,7 @@ public void Min52() } [Fact] - public void Min53() + public void Min51() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2819,7 +2799,7 @@ public void Min53() } [Fact] - public void Min54() + public void Min52() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2829,7 +2809,7 @@ public void Min54() } [Fact] - public void Min55() + public void Min53() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2839,7 +2819,7 @@ public void Min55() } [Fact] - public void Min56() + public void Min54() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2849,7 +2829,7 @@ public void Min56() } [Fact] - public void Min57() + public void Min55() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2859,7 +2839,7 @@ public void Min57() } [Fact] - public void Min58() + public void Min56() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2869,7 +2849,7 @@ public void Min58() } [Fact] - public void Min59() + public void Min57() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2879,7 +2859,7 @@ public void Min59() } [Fact] - public void Min60() + public void Min58() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2889,7 +2869,7 @@ public void Min60() } [Fact] - public void Min61() + public void Min59() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2899,7 +2879,7 @@ public void Min61() } [Fact] - public void Min62() + public void Min60() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2909,7 +2889,7 @@ public void Min62() } [Fact] - public void Min63() + public void Min61() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2919,7 +2899,7 @@ public void Min63() } [Fact] - public void Min64() + public void Min62() { AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2928,6 +2908,26 @@ public void Min64() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void Min63() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Min64() + { + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Min65() { @@ -3203,21 +3203,21 @@ public void SequenceEqual1() [Fact] public void SequenceEqual2() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SequenceEqual3() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); + var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3514,261 +3514,261 @@ public void Sum11() [Fact] public void Sum12() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum13() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum14() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum15() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum16() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum17() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum18() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum19() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum20() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum21() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum22() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum23() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum24() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum25() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum26() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum27() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum28() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum29() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum30() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum31() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum32() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum33() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum34() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum35() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum36() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum37() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum38() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4214,44 +4214,44 @@ public void ToDictionary6() [Fact] public void ToDictionary7() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary8() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary9() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionary10() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4446,44 +4446,44 @@ public void ToLookup6() [Fact] public void ToLookup7() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToLookup8() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToLookup9() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToLookup10() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt index d20394a958..fb72f0f634 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt @@ -132,7 +132,9 @@ foreach (var m in typeof(AsyncEnumerable).GetMethods() return false; }) .OrderBy(m => m.Name) - .ThenBy(m => m.GetParameters().Length)) + .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) + .ThenBy(m => m.GetParameters().Length) + .ThenBy(m => string.Join(", ", m.GetParameters().Select(p => p.Name)))) { var genArgs = m.GetGenericArguments(); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index bf0456f379..858dc489b7 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -256,21 +256,19 @@ public static Task Any(this IAsyncQueryable source) #endif } - public static Task Any(this IAsyncQueryable source, Expression> predicate) + public static Task Any(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Any(this IAsyncQueryable source, Expression>> predicate) + public static Task Any(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -278,21 +276,23 @@ public static Task Any(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Any(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Any(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } @@ -468,127 +468,115 @@ public static Task Average(this IAsyncQueryable source, Cancellati #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -596,13 +584,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -610,25 +598,27 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -636,13 +626,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -650,25 +640,27 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -676,13 +668,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -690,25 +682,27 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -716,13 +710,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -730,25 +724,27 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -756,13 +752,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -770,25 +766,27 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -796,13 +794,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -810,21 +808,23 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -1174,29 +1174,29 @@ public static Task Contains(this IAsyncQueryable source, #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) + public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) + public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } @@ -1226,21 +1226,19 @@ public static Task Count(this IAsyncQueryable source) #endif } - public static Task Count(this IAsyncQueryable source, Expression> predicate) + public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Count(this IAsyncQueryable source, Expression>> predicate) + public static Task Count(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1248,21 +1246,23 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Count(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } @@ -1610,99 +1610,99 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } @@ -1724,6 +1724,24 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1796,24 +1814,6 @@ public static IAsyncQueryable GroupBy #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -2412,179 +2412,151 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2592,13 +2564,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2606,25 +2578,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2632,13 +2592,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2646,25 +2606,27 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2672,13 +2634,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2686,25 +2648,27 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2712,13 +2676,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2726,25 +2690,27 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2752,13 +2718,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2766,25 +2732,27 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2792,13 +2760,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2806,37 +2774,41 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2844,13 +2816,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2858,9 +2830,9 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -3144,6 +3116,34 @@ public static Task Max(this IAsyncQueryable source, E #endif } + public static Task Max(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Max(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) @@ -3292,85 +3292,151 @@ public static Task Min(this IAsyncQueryable source) #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); +#endif + } + + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3378,25 +3444,27 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3404,13 +3472,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3418,25 +3486,27 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3444,13 +3514,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3458,21 +3528,23 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -3504,18 +3576,6 @@ public static Task Min(this IAsyncQueryable source, Ex #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -3544,18 +3604,6 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -3584,18 +3632,6 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -3624,18 +3660,6 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -3664,18 +3688,6 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -3704,46 +3716,6 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task Min(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); -#endif - } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) @@ -4024,6 +3996,34 @@ public static Task Min(this IAsyncQueryable source, E #endif } + public static Task Min(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task Min(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) @@ -4398,33 +4398,33 @@ public static Task SequenceEqual(this IAsyncQueryable fi #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw new ArgumentNullException(nameof(first)); if (second == null) throw new ArgumentNullException(nameof(second)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } @@ -4680,139 +4680,247 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); +#endif + } + + public static Task Sum(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -4844,18 +4952,6 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -4884,18 +4980,6 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -4924,18 +5008,6 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -4964,18 +5036,6 @@ public static Task Sum(this IAsyncQueryable source, Expre #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -5004,18 +5064,6 @@ public static Task Sum(this IAsyncQueryable source, Expr #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -5044,18 +5092,6 @@ public static Task Sum(this IAsyncQueryable source, Exp #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -5084,18 +5120,6 @@ public static Task Sum(this IAsyncQueryable source, Ex #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -5124,18 +5148,6 @@ public static Task Sum(this IAsyncQueryable source, E #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -5164,18 +5176,6 @@ public static Task Sum(this IAsyncQueryable source, E #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -5796,67 +5796,67 @@ public static Task> ToDictionary(this I #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } @@ -6128,67 +6128,67 @@ public static Task> ToLookup(this IAsyncQu #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index 517f910fb3..75c9df2656 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -127,7 +127,9 @@ foreach (var m in typeof(AsyncEnumerable).GetMethods() return false; }) .OrderBy(m => m.Name) - .ThenBy(m => m.GetParameters().Length)) + .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) + .ThenBy(m => m.GetParameters().Length) + .ThenBy(m => string.Join(", ", m.GetParameters().Select(p => p.Name)))) { var genArgs = m.GetGenericArguments(); From ed708c40e35c8db48e1b414940dccf07ab53146f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 18:49:35 -0700 Subject: [PATCH 321/862] Renaming a folder. --- Ix.NET/Source/Ix.NET.sln | 2 +- .../AssertEx.cs | 0 .../AsyncQueryableExTests.Generated.cs | 0 .../AsyncQueryableExTests.Generated.tt | 0 .../NopObserver.cs | 0 .../System.Interactive.Async.Providers.Tests.csproj | 0 .../xunit.runner.json | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename Ix.NET/Source/{System.Interactive.Async.Providers.Test => System.Interactive.Async.Providers.Tests}/AssertEx.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers.Test => System.Interactive.Async.Providers.Tests}/AsyncQueryableExTests.Generated.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers.Test => System.Interactive.Async.Providers.Tests}/AsyncQueryableExTests.Generated.tt (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers.Test => System.Interactive.Async.Providers.Tests}/NopObserver.cs (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers.Test => System.Interactive.Async.Providers.Tests}/System.Interactive.Async.Providers.Tests.csproj (100%) rename Ix.NET/Source/{System.Interactive.Async.Providers.Test => System.Interactive.Async.Providers.Tests}/xunit.runner.json (100%) diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index 036c081c30..49ca6aa248 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -49,7 +49,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Tests", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable.Tests", "System.Linq.Async.Queryable.Tests\System.Linq.Async.Queryable.Tests.csproj", "{134E9066-6217-4AF0-B408-47D92AB595BD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers.Tests", "System.Interactive.Async.Providers.Test\System.Interactive.Async.Providers.Tests.csproj", "{974056C0-91BD-4EB6-8431-E30A614FD1D4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers.Tests", "System.Interactive.Async.Providers.Tests\System.Interactive.Async.Providers.Tests.csproj", "{974056C0-91BD-4EB6-8431-E30A614FD1D4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AssertEx.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AssertEx.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers.Test/AssertEx.cs rename to Ix.NET/Source/System.Interactive.Async.Providers.Tests/AssertEx.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.cs rename to Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers.Test/AsyncQueryableExTests.Generated.tt rename to Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/NopObserver.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/NopObserver.cs similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers.Test/NopObserver.cs rename to Ix.NET/Source/System.Interactive.Async.Providers.Tests/NopObserver.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers.Test/System.Interactive.Async.Providers.Tests.csproj rename to Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Test/xunit.runner.json b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/xunit.runner.json similarity index 100% rename from Ix.NET/Source/System.Interactive.Async.Providers.Test/xunit.runner.json rename to Ix.NET/Source/System.Interactive.Async.Providers.Tests/xunit.runner.json From 15477f645cf4780920fc84c1f8bd383a05a11cb0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 18:50:09 -0700 Subject: [PATCH 322/862] Improving build script to run more tests. --- Ix.NET/Source/build-new.ps1 | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/build-new.ps1 b/Ix.NET/Source/build-new.ps1 index c9f96228ca..71ea137e33 100644 --- a/Ix.NET/Source/build-new.ps1 +++ b/Ix.NET/Source/build-new.ps1 @@ -137,12 +137,13 @@ if($hasSignClientSecret) { } Write-Host "Running tests" -Foreground Green -$testDirectory = Join-Path $scriptPath "System.Interactive.Tests" # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains # Use xUnit CLI as it's significantly faster than vstest (dotnet test) $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe" + +$testDirectory = Join-Path $scriptPath "System.Interactive.Tests" .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1" if ($LastExitCode -ne 0) { @@ -153,6 +154,17 @@ if ($LastExitCode -ne 0) { } } +$testDirectory = Join-Path $scriptPath "System.Linq.Async.Tests" +.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2" + +if ($LastExitCode -ne 0) { + Write-Host "Error with tests" -Foreground Red + if($isAppVeyor) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode + } +} + $testDirectory = Join-Path $scriptPath "System.Interactive.Async.Tests" .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2" @@ -164,6 +176,17 @@ if ($LastExitCode -ne 0) { } } +$testDirectory = Join-Path $scriptPath "System.Interactive.Async.Providers.Tests" +.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2" + +if ($LastExitCode -ne 0) { + Write-Host "Error with tests" -Foreground Red + if($isAppVeyor) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode + } +} + .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover" .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties From c67a16b871444679e9954b3a691e9679b97347af Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 21:46:19 -0700 Subject: [PATCH 323/862] Splitting aggregation tests. --- .../System/Linq/Operators/IsEmpty.cs | 31 +++++ .../System/Linq/Operators/Max.cs | 35 +++++ .../System/Linq/Operators/MaxBy.cs | 37 ++++++ .../System/Linq/Operators/Min.cs | 35 +++++ .../System/Linq/Operators/MinBy.cs | 37 ++++++ .../Tests.Aggregates.cs | 121 ------------------ 6 files changed, 175 insertions(+), 121 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IsEmpty.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Max.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MaxBy.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Min.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MinBy.cs delete mode 100644 Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IsEmpty.cs new file mode 100644 index 0000000000..bb175a4e87 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IsEmpty.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class IsEmpty : Tests + { + [Fact] + public void IsEmtpy_Arguments() + { + AssertThrows(() => EnumerableEx.IsEmpty(null)); + } + + [Fact] + public void IsEmpty_Empty() + { + Assert.True(Enumerable.Empty().IsEmpty()); + } + + [Fact] + public void IsEmpty_NonEmpty() + { + Assert.False(new[] { 1 }.IsEmpty()); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Max.cs new file mode 100644 index 0000000000..c55f069ab1 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Max.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Max : Tests + { + [Fact] + public void Max_Arguments() + { + AssertThrows(() => EnumerableEx.Max(null, Comparer.Default)); + AssertThrows(() => EnumerableEx.Max(new[] { 1 }, null)); + } + + [Fact] + public void Max1() + { + Assert.Equal(5, new[] { 2, 5, 3, 7 }.Max(new Mod7Comparer())); + } + + private sealed class Mod7Comparer : IComparer + { + public int Compare(int x, int y) + { + return Comparer.Default.Compare(x % 7, y % 7); + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MaxBy.cs new file mode 100644 index 0000000000..7495096404 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MaxBy.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class MaxBy : Tests + { + [Fact] + public void MaxBy_Arguments() + { + AssertThrows(() => EnumerableEx.MaxBy(null, (int x) => x)); + AssertThrows(() => EnumerableEx.MaxBy(new[] { 1 }, default(Func))); + AssertThrows(() => EnumerableEx.MaxBy(null, (int x) => x, Comparer.Default)); + AssertThrows(() => EnumerableEx.MaxBy(new[] { 1 }, default(Func), Comparer.Default)); + AssertThrows(() => EnumerableEx.MaxBy(new[] { 1 }, (int x) => x, null)); + } + + [Fact] + public void MaxBy1() + { + var res = new[] { 2, 5, 0, 7, 4, 3, 6, 2, 1 }.MaxBy(x => x % 3); + Assert.True(res.SequenceEqual(new[] { 2, 5, 2 })); + } + + [Fact] + public void MaxBy_Empty() + { + AssertThrows(() => Enumerable.Empty().MaxBy(x => x)); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Min.cs new file mode 100644 index 0000000000..485340bd23 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Min.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Min : Tests + { + [Fact] + public void Min_Arguments() + { + AssertThrows(() => EnumerableEx.Min(null, Comparer.Default)); + AssertThrows(() => EnumerableEx.Min(new[] { 1 }, null)); + } + + [Fact] + public void Min1() + { + Assert.Equal(3, new[] { 5, 3, 7 }.Min(new Mod3Comparer())); + } + + private sealed class Mod3Comparer : IComparer + { + public int Compare(int x, int y) + { + return Comparer.Default.Compare(x % 3, y % 3); + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MinBy.cs new file mode 100644 index 0000000000..eda1ef0f6a --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/MinBy.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class MinBy : Tests + { + [Fact] + public void MinBy_Arguments() + { + AssertThrows(() => EnumerableEx.MinBy(null, (int x) => x)); + AssertThrows(() => EnumerableEx.MinBy(new[] { 1 }, default(Func))); + AssertThrows(() => EnumerableEx.MinBy(null, (int x) => x, Comparer.Default)); + AssertThrows(() => EnumerableEx.MinBy(new[] { 1 }, default(Func), Comparer.Default)); + AssertThrows(() => EnumerableEx.MinBy(new[] { 1 }, (int x) => x, null)); + } + + [Fact] + public void MinBy1() + { + var res = new[] { 2, 5, 0, 7, 4, 3, 6, 2, 1 }.MinBy(x => x % 3); + Assert.True(res.SequenceEqual(new[] { 0, 3, 6 })); + } + + [Fact] + public void MinBy_Empty() + { + AssertThrows(() => Enumerable.Empty().MinBy(x => x)); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs deleted file mode 100644 index e7e87e7e63..0000000000 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Aggregates.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Xunit; - -namespace Tests -{ - public partial class Tests - { - [Fact] - public void IsEmtpy_Arguments() - { - AssertThrows(() => EnumerableEx.IsEmpty(null)); - } - - [Fact] - public void IsEmpty_Empty() - { - Assert.True(Enumerable.Empty().IsEmpty()); - } - - [Fact] - public void IsEmpty_NonEmpty() - { - Assert.False(new[] { 1 }.IsEmpty()); - } - - [Fact] - public void Min_Arguments() - { - AssertThrows(() => EnumerableEx.Min(null, Comparer.Default)); - AssertThrows(() => EnumerableEx.Min(new[] { 1 }, null)); - } - - [Fact] - public void Min() - { - Assert.Equal(3, new[] { 5, 3, 7 }.Min(new Mod3Comparer())); - } - - class Mod3Comparer : IComparer - { - public int Compare(int x, int y) - { - return Comparer.Default.Compare(x % 3, y % 3); - } - } - - [Fact] - public void MinBy_Arguments() - { - AssertThrows(() => EnumerableEx.MinBy(null, (int x) => x)); - AssertThrows(() => EnumerableEx.MinBy(new[] { 1 }, default(Func))); - AssertThrows(() => EnumerableEx.MinBy(null, (int x) => x, Comparer.Default)); - AssertThrows(() => EnumerableEx.MinBy(new[] { 1 }, default(Func), Comparer.Default)); - AssertThrows(() => EnumerableEx.MinBy(new[] { 1 }, (int x) => x, null)); - } - - [Fact] - public void MinBy() - { - var res = new[] { 2, 5, 0, 7, 4, 3, 6, 2, 1 }.MinBy(x => x % 3); - Assert.True(res.SequenceEqual(new[] { 0, 3, 6 })); - } - - [Fact] - public void MinBy_Empty() - { - AssertThrows(() => Enumerable.Empty().MinBy(x => x)); - } - - [Fact] - public void Max_Arguments() - { - AssertThrows(() => EnumerableEx.Max(null, Comparer.Default)); - AssertThrows(() => EnumerableEx.Max(new[] { 1 }, null)); - } - - [Fact] - public void Max() - { - Assert.Equal(5, new[] { 2, 5, 3, 7 }.Max(new Mod7Comparer())); - } - - class Mod7Comparer : IComparer - { - public int Compare(int x, int y) - { - return Comparer.Default.Compare(x % 7, y % 7); - } - } - - [Fact] - public void MaxBy_Arguments() - { - AssertThrows(() => EnumerableEx.MaxBy(null, (int x) => x)); - AssertThrows(() => EnumerableEx.MaxBy(new[] { 1 }, default(Func))); - AssertThrows(() => EnumerableEx.MaxBy(null, (int x) => x, Comparer.Default)); - AssertThrows(() => EnumerableEx.MaxBy(new[] { 1 }, default(Func), Comparer.Default)); - AssertThrows(() => EnumerableEx.MaxBy(new[] { 1 }, (int x) => x, null)); - } - - [Fact] - public void MaxBy() - { - var res = new[] { 2, 5, 0, 7, 4, 3, 6, 2, 1 }.MaxBy(x => x % 3); - Assert.True(res.SequenceEqual(new[] { 2, 5, 2 })); - } - - [Fact] - public void MaxBy_Empty() - { - AssertThrows(() => Enumerable.Empty().MaxBy(x => x)); - } - } -} From cb4a2899e7ce386d35d6ee499833f6d264050246 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 21:50:26 -0700 Subject: [PATCH 324/862] Splitting exception tests. --- .../Linq/Operators/Catch.cs} | 183 +----------------- .../System/Linq/Operators/Finally.cs | 88 +++++++++ .../Linq/Operators/OnErrorResumeNext.cs | 89 +++++++++ .../System/Linq/Operators/Retry.cs | 58 ++++++ 4 files changed, 237 insertions(+), 181 deletions(-) rename Ix.NET/Source/System.Interactive.Tests/{Tests.Exceptions.cs => System/Linq/Operators/Catch.cs} (57%) create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Finally.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/OnErrorResumeNext.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Retry.cs diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Catch.cs similarity index 57% rename from Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs rename to Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Catch.cs index e01ffcc52f..77fda11a14 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Exceptions.cs +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Catch.cs @@ -9,7 +9,7 @@ namespace Tests { - public partial class Tests + public class Catch : Tests { [Fact] public void Catch_Arguments() @@ -206,187 +206,8 @@ public void Catch11_Array() AssertThrows(() => e.MoveNext(), ex => ex == e3); } - [Fact] - public void Finally_Arguments() - { - AssertThrows(() => EnumerableEx.Finally(null, () => { })); - AssertThrows(() => EnumerableEx.Finally(new[] { 1 }, null)); - } - - [Fact] - public void Finally1() - { - var done = false; - - var xs = Enumerable.Range(0, 2).Finally(() => done = true); - Assert.False(done); - - var e = xs.GetEnumerator(); - Assert.False(done); - - HasNext(e, 0); - Assert.False(done); - - HasNext(e, 1); - Assert.False(done); - - NoNext(e); - Assert.True(done); - } - - [Fact] - public void Finally2() + private sealed class MyException : Exception { - var done = false; - - var xs = Enumerable.Range(0, 2).Finally(() => done = true); - Assert.False(done); - - var e = xs.GetEnumerator(); - Assert.False(done); - - HasNext(e, 0); - Assert.False(done); - - e.Dispose(); - Assert.True(done); - } - - [Fact] - public void Finally3() - { - var done = false; - - var ex = new MyException(); - var xs = EnumerableEx.Throw(ex).Finally(() => done = true); - Assert.False(done); - - var e = xs.GetEnumerator(); - Assert.False(done); - - try - { - HasNext(e, 0); - Assert.True(false); - } - catch (MyException ex_) - { - Assert.Same(ex, ex_); - } - - Assert.True(done); - } - - [Fact] - public void OnErrorResumeNext_Arguments() - { - AssertThrows(() => EnumerableEx.OnErrorResumeNext(null, new[] { 1 })); - AssertThrows(() => EnumerableEx.OnErrorResumeNext(new[] { 1 }, null)); - AssertThrows(() => EnumerableEx.OnErrorResumeNext(default(IEnumerable[]))); - AssertThrows(() => EnumerableEx.OnErrorResumeNext(default(IEnumerable>))); - } - - [Fact] - public void OnErrorResumeNext1() - { - var xs = new[] { 1, 2 }; - var ys = new[] { 3, 4 }; - - var res = xs.OnErrorResumeNext(ys); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); - } - - [Fact] - public void OnErrorResumeNext2() - { - var xs = new[] { 1, 2 }.Concat(EnumerableEx.Throw(new MyException())); - var ys = new[] { 3, 4 }; - - var res = xs.OnErrorResumeNext(ys); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); - } - - [Fact] - public void OnErrorResumeNext3() - { - var xs = new[] { 1, 2 }; - var ys = new[] { 3, 4 }; - var zs = new[] { 5, 6 }; - - var res = EnumerableEx.OnErrorResumeNext(xs, ys, zs); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4, 5, 6 })); - } - - [Fact] - public void OnErrorResumeNext4() - { - var xs = new[] { 1, 2 }.Concat(EnumerableEx.Throw(new MyException())); - var ys = new[] { 3, 4 }; - var zs = new[] { 5, 6 }; - - var res = EnumerableEx.OnErrorResumeNext(xs, ys, zs); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4, 5, 6 })); - } - - [Fact] - public void OnErrorResumeNext5() - { - var xs = new[] { 1, 2 }; - var ys = new[] { 3, 4 }; - - var res = new[] { xs, ys }.OnErrorResumeNext(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); - } - - [Fact] - public void OnErrorResumeNext6() - { - var xs = new[] { 1, 2 }.Concat(EnumerableEx.Throw(new MyException())); - var ys = new[] { 3, 4 }; - - var res = new[] { xs, ys }.OnErrorResumeNext(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); - } - - [Fact] - public void Retry_Arguments() - { - AssertThrows(() => EnumerableEx.Retry(null)); - AssertThrows(() => EnumerableEx.Retry(null, 5)); - AssertThrows(() => EnumerableEx.Retry(new[] { 1 }, -1)); - } - - [Fact] - public void Retry1() - { - var xs = Enumerable.Range(0, 10); - - var res = xs.Retry(); - Assert.True(Enumerable.SequenceEqual(res, xs)); - } - - [Fact] - public void Retry2() - { - var xs = Enumerable.Range(0, 10); - - var res = xs.Retry(2); - Assert.True(Enumerable.SequenceEqual(res, xs)); - } - - [Fact] - public void Retry3() - { - var ex = new MyException(); - var xs = Enumerable.Range(0, 2).Concat(EnumerableEx.Throw(ex)); - - var res = xs.Retry(2); - var e = res.GetEnumerator(); - HasNext(e, 0); - HasNext(e, 1); - HasNext(e, 0); - HasNext(e, 1); - AssertThrows(() => e.MoveNext(), ex_ => ex == ex_); } } } diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Finally.cs new file mode 100644 index 0000000000..90e1dacbb2 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Finally.cs @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Finally : Tests + { + [Fact] + public void Finally_Arguments() + { + AssertThrows(() => EnumerableEx.Finally(null, () => { })); + AssertThrows(() => EnumerableEx.Finally(new[] { 1 }, null)); + } + + [Fact] + public void Finally1() + { + var done = false; + + var xs = Enumerable.Range(0, 2).Finally(() => done = true); + Assert.False(done); + + var e = xs.GetEnumerator(); + Assert.False(done); + + HasNext(e, 0); + Assert.False(done); + + HasNext(e, 1); + Assert.False(done); + + NoNext(e); + Assert.True(done); + } + + [Fact] + public void Finally2() + { + var done = false; + + var xs = Enumerable.Range(0, 2).Finally(() => done = true); + Assert.False(done); + + var e = xs.GetEnumerator(); + Assert.False(done); + + HasNext(e, 0); + Assert.False(done); + + e.Dispose(); + Assert.True(done); + } + + [Fact] + public void Finally3() + { + var done = false; + + var ex = new MyException(); + var xs = EnumerableEx.Throw(ex).Finally(() => done = true); + Assert.False(done); + + var e = xs.GetEnumerator(); + Assert.False(done); + + try + { + HasNext(e, 0); + Assert.True(false); + } + catch (MyException ex_) + { + Assert.Same(ex, ex_); + } + + Assert.True(done); + } + + private sealed class MyException : Exception + { + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/OnErrorResumeNext.cs new file mode 100644 index 0000000000..5c34eef32f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -0,0 +1,89 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class OnErrorResumeNext : Tests + { + [Fact] + public void OnErrorResumeNext_Arguments() + { + AssertThrows(() => EnumerableEx.OnErrorResumeNext(null, new[] { 1 })); + AssertThrows(() => EnumerableEx.OnErrorResumeNext(new[] { 1 }, null)); + AssertThrows(() => EnumerableEx.OnErrorResumeNext(default(IEnumerable[]))); + AssertThrows(() => EnumerableEx.OnErrorResumeNext(default(IEnumerable>))); + } + + [Fact] + public void OnErrorResumeNext1() + { + var xs = new[] { 1, 2 }; + var ys = new[] { 3, 4 }; + + var res = xs.OnErrorResumeNext(ys); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); + } + + [Fact] + public void OnErrorResumeNext2() + { + var xs = new[] { 1, 2 }.Concat(EnumerableEx.Throw(new MyException())); + var ys = new[] { 3, 4 }; + + var res = xs.OnErrorResumeNext(ys); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); + } + + [Fact] + public void OnErrorResumeNext3() + { + var xs = new[] { 1, 2 }; + var ys = new[] { 3, 4 }; + var zs = new[] { 5, 6 }; + + var res = EnumerableEx.OnErrorResumeNext(xs, ys, zs); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4, 5, 6 })); + } + + [Fact] + public void OnErrorResumeNext4() + { + var xs = new[] { 1, 2 }.Concat(EnumerableEx.Throw(new MyException())); + var ys = new[] { 3, 4 }; + var zs = new[] { 5, 6 }; + + var res = EnumerableEx.OnErrorResumeNext(xs, ys, zs); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4, 5, 6 })); + } + + [Fact] + public void OnErrorResumeNext5() + { + var xs = new[] { 1, 2 }; + var ys = new[] { 3, 4 }; + + var res = new[] { xs, ys }.OnErrorResumeNext(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); + } + + [Fact] + public void OnErrorResumeNext6() + { + var xs = new[] { 1, 2 }.Concat(EnumerableEx.Throw(new MyException())); + var ys = new[] { 3, 4 }; + + var res = new[] { xs, ys }.OnErrorResumeNext(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4 })); + } + + private sealed class MyException : Exception + { + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Retry.cs new file mode 100644 index 0000000000..9c17683b00 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Retry.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Retry : Tests + { + [Fact] + public void Retry_Arguments() + { + AssertThrows(() => EnumerableEx.Retry(null)); + AssertThrows(() => EnumerableEx.Retry(null, 5)); + AssertThrows(() => EnumerableEx.Retry(new[] { 1 }, -1)); + } + + [Fact] + public void Retry1() + { + var xs = Enumerable.Range(0, 10); + + var res = xs.Retry(); + Assert.True(Enumerable.SequenceEqual(res, xs)); + } + + [Fact] + public void Retry2() + { + var xs = Enumerable.Range(0, 10); + + var res = xs.Retry(2); + Assert.True(Enumerable.SequenceEqual(res, xs)); + } + + [Fact] + public void Retry3() + { + var ex = new MyException(); + var xs = Enumerable.Range(0, 2).Concat(EnumerableEx.Throw(ex)); + + var res = xs.Retry(2); + var e = res.GetEnumerator(); + HasNext(e, 0); + HasNext(e, 1); + HasNext(e, 0); + HasNext(e, 1); + AssertThrows(() => e.MoveNext(), ex_ => ex == ex_); + } + + private sealed class MyException : Exception + { + } + } +} From 835b333df68dfae67b91835fad4d5558b004c1f0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 21:56:48 -0700 Subject: [PATCH 325/862] Splitting a bunch more tests. --- .../System/Linq/Operators/Buffer.cs | 86 ++++ .../System/Linq/Operators/Distinct.cs | 51 ++ .../Linq/Operators/DistinctUntilChanged.cs | 41 ++ .../System/Linq/Operators/Do.cs | 105 +++++ .../System/Linq/Operators/Expand.cs | 41 ++ .../System/Linq/Operators/ForEach.cs | 38 ++ .../System/Linq/Operators/Hide.cs | 29 ++ .../System/Linq/Operators/IgnoreElements.cs | 27 ++ .../System/Linq/Operators/Scan.cs | 36 ++ .../System/Linq/Operators/SkipLast.cs | 44 ++ .../System/Linq/Operators/StartWith.cs | 36 ++ .../System/Linq/Operators/TakeLast.cs | 52 +++ .../System.Interactive.Tests/Tests.Single.cs | 437 ------------------ 13 files changed, 586 insertions(+), 437 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Buffer.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Distinct.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DistinctUntilChanged.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Do.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Expand.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/ForEach.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Hide.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IgnoreElements.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Scan.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/StartWith.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs delete mode 100644 Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Buffer.cs new file mode 100644 index 0000000000..01507eb544 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Buffer.cs @@ -0,0 +1,86 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Buffer : Tests + { + [Fact] + public void Buffer_Arguments() + { + AssertThrows(() => EnumerableEx.Buffer(null, 5)); + AssertThrows(() => EnumerableEx.Buffer(null, 5, 3)); + AssertThrows(() => EnumerableEx.Buffer(new[] { 1 }, 0)); + AssertThrows(() => EnumerableEx.Buffer(new[] { 1 }, 5, 0)); + AssertThrows(() => EnumerableEx.Buffer(new[] { 1 }, 0, 3)); + } + + [Fact] + public void Buffer1() + { + var rng = Enumerable.Range(0, 10); + + var res = rng.Buffer(3).ToList(); + Assert.Equal(4, res.Count); + + Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2 })); + Assert.True(res[1].SequenceEqual(new[] { 3, 4, 5 })); + Assert.True(res[2].SequenceEqual(new[] { 6, 7, 8 })); + Assert.True(res[3].SequenceEqual(new[] { 9 })); + } + + [Fact] + public void Buffer2() + { + var rng = Enumerable.Range(0, 10); + + var res = rng.Buffer(5).ToList(); + Assert.Equal(2, res.Count); + + Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2, 3, 4 })); + Assert.True(res[1].SequenceEqual(new[] { 5, 6, 7, 8, 9 })); + } + + [Fact] + public void Buffer3() + { + var rng = Enumerable.Empty(); + + var res = rng.Buffer(5).ToList(); + Assert.Equal(0, res.Count); + } + + [Fact] + public void Buffer4() + { + var rng = Enumerable.Range(0, 10); + + var res = rng.Buffer(3, 2).ToList(); + Assert.Equal(5, res.Count); + + Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2 })); + Assert.True(res[1].SequenceEqual(new[] { 2, 3, 4 })); + Assert.True(res[2].SequenceEqual(new[] { 4, 5, 6 })); + Assert.True(res[3].SequenceEqual(new[] { 6, 7, 8 })); + Assert.True(res[4].SequenceEqual(new[] { 8, 9 })); + } + + [Fact] + public void Buffer5() + { + var rng = Enumerable.Range(0, 10); + + var res = rng.Buffer(3, 4).ToList(); + Assert.Equal(3, res.Count); + + Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2 })); + Assert.True(res[1].SequenceEqual(new[] { 4, 5, 6 })); + Assert.True(res[2].SequenceEqual(new[] { 8, 9 })); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Distinct.cs new file mode 100644 index 0000000000..988c8dea66 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Distinct.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Distinct : Tests + { + [Fact] + public void Distinct_Arguments() + { + AssertThrows(() => EnumerableEx.Distinct(null, _ => _)); + AssertThrows(() => EnumerableEx.Distinct(new[] { 1 }, null)); + AssertThrows(() => EnumerableEx.Distinct(null, _ => _, EqualityComparer.Default)); + AssertThrows(() => EnumerableEx.Distinct(new[] { 1 }, null, EqualityComparer.Default)); + AssertThrows(() => EnumerableEx.Distinct(new[] { 1 }, _ => _, null)); + } + + [Fact] + public void Distinct1() + { + var res = Enumerable.Range(0, 10).Distinct(x => x % 5).ToList(); + Assert.True(Enumerable.SequenceEqual(res, Enumerable.Range(0, 5))); + } + + [Fact] + public void Distinct2() + { + var res = Enumerable.Range(0, 10).Distinct(x => x % 5, new MyEqualityComparer()).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 0, 1 })); + } + + private sealed class MyEqualityComparer : IEqualityComparer + { + public bool Equals(int x, int y) + { + return x % 2 == y % 2; + } + + public int GetHashCode(int obj) + { + return EqualityComparer.Default.GetHashCode(obj % 2); + } + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DistinctUntilChanged.cs new file mode 100644 index 0000000000..4857d88521 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class DistinctUntilChanged : Tests + { + [Fact] + public void DistinctUntilChanged_Arguments() + { + AssertThrows(() => EnumerableEx.DistinctUntilChanged(null)); + AssertThrows(() => EnumerableEx.DistinctUntilChanged(null, EqualityComparer.Default)); + AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, null)); + AssertThrows(() => EnumerableEx.DistinctUntilChanged(null, _ => _)); + AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, null)); + AssertThrows(() => EnumerableEx.DistinctUntilChanged(null, _ => _, EqualityComparer.Default)); + AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, null, EqualityComparer.Default)); + AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, _ => _, null)); + } + + [Fact] + public void DistinctUntilChanged1() + { + var res = new[] { 1, 2, 2, 3, 3, 3, 2, 2, 1 }.DistinctUntilChanged().ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 2, 1 })); + } + + [Fact] + public void DistinctUntilChanged2() + { + var res = new[] { 1, 1, 2, 3, 4, 5, 5, 6, 7 }.DistinctUntilChanged(x => x / 2).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 4, 6 })); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Do.cs new file mode 100644 index 0000000000..c2b15767f3 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Do.cs @@ -0,0 +1,105 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Do : Tests + { + [Fact] + public void Do_Arguments() + { + AssertThrows(() => EnumerableEx.Do(null, _ => { })); + AssertThrows(() => EnumerableEx.Do(null, _ => { }, () => { })); + AssertThrows(() => EnumerableEx.Do(null, _ => { }, _ => { })); + AssertThrows(() => EnumerableEx.Do(null, _ => { }, _ => { }, () => { })); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action))); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action), () => { })); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, default(Action))); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action), _ => { }, () => { })); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, default(Action), () => { })); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, _ => { }, default(Action))); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action), _ => { })); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, default(Action))); + AssertThrows(() => EnumerableEx.Do(null, new MyObserver())); + AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(IObserver))); + } + + [Fact] + public void Do1() + { + var n = 0; + Enumerable.Range(0, 10).Do(x => n += x).ForEach(_ => { }); + Assert.Equal(45, n); + } + + [Fact] + public void Do2() + { + var n = 0; + Enumerable.Range(0, 10).Do(x => n += x, () => n *= 2).ForEach(_ => { }); + Assert.Equal(90, n); + } + + [Fact] + public void Do3() + { + var ex = new MyException(); + var ok = false; + AssertThrows(() => + EnumerableEx.Throw(ex).Do(x => { Assert.True(false); }, e => { Assert.Equal(ex, e); ok = true; }).ForEach(_ => { }) + ); + Assert.True(ok); + } + + [Fact] + public void Do4() + { + var obs = new MyObserver(); + Enumerable.Range(0, 10).Do(obs).ForEach(_ => { }); + + Assert.True(obs.Done); + Assert.Equal(45, obs.Sum); + } + + [Fact] + public void Do5() + { + var sum = 0; + var done = false; + Enumerable.Range(0, 10).Do(x => sum += x, ex => { throw ex; }, () => done = true).ForEach(_ => { }); + + Assert.True(done); + Assert.Equal(45, sum); + } + + private sealed class MyObserver : IObserver + { + public int Sum; + public bool Done; + + public void OnCompleted() + { + Done = true; + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnNext(int value) + { + Sum += value; + } + } + + private sealed class MyException : Exception + { + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Expand.cs new file mode 100644 index 0000000000..9829b8377b --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Expand.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Expand : Tests + { + [Fact] + public void Expand_Arguments() + { + AssertThrows(() => EnumerableEx.Expand(null, _ => new[] { _ })); + AssertThrows(() => EnumerableEx.Expand(new[] { 1 }, null)); + } + + [Fact] + public void Expand1() + { + var res = new[] { 0 }.Expand(x => new[] { x + 1 }).Take(10).ToList(); + Assert.True(Enumerable.SequenceEqual(res, Enumerable.Range(0, 10))); + } + + [Fact] + public void Expand2() + { + var res = new[] { 3 }.Expand(x => Enumerable.Range(0, x)).ToList(); + var exp = new[] { + 3, + 0, 1, 2, + 0, + 0, 1, + 0 + }; + Assert.True(Enumerable.SequenceEqual(res, exp)); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/ForEach.cs new file mode 100644 index 0000000000..ece57529d6 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/ForEach.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class ForEach : Tests + { + [Fact] + public void ForEach_Arguments() + { + AssertThrows(() => EnumerableEx.ForEach(null, x => { })); + AssertThrows(() => EnumerableEx.ForEach(new[] { 1 }, default(Action))); + AssertThrows(() => EnumerableEx.ForEach(null, (x, i) => { })); + AssertThrows(() => EnumerableEx.ForEach(new[] { 1 }, default(Action))); + } + + [Fact] + public void ForEach1() + { + var n = 0; + Enumerable.Range(5, 3).ForEach(x => n += x); + Assert.Equal(5 + 6 + 7, n); + } + + [Fact] + public void ForEach2() + { + var n = 0; + Enumerable.Range(5, 3).ForEach((x, i) => n += x * i); + Assert.Equal(5 * 0 + 6 * 1 + 7 * 2, n); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Hide.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Hide.cs new file mode 100644 index 0000000000..39a73d7d7d --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Hide.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Hide : Tests + { + [Fact] + public void Hide_Arguments() + { + AssertThrows(() => EnumerableEx.Hide(null)); + } + + [Fact] + public void Hide1() + { + var xs = new List { 1, 2, 3 }; + var ys = xs.Hide(); + Assert.False(ys is List); + Assert.True(xs.SequenceEqual(ys)); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IgnoreElements.cs new file mode 100644 index 0000000000..bdd8e4506b --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/IgnoreElements.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class IgnoreElements : Tests + { + [Fact] + public void IgnoreElements_Arguments() + { + AssertThrows(() => EnumerableEx.IgnoreElements(null)); + } + + [Fact] + public void IgnoreElements1() + { + var n = 0; + Enumerable.Range(0, 10).Do(_ => n++).IgnoreElements().Take(5).ForEach(_ => { }); + Assert.Equal(10, n); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Scan.cs new file mode 100644 index 0000000000..f8b3d3fca7 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Scan.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Scan : Tests + { + [Fact] + public void Scan_Arguments() + { + AssertThrows(() => EnumerableEx.Scan(null, (x, y) => x + y)); + AssertThrows(() => EnumerableEx.Scan(new[] { 1 }, null)); + AssertThrows(() => EnumerableEx.Scan(null, 0, (x, y) => x + y)); + AssertThrows(() => EnumerableEx.Scan(new[] { 1 }, 0, null)); + } + + [Fact] + public void Scan1() + { + var res = Enumerable.Range(0, 5).Scan((n, x) => n + x).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 3, 6, 10 })); + } + + [Fact] + public void Scan2() + { + var res = Enumerable.Range(0, 5).Scan(10, (n, x) => n - x).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 10, 9, 7, 4, 0 })); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs new file mode 100644 index 0000000000..b793526e89 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class SkipLast : Tests + { + [Fact] + public void SkipLast_Arguments() + { + AssertThrows(() => EnumerableEx.SkipLast(null, 5)); + AssertThrows(() => EnumerableEx.SkipLast(new[] { 1 }, -1)); + } + + [Fact] + public void SkipLast_Empty() + { + var e = Enumerable.Empty(); + var r = e.SkipLast(1).ToList(); + Assert.True(Enumerable.SequenceEqual(r, e)); + } + + [Fact] + public void SkipLast_All() + { + var e = Enumerable.Range(0, 5); + var r = e.SkipLast(0).ToList(); + Assert.True(Enumerable.SequenceEqual(r, e)); + } + + [Fact] + public void SkipLast_Part() + { + var e = Enumerable.Range(0, 5); + var r = e.SkipLast(3).ToList(); + Assert.True(Enumerable.SequenceEqual(r, e.Take(2))); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/StartWith.cs new file mode 100644 index 0000000000..6c884ca24f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/StartWith.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class StartWith : Tests + { + [Fact] + public void StartWith_Arguments() + { + AssertThrows(() => EnumerableEx.StartWith(null, 5)); + } + + [Fact] + public void StartWith1() + { + var e = Enumerable.Range(1, 5); + var r = e.StartWith(0).ToList(); + Assert.True(Enumerable.SequenceEqual(r, Enumerable.Range(0, 6))); + } + + [Fact] + public void StartWith2() + { + var oops = false; + var e = Enumerable.Range(1, 5).Do(_ => oops = true); + var r = e.StartWith(0).Take(1).ToList(); + Assert.False(oops); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs new file mode 100644 index 0000000000..ff865bbec1 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class TakeLast : Tests + { + [Fact] + public void TakeLast_Arguments() + { + AssertThrows(() => EnumerableEx.TakeLast(null, 5)); + AssertThrows(() => EnumerableEx.TakeLast(new[] { 1 }, -1)); + } + + [Fact] + public void TakeLast_TakeZero() + { + var e = Enumerable.Range(1, 5); + var r = e.TakeLast(0).ToList(); + Assert.True(Enumerable.SequenceEqual(r, Enumerable.Empty())); + } + + [Fact] + public void TakeLast_Empty() + { + var e = Enumerable.Empty(); + var r = e.TakeLast(1).ToList(); + Assert.True(Enumerable.SequenceEqual(r, e)); + } + + [Fact] + public void TakeLast_All() + { + var e = Enumerable.Range(0, 5); + var r = e.TakeLast(5).ToList(); + Assert.True(Enumerable.SequenceEqual(r, e)); + } + + [Fact] + public void TakeLast_Part() + { + var e = Enumerable.Range(0, 5); + var r = e.TakeLast(3).ToList(); + Assert.True(Enumerable.SequenceEqual(r, e.Skip(2))); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs deleted file mode 100644 index 285f0ac7c1..0000000000 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Single.cs +++ /dev/null @@ -1,437 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; - -namespace Tests -{ - public partial class Tests - { - [Fact] - public void Hide_Arguments() - { - AssertThrows(() => EnumerableEx.Hide(null)); - } - - [Fact] - public void Hide() - { - var xs = new List { 1, 2, 3 }; - var ys = xs.Hide(); - Assert.False(ys is List); - Assert.True(xs.SequenceEqual(ys)); - } - - [Fact] - public void ForEach_Arguments() - { - AssertThrows(() => EnumerableEx.ForEach(null, x => { })); - AssertThrows(() => EnumerableEx.ForEach(new[] { 1 }, default(Action))); - AssertThrows(() => EnumerableEx.ForEach(null, (x, i) => { })); - AssertThrows(() => EnumerableEx.ForEach(new[] { 1 }, default(Action))); - } - - [Fact] - public void ForEach1() - { - var n = 0; - Enumerable.Range(5, 3).ForEach(x => n += x); - Assert.Equal(5 + 6 + 7, n); - } - - [Fact] - public void ForEach2() - { - var n = 0; - Enumerable.Range(5, 3).ForEach((x, i) => n += x * i); - Assert.Equal(5 * 0 + 6 * 1 + 7 * 2, n); - } - - [Fact] - public void Buffer_Arguments() - { - AssertThrows(() => EnumerableEx.Buffer(null, 5)); - AssertThrows(() => EnumerableEx.Buffer(null, 5, 3)); - AssertThrows(() => EnumerableEx.Buffer(new[] { 1 }, 0)); - AssertThrows(() => EnumerableEx.Buffer(new[] { 1 }, 5, 0)); - AssertThrows(() => EnumerableEx.Buffer(new[] { 1 }, 0, 3)); - } - - [Fact] - public void Buffer1() - { - var rng = Enumerable.Range(0, 10); - - var res = rng.Buffer(3).ToList(); - Assert.Equal(4, res.Count); - - Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2 })); - Assert.True(res[1].SequenceEqual(new[] { 3, 4, 5 })); - Assert.True(res[2].SequenceEqual(new[] { 6, 7, 8 })); - Assert.True(res[3].SequenceEqual(new[] { 9 })); - } - - [Fact] - public void Buffer2() - { - var rng = Enumerable.Range(0, 10); - - var res = rng.Buffer(5).ToList(); - Assert.Equal(2, res.Count); - - Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2, 3, 4 })); - Assert.True(res[1].SequenceEqual(new[] { 5, 6, 7, 8, 9 })); - } - - [Fact] - public void Buffer3() - { - var rng = Enumerable.Empty(); - - var res = rng.Buffer(5).ToList(); - Assert.Equal(0, res.Count); - } - - [Fact] - public void Buffer4() - { - var rng = Enumerable.Range(0, 10); - - var res = rng.Buffer(3, 2).ToList(); - Assert.Equal(5, res.Count); - - Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2 })); - Assert.True(res[1].SequenceEqual(new[] { 2, 3, 4 })); - Assert.True(res[2].SequenceEqual(new[] { 4, 5, 6 })); - Assert.True(res[3].SequenceEqual(new[] { 6, 7, 8 })); - Assert.True(res[4].SequenceEqual(new[] { 8, 9 })); - } - - [Fact] - public void Buffer5() - { - var rng = Enumerable.Range(0, 10); - - var res = rng.Buffer(3, 4).ToList(); - Assert.Equal(3, res.Count); - - Assert.True(res[0].SequenceEqual(new[] { 0, 1, 2 })); - Assert.True(res[1].SequenceEqual(new[] { 4, 5, 6 })); - Assert.True(res[2].SequenceEqual(new[] { 8, 9 })); - } - - [Fact] - public void Do_Arguments() - { - AssertThrows(() => EnumerableEx.Do(null, _ => { })); - AssertThrows(() => EnumerableEx.Do(null, _ => { }, () => { })); - AssertThrows(() => EnumerableEx.Do(null, _ => { }, _ => { })); - AssertThrows(() => EnumerableEx.Do(null, _ => { }, _ => { }, () => { })); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action))); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action), () => { })); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, default(Action))); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action), _ => { }, () => { })); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, default(Action), () => { })); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, _ => { }, default(Action))); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(Action), _ => { })); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, _ => { }, default(Action))); - AssertThrows(() => EnumerableEx.Do(null, new MyObserver())); - AssertThrows(() => EnumerableEx.Do(new[] { 1 }, default(IObserver))); - } - - [Fact] - public void Do1() - { - var n = 0; - Enumerable.Range(0, 10).Do(x => n += x).ForEach(_ => { }); - Assert.Equal(45, n); - } - - [Fact] - public void Do2() - { - var n = 0; - Enumerable.Range(0, 10).Do(x => n += x, () => n *= 2).ForEach(_ => { }); - Assert.Equal(90, n); - } - - [Fact] - public void Do3() - { - var ex = new MyException(); - var ok = false; - AssertThrows(() => - EnumerableEx.Throw(ex).Do(x => { Assert.True(false); }, e => { Assert.Equal(ex, e); ok = true; }).ForEach(_ => { }) - ); - Assert.True(ok); - } - - [Fact] - public void Do4() - { - var obs = new MyObserver(); - Enumerable.Range(0, 10).Do(obs).ForEach(_ => { }); - - Assert.True(obs.Done); - Assert.Equal(45, obs.Sum); - } - - class MyObserver : IObserver - { - public int Sum; - public bool Done; - - public void OnCompleted() - { - Done = true; - } - - public void OnError(Exception error) - { - throw new NotImplementedException(); - } - - public void OnNext(int value) - { - Sum += value; - } - } - - [Fact] - public void Do5() - { - var sum = 0; - var done = false; - Enumerable.Range(0, 10).Do(x => sum += x, ex => { throw ex; }, () => done = true).ForEach(_ => { }); - - Assert.True(done); - Assert.Equal(45, sum); - } - - [Fact] - public void StartWith_Arguments() - { - AssertThrows(() => EnumerableEx.StartWith(null, 5)); - } - - [Fact] - public void StartWith1() - { - var e = Enumerable.Range(1, 5); - var r = e.StartWith(0).ToList(); - Assert.True(Enumerable.SequenceEqual(r, Enumerable.Range(0, 6))); - } - - [Fact] - public void StartWith2() - { - var oops = false; - var e = Enumerable.Range(1, 5).Do(_ => oops = true); - var r = e.StartWith(0).Take(1).ToList(); - Assert.False(oops); - } - - [Fact] - public void Expand_Arguments() - { - AssertThrows(() => EnumerableEx.Expand(null, _ => new[] { _ })); - AssertThrows(() => EnumerableEx.Expand(new[] { 1 }, null)); - } - - [Fact] - public void Expand1() - { - var res = new[] { 0 }.Expand(x => new[] { x + 1 }).Take(10).ToList(); - Assert.True(Enumerable.SequenceEqual(res, Enumerable.Range(0, 10))); - } - - [Fact] - public void Expand2() - { - var res = new[] { 3 }.Expand(x => Enumerable.Range(0, x)).ToList(); - var exp = new[] { - 3, - 0, 1, 2, - 0, - 0, 1, - 0 - }; - Assert.True(Enumerable.SequenceEqual(res, exp)); - } - - [Fact] - public void Distinct_Arguments() - { - AssertThrows(() => EnumerableEx.Distinct(null, _ => _)); - AssertThrows(() => EnumerableEx.Distinct(new[] { 1 }, null)); - AssertThrows(() => EnumerableEx.Distinct(null, _ => _, EqualityComparer.Default)); - AssertThrows(() => EnumerableEx.Distinct(new[] { 1 }, null, EqualityComparer.Default)); - AssertThrows(() => EnumerableEx.Distinct(new[] { 1 }, _ => _, null)); - } - - [Fact] - public void Distinct1() - { - var res = Enumerable.Range(0, 10).Distinct(x => x % 5).ToList(); - Assert.True(Enumerable.SequenceEqual(res, Enumerable.Range(0, 5))); - } - - [Fact] - public void Distinct2() - { - var res = Enumerable.Range(0, 10).Distinct(x => x % 5, new MyEqualityComparer()).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 0, 1 })); - } - - class MyEqualityComparer : IEqualityComparer - { - public bool Equals(int x, int y) - { - return x % 2 == y % 2; - } - - public int GetHashCode(int obj) - { - return EqualityComparer.Default.GetHashCode(obj % 2); - } - } - - [Fact] - public void DistinctUntilChanged_Arguments() - { - AssertThrows(() => EnumerableEx.DistinctUntilChanged(null)); - AssertThrows(() => EnumerableEx.DistinctUntilChanged(null, EqualityComparer.Default)); - AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, null)); - AssertThrows(() => EnumerableEx.DistinctUntilChanged(null, _ => _)); - AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, null)); - AssertThrows(() => EnumerableEx.DistinctUntilChanged(null, _ => _, EqualityComparer.Default)); - AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, null, EqualityComparer.Default)); - AssertThrows(() => EnumerableEx.DistinctUntilChanged(new[] { 1 }, _ => _, null)); - } - - [Fact] - public void DistinctUntilChanged1() - { - var res = new[] { 1, 2, 2, 3, 3, 3, 2, 2, 1 }.DistinctUntilChanged().ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 2, 1 })); - } - - [Fact] - public void DistinctUntilChanged2() - { - var res = new[] { 1, 1, 2, 3, 4, 5, 5, 6, 7 }.DistinctUntilChanged(x => x / 2).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 4, 6 })); - } - - [Fact] - public void IgnoreElements_Arguments() - { - AssertThrows(() => EnumerableEx.IgnoreElements(null)); - } - - [Fact] - public void IgnoreElements() - { - var n = 0; - Enumerable.Range(0, 10).Do(_ => n++).IgnoreElements().Take(5).ForEach(_ => { }); - Assert.Equal(10, n); - } - - [Fact] - public void TakeLast_Arguments() - { - AssertThrows(() => EnumerableEx.TakeLast(null, 5)); - AssertThrows(() => EnumerableEx.TakeLast(new[] { 1 }, -1)); - } - - [Fact] - public void TakeLast_TakeZero() - { - var e = Enumerable.Range(1, 5); - var r = e.TakeLast(0).ToList(); - Assert.True(Enumerable.SequenceEqual(r, Enumerable.Empty())); - } - - [Fact] - public void TakeLast_Empty() - { - var e = Enumerable.Empty(); - var r = e.TakeLast(1).ToList(); - Assert.True(Enumerable.SequenceEqual(r, e)); - } - - [Fact] - public void TakeLast_All() - { - var e = Enumerable.Range(0, 5); - var r = e.TakeLast(5).ToList(); - Assert.True(Enumerable.SequenceEqual(r, e)); - } - - [Fact] - public void TakeLast_Part() - { - var e = Enumerable.Range(0, 5); - var r = e.TakeLast(3).ToList(); - Assert.True(Enumerable.SequenceEqual(r, e.Skip(2))); - } - - [Fact] - public void SkipLast_Arguments() - { - AssertThrows(() => EnumerableEx.SkipLast(null, 5)); - AssertThrows(() => EnumerableEx.SkipLast(new[] { 1 }, -1)); - } - - [Fact] - public void SkipLast_Empty() - { - var e = Enumerable.Empty(); - var r = e.SkipLast(1).ToList(); - Assert.True(Enumerable.SequenceEqual(r, e)); - } - - [Fact] - public void SkipLast_All() - { - var e = Enumerable.Range(0, 5); - var r = e.SkipLast(0).ToList(); - Assert.True(Enumerable.SequenceEqual(r, e)); - } - - [Fact] - public void SkipLast_Part() - { - var e = Enumerable.Range(0, 5); - var r = e.SkipLast(3).ToList(); - Assert.True(Enumerable.SequenceEqual(r, e.Take(2))); - } - - [Fact] - public void Scan_Arguments() - { - AssertThrows(() => EnumerableEx.Scan(null, (x, y) => x + y)); - AssertThrows(() => EnumerableEx.Scan(new[] { 1 }, null)); - AssertThrows(() => EnumerableEx.Scan(null, 0, (x, y) => x + y)); - AssertThrows(() => EnumerableEx.Scan(new[] { 1 }, 0, null)); - } - - [Fact] - public void Scan1() - { - var res = Enumerable.Range(0, 5).Scan((n, x) => n + x).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 3, 6, 10 })); - } - - [Fact] - public void Scan2() - { - var res = Enumerable.Range(0, 5).Scan(10, (n, x) => n - x).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 10, 9, 7, 4, 0 })); - } - } -} From 0bd488e4a815e4a8289a411878c2adfbbeb83fbc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 21:58:29 -0700 Subject: [PATCH 326/862] Splitting more tests. --- .../Linq/Operators/Concat.cs} | 16 +---------- .../System/Linq/Operators/SelectMany.cs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 15 deletions(-) rename Ix.NET/Source/System.Interactive.Tests/{Tests.Multiple.cs => System/Linq/Operators/Concat.cs} (74%) create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SelectMany.cs diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Concat.cs similarity index 74% rename from Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs rename to Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Concat.cs index b90524ed2b..d89d166bb6 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Multiple.cs +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Concat.cs @@ -9,7 +9,7 @@ namespace Tests { - public partial class Tests + public class Concat : Tests { [Fact] public void Concat_Arguments() @@ -58,19 +58,5 @@ public void Concat3() Assert.True(Enumerable.SequenceEqual(res, new[] { 1, 2, 3, 4, 5 })); } - - [Fact] - public void SelectMany_Arguments() - { - AssertThrows(() => EnumerableEx.SelectMany(null, new[] { 1 })); - AssertThrows(() => EnumerableEx.SelectMany(new[] { 1 }, null)); - } - - [Fact] - public void SelectMany() - { - var res = new[] { 1, 2 }.SelectMany(new[] { 'a', 'b', 'c' }).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 'a', 'b', 'c', 'a', 'b', 'c' })); - } } } diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SelectMany.cs new file mode 100644 index 0000000000..2e625c7d92 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SelectMany.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class SelectMany : Tests + { + [Fact] + public void SelectMany_Arguments() + { + AssertThrows(() => EnumerableEx.SelectMany(null, new[] { 1 })); + AssertThrows(() => EnumerableEx.SelectMany(new[] { 1 }, null)); + } + + [Fact] + public void SelectMany1() + { + var res = new[] { 1, 2 }.SelectMany(new[] { 'a', 'b', 'c' }).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 'a', 'b', 'c', 'a', 'b', 'c' })); + } + } +} From 2c9ce4666b151087f28c5dfbc5f2149e00596ae4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:00:53 -0700 Subject: [PATCH 327/862] Splitting tests for imperative operators. --- .../System/Linq/Operators/Case.cs | 88 +++++++++ .../System/Linq/Operators/DoWhile.cs | 36 ++++ .../System/Linq/Operators/For.cs | 27 +++ .../System/Linq/Operators/If.cs | 47 +++++ .../System/Linq/Operators/While.cs | 36 ++++ .../Tests.Imperative.cs | 182 ------------------ 6 files changed, 234 insertions(+), 182 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Case.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DoWhile.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/For.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/If.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/While.cs delete mode 100644 Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Case.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Case.cs new file mode 100644 index 0000000000..dd06874fd6 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Case.cs @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Case : Tests + { + [Fact] + public void Case_Arguments() + { + AssertThrows(() => EnumerableEx.Case(null, new Dictionary>())); + AssertThrows(() => EnumerableEx.Case(() => 1, null)); + AssertThrows(() => EnumerableEx.Case(null, new Dictionary>(), new[] { 1 })); + AssertThrows(() => EnumerableEx.Case(() => 1, null, new[] { 1 })); + AssertThrows(() => EnumerableEx.Case(() => 1, new Dictionary>(), null)); + } + + [Fact] + public void Case1() + { + var x = 1; + var d = 'd'; + var res = EnumerableEx.Case(() => x, new Dictionary> + { + { 0, new[] { 'a' } }, + { 1, new[] { 'b' } }, + { 2, new[] { 'c' } }, + { 3, EnumerableEx.Defer(() => new[] { d }) }, + }); + + Assert.Equal('b', res.Single()); + Assert.Equal('b', res.Single()); + + x = 0; + Assert.Equal('a', res.Single()); + + x = 2; + Assert.Equal('c', res.Single()); + + x = 3; + Assert.Equal('d', res.Single()); + + d = 'e'; + Assert.Equal('e', res.Single()); + + x = 4; + Assert.True(res.IsEmpty()); + } + + [Fact] + public void Case2() + { + var x = 1; + var d = 'd'; + var res = EnumerableEx.Case(() => x, new Dictionary> + { + { 0, new[] { 'a' } }, + { 1, new[] { 'b' } }, + { 2, new[] { 'c' } }, + { 3, EnumerableEx.Defer(() => new[] { d }) }, + }, new[] { 'z' }); + + Assert.Equal('b', res.Single()); + Assert.Equal('b', res.Single()); + + x = 0; + Assert.Equal('a', res.Single()); + + x = 2; + Assert.Equal('c', res.Single()); + + x = 3; + Assert.Equal('d', res.Single()); + + d = 'e'; + Assert.Equal('e', res.Single()); + + x = 4; + Assert.Equal('z', res.Single()); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DoWhile.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DoWhile.cs new file mode 100644 index 0000000000..a863852f4c --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/DoWhile.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class DoWhile : Tests + { + [Fact] + public void DoWhile_Arguments() + { + AssertThrows(() => EnumerableEx.DoWhile(new[] { 1 }, null)); + AssertThrows(() => EnumerableEx.DoWhile(null, () => true)); + } + + [Fact] + public void DoWhile1() + { + var x = 5; + var res = EnumerableEx.DoWhile(EnumerableEx.Defer(() => new[] { x }).Do(_ => x--), () => x > 0).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 5, 4, 3, 2, 1 })); + } + + [Fact] + public void DoWhile2() + { + var x = 0; + var res = EnumerableEx.DoWhile(EnumerableEx.Defer(() => new[] { x }).Do(_ => x--), () => x > 0).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 0 })); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/For.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/For.cs new file mode 100644 index 0000000000..c4edfe12b3 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/For.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class For : Tests + { + [Fact] + public void For_Arguments() + { + AssertThrows(() => EnumerableEx.For(null, x => new[] { 1 })); + AssertThrows(() => EnumerableEx.For(new[] { 1 }, null)); + } + + [Fact] + public void For1() + { + var res = EnumerableEx.For(new[] { 1, 2, 3 }, x => Enumerable.Range(0, x)).ToList(); + Assert.True(res.SequenceEqual(new[] { 0, 0, 1, 0, 1, 2 })); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/If.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/If.cs new file mode 100644 index 0000000000..a182d59c0b --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/If.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class If : Tests + { + [Fact] + public void If_Arguments() + { + AssertThrows(() => EnumerableEx.If(null, new[] { 1 })); + AssertThrows(() => EnumerableEx.If(() => true, null)); + AssertThrows(() => EnumerableEx.If(null, new[] { 1 }, new[] { 1 })); + AssertThrows(() => EnumerableEx.If(() => true, null, new[] { 1 })); + AssertThrows(() => EnumerableEx.If(() => true, new[] { 1 }, null)); + } + + [Fact] + public void If1() + { + var x = 5; + var res = EnumerableEx.If(() => x > 0, new[] { +1 }, new[] { -1 }); + + Assert.Equal(+1, res.Single()); + + x = -x; + Assert.Equal(-1, res.Single()); + } + + [Fact] + public void If2() + { + var x = 5; + var res = EnumerableEx.If(() => x > 0, new[] { +1 }); + + Assert.Equal(+1, res.Single()); + + x = -x; + Assert.True(res.IsEmpty()); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/While.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/While.cs new file mode 100644 index 0000000000..d37e51a71b --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/While.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class While : Tests + { + [Fact] + public void While_Arguments() + { + AssertThrows(() => EnumerableEx.While(null, new[] { 1 })); + AssertThrows(() => EnumerableEx.While(() => true, null)); + } + + [Fact] + public void While1() + { + var x = 5; + var res = EnumerableEx.While(() => x > 0, EnumerableEx.Defer(() => new[] { x }).Do(_ => x--)).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 5, 4, 3, 2, 1 })); + } + + [Fact] + public void While2() + { + var x = 0; + var res = EnumerableEx.While(() => x > 0, EnumerableEx.Defer(() => new[] { x }).Do(_ => x--)).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new int[0])); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs deleted file mode 100644 index b0c33763fe..0000000000 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Imperative.cs +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit; - -namespace Tests -{ - public partial class Tests - { - [Fact] - public void While_Arguments() - { - AssertThrows(() => EnumerableEx.While(null, new[] { 1 })); - AssertThrows(() => EnumerableEx.While(() => true, null)); - } - - [Fact] - public void While1() - { - var x = 5; - var res = EnumerableEx.While(() => x > 0, EnumerableEx.Defer(() => new[] { x }).Do(_ => x--)).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 5, 4, 3, 2, 1 })); - } - - [Fact] - public void While2() - { - var x = 0; - var res = EnumerableEx.While(() => x > 0, EnumerableEx.Defer(() => new[] { x }).Do(_ => x--)).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new int[0])); - } - - [Fact] - public void DoWhile_Arguments() - { - AssertThrows(() => EnumerableEx.DoWhile(new[] { 1 }, null)); - AssertThrows(() => EnumerableEx.DoWhile(null, () => true)); - } - - [Fact] - public void DoWhile1() - { - var x = 5; - var res = EnumerableEx.DoWhile(EnumerableEx.Defer(() => new[] { x }).Do(_ => x--), () => x > 0).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 5, 4, 3, 2, 1 })); - } - - [Fact] - public void DoWhile2() - { - var x = 0; - var res = EnumerableEx.DoWhile(EnumerableEx.Defer(() => new[] { x }).Do(_ => x--), () => x > 0).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 0 })); - } - - [Fact] - public void If_Arguments() - { - AssertThrows(() => EnumerableEx.If(null, new[] { 1 })); - AssertThrows(() => EnumerableEx.If(() => true, null)); - AssertThrows(() => EnumerableEx.If(null, new[] { 1 }, new[] { 1 })); - AssertThrows(() => EnumerableEx.If(() => true, null, new[] { 1 })); - AssertThrows(() => EnumerableEx.If(() => true, new[] { 1 }, null)); - } - - [Fact] - public void If1() - { - var x = 5; - var res = EnumerableEx.If(() => x > 0, new[] { +1 }, new[] { -1 }); - - Assert.Equal(+1, res.Single()); - - x = -x; - Assert.Equal(-1, res.Single()); - } - - [Fact] - public void If2() - { - var x = 5; - var res = EnumerableEx.If(() => x > 0, new[] { +1 }); - - Assert.Equal(+1, res.Single()); - - x = -x; - Assert.True(res.IsEmpty()); - } - - [Fact] - public void Case_Arguments() - { - AssertThrows(() => EnumerableEx.Case(null, new Dictionary>())); - AssertThrows(() => EnumerableEx.Case(() => 1, null)); - AssertThrows(() => EnumerableEx.Case(null, new Dictionary>(), new[] { 1 })); - AssertThrows(() => EnumerableEx.Case(() => 1, null, new[] { 1 })); - AssertThrows(() => EnumerableEx.Case(() => 1, new Dictionary>(), null)); - } - - [Fact] - public void Case1() - { - var x = 1; - var d = 'd'; - var res = EnumerableEx.Case(() => x, new Dictionary> - { - { 0, new[] { 'a' } }, - { 1, new[] { 'b' } }, - { 2, new[] { 'c' } }, - { 3, EnumerableEx.Defer(() => new[] { d }) }, - }); - - Assert.Equal('b', res.Single()); - Assert.Equal('b', res.Single()); - - x = 0; - Assert.Equal('a', res.Single()); - - x = 2; - Assert.Equal('c', res.Single()); - - x = 3; - Assert.Equal('d', res.Single()); - - d = 'e'; - Assert.Equal('e', res.Single()); - - x = 4; - Assert.True(res.IsEmpty()); - } - - [Fact] - public void Case2() - { - var x = 1; - var d = 'd'; - var res = EnumerableEx.Case(() => x, new Dictionary> - { - { 0, new[] { 'a' } }, - { 1, new[] { 'b' } }, - { 2, new[] { 'c' } }, - { 3, EnumerableEx.Defer(() => new[] { d }) }, - }, new[] { 'z' }); - - Assert.Equal('b', res.Single()); - Assert.Equal('b', res.Single()); - - x = 0; - Assert.Equal('a', res.Single()); - - x = 2; - Assert.Equal('c', res.Single()); - - x = 3; - Assert.Equal('d', res.Single()); - - d = 'e'; - Assert.Equal('e', res.Single()); - - x = 4; - Assert.Equal('z', res.Single()); - } - - [Fact] - public void For_Arguments() - { - AssertThrows(() => EnumerableEx.For(null, x => new[] { 1 })); - AssertThrows(() => EnumerableEx.For(new[] { 1 }, null)); - } - - [Fact] - public void For() - { - var res = EnumerableEx.For(new[] { 1, 2, 3 }, x => Enumerable.Range(0, x)).ToList(); - Assert.True(res.SequenceEqual(new[] { 0, 0, 1, 0, 1, 2 })); - } - } -} From c2a9ca8609ab93036bd0dc13a9c9bee08c669a0b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:01:36 -0700 Subject: [PATCH 328/862] Some code cosmetics. --- .../System.Interactive.Tests/Tests.Creation.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs index 24aaaa60ce..35357335cf 100644 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs +++ b/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs @@ -48,7 +48,8 @@ public void CreateYield() { SynchronizationContext.SetSynchronizationContext(null); - var xs = EnumerableEx.Create(async yield => { + var xs = EnumerableEx.Create(async yield => + { var i = 0; while (i < 10) { @@ -71,7 +72,8 @@ public void CreateYieldBreak() { SynchronizationContext.SetSynchronizationContext(null); - var xs = EnumerableEx.Create(async yield => { + var xs = EnumerableEx.Create(async yield => + { var i = 0; while (true) { @@ -98,14 +100,14 @@ public void CreateYieldBreak() [Fact] public void YielderNoReset() { - var xs = EnumerableEx.Create(async yield => { - await yield.Break(); + var xs = EnumerableEx.Create(async yield => + { + await yield.Break(); }); AssertThrows(() => xs.GetEnumerator().Reset()); } - private static IEnumerator MyEnumerator() { yield return 1; From a62ec1206d56560f5faaff1fff5a02c98bc9896f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:10:50 -0700 Subject: [PATCH 329/862] Splitting creation operator tests. --- .../System/Linq/Operators/Create.cs | 117 +++++++ .../System/Linq/Operators/Defer.cs | 55 ++++ .../System/Linq/Operators/Generate.cs | 28 ++ .../System/Linq/Operators/Repeat.cs | 53 ++++ .../System/Linq/Operators/Return.cs | 18 ++ .../System/Linq/Operators/Throw.cs | 33 ++ .../System/Linq/Operators/Using.cs | 77 +++++ .../Tests.Creation.cs | 292 ------------------ 8 files changed, 381 insertions(+), 292 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Create.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Defer.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Generate.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Repeat.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Return.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Throw.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Using.cs delete mode 100644 Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Create.cs new file mode 100644 index 0000000000..7bb43ce33c --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Create.cs @@ -0,0 +1,117 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Xunit; + +namespace Tests +{ + public class Create : Tests + { + [Fact] + public void Create_Arguments() + { + AssertThrows(() => EnumerableEx.Create(default(Func>))); + } + + [Fact] + public void Create1() + { + var hot = false; + var res = EnumerableEx.Create(() => + { + hot = true; + return MyEnumerator(); + }); + + Assert.False(hot); + + var e = res.GetEnumerator(); + Assert.True(hot); + + HasNext(e, 1); + HasNext(e, 2); + NoNext(e); + + hot = false; + var f = ((IEnumerable)res).GetEnumerator(); + Assert.True(hot); + } + + [Fact] + public void CreateYield() + { + SynchronizationContext.SetSynchronizationContext(null); + + var xs = EnumerableEx.Create(async yield => + { + var i = 0; + while (i < 10) + { + await yield.Return(i++); + } + }); + + var j = 0; + foreach (var elem in xs) + { + Assert.Equal(j, elem); + j++; + } + + Assert.Equal(10, j); + } + + [Fact] + public void CreateYieldBreak() + { + SynchronizationContext.SetSynchronizationContext(null); + + var xs = EnumerableEx.Create(async yield => + { + var i = 0; + while (true) + { + if (i == 10) + { + await yield.Break(); + return; + } + + await yield.Return(i++); + } + }); + + var j = 0; + foreach (var elem in xs) + { + Assert.Equal(elem, j); + j++; + } + + Assert.Equal(10, j); + } + + [Fact] + public void YielderNoReset() + { + var xs = EnumerableEx.Create(async yield => + { + await yield.Break(); + }); + + AssertThrows(() => xs.GetEnumerator().Reset()); + } + + private static IEnumerator MyEnumerator() + { + yield return 1; + yield return 2; + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Defer.cs new file mode 100644 index 0000000000..e84b900288 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Defer.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Defer: Tests + { + [Fact] + public void Defer_Arguments() + { + AssertThrows(() => EnumerableEx.Defer(null)); + } + + [Fact] + public void Defer1() + { + var i = 0; + var n = 5; + var xs = EnumerableEx.Defer(() => + { + i++; + return Enumerable.Range(0, n); + }); + + Assert.Equal(0, i); + + Assert.True(Enumerable.SequenceEqual(xs, Enumerable.Range(0, n))); + Assert.Equal(1, i); + + n = 3; + Assert.True(Enumerable.SequenceEqual(xs, Enumerable.Range(0, n))); + Assert.Equal(2, i); + } + + [Fact] + public void Defer2() + { + var xs = EnumerableEx.Defer(() => + { + throw new MyException(); + }); + + AssertThrows(() => xs.GetEnumerator().MoveNext()); + } + + private sealed class MyException : Exception + { + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Generate.cs new file mode 100644 index 0000000000..867442ee0b --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Generate.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Generate : Tests + { + [Fact] + public void Generate_Arguments() + { + AssertThrows(() => EnumerableEx.Generate(0, null, _ => _, _ => _)); + AssertThrows(() => EnumerableEx.Generate(0, _ => true, null, _ => _)); + AssertThrows(() => EnumerableEx.Generate(0, _ => true, _ => _, null)); + } + + [Fact] + public void Generate1() + { + var res = EnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x).ToList(); + Assert.True(Enumerable.SequenceEqual(res, new[] { 0, 1, 4, 9, 16 })); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Repeat.cs new file mode 100644 index 0000000000..3d177e0036 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Repeat.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Repeat : Tests + { + [Fact] + public void RepeatElementInfinite() + { + var xs = EnumerableEx.Repeat(42).Take(1000); + Assert.True(xs.All(x => x == 42)); + Assert.True(xs.Count() == 1000); + } + + [Fact] + public void RepeatSequence_Arguments() + { + AssertThrows(() => EnumerableEx.Repeat(null)); + AssertThrows(() => EnumerableEx.Repeat(null, 5)); + AssertThrows(() => EnumerableEx.Repeat(new[] { 1 }, -1)); + } + + [Fact] + public void RepeatSequence1() + { + var i = 0; + var xs = new[] { 1, 2 }.Do(_ => i++).Repeat(); + + var res = xs.Take(10).ToList(); + Assert.Equal(10, res.Count); + Assert.True(res.Buffer(2).Select(b => b.Sum()).All(x => x == 3)); + Assert.Equal(10, i); + } + + [Fact] + public void RepeatSequence2() + { + var i = 0; + var xs = new[] { 1, 2 }.Do(_ => i++).Repeat(5); + + var res = xs.ToList(); + Assert.Equal(10, res.Count); + Assert.True(res.Buffer(2).Select(b => b.Sum()).All(x => x == 3)); + Assert.Equal(10, i); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Return.cs new file mode 100644 index 0000000000..7102f78e41 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Return.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Return : Tests + { + [Fact] + public void Return1() + { + Assert.Equal(42, EnumerableEx.Return(42).Single()); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Throw.cs new file mode 100644 index 0000000000..7175a981e1 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Throw.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Throw : Tests + { + [Fact] + public void Throw_Arguments() + { + AssertThrows(() => EnumerableEx.Throw(null)); + } + + [Fact] + public void Throw1() + { + var ex = new MyException(); + var xs = EnumerableEx.Throw(ex); + + var e = xs.GetEnumerator(); + AssertThrows(() => e.MoveNext()); + } + + private sealed class MyException : Exception + { + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Using.cs new file mode 100644 index 0000000000..aad907693f --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Using.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Using : Tests + { + [Fact] + public void Using_Arguments() + { + AssertThrows(() => EnumerableEx.Using(null, d => new[] { 1 })); + AssertThrows(() => EnumerableEx.Using(() => new MyDisposable(), null)); + } + + [Fact] + public void Using1() + { + var d = default(MyDisposable); + + var xs = EnumerableEx.Using(() => d = new MyDisposable(), d_ => new[] { 1 }); + Assert.Null(d); + + var d1 = default(MyDisposable); + xs.ForEach(_ => { d1 = d; Assert.NotNull(d1); Assert.False(d1.Done); }); + Assert.True(d1.Done); + + var d2 = default(MyDisposable); + xs.ForEach(_ => { d2 = d; Assert.NotNull(d2); Assert.False(d2.Done); }); + Assert.True(d2.Done); + + Assert.NotSame(d1, d2); + } + + [Fact] + public void Using2() + { + var d = default(MyDisposable); + + var xs = EnumerableEx.Using(() => d = new MyDisposable(), d_ => EnumerableEx.Throw(new MyException())); + Assert.Null(d); + + AssertThrows(() => xs.ForEach(_ => { })); + Assert.True(d.Done); + } + + [Fact] + public void Using3() + { + var d = default(MyDisposable); + + var xs = EnumerableEx.Using(() => d = new MyDisposable(), d_ => { throw new MyException(); }); + Assert.Null(d); + + AssertThrows(() => xs.ForEach(_ => { })); + Assert.True(d.Done); + } + + private sealed class MyDisposable : IDisposable + { + public bool Done; + + public void Dispose() + { + Done = true; + } + } + + private sealed class MyException : Exception + { + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs deleted file mode 100644 index 35357335cf..0000000000 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Creation.cs +++ /dev/null @@ -1,292 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Xunit; - -namespace Tests -{ - public partial class Tests - { - [Fact] - public void Create_Arguments() - { - AssertThrows(() => EnumerableEx.Create(default(Func>))); - } - - [Fact] - public void Create1() - { - var hot = false; - var res = EnumerableEx.Create(() => - { - hot = true; - return MyEnumerator(); - }); - - Assert.False(hot); - - var e = res.GetEnumerator(); - Assert.True(hot); - - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); - - hot = false; - var f = ((IEnumerable)res).GetEnumerator(); - Assert.True(hot); - } - - [Fact] - public void CreateYield() - { - SynchronizationContext.SetSynchronizationContext(null); - - var xs = EnumerableEx.Create(async yield => - { - var i = 0; - while (i < 10) - { - await yield.Return(i++); - } - }); - - var j = 0; - foreach (var elem in xs) - { - Assert.Equal(j, elem); - j++; - } - - Assert.Equal(10, j); - } - - [Fact] - public void CreateYieldBreak() - { - SynchronizationContext.SetSynchronizationContext(null); - - var xs = EnumerableEx.Create(async yield => - { - var i = 0; - while (true) - { - if (i == 10) - { - await yield.Break(); - return; - } - - await yield.Return(i++); - } - }); - - var j = 0; - foreach (var elem in xs) - { - Assert.Equal(elem, j); - j++; - } - - Assert.Equal(10, j); - } - - [Fact] - public void YielderNoReset() - { - var xs = EnumerableEx.Create(async yield => - { - await yield.Break(); - }); - - AssertThrows(() => xs.GetEnumerator().Reset()); - } - - private static IEnumerator MyEnumerator() - { - yield return 1; - yield return 2; - } - - [Fact] - public void Return() - { - Assert.Equal(42, EnumerableEx.Return(42).Single()); - } - - [Fact] - public void Throw_Arguments() - { - AssertThrows(() => EnumerableEx.Throw(null)); - } - - [Fact] - public void Throw() - { - var ex = new MyException(); - var xs = EnumerableEx.Throw(ex); - - var e = xs.GetEnumerator(); - AssertThrows(() => e.MoveNext()); - } - - [Fact] - public void Defer_Arguments() - { - AssertThrows(() => EnumerableEx.Defer(null)); - } - - [Fact] - public void Defer1() - { - var i = 0; - var n = 5; - var xs = EnumerableEx.Defer(() => - { - i++; - return Enumerable.Range(0, n); - }); - - Assert.Equal(0, i); - - Assert.True(Enumerable.SequenceEqual(xs, Enumerable.Range(0, n))); - Assert.Equal(1, i); - - n = 3; - Assert.True(Enumerable.SequenceEqual(xs, Enumerable.Range(0, n))); - Assert.Equal(2, i); - } - - [Fact] - public void Defer2() - { - var xs = EnumerableEx.Defer(() => - { - throw new MyException(); - }); - - AssertThrows(() => xs.GetEnumerator().MoveNext()); - } - - [Fact] - public void Generate_Arguments() - { - AssertThrows(() => EnumerableEx.Generate(0, null, _ => _, _ => _)); - AssertThrows(() => EnumerableEx.Generate(0, _ => true, null, _ => _)); - AssertThrows(() => EnumerableEx.Generate(0, _ => true, _ => _, null)); - } - - [Fact] - public void Generate() - { - var res = EnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x).ToList(); - Assert.True(Enumerable.SequenceEqual(res, new[] { 0, 1, 4, 9, 16 })); - } - - [Fact] - public void Using_Arguments() - { - AssertThrows(() => EnumerableEx.Using(null, d => new[] { 1 })); - AssertThrows(() => EnumerableEx.Using(() => new MyDisposable(), null)); - } - - [Fact] - public void Using1() - { - var d = default(MyDisposable); - - var xs = EnumerableEx.Using(() => d = new MyDisposable(), d_ => new[] { 1 }); - Assert.Null(d); - - var d1 = default(MyDisposable); - xs.ForEach(_ => { d1 = d; Assert.NotNull(d1); Assert.False(d1.Done); }); - Assert.True(d1.Done); - - var d2 = default(MyDisposable); - xs.ForEach(_ => { d2 = d; Assert.NotNull(d2); Assert.False(d2.Done); }); - Assert.True(d2.Done); - - Assert.NotSame(d1, d2); - } - - [Fact] - public void Using2() - { - var d = default(MyDisposable); - - var xs = EnumerableEx.Using(() => d = new MyDisposable(), d_ => EnumerableEx.Throw(new MyException())); - Assert.Null(d); - - AssertThrows(() => xs.ForEach(_ => { })); - Assert.True(d.Done); - } - - [Fact] - public void Using3() - { - var d = default(MyDisposable); - - var xs = EnumerableEx.Using(() => d = new MyDisposable(), d_ => { throw new MyException(); }); - Assert.Null(d); - - AssertThrows(() => xs.ForEach(_ => { })); - Assert.True(d.Done); - } - - class MyDisposable : IDisposable - { - public bool Done; - - public void Dispose() - { - Done = true; - } - } - - [Fact] - public void RepeatElementInfinite() - { - var xs = EnumerableEx.Repeat(42).Take(1000); - Assert.True(xs.All(x => x == 42)); - Assert.True(xs.Count() == 1000); - } - - [Fact] - public void RepeatSequence_Arguments() - { - AssertThrows(() => EnumerableEx.Repeat(null)); - AssertThrows(() => EnumerableEx.Repeat(null, 5)); - AssertThrows(() => EnumerableEx.Repeat(new[] { 1 }, -1)); - } - - [Fact] - public void RepeatSequence1() - { - var i = 0; - var xs = new[] { 1, 2 }.Do(_ => i++).Repeat(); - - var res = xs.Take(10).ToList(); - Assert.Equal(10, res.Count); - Assert.True(res.Buffer(2).Select(b => b.Sum()).All(x => x == 3)); - Assert.Equal(10, i); - } - - [Fact] - public void RepeatSequence2() - { - var i = 0; - var xs = new[] { 1, 2 }.Do(_ => i++).Repeat(5); - - var res = xs.ToList(); - Assert.Equal(10, res.Count); - Assert.True(res.Buffer(2).Select(b => b.Sum()).All(x => x == 3)); - Assert.Equal(10, i); - } - } -} From 8534f05d943d7a540b5a71183d8acfaf384b225b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:15:35 -0700 Subject: [PATCH 330/862] Splitting tests for sharing operators. --- .../System/Linq/Operators/Memoize.cs | 296 +++++++++ .../System/Linq/Operators/Publish.cs | 259 ++++++++ .../System/Linq/Operators/Share.cs | 123 ++++ .../Tests.Buffering.cs | 628 ------------------ 4 files changed, 678 insertions(+), 628 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Memoize.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Publish.cs create mode 100644 Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Share.cs delete mode 100644 Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Memoize.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Memoize.cs new file mode 100644 index 0000000000..3ac259625c --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Memoize.cs @@ -0,0 +1,296 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Memoize : Tests + { + [Fact] + public void Memoize_Arguments() + { + AssertThrows(() => EnumerableEx.Memoize(null)); + } + + [Fact] + public void MemoizeLimited_Arguments() + { + AssertThrows(() => EnumerableEx.Memoize(null, 2)); + AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, 0)); + AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, -1)); + } + + [Fact] + public void Memoize0() + { + var n = 0; + var rng = Tick(i => n += i).Memoize(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + + HasNext(e1, 0); + Assert.Equal(0, n); + + HasNext(e1, 1); + Assert.Equal(1, n); + + HasNext(e1, 2); + Assert.Equal(3, n); + HasNext(e2, 0); + Assert.Equal(3, n); + + HasNext(e1, 3); + Assert.Equal(6, n); + HasNext(e2, 1); + Assert.Equal(6, n); + + HasNext(e2, 2); + Assert.Equal(6, n); + HasNext(e2, 3); + Assert.Equal(6, n); + + HasNext(e2, 4); + Assert.Equal(10, n); + HasNext(e1, 4); + Assert.Equal(10, n); + } + + [Fact] + public void Publish11() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + e1.Dispose(); + + HasNext(e2, 0); + HasNext(e2, 1); + e2.Dispose(); + + var e3 = rng.GetEnumerator(); + HasNext(e3, 3); + HasNext(e3, 4); + NoNext(e3); + } + + [Fact] + public void Memoize1() + { + var rng = Enumerable.Range(0, 5).Memoize(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + HasNext(e1, 3); + HasNext(e1, 4); + NoNext(e1); + } + + [Fact] + public void Memoize2() + { + var rng = Enumerable.Range(0, 5).Memoize(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + HasNext(e1, 3); + HasNext(e1, 4); + NoNext(e1); + + var e2 = rng.GetEnumerator(); + HasNext(e2, 0); + HasNext(e2, 1); + HasNext(e2, 2); + HasNext(e2, 3); + HasNext(e2, 4); + NoNext(e2); + } + + [Fact] + public void Memoize3() + { + var rng = Enumerable.Range(0, 5).Memoize(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + var e2 = rng.GetEnumerator(); + HasNext(e1, 3); + HasNext(e2, 0); + HasNext(e2, 1); + HasNext(e1, 4); + HasNext(e2, 2); + NoNext(e1); + + HasNext(e2, 3); + HasNext(e2, 4); + NoNext(e2); + } + + [Fact] + public void Memoize4() + { + var rng = Enumerable.Range(0, 5).Memoize(2); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + var e2 = rng.GetEnumerator(); + HasNext(e2, 0); + HasNext(e2, 1); + HasNext(e2, 2); + + var e3 = rng.GetEnumerator(); + AssertThrows(() => e3.MoveNext()); + } + + [Fact] + public void Memoize6() + { + var ex = new MyException(); + var rng = Enumerable.Range(0, 2).Concat(EnumerableEx.Throw(ex)).Memoize(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + AssertThrows(() => e1.MoveNext()); + + HasNext(e2, 0); + HasNext(e2, 1); + AssertThrows(() => e2.MoveNext()); + } + + [Fact] + public void Memoize7() + { + var rng = Enumerable.Range(0, 5).Memoize(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + e1.Dispose(); + + var e2 = rng.GetEnumerator(); + HasNext(e2, 0); + HasNext(e2, 1); + e2.Dispose(); + + var e3 = rng.GetEnumerator(); + HasNext(e3, 0); + HasNext(e3, 1); + HasNext(e3, 2); + HasNext(e3, 3); + HasNext(e3, 4); + NoNext(e3); + } + + [Fact] + public void Memoize8() + { + var rng = Enumerable.Range(0, 5).Memoize(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + rng.Dispose(); + AssertThrows(() => e1.MoveNext()); + AssertThrows(() => rng.GetEnumerator()); + AssertThrows(() => ((IEnumerable)rng).GetEnumerator()); + } + + [Fact] + public void Memoize9() + { + var rng = Enumerable.Range(0, 5).Memoize(); + + var e1 = ((IEnumerable)rng).GetEnumerator(); + Assert.True(e1.MoveNext()); + Assert.Equal(0, (int)e1.Current); + } + + [Fact] + public void Memoize10() + { + var rnd = Rand().Take(1000).Memoize(); + Assert.True(rnd.Zip(rnd, (l, r) => l == r).All(x => x)); + } + + private static IEnumerable Tick(Action t) + { + var i = 0; + while (true) + { + t(i); + yield return i++; + } + } + + [Fact] + public void MemoizeLambda_Arguments() + { + AssertThrows(() => EnumerableEx.Memoize(null, xs => xs)); + AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, null)); + } + + [Fact] + public void MemoizeLambda() + { + var n = 0; + var res = Enumerable.Range(0, 10).Do(_ => n++).Memoize(xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); + Assert.True(res.SequenceEqual(Enumerable.Range(0, 4).Select(x => x * 2))); + Assert.Equal(4, n); + } + + [Fact] + public void MemoizeLimitedLambda_Arguments() + { + AssertThrows(() => EnumerableEx.Memoize(null, 2, xs => xs)); + AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, 2, null)); + AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, 0, xs => xs)); + AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, -1, xs => xs)); + } + + [Fact] + public void MemoizeLimitedLambda() + { + var n = 0; + var res = Enumerable.Range(0, 10).Do(_ => n++).Memoize(2, xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); + Assert.True(res.SequenceEqual(Enumerable.Range(0, 4).Select(x => x * 2))); + Assert.Equal(4, n); + } + + private static readonly Random s_rand = new Random(); + + private static IEnumerable Rand() + { + while (true) + yield return s_rand.Next(); + } + + private sealed class MyException : Exception + { + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Publish.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Publish.cs new file mode 100644 index 0000000000..cb6ad405de --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Publish.cs @@ -0,0 +1,259 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Publish : Tests + { + [Fact] + public void Publish_Arguments() + { + AssertThrows(() => EnumerableEx.Publish(null)); + } + + [Fact] + public void Publish0() + { + var n = 0; + var rng = Tick(i => n += i).Publish(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + + HasNext(e1, 0); + Assert.Equal(0, n); + + HasNext(e1, 1); + Assert.Equal(1, n); + + HasNext(e1, 2); + Assert.Equal(3, n); + HasNext(e2, 0); + Assert.Equal(3, n); + + HasNext(e1, 3); + Assert.Equal(6, n); + HasNext(e2, 1); + Assert.Equal(6, n); + + HasNext(e2, 2); + Assert.Equal(6, n); + HasNext(e2, 3); + Assert.Equal(6, n); + + HasNext(e2, 4); + Assert.Equal(10, n); + HasNext(e1, 4); + Assert.Equal(10, n); + } + + [Fact] + public void Publish1() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + HasNext(e1, 3); + HasNext(e1, 4); + NoNext(e1); + } + + [Fact] + public void Publish2() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e2, 0); + HasNext(e1, 1); + HasNext(e2, 1); + HasNext(e1, 2); + HasNext(e2, 2); + HasNext(e1, 3); + HasNext(e2, 3); + HasNext(e1, 4); + HasNext(e2, 4); + NoNext(e1); + NoNext(e2); + } + + [Fact] + public void Publish3() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + HasNext(e1, 3); + HasNext(e1, 4); + HasNext(e2, 0); + HasNext(e2, 1); + HasNext(e2, 2); + HasNext(e2, 3); + HasNext(e2, 4); + NoNext(e1); + NoNext(e2); + } + + [Fact] + public void Publish4() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + var e2 = rng.GetEnumerator(); + HasNext(e1, 3); + HasNext(e1, 4); + HasNext(e2, 3); + HasNext(e2, 4); + NoNext(e1); + NoNext(e2); + } + + [Fact] + public void Publish5() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + e1.Dispose(); + + var e2 = rng.GetEnumerator(); + HasNext(e2, 3); + HasNext(e2, 4); + NoNext(e2); + } + + [Fact] + public void Publish6() + { + var ex = new MyException(); + var rng = Enumerable.Range(0, 2).Concat(EnumerableEx.Throw(ex)).Publish(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + AssertThrows(() => e1.MoveNext()); + + HasNext(e2, 0); + HasNext(e2, 1); + AssertThrows(() => e2.MoveNext()); + } + + class MyException : Exception + { + } + + [Fact] + public void Publish7() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + var e2 = rng.GetEnumerator(); + HasNext(e2, 3); + HasNext(e2, 4); + NoNext(e2); + + HasNext(e1, 3); + HasNext(e1, 4); + NoNext(e2); + + var e3 = rng.GetEnumerator(); + NoNext(e3); + } + + [Fact] + public void Publish8() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + rng.Dispose(); + AssertThrows(() => e1.MoveNext()); + AssertThrows(() => rng.GetEnumerator()); + AssertThrows(() => ((IEnumerable)rng).GetEnumerator()); + } + + [Fact] + public void Publish9() + { + var rng = Enumerable.Range(0, 5).Publish(); + + var e1 = ((IEnumerable)rng).GetEnumerator(); + Assert.True(e1.MoveNext()); + Assert.Equal(0, (int)e1.Current); + } + + [Fact] + public void Publish10() + { + var rnd = Rand().Take(1000).Publish(); + Assert.True(rnd.Zip(rnd, (l, r) => l == r).All(x => x)); + } + + [Fact] + public void PublishLambda_Arguments() + { + AssertThrows(() => EnumerableEx.Publish(null, xs => xs)); + AssertThrows(() => EnumerableEx.Publish(new[] { 1 }, null)); + } + + [Fact] + public void PublishLambda() + { + var n = 0; + var res = Enumerable.Range(0, 10).Do(_ => n++).Publish(xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); + Assert.True(res.SequenceEqual(Enumerable.Range(0, 4).Select(x => x * 2))); + Assert.Equal(4, n); + } + + private static IEnumerable Tick(Action t) + { + var i = 0; + while (true) + { + t(i); + yield return i++; + } + } + + private static readonly Random s_rand = new Random(); + + private static IEnumerable Rand() + { + while (true) + yield return s_rand.Next(); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Share.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Share.cs new file mode 100644 index 0000000000..6c35b39eef --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Share.cs @@ -0,0 +1,123 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Linq; +using Xunit; + +namespace Tests +{ + public class Share : Tests + { + [Fact] + public void Share_Arguments() + { + AssertThrows(() => EnumerableEx.Share(null)); + } + + [Fact] + public void Share1() + { + var rng = Enumerable.Range(0, 5).Share(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + HasNext(e1, 3); + HasNext(e1, 4); + NoNext(e1); + } + + [Fact] + public void Share2() + { + var rng = Enumerable.Range(0, 5).Share(); + + var e1 = rng.GetEnumerator(); + var e2 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e2, 1); + HasNext(e1, 2); + HasNext(e2, 3); + HasNext(e1, 4); + NoNext(e2); + NoNext(e1); + } + + [Fact] + public void Share3() + { + var rng = Enumerable.Range(0, 5).Share(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + var e2 = rng.GetEnumerator(); + HasNext(e2, 3); + HasNext(e2, 4); + NoNext(e2); + NoNext(e1); + } + + //[Fact] + public void Share4() + { + var rng = Enumerable.Range(0, 5).Share(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + e1.Dispose(); + Assert.False(e1.MoveNext()); + } + + [Fact] + public void Share5() + { + var rng = Enumerable.Range(0, 5).Share(); + + var e1 = rng.GetEnumerator(); + HasNext(e1, 0); + HasNext(e1, 1); + HasNext(e1, 2); + + rng.Dispose(); + AssertThrows(() => e1.MoveNext()); + AssertThrows(() => rng.GetEnumerator()); + AssertThrows(() => ((IEnumerable)rng).GetEnumerator()); + } + + [Fact] + public void Share6() + { + var rng = Enumerable.Range(0, 5).Share(); + + var e1 = ((IEnumerable)rng).GetEnumerator(); + Assert.True(e1.MoveNext()); + Assert.Equal(0, (int)e1.Current); + } + + [Fact] + public void ShareLambda_Arguments() + { + AssertThrows(() => EnumerableEx.Share(null, xs => xs)); + AssertThrows(() => EnumerableEx.Share(new[] { 1 }, null)); + } + + [Fact] + public void ShareLambda() + { + var n = 0; + var res = Enumerable.Range(0, 10).Do(_ => n++).Share(xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); + Assert.True(res.SequenceEqual(new[] { 0 + 1, 2 + 3, 4 + 5, 6 + 7 })); + Assert.Equal(8, n); + } + } +} diff --git a/Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs b/Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs deleted file mode 100644 index 2dba167205..0000000000 --- a/Ix.NET/Source/System.Interactive.Tests/Tests.Buffering.cs +++ /dev/null @@ -1,628 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Text; -using System.Collections.Generic; -using System.Linq; -using Xunit; -using System.Collections; - -namespace Tests -{ - public partial class Tests - { - [Fact] - public void Share_Arguments() - { - AssertThrows(() => EnumerableEx.Share(null)); - } - - [Fact] - public void Share1() - { - var rng = Enumerable.Range(0, 5).Share(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - HasNext(e1, 3); - HasNext(e1, 4); - NoNext(e1); - } - - [Fact] - public void Share2() - { - var rng = Enumerable.Range(0, 5).Share(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e2, 1); - HasNext(e1, 2); - HasNext(e2, 3); - HasNext(e1, 4); - NoNext(e2); - NoNext(e1); - } - - [Fact] - public void Share3() - { - var rng = Enumerable.Range(0, 5).Share(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - var e2 = rng.GetEnumerator(); - HasNext(e2, 3); - HasNext(e2, 4); - NoNext(e2); - NoNext(e1); - } - - //[Fact] - public void Share4() - { - var rng = Enumerable.Range(0, 5).Share(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - e1.Dispose(); - Assert.False(e1.MoveNext()); - } - - [Fact] - public void Share5() - { - var rng = Enumerable.Range(0, 5).Share(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - rng.Dispose(); - AssertThrows(() => e1.MoveNext()); - AssertThrows(() => rng.GetEnumerator()); - AssertThrows(() => ((IEnumerable)rng).GetEnumerator()); - } - - [Fact] - public void Share6() - { - var rng = Enumerable.Range(0, 5).Share(); - - var e1 = ((IEnumerable)rng).GetEnumerator(); - Assert.True(e1.MoveNext()); - Assert.Equal(0, (int)e1.Current); - } - - [Fact] - public void Publish_Arguments() - { - AssertThrows(() => EnumerableEx.Publish(null)); - } - - [Fact] - public void Publish0() - { - var n = 0; - var rng = Tick(i => n += i).Publish(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - - HasNext(e1, 0); - Assert.Equal(0, n); - - HasNext(e1, 1); - Assert.Equal(1, n); - - HasNext(e1, 2); - Assert.Equal(3, n); - HasNext(e2, 0); - Assert.Equal(3, n); - - HasNext(e1, 3); - Assert.Equal(6, n); - HasNext(e2, 1); - Assert.Equal(6, n); - - HasNext(e2, 2); - Assert.Equal(6, n); - HasNext(e2, 3); - Assert.Equal(6, n); - - HasNext(e2, 4); - Assert.Equal(10, n); - HasNext(e1, 4); - Assert.Equal(10, n); - } - - static IEnumerable Tick(Action t) - { - var i = 0; - while (true) - { - t(i); - yield return i++; - } - } - - [Fact] - public void Publish1() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - HasNext(e1, 3); - HasNext(e1, 4); - NoNext(e1); - } - - [Fact] - public void Publish2() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e2, 0); - HasNext(e1, 1); - HasNext(e2, 1); - HasNext(e1, 2); - HasNext(e2, 2); - HasNext(e1, 3); - HasNext(e2, 3); - HasNext(e1, 4); - HasNext(e2, 4); - NoNext(e1); - NoNext(e2); - } - - [Fact] - public void Publish3() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - HasNext(e1, 3); - HasNext(e1, 4); - HasNext(e2, 0); - HasNext(e2, 1); - HasNext(e2, 2); - HasNext(e2, 3); - HasNext(e2, 4); - NoNext(e1); - NoNext(e2); - } - - [Fact] - public void Publish4() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - var e2 = rng.GetEnumerator(); - HasNext(e1, 3); - HasNext(e1, 4); - HasNext(e2, 3); - HasNext(e2, 4); - NoNext(e1); - NoNext(e2); - } - - [Fact] - public void Publish5() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - e1.Dispose(); - - var e2 = rng.GetEnumerator(); - HasNext(e2, 3); - HasNext(e2, 4); - NoNext(e2); - } - - [Fact] - public void Publish6() - { - var ex = new MyException(); - var rng = Enumerable.Range(0, 2).Concat(EnumerableEx.Throw(ex)).Publish(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - AssertThrows(() => e1.MoveNext()); - - HasNext(e2, 0); - HasNext(e2, 1); - AssertThrows(() => e2.MoveNext()); - } - - class MyException : Exception - { - } - - [Fact] - public void Publish7() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - var e2 = rng.GetEnumerator(); - HasNext(e2, 3); - HasNext(e2, 4); - NoNext(e2); - - HasNext(e1, 3); - HasNext(e1, 4); - NoNext(e2); - - var e3 = rng.GetEnumerator(); - NoNext(e3); - } - - [Fact] - public void Publish8() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - rng.Dispose(); - AssertThrows(() => e1.MoveNext()); - AssertThrows(() => rng.GetEnumerator()); - AssertThrows(() => ((IEnumerable)rng).GetEnumerator()); - } - - [Fact] - public void Publish9() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = ((IEnumerable)rng).GetEnumerator(); - Assert.True(e1.MoveNext()); - Assert.Equal(0, (int)e1.Current); - } - - [Fact] - public void Publish10() - { - var rnd = Rand().Take(1000).Publish(); - Assert.True(rnd.Zip(rnd, (l, r) => l == r).All(x => x)); - } - - [Fact] - public void Memoize_Arguments() - { - AssertThrows(() => EnumerableEx.Memoize(null)); - } - - [Fact] - public void MemoizeLimited_Arguments() - { - AssertThrows(() => EnumerableEx.Memoize(null, 2)); - AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, 0)); - AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, -1)); - } - - [Fact] - public void Memoize0() - { - var n = 0; - var rng = Tick(i => n += i).Memoize(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - - HasNext(e1, 0); - Assert.Equal(0, n); - - HasNext(e1, 1); - Assert.Equal(1, n); - - HasNext(e1, 2); - Assert.Equal(3, n); - HasNext(e2, 0); - Assert.Equal(3, n); - - HasNext(e1, 3); - Assert.Equal(6, n); - HasNext(e2, 1); - Assert.Equal(6, n); - - HasNext(e2, 2); - Assert.Equal(6, n); - HasNext(e2, 3); - Assert.Equal(6, n); - - HasNext(e2, 4); - Assert.Equal(10, n); - HasNext(e1, 4); - Assert.Equal(10, n); - } - - [Fact] - public void Publish11() - { - var rng = Enumerable.Range(0, 5).Publish(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - e1.Dispose(); - - HasNext(e2, 0); - HasNext(e2, 1); - e2.Dispose(); - - var e3 = rng.GetEnumerator(); - HasNext(e3, 3); - HasNext(e3, 4); - NoNext(e3); - } - - [Fact] - public void Memoize1() - { - var rng = Enumerable.Range(0, 5).Memoize(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - HasNext(e1, 3); - HasNext(e1, 4); - NoNext(e1); - } - - [Fact] - public void Memoize2() - { - var rng = Enumerable.Range(0, 5).Memoize(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - HasNext(e1, 3); - HasNext(e1, 4); - NoNext(e1); - - var e2 = rng.GetEnumerator(); - HasNext(e2, 0); - HasNext(e2, 1); - HasNext(e2, 2); - HasNext(e2, 3); - HasNext(e2, 4); - NoNext(e2); - } - - [Fact] - public void Memoize3() - { - var rng = Enumerable.Range(0, 5).Memoize(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - var e2 = rng.GetEnumerator(); - HasNext(e1, 3); - HasNext(e2, 0); - HasNext(e2, 1); - HasNext(e1, 4); - HasNext(e2, 2); - NoNext(e1); - - HasNext(e2, 3); - HasNext(e2, 4); - NoNext(e2); - } - - [Fact] - public void Memoize4() - { - var rng = Enumerable.Range(0, 5).Memoize(2); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - var e2 = rng.GetEnumerator(); - HasNext(e2, 0); - HasNext(e2, 1); - HasNext(e2, 2); - - var e3 = rng.GetEnumerator(); - AssertThrows(() => e3.MoveNext()); - } - - [Fact] - public void Memoize6() - { - var ex = new MyException(); - var rng = Enumerable.Range(0, 2).Concat(EnumerableEx.Throw(ex)).Memoize(); - - var e1 = rng.GetEnumerator(); - var e2 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - AssertThrows(() => e1.MoveNext()); - - HasNext(e2, 0); - HasNext(e2, 1); - AssertThrows(() => e2.MoveNext()); - } - - [Fact] - public void Memoize7() - { - var rng = Enumerable.Range(0, 5).Memoize(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - e1.Dispose(); - - var e2 = rng.GetEnumerator(); - HasNext(e2, 0); - HasNext(e2, 1); - e2.Dispose(); - - var e3 = rng.GetEnumerator(); - HasNext(e3, 0); - HasNext(e3, 1); - HasNext(e3, 2); - HasNext(e3, 3); - HasNext(e3, 4); - NoNext(e3); - } - - [Fact] - public void Memoize8() - { - var rng = Enumerable.Range(0, 5).Memoize(); - - var e1 = rng.GetEnumerator(); - HasNext(e1, 0); - HasNext(e1, 1); - HasNext(e1, 2); - - rng.Dispose(); - AssertThrows(() => e1.MoveNext()); - AssertThrows(() => rng.GetEnumerator()); - AssertThrows(() => ((IEnumerable)rng).GetEnumerator()); - } - - [Fact] - public void Memoize9() - { - var rng = Enumerable.Range(0, 5).Memoize(); - - var e1 = ((IEnumerable)rng).GetEnumerator(); - Assert.True(e1.MoveNext()); - Assert.Equal(0, (int)e1.Current); - } - - [Fact] - public void Memoize10() - { - var rnd = Rand().Take(1000).Memoize(); - Assert.True(rnd.Zip(rnd, (l, r) => l == r).All(x => x)); - } - - static Random s_rand = new Random(); - - static IEnumerable Rand() - { - while (true) - yield return s_rand.Next(); - } - - [Fact] - public void ShareLambda_Arguments() - { - AssertThrows(() => EnumerableEx.Share(null, xs => xs)); - AssertThrows(() => EnumerableEx.Share(new[] { 1 }, null)); - } - - [Fact] - public void ShareLambda() - { - var n = 0; - var res = Enumerable.Range(0, 10).Do(_ => n++).Share(xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); - Assert.True(res.SequenceEqual(new[] { 0 + 1, 2 + 3, 4 + 5, 6 + 7 })); - Assert.Equal(8, n); - } - - [Fact] - public void PublishLambda_Arguments() - { - AssertThrows(() => EnumerableEx.Publish(null, xs => xs)); - AssertThrows(() => EnumerableEx.Publish(new[] { 1 }, null)); - } - - [Fact] - public void PublishLambda() - { - var n = 0; - var res = Enumerable.Range(0, 10).Do(_ => n++).Publish(xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); - Assert.True(res.SequenceEqual(Enumerable.Range(0, 4).Select(x => x * 2))); - Assert.Equal(4, n); - } - - [Fact] - public void MemoizeLambda_Arguments() - { - AssertThrows(() => EnumerableEx.Memoize(null, xs => xs)); - AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, null)); - } - - [Fact] - public void MemoizeLambda() - { - var n = 0; - var res = Enumerable.Range(0, 10).Do(_ => n++).Memoize(xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); - Assert.True(res.SequenceEqual(Enumerable.Range(0, 4).Select(x => x * 2))); - Assert.Equal(4, n); - } - - [Fact] - public void MemoizeLimitedLambda_Arguments() - { - AssertThrows(() => EnumerableEx.Memoize(null, 2, xs => xs)); - AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, 2, null)); - AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, 0, xs => xs)); - AssertThrows(() => EnumerableEx.Memoize(new[] { 1 }, -1, xs => xs)); - } - - [Fact] - public void MemoizeLimitedLambda() - { - var n = 0; - var res = Enumerable.Range(0, 10).Do(_ => n++).Memoize(2, xs => xs.Zip(xs, (l, r) => l + r).Take(4)).ToList(); - Assert.True(res.SequenceEqual(Enumerable.Range(0, 4).Select(x => x * 2))); - Assert.Equal(4, n); - } - } -} From 3c7f7f163778fd2a2205c5fe721da75858b266e9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:17:28 -0700 Subject: [PATCH 331/862] Splitting First and FirstOrDefault. --- .../System/Linq/Operators/First.cs | 81 ---------------- .../System/Linq/Operators/FirstOrDefault.cs | 94 +++++++++++++++++++ 2 files changed, 94 insertions(+), 81 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index ae2daed898..72874c5f91 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -66,62 +66,6 @@ public static Task First(this IAsyncEnumerable source return source.Where(predicate).First(cancellationToken); } - public static Task FirstOrDefault(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return FirstOrDefault(source, CancellationToken.None); - } - - public static Task FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return FirstOrDefault_(source, cancellationToken); - } - - public static Task FirstOrDefault(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return FirstOrDefault(source, predicate, CancellationToken.None); - } - - public static Task FirstOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).FirstOrDefault(cancellationToken); - } - - public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return FirstOrDefault(source, predicate, CancellationToken.None); - } - - public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).FirstOrDefault(cancellationToken); - } - private static async Task First_(IAsyncEnumerable source, CancellationToken cancellationToken) { var list = source as IList; @@ -146,30 +90,5 @@ private static async Task First_(IAsyncEnumerable sou throw new InvalidOperationException(Strings.NO_ELEMENTS); } - - private static async Task FirstOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var list = source as IList; - if (list?.Count > 0) - { - return list[0]; - } - - var e = source.GetAsyncEnumerator(); - - try - { - if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - return e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return default(TSource); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs new file mode 100644 index 0000000000..2f3363efb7 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task FirstOrDefault(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return FirstOrDefault(source, CancellationToken.None); + } + + public static Task FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return FirstOrDefault_(source, cancellationToken); + } + + public static Task FirstOrDefault(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return FirstOrDefault(source, predicate, CancellationToken.None); + } + + public static Task FirstOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).FirstOrDefault(cancellationToken); + } + + public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return FirstOrDefault(source, predicate, CancellationToken.None); + } + + public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).FirstOrDefault(cancellationToken); + } + + private static async Task FirstOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var list = source as IList; + if (list?.Count > 0) + { + return list[0]; + } + + var e = source.GetAsyncEnumerator(); + + try + { + if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return default(TSource); + } + } +} From d5064154516322201076d8636385d4a046dede2a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:18:35 -0700 Subject: [PATCH 332/862] Splitting Last and LastOrDefault. --- .../System/Linq/Operators/Last.cs | 88 --------------- .../System/Linq/Operators/LastOrDefault.cs | 101 ++++++++++++++++++ 2 files changed, 101 insertions(+), 88 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index b61a2d64eb..b37bf2ae46 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -66,62 +66,6 @@ public static Task Last(this IAsyncEnumerable source, return source.Where(predicate).Last(cancellationToken); } - public static Task LastOrDefault(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return LastOrDefault(source, CancellationToken.None); - } - - public static Task LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return LastOrDefault_(source, cancellationToken); - } - - public static Task LastOrDefault(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return LastOrDefault(source, predicate, CancellationToken.None); - } - - public static Task LastOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).LastOrDefault(cancellationToken); - } - - public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return LastOrDefault(source, predicate, CancellationToken.None); - } - - public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).LastOrDefault(cancellationToken); - } - private static async Task Last_(IAsyncEnumerable source, CancellationToken cancellationToken) { var last = default(TSource); @@ -156,37 +100,5 @@ private static async Task Last_(IAsyncEnumerable sour return last; } - - private static async Task LastOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var last = default(TSource); - var hasLast = false; - - if (source is IList list) - { - var count = list.Count; - if (count > 0) - { - return list[count - 1]; - } - } - - var e = source.GetAsyncEnumerator(); - - try - { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - hasLast = true; - last = e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return !hasLast ? default(TSource) : last; - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs new file mode 100644 index 0000000000..6cd2204720 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task LastOrDefault(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return LastOrDefault(source, CancellationToken.None); + } + + public static Task LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return LastOrDefault_(source, cancellationToken); + } + + public static Task LastOrDefault(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return LastOrDefault(source, predicate, CancellationToken.None); + } + + public static Task LastOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).LastOrDefault(cancellationToken); + } + + public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return LastOrDefault(source, predicate, CancellationToken.None); + } + + public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).LastOrDefault(cancellationToken); + } + + private static async Task LastOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var last = default(TSource); + var hasLast = false; + + if (source is IList list) + { + var count = list.Count; + if (count > 0) + { + return list[count - 1]; + } + } + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + hasLast = true; + last = e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return !hasLast ? default(TSource) : last; + } + } +} From f14bdfa664b5433ea25f84fe2255ff715d26edd1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:19:32 -0700 Subject: [PATCH 333/862] Splitting Single and SingleOrDefault. --- .../System/Linq/Operators/Single.cs | 92 --------------- .../System/Linq/Operators/SingleOrDefault.cs | 105 ++++++++++++++++++ 2 files changed, 105 insertions(+), 92 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index d38e28a4aa..666d87e30f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -66,62 +66,6 @@ public static Task Single(this IAsyncEnumerable sourc return source.Where(predicate).Single(cancellationToken); } - public static Task SingleOrDefault(this IAsyncEnumerable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return SingleOrDefault(source, CancellationToken.None); - } - - public static Task SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return SingleOrDefault_(source, cancellationToken); - } - - public static Task SingleOrDefault(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return SingleOrDefault(source, predicate, CancellationToken.None); - } - - public static Task SingleOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).SingleOrDefault(cancellationToken); - } - - public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return SingleOrDefault(source, predicate, CancellationToken.None); - } - - public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - - return source.Where(predicate).SingleOrDefault(cancellationToken); - } - private static async Task Single_(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) @@ -157,41 +101,5 @@ private static async Task Single_(IAsyncEnumerable so await e.DisposeAsync().ConfigureAwait(false); } } - - private static async Task SingleOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source is IList list) - { - switch (list.Count) - { - case 0: return default(TSource); - case 1: return list[0]; - } - - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); - } - - var e = source.GetAsyncEnumerator(); - - try - { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - return default(TSource); - } - - var result = e.Current; - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - return result; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs new file mode 100644 index 0000000000..05e8cd71a3 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -0,0 +1,105 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task SingleOrDefault(this IAsyncEnumerable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return SingleOrDefault(source, CancellationToken.None); + } + + public static Task SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return SingleOrDefault_(source, cancellationToken); + } + + public static Task SingleOrDefault(this IAsyncEnumerable source, Func predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return SingleOrDefault(source, predicate, CancellationToken.None); + } + + public static Task SingleOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).SingleOrDefault(cancellationToken); + } + + public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return SingleOrDefault(source, predicate, CancellationToken.None); + } + + public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + + return source.Where(predicate).SingleOrDefault(cancellationToken); + } + + private static async Task SingleOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source is IList list) + { + switch (list.Count) + { + case 0: return default(TSource); + case 1: return list[0]; + } + + throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + } + + var e = source.GetAsyncEnumerator(); + + try + { + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return default(TSource); + } + + var result = e.Current; + if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return result; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + } + } +} From 0687dbab765337ad429392682cd7616d94cc42f7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:20:30 -0700 Subject: [PATCH 334/862] Splitting ElementAt and ElementAtOrDefault. --- .../System/Linq/Operators/ElementAt.cs | 45 -------------- .../Linq/Operators/ElementAtOrDefault.cs | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 33b800522b..62dc83e7aa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -28,24 +28,6 @@ public static Task ElementAt(this IAsyncEnumerable so return ElementAt_(source, index, cancellationToken); } - public static Task ElementAtOrDefault(this IAsyncEnumerable source, int index) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - - return ElementAtOrDefault(source, index, CancellationToken.None); - } - - public static Task ElementAtOrDefault(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - return ElementAtOrDefault_(source, index, cancellationToken); - } - private static async Task ElementAt_(IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source is IList list) @@ -77,32 +59,5 @@ private static async Task ElementAt_(IAsyncEnumerable throw new ArgumentOutOfRangeException(nameof(index)); } - - private static async Task ElementAtOrDefault_(IAsyncEnumerable source, int index, CancellationToken cancellationToken) - { - if (index >= 0) - { - var e = source.GetAsyncEnumerator(); - - try - { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - if (index == 0) - { - return e.Current; - } - - index--; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - return default(TSource); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs new file mode 100644 index 0000000000..4202a43292 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static Task ElementAtOrDefault(this IAsyncEnumerable source, int index) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + return ElementAtOrDefault(source, index, CancellationToken.None); + } + + public static Task ElementAtOrDefault(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + return ElementAtOrDefault_(source, index, cancellationToken); + } + + private static async Task ElementAtOrDefault_(IAsyncEnumerable source, int index, CancellationToken cancellationToken) + { + if (index >= 0) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + if (index == 0) + { + return e.Current; + } + + index--; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return default(TSource); + } + } +} From 2e45ab5b38b9ec4fd26ef8f8f7ff48876c473ee1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 4 Sep 2017 22:23:39 -0700 Subject: [PATCH 335/862] Renaming some methods to use Core suffix. --- .../System/Linq/Operators/Aggregate.cs | 16 ++++---- .../System/Linq/Operators/All.cs | 8 ++-- .../System/Linq/Operators/Any.cs | 8 ++-- .../Linq/Operators/Average.Generated.cs | 40 +++++++++---------- .../Linq/Operators/Average.Generated.tt | 4 +- .../System/Linq/Operators/Average.cs | 20 +++++----- .../System/Linq/Operators/ElementAt.cs | 4 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/First.cs | 4 +- .../System/Linq/Operators/FirstOrDefault.cs | 4 +- .../System/Linq/Operators/ForEach.cs | 8 ++-- .../System/Linq/Operators/Last.cs | 4 +- .../System/Linq/Operators/LastOrDefault.cs | 4 +- .../System/Linq/Operators/Max.cs | 2 +- .../System/Linq/Operators/Min.cs | 2 +- .../System/Linq/Operators/SequenceEqual.cs | 4 +- .../System/Linq/Operators/Single.cs | 4 +- .../System/Linq/Operators/SingleOrDefault.cs | 4 +- 18 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 814dc3dd7b..2444da0d12 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -27,7 +27,7 @@ public static Task Aggregate(this IAsyncEnumerable so if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate_(source, accumulator, cancellationToken); + return AggregateCore(source, accumulator, cancellationToken); } public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator) @@ -47,7 +47,7 @@ public static Task Aggregate(this IAsyncEnumerable so if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate_(source, accumulator, cancellationToken); + return AggregateCore(source, accumulator, cancellationToken); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) @@ -111,7 +111,7 @@ public static Task Aggregate(this IAsync if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - return Aggregate_(source, seed, accumulator, resultSelector, cancellationToken); + return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) @@ -135,10 +135,10 @@ public static Task Aggregate(this IAsync if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - return Aggregate_(source, seed, accumulator, resultSelector, cancellationToken); + return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } - private static async Task Aggregate_(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) + private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { var acc = seed; @@ -159,7 +159,7 @@ private static async Task Aggregate_(IAs return resultSelector(acc); } - private static async Task Aggregate_(IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) + private static async Task AggregateCore(IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) { var first = true; var acc = default(TSource); @@ -185,7 +185,7 @@ private static async Task Aggregate_(IAsyncEnumerable return acc; } - private static async Task Aggregate_(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { var acc = seed; @@ -206,7 +206,7 @@ private static async Task Aggregate_(IAs return await resultSelector(acc).ConfigureAwait(false); } - private static async Task Aggregate_(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { var first = true; var acc = default(TSource); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index bef9eac3ee..20889a6b63 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -37,7 +37,7 @@ public static Task All(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return All_(source, predicate, cancellationToken); + return AllCore(source, predicate, cancellationToken); } public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -47,10 +47,10 @@ public static Task All(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return All_(source, predicate, cancellationToken); + return AllCore(source, predicate, cancellationToken); } - private static async Task All_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task AllCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -70,7 +70,7 @@ private static async Task All_(IAsyncEnumerable source, return true; } - private static async Task All_(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 067aff0e27..a0158f9480 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -45,7 +45,7 @@ public static Task Any(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Any_(source, predicate, cancellationToken); + return AnyCore(source, predicate, cancellationToken); } public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -55,7 +55,7 @@ public static Task Any(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Any_(source, predicate, cancellationToken); + return AnyCore(source, predicate, cancellationToken); } public static async Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -75,7 +75,7 @@ public static async Task Any(this IAsyncEnumerable sourc } } - private static async Task Any_(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task AnyCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -95,7 +95,7 @@ private static async Task Any_(IAsyncEnumerable source, return false; } - private static async Task Any_(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index c6f38525ef..601636d8a7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -15,7 +15,7 @@ public static Task Average(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,7 +23,7 @@ public static Task Average(this IAsyncEnumerable source, Cancellati if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -71,7 +71,7 @@ public static Task Average(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -79,7 +79,7 @@ public static Task Average(this IAsyncEnumerable source, Cancellat if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -127,7 +127,7 @@ public static Task Average(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -135,7 +135,7 @@ public static Task Average(this IAsyncEnumerable source, Cancellat if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -183,7 +183,7 @@ public static Task Average(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -191,7 +191,7 @@ public static Task Average(this IAsyncEnumerable source, Cancell if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -239,7 +239,7 @@ public static Task Average(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -247,7 +247,7 @@ public static Task Average(this IAsyncEnumerable source, Cance if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -295,7 +295,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -303,7 +303,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -351,7 +351,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -359,7 +359,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -407,7 +407,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -415,7 +415,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -463,7 +463,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -471,7 +471,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) @@ -519,7 +519,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -527,7 +527,7 @@ public static Task Average(this IAsyncEnumerable sour if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task Average(this IAsyncEnumerable source, Func selector) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index f7118ace8d..1bd2bb7cfe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -40,7 +40,7 @@ foreach (var o in os) if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, CancellationToken.None); + return AverageCore(source, CancellationToken.None); } public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) @@ -48,7 +48,7 @@ foreach (var o in os) if (source == null) throw new ArgumentNullException(nameof(source)); - return Average_(source, cancellationToken); + return AverageCore(source, cancellationToken); } public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func> selector) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index e3a1aea31a..4d7b052227 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - private static async Task Average_(this IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(this IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -40,7 +40,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca } } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -78,7 +78,7 @@ private static async Task Average_(this IAsyncEnumerable source, Ca return null; } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -108,7 +108,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel } } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -146,7 +146,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel return null; } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -176,7 +176,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc } } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -214,7 +214,7 @@ private static async Task Average_(IAsyncEnumerable source, Canc return null; } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -241,7 +241,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel } } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -279,7 +279,7 @@ private static async Task Average_(IAsyncEnumerable source, Cancel return null; } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); @@ -306,7 +306,7 @@ private static async Task Average_(IAsyncEnumerable source, Ca } } - private static async Task Average_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 62dc83e7aa..a01b988086 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -25,10 +25,10 @@ public static Task ElementAt(this IAsyncEnumerable so if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); - return ElementAt_(source, index, cancellationToken); + return ElementAtCore(source, index, cancellationToken); } - private static async Task ElementAt_(IAsyncEnumerable source, int index, CancellationToken cancellationToken) + private static async Task ElementAtCore(IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source is IList list) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 4202a43292..7f22fca556 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -25,10 +25,10 @@ public static Task ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefault_(IAsyncEnumerable source, int index, CancellationToken cancellationToken) + private static async Task ElementAtOrDefaultCore(IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (index >= 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 72874c5f91..4884ccce99 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -23,7 +23,7 @@ public static Task First(this IAsyncEnumerable source if (source == null) throw new ArgumentNullException(nameof(source)); - return First_(source, cancellationToken); + return FirstCore(source, cancellationToken); } public static Task First(this IAsyncEnumerable source, Func predicate) @@ -66,7 +66,7 @@ public static Task First(this IAsyncEnumerable source return source.Where(predicate).First(cancellationToken); } - private static async Task First_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var list = source as IList; if (list?.Count > 0) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 2f3363efb7..94c60d1e22 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -23,7 +23,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func predicate) @@ -66,7 +66,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var list = source as IList; if (list?.Count > 0) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 47386a28a8..6340487ecc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -47,7 +47,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, if (action == null) throw new ArgumentNullException(nameof(action)); - return ForEachAsync_(source, action, cancellationToken); + return ForEachAsyncCore(source, action, cancellationToken); } public static Task ForEachAsync(this IAsyncEnumerable source, Func action) @@ -107,10 +107,10 @@ public static Task ForEachAsync(this IAsyncEnumerable source, if (action == null) throw new ArgumentNullException(nameof(action)); - return ForEachAsync_(source, action, cancellationToken); + return ForEachAsyncCore(source, action, cancellationToken); } - private static async Task ForEachAsync_(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) + private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { var index = 0; @@ -129,7 +129,7 @@ private static async Task ForEachAsync_(IAsyncEnumerable sourc } } - private static async Task ForEachAsync_(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { var index = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index b37bf2ae46..82c4e4d12e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -23,7 +23,7 @@ public static Task Last(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return Last_(source, cancellationToken); + return LastCore(source, cancellationToken); } public static Task Last(this IAsyncEnumerable source, Func predicate) @@ -66,7 +66,7 @@ public static Task Last(this IAsyncEnumerable source, return source.Where(predicate).Last(cancellationToken); } - private static async Task Last_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var last = default(TSource); var hasLast = false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 6cd2204720..451a021e1b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -23,7 +23,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func predicate) @@ -66,7 +66,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task LastOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var last = default(TSource); var hasLast = false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 5bbced0c04..ad464f8615 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -67,7 +67,7 @@ public static Task Max(this IAsyncEnumerable return source.Select(selector).Max(cancellationToken); } - private static async Task Max_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 3da6c74a25..278c1fca46 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -67,7 +67,7 @@ public static Task Min(this IAsyncEnumerable return source.Select(selector).Min(cancellationToken); } - private static async Task Min_(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index ee5363248f..660230bbf5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -42,7 +42,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return SequenceEqual_(first, second, comparer, cancellationToken); + return SequenceEqualCore(first, second, comparer, cancellationToken); } public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) @@ -55,7 +55,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f return first.SequenceEqual(second, EqualityComparer.Default, cancellationToken); } - private static async Task SequenceEqual_(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + private static async Task SequenceEqualCore(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first is ICollection firstCol && second is ICollection secondCol && firstCol.Count != secondCol.Count) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 666d87e30f..43dbc2e82f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -23,7 +23,7 @@ public static Task Single(this IAsyncEnumerable sourc if (source == null) throw new ArgumentNullException(nameof(source)); - return Single_(source, cancellationToken); + return SingleCore(source, cancellationToken); } public static Task Single(this IAsyncEnumerable source, Func predicate) @@ -66,7 +66,7 @@ public static Task Single(this IAsyncEnumerable sourc return source.Where(predicate).Single(cancellationToken); } - private static async Task Single_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SingleCore(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 05e8cd71a3..33d80f02b5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -23,7 +23,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func predicate) @@ -66,7 +66,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault_(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SingleOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { From ada8a640363f53ef64b8c62b5cc0bd1f904d5308 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 11:45:31 -0700 Subject: [PATCH 336/862] Renaming IIListProvider to IAsyncIListProvider. --- .../System/Linq/Operators/Distinct.cs | 4 +-- ...ListProvider.cs => IAsyncIListProvider.cs} | 2 +- .../System/Linq/Operators/AppendPrepend.cs | 6 ++-- .../System/Linq/Operators/Concat.cs | 2 +- .../System/Linq/Operators/Count.cs | 2 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +-- .../System/Linq/Operators/Distinct.cs | 2 +- .../System/Linq/Operators/GroupBy.cs | 28 +++++++++---------- .../System/Linq/Operators/Reverse.cs | 4 +-- .../System/Linq/Operators/ToArray.cs | 2 +- .../Linq/Operators/ToAsyncEnumerable.cs | 6 ++-- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/ToLookup.cs | 12 ++++---- 13 files changed, 38 insertions(+), 38 deletions(-) rename Ix.NET/Source/System.Linq.Async/System/Linq/{IIListProvider.cs => IAsyncIListProvider.cs} (95%) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 4990047ed1..de152d38d5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -65,7 +65,7 @@ private static IAsyncEnumerable DistinctCore(IAsyncEnume return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); } - private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider + private sealed class DistinctAsyncIterator : AsyncIterator, IAsyncIListProvider { private readonly IEqualityComparer comparer; private readonly Func keySelector; @@ -211,7 +211,7 @@ private async Task> FillSetAsync(CancellationToken cancellationTok } } - private sealed class DistinctAsyncIteratorWithTask : AsyncIterator, IIListProvider + private sealed class DistinctAsyncIteratorWithTask : AsyncIterator, IAsyncIListProvider { private readonly IEqualityComparer comparer; private readonly Func> keySelector; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncIListProvider.cs similarity index 95% rename from Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncIListProvider.cs index d396d353cc..a7e77767db 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IIListProvider.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncIListProvider.cs @@ -11,7 +11,7 @@ namespace System.Linq /// /// An iterator that can produce an array or through an optimized path. /// - public interface IIListProvider : IAsyncEnumerable + public interface IAsyncIListProvider : IAsyncEnumerable { /// /// Produce an array of the sequence through an optimized path. diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index c67ea31ade..15d9ea8f36 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -37,7 +37,7 @@ public static IAsyncEnumerable Prepend(this IAsyncEnumerable(source, element, false); } - private abstract class AppendPrependAsyncIterator : AsyncIterator, IIListProvider + private abstract class AppendPrependAsyncIterator : AsyncIterator, IAsyncIListProvider { protected readonly IAsyncEnumerable source; protected IAsyncEnumerator enumerator; @@ -259,7 +259,7 @@ public override async Task> ToListAsync(CancellationToken cancella public override async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - if (source is IIListProvider listProv) + if (source is IAsyncIListProvider listProv) { var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + 1; @@ -508,7 +508,7 @@ public override async Task> ToListAsync(CancellationToken cancella public override async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - if (source is IIListProvider listProv) + if (source is IAsyncIListProvider listProv) { var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + (appended == null ? 0 : appended.Count) + (prepended == null ? 0 : prepended.Count); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 0548762fb4..cdf66475be 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -62,7 +62,7 @@ internal override IAsyncEnumerable GetAsyncEnumerable(int index) } } - private abstract class ConcatAsyncIterator : AsyncIterator, IIListProvider + private abstract class ConcatAsyncIterator : AsyncIterator, IAsyncIListProvider { private int counter; private IAsyncEnumerator enumerator; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index bc72bcdd8a..edd0bc705b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -20,7 +20,7 @@ public static Task Count(this IAsyncEnumerable source, Ca return Task.FromResult(collection.Count); } - if (source is IIListProvider listProv) + if (source is IAsyncIListProvider listProv) { return listProv.GetCountAsync(false, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 6ff1131266..4e5c002a2c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -28,7 +28,7 @@ public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnume return DefaultIfEmpty(source, default(TSource)); } - private sealed class DefaultIfEmptyAsyncIterator : AsyncIterator, IIListProvider + private sealed class DefaultIfEmptyAsyncIterator : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable source; private readonly TSource defaultValue; @@ -119,7 +119,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } else { - var listProv = source as IIListProvider; + var listProv = source as IAsyncIListProvider; count = listProv == null ? -1 : await listProv.GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 36650d444b..37d70ae0ca 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -29,7 +29,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnumerable< return new DistinctAsyncIterator(source, comparer); } - private sealed class DistinctAsyncIterator : AsyncIterator, IIListProvider + private sealed class DistinctAsyncIterator : AsyncIterator, IAsyncIListProvider { private readonly IEqualityComparer comparer; private readonly IAsyncEnumerable source; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 2e1e271c12..d64de87650 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -219,7 +219,7 @@ public static IAsyncEnumerable GroupBy resultSelector(g.Key, g)); } - internal sealed class GroupedResultAsyncEnumerable : AsyncIterator, IIListProvider + internal sealed class GroupedResultAsyncEnumerable : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable source; private readonly Func keySelector; @@ -308,7 +308,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } - internal sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IIListProvider + internal sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable source; private readonly Func> keySelector; @@ -397,7 +397,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } - internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable source; private readonly Func keySelector; @@ -463,13 +463,13 @@ protected override async Task MoveNextCore() public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -486,7 +486,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } - internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IIListProvider> + internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable source; private readonly Func> keySelector; @@ -552,13 +552,13 @@ protected override async Task MoveNextCore() public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -575,7 +575,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } - internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IIListProvider> + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable source; private readonly Func keySelector; @@ -637,13 +637,13 @@ protected override async Task MoveNextCore() public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -660,7 +660,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } - internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IIListProvider> + internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable source; private readonly Func> keySelector; @@ -722,13 +722,13 @@ protected override async Task MoveNextCore() public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index eed713263c..4ec9541795 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable Reverse(this IAsyncEnumerable(source); } - private sealed class ReverseAsyncIterator : AsyncIterator, IIListProvider + private sealed class ReverseAsyncIterator : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable source; @@ -62,7 +62,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT { if (onlyIfCheap) { - if (source is IIListProvider listProv) + if (source is IAsyncIListProvider listProv) { return listProv.GetCountAsync(true, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs index 4d4564b340..1d506418be 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs @@ -23,7 +23,7 @@ public static Task ToArray(this IAsyncEnumerable so if (source == null) throw new ArgumentNullException(nameof(source)); - if (source is IIListProvider arrayProvider) + if (source is IAsyncIListProvider arrayProvider) return arrayProvider.ToArrayAsync(cancellationToken); return AsyncEnumerableHelpers.ToArray(source, cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 1accb3091e..5069b132e2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -118,7 +118,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva }); } - internal sealed class AsyncEnumerableAdapter : AsyncIterator, IIListProvider + internal sealed class AsyncEnumerableAdapter : AsyncIterator, IAsyncIListProvider { private readonly IEnumerable source; @@ -188,7 +188,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT } } - internal sealed class AsyncIListEnumerableAdapter : AsyncIterator, IIListProvider, IList + internal sealed class AsyncIListEnumerableAdapter : AsyncIterator, IAsyncIListProvider, IList { private readonly IList source; private IEnumerator enumerator; @@ -292,7 +292,7 @@ T IList.this[int index] } } - internal sealed class AsyncICollectionEnumerableAdapter : AsyncIterator, IIListProvider, ICollection + internal sealed class AsyncICollectionEnumerableAdapter : AsyncIterator, IAsyncIListProvider, ICollection { private readonly ICollection source; private IEnumerator enumerator; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 5277b2fcdf..9034830b54 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -23,7 +23,7 @@ public static Task> ToList(this IAsyncEnumerable if (source == null) throw new ArgumentNullException(nameof(source)); - if (source is IIListProvider listProvider) + if (source is IAsyncIListProvider listProvider) return listProvider.ToListAsync(cancellationToken); return source.Aggregate( diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 3c25f7cbf5..8d1f569bd5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -214,7 +214,7 @@ public static async Task> ToLookup : ILookup, IIListProvider> + internal class Lookup : ILookup, IAsyncIListProvider> { private readonly IEqualityComparer _comparer; private Grouping[] _groupings; @@ -479,7 +479,7 @@ IAsyncEnumerator> IAsyncEnumerable>(this).ToAsyncEnumerable().GetAsyncEnumerator(); } - Task>> IIListProvider>.ToListAsync(CancellationToken cancellationToken) + Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) { var list = new List>(Count); var g = _lastGrouping; @@ -496,7 +496,7 @@ Task>> IIListProvider[]> IIListProvider>.ToArrayAsync(CancellationToken cancellationToken) + Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) { var array = new IAsyncGrouping[Count]; var index = 0; @@ -516,7 +516,7 @@ Task[]> IIListProvider : ILookup, IIListProvider> + internal class LookupWithTask : ILookup, IAsyncIListProvider> { private readonly IEqualityComparer _comparer; private Grouping[] _groupings; @@ -765,7 +765,7 @@ IAsyncEnumerator> IAsyncEnumerable>(this).ToAsyncEnumerable().GetAsyncEnumerator(); } - Task>> IIListProvider>.ToListAsync(CancellationToken cancellationToken) + Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) { var list = new List>(Count); var g = _lastGrouping; @@ -782,7 +782,7 @@ Task>> IIListProvider[]> IIListProvider>.ToArrayAsync(CancellationToken cancellationToken) + Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) { var array = new IAsyncGrouping[Count]; var index = 0; From e47142a5a77d6d49543f3229d0f1803f9fea7c95 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 11:54:04 -0700 Subject: [PATCH 337/862] Hand-rolling Empty iterator. --- .../System.Linq.Async/System/Linq/Operators/Empty.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 5bf1c12ed2..236336fd4d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -11,7 +11,14 @@ public static partial class AsyncEnumerable { public static IAsyncEnumerable Empty() { - return CreateEnumerable(() => CreateEnumerator(ct => TaskExt.False, current: null, dispose: null)); + return new EmptyAsyncIterator(); + } + + private sealed class EmptyAsyncIterator : AsyncIterator + { + public override AsyncIterator Clone() => new EmptyAsyncIterator(); + + protected override Task MoveNextCore() => TaskExt.False; } } } From 5d3b50c6fbb35aeb30b6f3cee8fb6b00c75753e8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:09:11 -0700 Subject: [PATCH 338/862] Hand-rolling Repeat iterator. --- .../System/Linq/Operators/Repeat.cs | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 0b928d1b9f..3ff1661b89 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Diagnostics; using System.Threading.Tasks; namespace System.Linq @@ -17,5 +16,49 @@ public static IAsyncEnumerable Repeat(TResult element, int cou return Enumerable.Repeat(element, count).ToAsyncEnumerable(); } + + private sealed class RepeatAsyncIterator : AsyncIterator + { + private readonly TResult element; + private readonly int count; + private int remaining; + + public RepeatAsyncIterator(TResult element, int count) + { + this.element = element; + this.count = count; + } + + public override AsyncIterator Clone() => new RepeatAsyncIterator(element, count); + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + remaining = count; + + if (remaining > 0) + { + current = element; + } + + state = AsyncIteratorState.Iterating; + + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (remaining-- != 0) + { + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } } } From 329bcd5f3d6481090921e29bde3d7592e7cfef23 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:10:29 -0700 Subject: [PATCH 339/862] Fixing omission. --- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 3ff1661b89..fad35dd547 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -14,7 +14,7 @@ public static IAsyncEnumerable Repeat(TResult element, int cou if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - return Enumerable.Repeat(element, count).ToAsyncEnumerable(); + return new RepeatAsyncIterator(element, count); } private sealed class RepeatAsyncIterator : AsyncIterator From 0dfce7fee39e8d785d39f1d658d1d5f035478211 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:11:49 -0700 Subject: [PATCH 340/862] Implementing IAsyncIListProvider on Empty. --- .../System.Linq.Async/System/Linq/Operators/Empty.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 236336fd4d..33927869b7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -14,10 +15,16 @@ public static IAsyncEnumerable Empty() return new EmptyAsyncIterator(); } - private sealed class EmptyAsyncIterator : AsyncIterator + private sealed class EmptyAsyncIterator : AsyncIterator, IAsyncIListProvider { public override AsyncIterator Clone() => new EmptyAsyncIterator(); + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(0); + + public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(Array.Empty()); + + public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); + protected override Task MoveNextCore() => TaskExt.False; } } From 0ac547164698a4ded26c385f7f4079fd92dd9266 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:14:20 -0700 Subject: [PATCH 341/862] Implementing IAsyncIListProvider on Repeat. --- .../System/Linq/Operators/Repeat.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index fad35dd547..01cef211c1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -17,7 +18,7 @@ public static IAsyncEnumerable Repeat(TResult element, int cou return new RepeatAsyncIterator(element, count); } - private sealed class RepeatAsyncIterator : AsyncIterator + private sealed class RepeatAsyncIterator : AsyncIterator, IAsyncIListProvider { private readonly TResult element; private readonly int count; @@ -31,6 +32,32 @@ public RepeatAsyncIterator(TResult element, int count) public override AsyncIterator Clone() => new RepeatAsyncIterator(element, count); + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(count); + + public Task ToArrayAsync(CancellationToken cancellationToken) + { + var res = new TResult[count]; + + for (var i = 0; i < count; i++) + { + res[i] = element; + } + + return Task.FromResult(res); + } + + public Task> ToListAsync(CancellationToken cancellationToken) + { + var res = new List(count); + + for (var i = 0; i < count; i++) + { + res.Add(element); + } + + return Task.FromResult(res); + } + protected override async Task MoveNextCore() { switch (state) From 7128e70cb73ac8be4090ae21c1d29011beabed22 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:29:13 -0700 Subject: [PATCH 342/862] Hand-rolling Range iterator. --- .../System/Linq/Operators/Range.cs | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 0edf304281..d00c0b4d9a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; namespace System.Linq { @@ -13,7 +15,51 @@ public static IAsyncEnumerable Range(int start, int count) if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - return Enumerable.Range(start, count).ToAsyncEnumerable(); + if (count == 0) + return Empty(); + + return new RangeAsyncIterator(start, count); + } + + private sealed class RangeAsyncIterator : AsyncIterator + { + private readonly int start; + private readonly int end; + + public RangeAsyncIterator(int start, int count) + { + Debug.Assert(count > 0); + + this.start = start; + this.end = start + count; + } + + public override AsyncIterator Clone() => new RangeAsyncIterator(start, end - start); + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + current = start; + + state = AsyncIteratorState.Iterating; + return true; + + case AsyncIteratorState.Iterating: + current++; + + if (current != end) + { + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } } } } From 90d71d96864c49745158deadd59a86c760506122 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:29:29 -0700 Subject: [PATCH 343/862] Implementing IAsyncIListProvider on Range. --- .../System/Linq/Operators/Range.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index d00c0b4d9a..f0650267eb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -21,7 +22,7 @@ public static IAsyncEnumerable Range(int start, int count) return new RangeAsyncIterator(start, count); } - private sealed class RangeAsyncIterator : AsyncIterator + private sealed class RangeAsyncIterator : AsyncIterator, IAsyncIListProvider { private readonly int start; private readonly int end; @@ -36,6 +37,34 @@ public RangeAsyncIterator(int start, int count) public override AsyncIterator Clone() => new RangeAsyncIterator(start, end - start); + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(end - start); + + public Task ToArrayAsync(CancellationToken cancellationToken) + { + var res = new int[end - start]; + + var value = start; + + for (var i = 0; i < res.Length; i++) + { + res[i] = value++; + } + + return Task.FromResult(res); + } + + public Task> ToListAsync(CancellationToken cancellationToken) + { + var res = new List(end - start); + + for (var value = start; value < end; value++) + { + res.Add(value); + } + + return Task.FromResult(res); + } + protected override async Task MoveNextCore() { switch (state) From 106df57bb54206eef3e3680764dafd521fc86dea Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:31:06 -0700 Subject: [PATCH 344/862] Adding overflow check to Range. --- .../Source/System.Linq.Async/System/Linq/Operators/Range.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index f0650267eb..79e6aa40bb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -16,6 +16,10 @@ public static IAsyncEnumerable Range(int start, int count) if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); + var end = (long)start + count - 1L; + if (count < 0 || end > int.MaxValue) + throw new ArgumentOutOfRangeException(nameof(count)); + if (count == 0) return Empty(); From 98c1791a5a7320f301542aaddc6eb6593fc10f6a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 12:56:53 -0700 Subject: [PATCH 345/862] Moving SingleLinkedNode to a separate file. --- .../System/Linq/Operators/AppendPrepend.cs | 46 ---------------- .../System/Linq/Operators/SingleLinkedNode.cs | 55 +++++++++++++++++++ 2 files changed, 55 insertions(+), 46 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 15d9ea8f36..7a2e16a648 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -269,52 +269,6 @@ public override async Task GetCountAsync(bool onlyIfCheap, CancellationToke } } - private sealed class SingleLinkedNode - { - public SingleLinkedNode(TSource first, TSource second) - { - Linked = new SingleLinkedNode(first); - Item = second; - Count = 2; - } - - public SingleLinkedNode(TSource item) - { - Item = item; - Count = 1; - } - - private SingleLinkedNode(SingleLinkedNode linked, TSource item) - { - Debug.Assert(linked != null); - Linked = linked; - Item = item; - Count = linked.Count + 1; - } - - public TSource Item { get; } - - public SingleLinkedNode Linked { get; } - - public int Count { get; } - - public SingleLinkedNode Add(TSource item) => new SingleLinkedNode(this, item); - - public IEnumerator GetEnumerator() - { - var array = new TSource[Count]; - var index = Count; - for (var n = this; n != null; n = n.Linked) - { - --index; - array[index] = n.Item; - } - - Debug.Assert(index == 0); - return ((IEnumerable)array).GetEnumerator(); - } - } - private sealed class AppendPrependNAsyncIterator : AppendPrependAsyncIterator { private readonly SingleLinkedNode prepended; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs new file mode 100644 index 0000000000..9a98b25d1e --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace System.Linq +{ + internal sealed class SingleLinkedNode + { + public SingleLinkedNode(TSource first, TSource second) + { + Linked = new SingleLinkedNode(first); + Item = second; + Count = 2; + } + + public SingleLinkedNode(TSource item) + { + Item = item; + Count = 1; + } + + private SingleLinkedNode(SingleLinkedNode linked, TSource item) + { + Debug.Assert(linked != null); + Linked = linked; + Item = item; + Count = linked.Count + 1; + } + + public TSource Item { get; } + + public SingleLinkedNode Linked { get; } + + public int Count { get; } + + public SingleLinkedNode Add(TSource item) => new SingleLinkedNode(this, item); + + public IEnumerator GetEnumerator() + { + var array = new TSource[Count]; + var index = Count; + for (var n = this; n != null; n = n.Linked) + { + --index; + array[index] = n.Item; + } + + Debug.Assert(index == 0); + return ((IEnumerable)array).GetEnumerator(); + } + } +} From 1cf439007cfb3dc7ebc29808315b4b0a078d9713 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 13:07:27 -0700 Subject: [PATCH 346/862] Reducing size of linked list nodes. --- .../System/Linq/Operators/AppendPrepend.cs | 47 +++++---- .../System/Linq/Operators/SingleLinkedNode.cs | 98 +++++++++++++++---- 2 files changed, 111 insertions(+), 34 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 7a2e16a648..e90566e834 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable Append(this IAsyncEnumerable(source, element, true); + return new AppendPrepend1AsyncIterator(source, element, appending: true); } public static IAsyncEnumerable Prepend(this IAsyncEnumerable source, TSource element) @@ -34,7 +34,7 @@ public static IAsyncEnumerable Prepend(this IAsyncEnumerable(source, element, false); + return new AppendPrepend1AsyncIterator(source, element, appending: false); } private abstract class AppendPrependAsyncIterator : AsyncIterator, IAsyncIListProvider @@ -158,20 +158,24 @@ public override AppendPrependAsyncIterator Append(TSource element) { if (appending) { - return new AppendPrependNAsyncIterator(source, null, new SingleLinkedNode(item, element)); + return new AppendPrependNAsyncIterator(source, null, new SingleLinkedNode(item).Add(element), prependCount: 0, appendCount: 2); + } + else + { + return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(item), new SingleLinkedNode(element), prependCount: 1, appendCount: 1); } - - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(item), new SingleLinkedNode(element)); } public override AppendPrependAsyncIterator Prepend(TSource element) { if (appending) { - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(element), new SingleLinkedNode(item)); + return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(element), new SingleLinkedNode(item), prependCount: 1, appendCount: 1); + } + else + { + return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(item).Add(element), null, prependCount: 2, appendCount: 0); } - - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(item, element), null); } public override async Task ToArrayAsync(CancellationToken cancellationToken) @@ -273,21 +277,28 @@ private sealed class AppendPrependNAsyncIterator : AppendPrependAsyncIt { private readonly SingleLinkedNode prepended; private readonly SingleLinkedNode appended; - + private readonly int prependCount; + private readonly int appendCount; private SingleLinkedNode node; - public AppendPrependNAsyncIterator(IAsyncEnumerable source, SingleLinkedNode prepended, SingleLinkedNode appended) + public AppendPrependNAsyncIterator(IAsyncEnumerable source, SingleLinkedNode prepended, SingleLinkedNode appended, int prependCount, int appendCount) : base(source) { Debug.Assert(prepended != null || appended != null); + Debug.Assert(prependCount > 0 || appendCount > 0); + Debug.Assert(prependCount + appendCount >= 2); + Debug.Assert((prepended?.GetCount() ?? 0) == prependCount); + Debug.Assert((appended?.GetCount() ?? 0) == appendCount); this.prepended = prepended; this.appended = appended; + this.prependCount = prependCount; + this.appendCount = appendCount; } public override AsyncIterator Clone() { - return new AppendPrependNAsyncIterator(source, prepended, appended); + return new AppendPrependNAsyncIterator(source, prepended, appended, prependCount, appendCount); } int mode; @@ -341,7 +352,7 @@ protected override async Task MoveNextCore() if (appended != null) { - appendedEnumerator = appended.GetEnumerator(); + appendedEnumerator = appended.GetEnumerator(appendCount); mode = 4; goto case 4; } @@ -367,12 +378,14 @@ protected override async Task MoveNextCore() public override AppendPrependAsyncIterator Append(TSource item) { - return new AppendPrependNAsyncIterator(source, prepended, appended != null ? appended.Add(item) : new SingleLinkedNode(item)); + var res = appended != null ? appended.Add(item) : new SingleLinkedNode(item); + return new AppendPrependNAsyncIterator(source, prepended, res, prependCount, appendCount + 1); } public override AppendPrependAsyncIterator Prepend(TSource item) { - return new AppendPrependNAsyncIterator(source, prepended != null ? prepended.Add(item) : new SingleLinkedNode(item), appended); + var res = prepended != null ? prepended.Add(item) : new SingleLinkedNode(item); + return new AppendPrependNAsyncIterator(source, res, appended, prependCount + 1, appendCount); } public override async Task ToArrayAsync(CancellationToken cancellationToken) @@ -448,7 +461,7 @@ public override async Task> ToListAsync(CancellationToken cancella if (appended != null) { - using (var en2 = appended.GetEnumerator()) + using (var en2 = appended.GetEnumerator(appendCount)) { while (en2.MoveNext()) { @@ -465,10 +478,10 @@ public override async Task GetCountAsync(bool onlyIfCheap, CancellationToke if (source is IAsyncIListProvider listProv) { var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); - return count == -1 ? -1 : count + (appended == null ? 0 : appended.Count) + (prepended == null ? 0 : prepended.Count); + return count == -1 ? -1 : count + appendCount + prependCount; } - return !onlyIfCheap || source is ICollection ? await source.Count(cancellationToken).ConfigureAwait(false) + (appended == null ? 0 : appended.Count) + (prepended == null ? 0 : prepended.Count) : -1; + return !onlyIfCheap || source is ICollection ? await source.Count(cancellationToken).ConfigureAwait(false) + appendCount + prependCount : -1; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs index 9a98b25d1e..e22fc6431c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs @@ -2,54 +2,118 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +// Copied from https://github.com/dotnet/corefx/blob/f17f1e847aeab830de77f8a46656339d7b0f1b43/src/System.Linq/src/System/Linq/SingleLinkedNode.cs + using System.Collections.Generic; using System.Diagnostics; namespace System.Linq { + /// + /// An immutable node in a singly-linked list of items. + /// + /// The type of the node's item. internal sealed class SingleLinkedNode { - public SingleLinkedNode(TSource first, TSource second) - { - Linked = new SingleLinkedNode(first); - Item = second; - Count = 2; - } - + /// + /// Constructs a tail node. + /// + /// The item to place in the tail node. public SingleLinkedNode(TSource item) { Item = item; - Count = 1; } + /// + /// Constructs a node linked to the specified node. + /// + /// The linked node. + /// The item to place in this node. private SingleLinkedNode(SingleLinkedNode linked, TSource item) { Debug.Assert(linked != null); Linked = linked; Item = item; - Count = linked.Count + 1; } + /// + /// The item held by this node. + /// public TSource Item { get; } + /// + /// The next node in the singly-linked list. + /// public SingleLinkedNode Linked { get; } - public int Count { get; } - + /// + /// Creates a new node that holds the specified item and is linked to this node. + /// + /// The item to place in the new node. public SingleLinkedNode Add(TSource item) => new SingleLinkedNode(this, item); - public IEnumerator GetEnumerator() + /// + /// Gets the number of items in this and subsequent nodes by walking the linked list. + /// + public int GetCount() + { + int count = 0; + for (SingleLinkedNode node = this; node != null; node = node.Linked) + { + count++; + } + + return count; + } + + /// + /// Gets an that enumerates the items of this node's singly-linked list in reverse. + /// + /// The number of items in this node. + public IEnumerator GetEnumerator(int count) { - var array = new TSource[Count]; - var index = Count; - for (var n = this; n != null; n = n.Linked) + return ((IEnumerable)ToArray(count)).GetEnumerator(); + } + + /// + /// Gets the node at a logical index by walking the linked list. + /// + /// The logical index. + /// + /// The caller should make sure is less than this node's count. + /// + public SingleLinkedNode GetNode(int index) + { + Debug.Assert(index >= 0 && index < GetCount()); + + SingleLinkedNode node = this; + for (; index > 0; index--) + { + node = node.Linked; + } + + Debug.Assert(node != null); + return node; + } + + /// + /// Returns an that contains the items of this node's singly-linked list in reverse. + /// + /// The number of items in this node. + private TSource[] ToArray(int count) + { + Debug.Assert(count == GetCount()); + + TSource[] array = new TSource[count]; + int index = count; + for (SingleLinkedNode node = this; node != null; node = node.Linked) { --index; - array[index] = n.Item; + array[index] = node.Item; } Debug.Assert(index == 0); - return ((IEnumerable)array).GetEnumerator(); + return array; } } } From f145d268f11c88c6886134b0a9333a5fdaf496ae Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 13:07:52 -0700 Subject: [PATCH 347/862] Improving source copy comment in Set. --- Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index 0c28569f4a..fe5ec56385 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -2,11 +2,12 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +// Copied from https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/System.Linq/src/System/Linq/Set.cs + using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -// from https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/System.Linq/src/System/Linq/Set.cs namespace System.Linq { [ExcludeFromCodeCoverage] From 73f67584892b48fd39a25b8aac4bf2ef4795f625 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 13:13:04 -0700 Subject: [PATCH 348/862] Adding UnionWithAsync to Set. --- .../System/Linq/Operators/Distinct.cs | 14 +------------- .../System.Linq.Async/System/Linq/Set.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 37d70ae0ca..cab881a348 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -121,19 +121,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke { var s = new Set(comparer); - var enu = source.GetAsyncEnumerator(); - - try - { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) - { - s.Add(enu.Current); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } + await s.UnionWithAsync(source); return s; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index fe5ec56385..1b0c578902 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace System.Linq { @@ -143,6 +144,23 @@ private void Resize() _slots = newSlots; } + public async Task UnionWithAsync(IAsyncEnumerable other) + { + var enu = other.GetAsyncEnumerator(); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + Add(enu.Current); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + } + internal struct Slot { internal int _hashCode; From 6d8619b4acc3f1fe40cd42e0dadac4ac29d0d4e0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 13:50:09 -0700 Subject: [PATCH 349/862] Improving Union. --- .../System/Linq/Operators/Union.cs | 19 ++ .../System/Linq/Operators/Union.cs | 230 +++++++++++++++++- 2 files changed, 248 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs index cf1664c403..475969c454 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -54,6 +54,25 @@ public void Union2() NoNext(e); } + [Fact] + public void Union3() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); + var zs = new[] { 5, 7, 8, 1 }.ToAsyncEnumerable(); + var res = xs.Union(ys).Union(zs); + + var e = res.GetAsyncEnumerator(); + HasNext(e, 1); + HasNext(e, 2); + HasNext(e, 3); + HasNext(e, 5); + HasNext(e, 4); + HasNext(e, 7); + HasNext(e, 8); + NoNext(e); + } + private sealed class Eq : IEqualityComparer { public bool Equals(int x, int y) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index ac396f20c3..c93ff63dfd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -3,6 +3,9 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; namespace System.Linq { @@ -27,7 +30,232 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable union && AreEqualityComparersEqual(comparer, union._comparer) ? union.Union(second) : new UnionAsyncIterator2(first, second, comparer); + } + + private static bool AreEqualityComparersEqual(IEqualityComparer first, IEqualityComparer second) + { + return first == second || (first != null && second != null && first.Equals(second)); + } + + /// + /// An iterator that yields distinct values from two or more . + /// + /// The type of the source enumerables. + private abstract class UnionAsyncIterator : AsyncIterator, IAsyncIListProvider + { + internal readonly IEqualityComparer _comparer; + private IAsyncEnumerator _enumerator; + private Set _set; + private int _index; + + protected UnionAsyncIterator(IEqualityComparer comparer) + { + _comparer = comparer; + } + + public sealed override async Task DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _set = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + internal abstract IAsyncEnumerable GetEnumerable(int index); + + internal abstract UnionAsyncIterator Union(IAsyncEnumerable next); + + private async Task SetEnumeratorAsync(IAsyncEnumerator enumerator) + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + } + + _enumerator = enumerator; + } + + private void StoreFirst() + { + var set = new Set(_comparer); + var element = _enumerator.Current; + set.Add(element); + current = element; + _set = set; + } + + private async Task GetNextAsync() + { + var set = _set; + Debug.Assert(set != null); + + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var element = _enumerator.Current; + if (set.Add(element)) + { + current = element; + return true; + } + } + + return false; + } + + protected sealed override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + _index = 0; + + for (var enumerable = GetEnumerable(0); enumerable != null; enumerable = GetEnumerable(_index)) + { + ++_index; + + var enumerator = enumerable.GetAsyncEnumerator(); + + if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + { + await SetEnumeratorAsync(enumerator).ConfigureAwait(false); + StoreFirst(); + + state = AsyncIteratorState.Iterating; + return true; + } + } + + break; + + case AsyncIteratorState.Iterating: + while (true) + { + if (await GetNextAsync().ConfigureAwait(false)) + { + return true; + } + + var enumerable = GetEnumerable(_index); + if (enumerable == null) + { + break; + } + + await SetEnumeratorAsync(enumerable.GetAsyncEnumerator()).ConfigureAwait(false); + ++_index; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + + private async Task> FillSetAsync(CancellationToken cancellationToken) + { + var set = new Set(_comparer); + + for (var index = 0; ; ++index) + { + var enumerable = GetEnumerable(index); + if (enumerable == null) + { + return set; + } + + await set.UnionWithAsync(enumerable); + } + } + + public Task ToArrayAsync(CancellationToken cancellationToken) => FillSetAsync(cancellationToken).ContinueWith(set => set.Result.ToArray()); + + public Task> ToListAsync(CancellationToken cancellationToken) => FillSetAsync(cancellationToken).ContinueWith(set => set.Result.ToList()); + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => onlyIfCheap ? Task.FromResult(-1) : FillSetAsync(cancellationToken).ContinueWith(set => set.Result.Count); + } + + /// + /// An iterator that yields distinct values from two . + /// + /// The type of the source enumerables. + private sealed class UnionAsyncIterator2 : UnionAsyncIterator + { + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; + + public UnionAsyncIterator2(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) + : base(comparer) + { + Debug.Assert(first != null); + Debug.Assert(second != null); + _first = first; + _second = second; + } + + public override AsyncIterator Clone() => new UnionAsyncIterator2(_first, _second, _comparer); + + internal override IAsyncEnumerable GetEnumerable(int index) + { + Debug.Assert(index >= 0 && index <= 2); + switch (index) + { + case 0: + return _first; + case 1: + return _second; + default: + return null; + } + } + + internal override UnionAsyncIterator Union(IAsyncEnumerable next) + { + var sources = new SingleLinkedNode>(_first).Add(_second).Add(next); + return new UnionAsyncIteratorN(sources, 2, _comparer); + } + } + + /// + /// An iterator that yields distinct values from three or more . + /// + /// The type of the source enumerables. + private sealed class UnionAsyncIteratorN : UnionAsyncIterator + { + private readonly SingleLinkedNode> _sources; + private readonly int _headIndex; + + public UnionAsyncIteratorN(SingleLinkedNode> sources, int headIndex, IEqualityComparer comparer) + : base(comparer) + { + Debug.Assert(headIndex >= 2); + Debug.Assert(sources?.GetCount() == headIndex + 1); + + _sources = sources; + _headIndex = headIndex; + } + + public override AsyncIterator Clone() => new UnionAsyncIteratorN(_sources, _headIndex, _comparer); + + internal override IAsyncEnumerable GetEnumerable(int index) => index > _headIndex ? null : _sources.GetNode(_headIndex - index).Item; + + internal override UnionAsyncIterator Union(IAsyncEnumerable next) + { + if (_headIndex == int.MaxValue - 2) + { + // In the unlikely case of this many unions, if we produced a UnionIteratorN + // with int.MaxValue then state would overflow before it matched it's index. + // So we use the naïve approach of just having a left and right sequence. + return new UnionAsyncIterator2(this, next, _comparer); + } + + return new UnionAsyncIteratorN(_sources.Add(next), _headIndex + 1, _comparer); + } } } } From ad43dddfe29a05da97a36d27bca9835fed81157e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 14:00:22 -0700 Subject: [PATCH 350/862] Some minor tweaks to Select. --- .../System.Linq.Async/System/Linq/Operators/Select.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 5f256376af..df419438bc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -133,10 +133,10 @@ protected override async Task MoveNextCore() return true; } - await DisposeAsync().ConfigureAwait(false); break; } + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -194,10 +194,10 @@ protected override async Task MoveNextCore() return true; } - await DisposeAsync().ConfigureAwait(false); break; } + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -315,10 +315,10 @@ protected override async Task MoveNextCore() return true; } - await DisposeAsync().ConfigureAwait(false); break; } + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -376,10 +376,10 @@ protected override async Task MoveNextCore() return true; } - await DisposeAsync().ConfigureAwait(false); break; } + await DisposeAsync().ConfigureAwait(false); return false; } } @@ -436,10 +436,10 @@ protected override async Task MoveNextCore() return true; } - await DisposeAsync().ConfigureAwait(false); break; } + await DisposeAsync().ConfigureAwait(false); return false; } } From 488a36e2e005593847fcb559938363a18420a9c2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 14:21:57 -0700 Subject: [PATCH 351/862] Adding IAsyncIListProvider on Select. --- .../System/Linq/Operators/Select.cs | 105 +++++++++++++++++- 1 file changed, 103 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index df419438bc..125fb4998e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -202,7 +203,7 @@ protected override async Task MoveNextCore() } } - internal sealed class SelectIListIterator : AsyncIterator + internal sealed class SelectIListIterator : AsyncIterator, IAsyncIListProvider { private readonly Func selector; private readonly IList source; @@ -233,11 +234,61 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return Task.FromResult(-1); + } + + var count = 0; + + foreach (var item in source) + { + selector(item); + + checked + { + count++; + } + } + + return Task.FromResult(count); + } + public override IAsyncEnumerable Select(Func selector) { return new SelectIListIterator(source, CombineSelectors(this.selector, selector)); } + public Task ToArrayAsync(CancellationToken cancellationToken) + { + var n = source.Count; + + var res = new TResult[n]; + + for (var i = 0; i < n; i++) + { + res[i] = selector(source[i]); + } + + return Task.FromResult(res); + } + + public Task> ToListAsync(CancellationToken cancellationToken) + { + var n = source.Count; + + var res = new List(n); + + for (var i = 0; i < n; i++) + { + res.Add(selector(source[i])); + } + + return Task.FromResult(res); + } + protected override async Task MoveNextCore() { switch (state) @@ -384,7 +435,7 @@ protected override async Task MoveNextCore() } } - internal sealed class SelectIListIteratorWithTask : AsyncIterator + internal sealed class SelectIListIteratorWithTask : AsyncIterator, IAsyncIListProvider { private readonly Func> selector; private readonly IList source; @@ -415,11 +466,61 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var count = 0; + + foreach (var item in source) + { + await selector(item).ConfigureAwait(false); + + checked + { + count++; + } + } + + return count; + } + public override IAsyncEnumerable Select(Func> selector) { return new SelectIListIteratorWithTask(source, CombineSelectors(this.selector, selector)); } + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var n = source.Count; + + var res = new TResult[n]; + + for (var i = 0; i < n; i++) + { + res[i] = await selector(source[i]).ConfigureAwait(false); + } + + return res; + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var n = source.Count; + + var res = new List(n); + + for (var i = 0; i < n; i++) + { + res.Add(await selector(source[i]).ConfigureAwait(false)); + } + + return res; + } + protected override async Task MoveNextCore() { switch (state) From 429f3d34f24a691fdee5974466335beb5d823c4d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 14:46:03 -0700 Subject: [PATCH 352/862] Adding IAsyncPartition. --- .../System/Linq/IAsyncPartition.cs | 47 +++++++++++++++++++ .../System.Linq.Async/System/Linq/Maybe.cs | 27 +++++++++++ 2 files changed, 74 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs new file mode 100644 index 0000000000..9b1497f784 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading.Tasks; + +namespace System.Linq +{ + /// + /// An iterator that supports random access and can produce a partial sequence of its items through an optimized path. + /// + internal interface IAsyncPartition : IAsyncIListProvider + { + /// + /// Creates a new partition that skips the specified number of elements from this sequence. + /// + /// The number of elements to skip. + /// An with the first items removed. + IAsyncPartition Skip(int count); + + /// + /// Creates a new partition that takes the specified number of elements from this sequence. + /// + /// The number of elements to take. + /// An with only the first items. + IAsyncPartition Take(int count); + + /// + /// Gets the item associated with a 0-based index in this sequence. + /// + /// The 0-based index to access. + /// The element if found, otherwise, the default value of . + Task> TryGetElementAt(int index); + + /// + /// Gets the first item in this sequence. + /// + /// The element if found, otherwise, the default value of . + Task> TryGetFirst(); + + /// + /// Gets the last item in this sequence. + /// + /// The element if found, otherwise, the default value of . + Task> TryGetLast(); + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs new file mode 100644 index 0000000000..6f6d2bc74b --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + internal struct Maybe : IEquatable> + { + public Maybe(T value) + { + HasValue = false; + Value = value; + } + + public bool HasValue { get; } + public T Value { get; } + + public bool Equals(Maybe other) => HasValue == other.HasValue && EqualityComparer.Default.Equals(Value, other.Value); + public override bool Equals(object other) => other is Maybe m && Equals(m); + public override int GetHashCode() => HasValue ? EqualityComparer.Default.GetHashCode(Value) : 0; + + public static bool operator ==(Maybe first, Maybe second) => first.Equals(second); + public static bool operator !=(Maybe first, Maybe second) => !first.Equals(second); + } +} From 2bcf517a5510b9a091944cdef62764bf2de4e5c9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 14:49:11 -0700 Subject: [PATCH 353/862] Implement IAsyncIListProvider on Empty. --- .../System.Linq.Async/System/Linq/Operators/Empty.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 33927869b7..1e024dd2b9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -15,16 +15,26 @@ public static IAsyncEnumerable Empty() return new EmptyAsyncIterator(); } - private sealed class EmptyAsyncIterator : AsyncIterator, IAsyncIListProvider + private sealed class EmptyAsyncIterator : AsyncIterator, IAsyncPartition { public override AsyncIterator Clone() => new EmptyAsyncIterator(); public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(0); + public IAsyncPartition Skip(int count) => this; + + public IAsyncPartition Take(int count) => this; + public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(Array.Empty()); public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); + public Task> TryGetElementAt(int index) => Task.FromResult(new Maybe()); + + public Task> TryGetFirst() => Task.FromResult(new Maybe()); + + public Task> TryGetLast() => Task.FromResult(new Maybe()); + protected override Task MoveNextCore() => TaskExt.False; } } From 82ad94d260f2640b392a3d0ad3bff65a9fc2ce8d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 14:51:59 -0700 Subject: [PATCH 354/862] Using a singleton instance for Empty. --- .../System/Linq/Operators/Empty.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 1e024dd2b9..ce64b8773f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -10,14 +10,13 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Empty() - { - return new EmptyAsyncIterator(); - } + public static IAsyncEnumerable Empty() => EmptyAsyncIterator.Instance; - private sealed class EmptyAsyncIterator : AsyncIterator, IAsyncPartition + private sealed class EmptyAsyncIterator : IAsyncPartition, IAsyncEnumerator { - public override AsyncIterator Clone() => new EmptyAsyncIterator(); + public static readonly EmptyAsyncIterator Instance = new EmptyAsyncIterator(); + + public TValue Current => default(TValue); public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(0); @@ -35,7 +34,11 @@ private sealed class EmptyAsyncIterator : AsyncIterator, IAsyncP public Task> TryGetLast() => Task.FromResult(new Maybe()); - protected override Task MoveNextCore() => TaskExt.False; + public Task MoveNextAsync() => TaskExt.False; + + public IAsyncEnumerator GetAsyncEnumerator() => this; + + public Task DisposeAsync() => TaskExt.CompletedTask; } } } From 44199a79efd5bfbe2f00e6b7f0a3bcb992e6430f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 14:58:11 -0700 Subject: [PATCH 355/862] Implement IAsyncPartition on Range. --- .../System/Linq/Operators/Range.cs | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 79e6aa40bb..5d2fb52de0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -26,7 +26,7 @@ public static IAsyncEnumerable Range(int start, int count) return new RangeAsyncIterator(start, count); } - private sealed class RangeAsyncIterator : AsyncIterator, IAsyncIListProvider + private sealed class RangeAsyncIterator : AsyncIterator, IAsyncPartition { private readonly int start; private readonly int end; @@ -43,6 +43,30 @@ public RangeAsyncIterator(int start, int count) public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(end - start); + public IAsyncPartition Skip(int count) + { + var n = end - start; + + if (count >= n) + { + return EmptyAsyncIterator.Instance; + } + + return new RangeAsyncIterator(start + count, n - count); + } + + public IAsyncPartition Take(int count) + { + var n = end - start; + + if (count >= n) + { + return this; + } + + return new RangeAsyncIterator(start, count); + } + public Task ToArrayAsync(CancellationToken cancellationToken) { var res = new int[end - start]; @@ -69,6 +93,20 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } + public Task> TryGetElementAt(int index) + { + if ((uint)index < (uint)(end - start)) + { + return Task.FromResult(new Maybe(start + index)); + } + + return Task.FromResult(new Maybe()); + } + + public Task> TryGetFirst() => Task.FromResult(new Maybe(start)); + + public Task> TryGetLast() => Task.FromResult(new Maybe(end - 1)); + protected override async Task MoveNextCore() { switch (state) From ba258fdb701b8ee284af8f7b215dea9c61b72c08 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 15:00:32 -0700 Subject: [PATCH 356/862] Simplifying some logic in First[OrDefault]. --- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs | 3 +-- .../System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 4884ccce99..d0defe5cd8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -68,8 +68,7 @@ public static Task First(this IAsyncEnumerable source private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var list = source as IList; - if (list?.Count > 0) + if (source is IList list && list.Count > 0) { return list[0]; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 94c60d1e22..c10e47f165 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -68,8 +68,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var list = source as IList; - if (list?.Count > 0) + if (source is IList list && list.Count > 0) { return list[0]; } From de7600a4a58253fec17569842202517114e5f8a8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 15:26:36 -0700 Subject: [PATCH 357/862] Fixing test for Empty. --- .../System.Linq.Async.Tests/System/Linq/Operators/Empty.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs index 1d283ab225..6dcbdc839c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs @@ -24,7 +24,6 @@ public void Empty2() var e = xs.GetAsyncEnumerator(); Assert.False(e.MoveNextAsync().Result); - AssertThrows(() => Nop(e.Current)); } private void Nop(object o) From df9874703a62b6f030e33c89f06969c6d5018373 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 15:26:50 -0700 Subject: [PATCH 358/862] Supporting IAsyncPartition in [First|Last|ElementAt][OrDefaut]. --- .../System/Linq/Operators/ElementAt.cs | 19 +++++++- .../Linq/Operators/ElementAtOrDefault.cs | 18 +++++++- .../System/Linq/Operators/First.cs | 34 +++++++++----- .../System/Linq/Operators/FirstOrDefault.cs | 34 +++++++++----- .../System/Linq/Operators/Last.cs | 45 ++++++++++++------- .../System/Linq/Operators/LastOrDefault.cs | 42 +++++++++++------ 6 files changed, 140 insertions(+), 52 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index a01b988086..8c186e1d6e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -32,10 +32,25 @@ private static async Task ElementAtCore(IAsyncEnumerable list) { - return list[index]; + if (index < list.Count) + { + return list[index]; + } } + else if (source is IAsyncPartition p) + { + var first = await p.TryGetElementAt(index).ConfigureAwait(false); - if (index >= 0) + if (first.HasValue) + { + return first.Value; + } + else + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + } + else { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 7f22fca556..12d9de2138 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -30,7 +30,23 @@ public static Task ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefaultCore(IAsyncEnumerable source, int index, CancellationToken cancellationToken) { - if (index >= 0) + if (source is IList list) + { + if (index < list.Count) + { + return list[index]; + } + } + else if (source is IAsyncPartition p) + { + var first = await p.TryGetElementAt(index).ConfigureAwait(false); + + if (first.HasValue) + { + return first.Value; + } + } + else { var e = source.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index d0defe5cd8..599af157b9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -68,23 +68,37 @@ public static Task First(this IAsyncEnumerable source private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - if (source is IList list && list.Count > 0) + if (source is IList list) { - return list[0]; + if (list.Count > 0) + { + return list[0]; + } } - - var e = source.GetAsyncEnumerator(); - - try + else if (source is IAsyncPartition p) { - if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + var first = await p.TryGetFirst().ConfigureAwait(false); + + if (first.HasValue) { - return e.Current; + return first.Value; } } - finally + else { - await e.DisposeAsync().ConfigureAwait(false); + var e = source.GetAsyncEnumerator(); + + try + { + if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } throw new InvalidOperationException(Strings.NO_ELEMENTS); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index c10e47f165..9f21899100 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -68,23 +68,37 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - if (source is IList list && list.Count > 0) + if (source is IList list) { - return list[0]; + if (list.Count > 0) + { + return list[0]; + } } - - var e = source.GetAsyncEnumerator(); - - try + else if (source is IAsyncPartition p) { - if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + var first = await p.TryGetFirst().ConfigureAwait(false); + + if (first.HasValue) { - return e.Current; + return first.Value; } } - finally + else { - await e.DisposeAsync().ConfigureAwait(false); + var e = source.GetAsyncEnumerator(); + + try + { + if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } return default(TSource); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 82c4e4d12e..673d534dee 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -68,9 +68,6 @@ public static Task Last(this IAsyncEnumerable source, private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var last = default(TSource); - var hasLast = false; - if (source is IList list) { var count = list.Count; @@ -79,26 +76,42 @@ private static async Task LastCore(IAsyncEnumerable s return list[count - 1]; } } - - var e = source.GetAsyncEnumerator(); - - try + else if (source is IAsyncPartition p) { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + var first = await p.TryGetLast().ConfigureAwait(false); + + if (first.HasValue) { - hasLast = true; - last = e.Current; + return first.Value; } } - finally + else { - await e.DisposeAsync().ConfigureAwait(false); - } + var last = default(TSource); + var hasLast = false; + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + hasLast = true; + last = e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - if (!hasLast) - throw new InvalidOperationException(Strings.NO_ELEMENTS); + if (hasLast) + { + return last; + } + } - return last; + throw new InvalidOperationException(Strings.NO_ELEMENTS); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 451a021e1b..f3598ebbc0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -68,9 +68,6 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var last = default(TSource); - var hasLast = false; - if (source is IList list) { var count = list.Count; @@ -79,23 +76,42 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable p) { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + var first = await p.TryGetLast().ConfigureAwait(false); + + if (first.HasValue) { - hasLast = true; - last = e.Current; + return first.Value; } } - finally + else { - await e.DisposeAsync().ConfigureAwait(false); + var last = default(TSource); + var hasLast = false; + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + hasLast = true; + last = e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + if (hasLast) + { + return last; + } } - return !hasLast ? default(TSource) : last; + return default(TSource); } } } From e163c5a885c76afdbd6ef59eb4d1304605ef0bfa Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 15:27:13 -0700 Subject: [PATCH 359/862] Removing dead code. --- .../System.Linq.Async.Tests/System/Linq/Operators/Empty.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs index 6dcbdc839c..17c40213b1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs @@ -25,9 +25,5 @@ public void Empty2() var e = xs.GetAsyncEnumerator(); Assert.False(e.MoveNextAsync().Result); } - - private void Nop(object o) - { - } } } From e9f72835b47ab59da09f171301fe1983ef7de789 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 15:28:02 -0700 Subject: [PATCH 360/862] Renaming IAsyncPartition methods to use Async suffix. --- .../Source/System.Linq.Async/System/Linq/IAsyncPartition.cs | 6 +++--- .../System.Linq.Async/System/Linq/Operators/ElementAt.cs | 2 +- .../System/Linq/Operators/ElementAtOrDefault.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/Empty.cs | 6 +++--- .../Source/System.Linq.Async/System/Linq/Operators/First.cs | 2 +- .../System/Linq/Operators/FirstOrDefault.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/Last.cs | 2 +- .../System/Linq/Operators/LastOrDefault.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/Range.cs | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs index 9b1497f784..6566f197a0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs @@ -30,18 +30,18 @@ internal interface IAsyncPartition : IAsyncIListProvider /// /// The 0-based index to access. /// The element if found, otherwise, the default value of . - Task> TryGetElementAt(int index); + Task> TryGetElementAsync(int index); /// /// Gets the first item in this sequence. /// /// The element if found, otherwise, the default value of . - Task> TryGetFirst(); + Task> TryGetFirstAsync(); /// /// Gets the last item in this sequence. /// /// The element if found, otherwise, the default value of . - Task> TryGetLast(); + Task> TryGetLastAsync(); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 8c186e1d6e..737d44f1a9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -39,7 +39,7 @@ private static async Task ElementAtCore(IAsyncEnumerable p) { - var first = await p.TryGetElementAt(index).ConfigureAwait(false); + var first = await p.TryGetElementAsync(index).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 12d9de2138..92bff76ba6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -39,7 +39,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera } else if (source is IAsyncPartition p) { - var first = await p.TryGetElementAt(index).ConfigureAwait(false); + var first = await p.TryGetElementAsync(index).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index ce64b8773f..01817e5d9e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -28,11 +28,11 @@ private sealed class EmptyAsyncIterator : IAsyncPartition, IAsyn public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); - public Task> TryGetElementAt(int index) => Task.FromResult(new Maybe()); + public Task> TryGetElementAsync(int index) => Task.FromResult(new Maybe()); - public Task> TryGetFirst() => Task.FromResult(new Maybe()); + public Task> TryGetFirstAsync() => Task.FromResult(new Maybe()); - public Task> TryGetLast() => Task.FromResult(new Maybe()); + public Task> TryGetLastAsync() => Task.FromResult(new Maybe()); public Task MoveNextAsync() => TaskExt.False; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 599af157b9..3f120954a6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -77,7 +77,7 @@ private static async Task FirstCore(IAsyncEnumerable } else if (source is IAsyncPartition p) { - var first = await p.TryGetFirst().ConfigureAwait(false); + var first = await p.TryGetFirstAsync().ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 9f21899100..1e2e3b1de7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -77,7 +77,7 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< } else if (source is IAsyncPartition p) { - var first = await p.TryGetFirst().ConfigureAwait(false); + var first = await p.TryGetFirstAsync().ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 673d534dee..a6b8653c58 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -78,7 +78,7 @@ private static async Task LastCore(IAsyncEnumerable s } else if (source is IAsyncPartition p) { - var first = await p.TryGetLast().ConfigureAwait(false); + var first = await p.TryGetLastAsync().ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index f3598ebbc0..a8060a484b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -78,7 +78,7 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable p) { - var first = await p.TryGetLast().ConfigureAwait(false); + var first = await p.TryGetLastAsync().ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 5d2fb52de0..6c67057702 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -93,7 +93,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - public Task> TryGetElementAt(int index) + public Task> TryGetElementAsync(int index) { if ((uint)index < (uint)(end - start)) { @@ -103,9 +103,9 @@ public Task> TryGetElementAt(int index) return Task.FromResult(new Maybe()); } - public Task> TryGetFirst() => Task.FromResult(new Maybe(start)); + public Task> TryGetFirstAsync() => Task.FromResult(new Maybe(start)); - public Task> TryGetLast() => Task.FromResult(new Maybe(end - 1)); + public Task> TryGetLastAsync() => Task.FromResult(new Maybe(end - 1)); protected override async Task MoveNextCore() { From 36316c6385e9be62ebdab5bf17561a59b3c3e3be Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 15:31:24 -0700 Subject: [PATCH 361/862] Checking for IAsyncPartition in Skip and Take. --- .../Source/System.Linq.Async/System/Linq/Operators/Skip.cs | 6 +++++- .../Source/System.Linq.Async/System/Linq/Operators/Take.cs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs index 580d71c3a6..4e06dba188 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs @@ -19,13 +19,17 @@ public static IAsyncEnumerable Skip(this IAsyncEnumerable) + if (source is AsyncIterator || source is IAsyncPartition) { return source; } count = 0; } + else if (source is IAsyncPartition partition) + { + return partition.Skip(count); + } return new SkipAsyncIterator(source, count); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs index 8e53616500..58483249cb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs @@ -19,6 +19,10 @@ public static IAsyncEnumerable Take(this IAsyncEnumerable(); } + else if (source is IAsyncPartition partition) + { + return partition.Take(count); + } return new TakeAsyncIterator(source, count); } From bcd05125157581e3cd3629c840f20b8ca3dd82d1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 15:57:47 -0700 Subject: [PATCH 362/862] Feeding CancellationToken to IAsyncPartition operations. --- .../System.Linq.Async/System/Linq/IAsyncPartition.cs | 10 +++++++--- .../System/Linq/Operators/ElementAt.cs | 2 +- .../System/Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/Empty.cs | 8 ++++---- .../System.Linq.Async/System/Linq/Operators/First.cs | 2 +- .../System/Linq/Operators/FirstOrDefault.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/Last.cs | 2 +- .../System/Linq/Operators/LastOrDefault.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/Range.cs | 6 +++--- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs index 6566f197a0..b3af5c8cee 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -29,19 +30,22 @@ internal interface IAsyncPartition : IAsyncIListProvider /// Gets the item associated with a 0-based index in this sequence. /// /// The 0-based index to access. + /// Token to observe for cancellation requests. /// The element if found, otherwise, the default value of . - Task> TryGetElementAsync(int index); + Task> TryGetElementAsync(int index, CancellationToken cancellationToken); /// /// Gets the first item in this sequence. /// + /// Token to observe for cancellation requests. /// The element if found, otherwise, the default value of . - Task> TryGetFirstAsync(); + Task> TryGetFirstAsync(CancellationToken cancellationToken); /// /// Gets the last item in this sequence. /// + /// Token to observe for cancellation requests. /// The element if found, otherwise, the default value of . - Task> TryGetLastAsync(); + Task> TryGetLastAsync(CancellationToken cancellationToken); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 737d44f1a9..dd0dc6ed66 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -39,7 +39,7 @@ private static async Task ElementAtCore(IAsyncEnumerable p) { - var first = await p.TryGetElementAsync(index).ConfigureAwait(false); + var first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 92bff76ba6..2d7709d968 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -39,7 +39,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera } else if (source is IAsyncPartition p) { - var first = await p.TryGetElementAsync(index).ConfigureAwait(false); + var first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 01817e5d9e..1728b641ea 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -12,7 +12,7 @@ public static partial class AsyncEnumerable { public static IAsyncEnumerable Empty() => EmptyAsyncIterator.Instance; - private sealed class EmptyAsyncIterator : IAsyncPartition, IAsyncEnumerator + internal sealed class EmptyAsyncIterator : IAsyncPartition, IAsyncEnumerator { public static readonly EmptyAsyncIterator Instance = new EmptyAsyncIterator(); @@ -28,11 +28,11 @@ private sealed class EmptyAsyncIterator : IAsyncPartition, IAsyn public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); - public Task> TryGetElementAsync(int index) => Task.FromResult(new Maybe()); + public Task> TryGetElementAsync(int index, CancellationToken cancellationToken) => Task.FromResult(new Maybe()); - public Task> TryGetFirstAsync() => Task.FromResult(new Maybe()); + public Task> TryGetFirstAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe()); - public Task> TryGetLastAsync() => Task.FromResult(new Maybe()); + public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe()); public Task MoveNextAsync() => TaskExt.False; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 3f120954a6..e2b0c68a89 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -77,7 +77,7 @@ private static async Task FirstCore(IAsyncEnumerable } else if (source is IAsyncPartition p) { - var first = await p.TryGetFirstAsync().ConfigureAwait(false); + var first = await p.TryGetFirstAsync(cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 1e2e3b1de7..9e23d5a9c9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -77,7 +77,7 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< } else if (source is IAsyncPartition p) { - var first = await p.TryGetFirstAsync().ConfigureAwait(false); + var first = await p.TryGetFirstAsync(cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index a6b8653c58..81e228d9fe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -78,7 +78,7 @@ private static async Task LastCore(IAsyncEnumerable s } else if (source is IAsyncPartition p) { - var first = await p.TryGetLastAsync().ConfigureAwait(false); + var first = await p.TryGetLastAsync(cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index a8060a484b..5e7aa030d4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -78,7 +78,7 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable p) { - var first = await p.TryGetLastAsync().ConfigureAwait(false); + var first = await p.TryGetLastAsync(cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 6c67057702..f18e202b5d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -93,7 +93,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - public Task> TryGetElementAsync(int index) + public Task> TryGetElementAsync(int index, CancellationToken cancellationToken) { if ((uint)index < (uint)(end - start)) { @@ -103,9 +103,9 @@ public Task> TryGetElementAsync(int index) return Task.FromResult(new Maybe()); } - public Task> TryGetFirstAsync() => Task.FromResult(new Maybe(start)); + public Task> TryGetFirstAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(start)); - public Task> TryGetLastAsync() => Task.FromResult(new Maybe(end - 1)); + public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(end - 1)); protected override async Task MoveNextCore() { From 6f2e856fd23033ad9178dbe01e41b6e9f96ed7cb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 16:51:32 -0700 Subject: [PATCH 363/862] Adding Async[Enumerable|List]Partition and use it for Skip and Take. --- .../System/Linq/AsyncEnumerablePartition.cs | 379 ++++++++++++++++++ .../System/Linq/AsyncListPartition.cs | 180 +++++++++ .../System/Linq/Operators/Skip.cs | 73 +--- .../System/Linq/Operators/Take.cs | 64 +-- 4 files changed, 565 insertions(+), 131 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs new file mode 100644 index 0000000000..8bb31f0a9b --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -0,0 +1,379 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +// Copied from https://github.com/dotnet/corefx/blob/5f1dd8298e4355b63bb760d88d437a91b3ca808c/src/System.Linq/src/System/Linq/Partition.cs + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + /// + /// An iterator that yields the items of part of an . + /// + /// The type of the source enumerable. + internal sealed class AsyncEnumerablePartition : AsyncIterator, IAsyncPartition + { + private readonly IAsyncEnumerable _source; + private readonly int _minIndexInclusive; + private readonly int _maxIndexInclusive; // -1 if we want everything past _minIndexInclusive. + // If this is -1, it's impossible to set a limit on the count. + private IAsyncEnumerator _enumerator; + + internal AsyncEnumerablePartition(IAsyncEnumerable source, int minIndexInclusive, int maxIndexInclusive) + { + Debug.Assert(source != null); + Debug.Assert(!(source is IList), $"The caller needs to check for {nameof(IList)}."); + Debug.Assert(minIndexInclusive >= 0); + Debug.Assert(maxIndexInclusive >= -1); + // Note that although maxIndexInclusive can't grow, it can still be int.MaxValue. + // We support partitioning enumerables with > 2B elements. For example, e.Skip(1).Take(int.MaxValue) should work. + // But if it is int.MaxValue, then minIndexInclusive must != 0. Otherwise, our count may overflow. + Debug.Assert(maxIndexInclusive == -1 || (maxIndexInclusive - minIndexInclusive < int.MaxValue), $"{nameof(Limit)} will overflow!"); + Debug.Assert(maxIndexInclusive == -1 || minIndexInclusive <= maxIndexInclusive); + + _source = source; + _minIndexInclusive = minIndexInclusive; + _maxIndexInclusive = maxIndexInclusive; + } + + // If this is true (e.g. at least one Take call was made), then we have an upper bound + // on how many elements we can have. + private bool HasLimit => _maxIndexInclusive != -1; + + private int Limit => (_maxIndexInclusive + 1) - _minIndexInclusive; // This is that upper bound. + + public override AsyncIterator Clone() + { + return new AsyncEnumerablePartition(_source, _minIndexInclusive, _maxIndexInclusive); + } + + public override async Task DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + if (!HasLimit) + { + // If HasLimit is false, we contain everything past _minIndexInclusive. + // Therefore, we have to iterate the whole enumerable. + return Math.Max(await _source.Count(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); + } + + var en = _source.GetAsyncEnumerator(); + + try + { + // We only want to iterate up to _maxIndexInclusive + 1. + // Past that, we know the enumerable will be able to fit this partition, + // so the count will just be _maxIndexInclusive + 1 - _minIndexInclusive. + + // Note that it is possible for _maxIndexInclusive to be int.MaxValue here, + // so + 1 may result in signed integer overflow. We need to handle this. + // At the same time, however, we are guaranteed that our max count can fit + // in an int because if that is true, then _minIndexInclusive must > 0. + + var count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en, cancellationToken).ConfigureAwait(false); + Debug.Assert(count != (uint)int.MaxValue + 1 || _minIndexInclusive > 0, "Our return value will be incorrect."); + return Math.Max((int)count - _minIndexInclusive, 0); + } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } + } + + private bool hasSkipped; + private int taken; + + protected override async Task MoveNextCore() + { + switch (state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(); + hasSkipped = false; + taken = 0; + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (!hasSkipped) + { + if (!await SkipBeforeFirstAsync(_enumerator, CancellationToken.None).ConfigureAwait(false)) + { + // Reached the end before we finished skipping. + break; + } + + hasSkipped = true; + } + + if ((!HasLimit || taken < Limit) && await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (HasLimit) + { + // If we are taking an unknown number of elements, it's important not to increment _state. + // _state - 3 may eventually end up overflowing & we'll hit the Dispose branch even though + // we haven't finished enumerating. + taken++; + } + + current = _enumerator.Current; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + +#if NOTYET + public override IAsyncEnumerable Select(Func selector) + { + return new SelectIPartitionIterator(this, selector); + } + + public override IAsyncEnumerable Select(Func> selector) + { + return new SelectIPartitionIterator(this, selector); + } +#endif + + public IAsyncPartition Skip(int count) + { + var minIndex = _minIndexInclusive + count; + if (!HasLimit) + { + if (minIndex < 0) + { + // If we don't know our max count and minIndex can no longer fit in a positive int, + // then we will need to wrap ourselves in another iterator. + // This can happen, for example, during e.Skip(int.MaxValue).Skip(int.MaxValue). + return new AsyncEnumerablePartition(this, count, -1); + } + } + else if ((uint)minIndex > (uint)_maxIndexInclusive) + { + // If minIndex overflows and we have an upper bound, we will go down this branch. + // We know our upper bound must be smaller than minIndex, since our upper bound fits in an int. + // This branch should not be taken if we don't have a bound. + return AsyncEnumerable.EmptyAsyncIterator.Instance; + } + + Debug.Assert(minIndex >= 0, $"We should have taken care of all cases when {nameof(minIndex)} overflows."); + return new AsyncEnumerablePartition(_source, minIndex, _maxIndexInclusive); + } + + public IAsyncPartition Take(int count) + { + var maxIndex = _minIndexInclusive + count - 1; + if (!HasLimit) + { + if (maxIndex < 0) + { + // If we don't know our max count and maxIndex can no longer fit in a positive int, + // then we will need to wrap ourselves in another iterator. + // Note that although maxIndex may be too large, the difference between it and + // _minIndexInclusive (which is count - 1) must fit in an int. + // Example: e.Skip(50).Take(int.MaxValue). + + return new AsyncEnumerablePartition(this, 0, count - 1); + } + } + else if ((uint)maxIndex >= (uint)_maxIndexInclusive) + { + // If we don't know our max count, we can't go down this branch. + // It's always possible for us to contain more than count items, as the rest + // of the enumerable past _minIndexInclusive can be arbitrarily long. + return this; + } + + Debug.Assert(maxIndex >= 0, $"We should have taken care of all cases when {nameof(maxIndex)} overflows."); + return new AsyncEnumerablePartition(_source, _minIndexInclusive, maxIndex); + } + + public async Task> TryGetElementAsync(int index, CancellationToken cancellationToken) + { + // If the index is negative or >= our max count, return early. + if (index >= 0 && (!HasLimit || index < Limit)) + { + var en = _source.GetAsyncEnumerator(); + + try + { + Debug.Assert(_minIndexInclusive + index >= 0, $"Adding {nameof(index)} caused {nameof(_minIndexInclusive)} to overflow."); + + if (await SkipBeforeAsync(_minIndexInclusive + index, en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return new Maybe(en.Current); + } + } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } + } + + return new Maybe(); + } + + public async Task> TryGetFirstAsync(CancellationToken cancellationToken) + { + var en = _source.GetAsyncEnumerator(); + + try + { + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return new Maybe(en.Current); + } + } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } + + return new Maybe(); + } + + public async Task> TryGetLastAsync(CancellationToken cancellationToken) + { + var en = _source.GetAsyncEnumerator(); + + try + { + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var remaining = Limit - 1; // Max number of items left, not counting the current element. + var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + TSource result; + + do + { + remaining--; + result = en.Current; + } + while (remaining >= comparand && await en.MoveNextAsync().ConfigureAwait(false)); + + return new Maybe(result); + } + } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } + + return new Maybe(); + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var en = _source.GetAsyncEnumerator(); + + try + { + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var remaining = Limit - 1; // Max number of items left, not counting the current element. + var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + + var maxCapacity = HasLimit ? Limit : int.MaxValue; + var builder = new List(maxCapacity); + + do + { + remaining--; + builder.Add(en.Current); + } + while (remaining >= comparand && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)); + + return builder.ToArray(); + } + } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } + + return Array.Empty(); + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var list = new List(); + + var en = _source.GetAsyncEnumerator(); + + try + { + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + var remaining = Limit - 1; // Max number of items left, not counting the current element. + var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + + do + { + remaining--; + list.Add(en.Current); + } + while (remaining >= comparand && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)); + } + } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } + + return list; + } + + private Task SkipBeforeFirstAsync(IAsyncEnumerator en, CancellationToken cancellationToken) => SkipBeforeAsync(_minIndexInclusive, en, cancellationToken); + + private static async Task SkipBeforeAsync(int index, IAsyncEnumerator en, CancellationToken cancellationToken) + { + var n = await SkipAndCountAsync(index, en, cancellationToken).ConfigureAwait(false); + return n == index; + } + + private static async Task SkipAndCountAsync(int index, IAsyncEnumerator en, CancellationToken cancellationToken) + { + Debug.Assert(index >= 0); + return (int)await SkipAndCountAsync((uint)index, en, cancellationToken).ConfigureAwait(false); + } + + private static async Task SkipAndCountAsync(uint index, IAsyncEnumerator en, CancellationToken cancellationToken) + { + Debug.Assert(en != null); + + for (uint i = 0; i < index; i++) + { + if (!await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + { + return i; + } + } + + return index; + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs new file mode 100644 index 0000000000..0ee0ef5bc6 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -0,0 +1,180 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +// Copied from https://github.com/dotnet/corefx/blob/5f1dd8298e4355b63bb760d88d437a91b3ca808c/src/System.Linq/src/System/Linq/Partition.cs + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + /// + /// An iterator that yields the items of part of an . + /// + /// The type of the source list. + internal sealed class AsyncListPartition : AsyncIterator, IAsyncPartition + { + private readonly IList _source; + private readonly int _minIndexInclusive; + private readonly int _maxIndexInclusive; + private int _index; + + public AsyncListPartition(IList source, int minIndexInclusive, int maxIndexInclusive) + { + Debug.Assert(source != null); + Debug.Assert(minIndexInclusive >= 0); + Debug.Assert(minIndexInclusive <= maxIndexInclusive); + _source = source; + _minIndexInclusive = minIndexInclusive; + _maxIndexInclusive = maxIndexInclusive; + _index = 0; + } + + public override AsyncIterator Clone() + { + return new AsyncListPartition(_source, _minIndexInclusive, _maxIndexInclusive); + } + + protected override async Task MoveNextCore() + { + if ((uint)_index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && _index < _source.Count - _minIndexInclusive) + { + current = _source[_minIndexInclusive + _index]; + ++_index; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + +#if NOT_YET + public override IEnumerable Select(Func selector) + { + return new SelectListPartitionIterator(_source, selector, _minIndexInclusive, _maxIndexInclusive); + } + + public override IEnumerable Select(Func> selector) + { + return new SelectListPartitionIterator(_source, selector, _minIndexInclusive, _maxIndexInclusive); + } +#endif + + public IAsyncPartition Skip(int count) + { + var minIndex = _minIndexInclusive + count; + if ((uint)minIndex > (uint)_maxIndexInclusive) + { + return AsyncEnumerable.EmptyAsyncIterator.Instance; + } + else + { + return new AsyncListPartition(_source, minIndex, _maxIndexInclusive); + } + } + + public IAsyncPartition Take(int count) + { + var maxIndex = _minIndexInclusive + count - 1; + if ((uint)maxIndex >= (uint)_maxIndexInclusive) + { + return this; + } + else + { + return new AsyncListPartition(_source, _minIndexInclusive, maxIndex); + } + } + + public Task> TryGetElementAsync(int index, CancellationToken cancellationToken) + { + if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < _source.Count - _minIndexInclusive) + { + var res = _source[_minIndexInclusive + index]; + return Task.FromResult(new Maybe(res)); + } + + return Task.FromResult(new Maybe()); + } + + public Task> TryGetFirstAsync(CancellationToken cancellationToken) + { + if (_source.Count > _minIndexInclusive) + { + var res = _source[_minIndexInclusive]; + return Task.FromResult(new Maybe(res)); + } + + return Task.FromResult(new Maybe()); + } + + public Task> TryGetLastAsync(CancellationToken cancellationToken) + { + var lastIndex = _source.Count - 1; + if (lastIndex >= _minIndexInclusive) + { + var res = _source[Math.Min(lastIndex, _maxIndexInclusive)]; + return Task.FromResult(new Maybe(res)); + } + + return Task.FromResult(new Maybe()); + } + + private int Count + { + get + { + var count = _source.Count; + if (count <= _minIndexInclusive) + { + return 0; + } + + return Math.Min(count - 1, _maxIndexInclusive) - _minIndexInclusive + 1; + } + } + + public Task ToArrayAsync(CancellationToken cancellationToken) + { + var count = Count; + if (count == 0) + { + return Task.FromResult(Array.Empty()); + } + + var array = new TSource[count]; + for (int i = 0, curIdx = _minIndexInclusive; i != array.Length; ++i, ++curIdx) + { + array[i] = _source[curIdx]; + } + + return Task.FromResult(array); + } + + public Task> ToListAsync(CancellationToken cancellationToken) + { + var count = Count; + if (count == 0) + { + return Task.FromResult(new List()); + } + + var list = new List(count); + var end = _minIndexInclusive + count; + for (var i = _minIndexInclusive; i != end; ++i) + { + list.Add(_source[i]); + } + + return Task.FromResult(list); + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + return Task.FromResult(Count); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs index 4e06dba188..c66d391abc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Diagnostics; -using System.Threading.Tasks; namespace System.Linq { @@ -30,77 +28,12 @@ public static IAsyncEnumerable Skip(this IAsyncEnumerable(source, count); - } - - private sealed class SkipAsyncIterator : AsyncIterator - { - private readonly int count; - private readonly IAsyncEnumerable source; - - private int currentCount; - private IAsyncEnumerator enumerator; - - public SkipAsyncIterator(IAsyncEnumerable source, int count) - { - Debug.Assert(source != null); - - this.source = source; - this.count = count; - currentCount = count; - } - - public override AsyncIterator Clone() - { - return new SkipAsyncIterator(source, count); - } - - public override async Task DisposeAsync() + else if (source is IList list) { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); + return new AsyncListPartition(list, count, int.MaxValue); } - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - // skip elements as requested - while (currentCount > 0 && await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - currentCount--; - } - - if (currentCount <= 0) - { - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - } - - break; - - case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = enumerator.Current; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } + return new AsyncEnumerablePartition(source, count, -1); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs index 58483249cb..3a8c1af852 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Diagnostics; -using System.Threading.Tasks; namespace System.Linq { @@ -23,68 +21,12 @@ public static IAsyncEnumerable Take(this IAsyncEnumerable(source, count); - } - - private sealed class TakeAsyncIterator : AsyncIterator - { - private readonly int count; - private readonly IAsyncEnumerable source; - - private int currentCount; - private IAsyncEnumerator enumerator; - - public TakeAsyncIterator(IAsyncEnumerable source, int count) + else if (source is IList list) { - Debug.Assert(source != null); - - this.source = source; - this.count = count; - currentCount = count; + return new AsyncListPartition(list, 0, count - 1); } - public override AsyncIterator Clone() - { - return new TakeAsyncIterator(source, count); - } - - public override async Task DisposeAsync() - { - if (enumerator != null) - { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - } - - await base.DisposeAsync().ConfigureAwait(false); - } - - - protected override async Task MoveNextCore() - { - switch (state) - { - case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); - - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (currentCount > 0 && await enumerator.MoveNextAsync().ConfigureAwait(false)) - { - current = enumerator.Current; - currentCount--; - return true; - } - - break; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } + return new AsyncEnumerablePartition(source, 0, count - 1); } } } From 243d99b61cb7ccd969f449f5c48887090d230d35 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 5 Sep 2017 16:59:54 -0700 Subject: [PATCH 364/862] Adding some comment to Select. --- .../Source/System.Linq.Async/System/Linq/Operators/Select.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 125fb4998e..0b00653712 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -435,6 +435,11 @@ protected override async Task MoveNextCore() } } + // NB: LINQ to Objects implements IPartition for this. However, it seems incorrect to do so in a trivial + // manner where e.g. TryGetLast simply indexes into the list without running the selector for the first n - 1 + // elements in order to ensure side-effects. We should consider whether we want to follow this implementation + // strategy or support IAsyncPartition in a less efficient but more correct manner here. + internal sealed class SelectIListIteratorWithTask : AsyncIterator, IAsyncIListProvider { private readonly Func> selector; From e762b9295d6c85aa66d65fc840349a0e9d857d95 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 6 Sep 2017 10:01:04 -0700 Subject: [PATCH 365/862] Adding a perf suite to compare interface designs. --- Ix.NET/Source/FasterLinq/FasterLinq.csproj | 8 + Ix.NET/Source/FasterLinq/Program.cs | 1570 ++++++++++++++++++++ Ix.NET/Source/Ix.NET.sln | 19 + 3 files changed, 1597 insertions(+) create mode 100644 Ix.NET/Source/FasterLinq/FasterLinq.csproj create mode 100644 Ix.NET/Source/FasterLinq/Program.cs diff --git a/Ix.NET/Source/FasterLinq/FasterLinq.csproj b/Ix.NET/Source/FasterLinq/FasterLinq.csproj new file mode 100644 index 0000000000..abb9969a56 --- /dev/null +++ b/Ix.NET/Source/FasterLinq/FasterLinq.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp1.1 + + + diff --git a/Ix.NET/Source/FasterLinq/Program.cs b/Ix.NET/Source/FasterLinq/Program.cs new file mode 100644 index 0000000000..51e2b79999 --- /dev/null +++ b/Ix.NET/Source/FasterLinq/Program.cs @@ -0,0 +1,1570 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Labs.Linq; +using System.Threading.Tasks; + +namespace FasterLinq +{ + class Program + { + static void Main(string[] args) + { + var N = 4; + + Sync(N); + Async1(N).Wait(); + Async2(N).Wait(); + } + + static void Sync(int n) + { + Console.WriteLine("IEnumerable and IFastEnumerable"); + Console.WriteLine(); + + var sw = new Stopwatch(); + + var N = 10_000_000; + + var next = new Action(_ => { }); + + var slowRange = Enumerable.Range(0, N); + var fastRange = FastEnumerable.Range(0, N); + var brdgRange = slowRange.ToFastEnumerable(); + + var slow = slowRange.Where(x => x % 2 == 0).Select(x => x + 1); + var fast = fastRange.Where(x => x % 2 == 0).Select(x => x + 1); + var brdg = brdgRange.Where(x => x % 2 == 0).Select(x => x + 1).ToEnumerable(); + + Console.WriteLine("slow.Sum() = " + slow.Aggregate(0, (sum, x) => sum + x)); + Console.WriteLine("fast.Sum() = " + fast.Aggregate(0, (sum, x) => sum + x)); + Console.WriteLine("brdg.Sum() = " + brdg.Aggregate(0, (sum, x) => sum + x)); + Console.WriteLine(); + + for (var i = 0; i < n; i++) + { + sw.Restart(); + { + slow.ForEach(next); + } + Console.WriteLine("SLOW " + sw.Elapsed); + + sw.Restart(); + { + fast.ForEach(next); + } + Console.WriteLine("FAST " + sw.Elapsed); + + sw.Restart(); + { + brdg.ForEach(next); + } + Console.WriteLine("BRDG " + sw.Elapsed); + + Console.WriteLine(); + } + + Console.WriteLine(); + } + + static async Task Async1(int n) + { + Console.WriteLine("IAsyncEnumerable and IAsyncFastEnumerable - Synchronous query operators"); + Console.WriteLine(); + + var sw = new Stopwatch(); + + var N = 10_000_000; + + var next = new Func(_ => Task.CompletedTask); + + var slowRange = AsyncEnumerable.Range(0, N); + var fastRange = AsyncFastEnumerable.Range(0, N); + var brdgRange = slowRange.ToAsyncFastEnumerable(); + + var slow = slowRange.Where(x => x % 2 == 0).Select(x => x + 1); + var fast = fastRange.Where(x => x % 2 == 0).Select(x => x + 1); + var brdg = brdgRange.Where(x => x % 2 == 0).Select(x => x + 1).ToAsyncEnumerable(); + + Console.WriteLine("slow.Sum() = " + slow.Aggregate(0, (sum, x) => sum + x).Result); + Console.WriteLine("fast.Sum() = " + fast.Aggregate(0, (sum, x) => sum + x).Result); + Console.WriteLine("brdg.Sum() = " + brdg.Aggregate(0, (sum, x) => sum + x).Result); + Console.WriteLine(); + + for (var i = 0; i < n; i++) + { + sw.Restart(); + { + await slow.ForEachAsync(next); + } + Console.WriteLine("SLOW " + sw.Elapsed); + + sw.Restart(); + { + await fast.ForEachAsync(next); + } + Console.WriteLine("FAST " + sw.Elapsed); + + sw.Restart(); + { + await brdg.ForEachAsync(next); + } + Console.WriteLine("BRDG " + sw.Elapsed); + + Console.WriteLine(); + } + + Console.WriteLine(); + } + + static async Task Async2(int n) + { + Console.WriteLine("IAsyncEnumerable and IAsyncFastEnumerable - Asynchronous query operators"); + Console.WriteLine(); + + var sw = new Stopwatch(); + + var N = 10_000_000; + + var next = new Func(_ => Task.CompletedTask); + + var slowRange = AsyncEnumerable.Range(0, N); + var fastRange = AsyncFastEnumerable.Range(0, N); + var brdgRange = slowRange.ToAsyncFastEnumerable(); + + var slow = slowRange.Where(x => Task.FromResult(x % 2 == 0)).Select(x => Task.FromResult(x + 1)); + var fast = fastRange.Where(x => Task.FromResult(x % 2 == 0)).Select(x => Task.FromResult(x + 1)); + var brdg = brdgRange.Where(x => Task.FromResult(x % 2 == 0)).Select(x => Task.FromResult(x + 1)).ToAsyncEnumerable(); + + Console.WriteLine("slow.Sum() = " + slow.Aggregate(0, (sum, x) => sum + x).Result); + Console.WriteLine("fast.Sum() = " + fast.Aggregate(0, (sum, x) => sum + x).Result); + Console.WriteLine("brdg.Sum() = " + brdg.Aggregate(0, (sum, x) => sum + x).Result); + Console.WriteLine(); + + for (var i = 0; i < n; i++) + { + sw.Restart(); + { + await slow.ForEachAsync(next); + } + Console.WriteLine("SLOW " + sw.Elapsed); + + sw.Restart(); + { + await fast.ForEachAsync(next); + } + Console.WriteLine("FAST " + sw.Elapsed); + + sw.Restart(); + { + await brdg.ForEachAsync(next); + } + Console.WriteLine("BRDG " + sw.Elapsed); + + Console.WriteLine(); + } + + Console.WriteLine(); + } + } +} + +namespace System +{ + public interface IAsyncDisposable + { + Task DisposeAsync(); + } +} + +namespace System.Collections.Generic +{ + public interface IAsyncEnumerable + { + IAsyncEnumerator GetAsyncEnumerator(); + } + + public interface IAsyncEnumerator : IAsyncDisposable + { + Task MoveNextAsync(); + T Current { get; } + } + + public interface IFastEnumerable + { + IFastEnumerator GetEnumerator(); + } + + public interface IFastEnumerator : IDisposable + { + T TryGetNext(out bool success); + } + + public interface IAsyncFastEnumerable + { + IAsyncFastEnumerator GetAsyncEnumerator(); + } + + public interface IAsyncFastEnumerator : IAsyncDisposable + { + Task WaitForNextAsync(); + T TryGetNext(out bool success); + } +} + +namespace System.Labs.Linq +{ + internal abstract class Iterator : IEnumerable, IEnumerator + { + private readonly int _threadId; + internal int _state; + protected T _current; + + protected Iterator() + { + _threadId = Environment.CurrentManagedThreadId; + } + + public abstract Iterator Clone(); + + public virtual void Dispose() + { + _state = -1; + } + + public IEnumerator GetEnumerator() + { + Iterator enumerator = _state == 0 && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); + enumerator._state = 1; + return enumerator; + } + + public abstract bool MoveNext(); + + public T Current => _current; + + object IEnumerator.Current => _current; + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + public void Reset() => throw new NotSupportedException(); + } + + internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator + { + private readonly int _threadId; + internal int _state; + protected T _current; + + protected AsyncIterator() + { + _threadId = Environment.CurrentManagedThreadId; + } + + public abstract AsyncIterator Clone(); + + public virtual Task DisposeAsync() + { + _state = -1; + return Task.CompletedTask; + } + + public IAsyncEnumerator GetAsyncEnumerator() + { + AsyncIterator enumerator = _state == 0 && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); + enumerator._state = 1; + return enumerator; + } + + public abstract Task MoveNextAsync(); + + public T Current => _current; + } + + internal abstract class FastIterator : IFastEnumerable, IFastEnumerator + { + private readonly int _threadId; + internal int _state; + + protected FastIterator() + { + _threadId = Environment.CurrentManagedThreadId; + } + + public abstract FastIterator Clone(); + + public virtual void Dispose() + { + _state = -1; + } + + public IFastEnumerator GetEnumerator() + { + FastIterator enumerator = _state == 0 && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); + enumerator._state = 1; + return enumerator; + } + + public abstract T TryGetNext(out bool success); + } + + internal abstract class AsyncFastIterator : IAsyncFastEnumerable, IAsyncFastEnumerator + { + private readonly int _threadId; + internal int _state; + + protected AsyncFastIterator() + { + _threadId = Environment.CurrentManagedThreadId; + } + + public abstract AsyncFastIterator Clone(); + + public virtual Task DisposeAsync() + { + _state = -1; + return Task.CompletedTask; + } + + public IAsyncFastEnumerator GetAsyncEnumerator() + { + AsyncFastIterator enumerator = _state == 0 && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); + enumerator._state = 1; + return enumerator; + } + + public abstract Task WaitForNextAsync(); + + public abstract T TryGetNext(out bool success); + } + + public static class Enumerable + { + public static R Aggregate(this IEnumerable source, R seed, Func aggregate) + { + var res = seed; + + foreach (var item in source) + { + res = aggregate(res, item); + } + + return res; + } + + public static IEnumerable Empty() => EmptyIterator.Instance; + + public static void ForEach(this IEnumerable source, Action next) + { + foreach (var item in source) + { + next(item); + } + } + + public static IEnumerable Range(int start, int count) => new RangeIterator(start, count); + + public static IEnumerable Select(this IEnumerable source, Func selector) => new SelectIterator(source, selector); + + public static IEnumerable Where(this IEnumerable source, Func predicate) => new WhereIterator(source, predicate); + + private sealed class EmptyIterator : IEnumerable, IEnumerator + { + public static readonly EmptyIterator Instance = new EmptyIterator(); + + public T Current => default(T); + + object IEnumerator.Current => default(T); + + public void Dispose() { } + + public IEnumerator GetEnumerator() => this; + + public bool MoveNext() => false; + + public void Reset() { } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } + + private sealed class RangeIterator : Iterator + { + private readonly int _start; + private readonly int _end; + private int _next; + + public RangeIterator(int start, int count) + { + _start = start; + _end = start + count; + } + + public override Iterator Clone() => new RangeIterator(_start, _end - _start); + + public override bool MoveNext() + { + switch (_state) + { + case 1: + _next = _start; + _state = 2; + goto case 2; + + case 2: + if (_next < _end) + { + _current = _next++; + return true; + } + break; + } + + return false; + } + } + + private sealed class SelectIterator : Iterator + { + private readonly IEnumerable _source; + private readonly Func _selector; + private IEnumerator _enumerator; + + public SelectIterator(IEnumerable source, Func selector) + { + _source = source; + _selector = selector; + } + + public override Iterator Clone() => new SelectIterator(_source, _selector); + + public override bool MoveNext() + { + switch (_state) + { + case 1: + _enumerator = _source.GetEnumerator(); + _state = 2; + goto case 2; + + case 2: + if (_enumerator.MoveNext()) + { + _current = _selector(_enumerator.Current); + return true; + } + break; + } + + return false; + } + + public override void Dispose() => _enumerator?.Dispose(); + } + + private sealed class WhereIterator : Iterator + { + private readonly IEnumerable _source; + private readonly Func _predicate; + private IEnumerator _enumerator; + + public WhereIterator(IEnumerable source, Func predicate) + { + _source = source; + _predicate = predicate; + } + + public override Iterator Clone() => new WhereIterator(_source, _predicate); + + public override bool MoveNext() + { + switch (_state) + { + case 1: + _enumerator = _source.GetEnumerator(); + _state = 2; + goto case 2; + + case 2: + while (_enumerator.MoveNext()) + { + var item = _enumerator.Current; + + if (_predicate(item)) + { + _current = item; + return true; + } + } + break; + } + + return false; + } + + public override void Dispose() => _enumerator?.Dispose(); + } + } + + public static class FastEnumerable + { + public static R Aggregate(this IFastEnumerable source, R seed, Func aggregate) + { + var res = seed; + + using (var e = source.GetEnumerator()) + { + while (true) + { + var item = e.TryGetNext(out var success); + + if (!success) + { + break; + } + + res = aggregate(res, item); + } + } + + return res; + } + + public static IFastEnumerable Empty() => EmptyIterator.Instance; + + public static void ForEach(this IFastEnumerable source, Action next) + { + using (var e = source.GetEnumerator()) + { + while (true) + { + var item = e.TryGetNext(out var success); + + if (!success) + { + break; + } + + next(item); + } + } + } + + public static IFastEnumerable Range(int start, int count) => new RangeIterator(start, count); + + public static IFastEnumerable Select(this IFastEnumerable source, Func selector) => new SelectFastIterator(source, selector); + + public static IFastEnumerable ToFastEnumerable(this IEnumerable source) => new EnumerableToFastEnumerable(source); + + public static IEnumerable ToEnumerable(this IFastEnumerable source) => new FastEnumerableToEnumerable(source); + + public static IFastEnumerable Where(this IFastEnumerable source, Func predicate) => new WhereFastIterator(source, predicate); + + private sealed class EmptyIterator : IFastEnumerable, IFastEnumerator + { + public static readonly EmptyIterator Instance = new EmptyIterator(); + + public void Dispose() { } + + public IFastEnumerator GetEnumerator() => this; + + public T TryGetNext(out bool success) + { + success = false; + return default(T); + } + } + + private sealed class EnumerableToFastEnumerable : FastIterator + { + private readonly IEnumerable _source; + private IEnumerator _enumerator; + + public EnumerableToFastEnumerable(IEnumerable source) + { + _source = source; + } + + public override FastIterator Clone() => new EnumerableToFastEnumerable(_source); + + public override T TryGetNext(out bool success) + { + switch (_state) + { + case 1: + _enumerator = _source.GetEnumerator(); + _state = 2; + goto case 2; + + case 2: + success = _enumerator.MoveNext(); + if (success) + { + return _enumerator.Current; + } + break; + } + + success = false; + return default(T); + } + + public override void Dispose() => _enumerator?.Dispose(); + } + + private sealed class FastEnumerableToEnumerable : Iterator + { + private readonly IFastEnumerable _source; + private IFastEnumerator _enumerator; + + public FastEnumerableToEnumerable(IFastEnumerable source) + { + _source = source; + } + + public override Iterator Clone() => new FastEnumerableToEnumerable(_source); + + public override bool MoveNext() + { + switch (_state) + { + case 1: + _enumerator = _source.GetEnumerator(); + _state = 2; + goto case 2; + + case 2: + _current = _enumerator.TryGetNext(out var success); + return success; + } + + return false; + } + + public override void Dispose() => _enumerator?.Dispose(); + } + + private sealed class RangeIterator : FastIterator + { + private readonly int _start; + private readonly int _end; + private int _next; + + public RangeIterator(int start, int count) + { + _start = start; + _end = start + count; + } + + public override FastIterator Clone() => new RangeIterator(_start, _end - _start); + + public override int TryGetNext(out bool success) + { + switch (_state) + { + case 1: + _next = _start; + _state = 2; + goto case 2; + + case 2: + if (_next < _end) + { + success = true; + return _next++; + } + break; + } + + success = false; + return default(int); + } + } + + private sealed class SelectFastIterator : FastIterator + { + private readonly IFastEnumerable _source; + private readonly Func _selector; + private IFastEnumerator _enumerator; + + public SelectFastIterator(IFastEnumerable source, Func selector) + { + _source = source; + _selector = selector; + } + + public override FastIterator Clone() => new SelectFastIterator(_source, _selector); + + public override R TryGetNext(out bool success) + { + switch (_state) + { + case 1: + _enumerator = _source.GetEnumerator(); + _state = 2; + goto case 2; + + case 2: + var item = _enumerator.TryGetNext(out success); + if (success) + { + return _selector(item); + } + break; + } + + success = false; + return default(R); + } + + public override void Dispose() => _enumerator?.Dispose(); + } + + private sealed class WhereFastIterator : FastIterator + { + private readonly IFastEnumerable _source; + private readonly Func _predicate; + private IFastEnumerator _enumerator; + + public WhereFastIterator(IFastEnumerable source, Func predicate) + { + _source = source; + _predicate = predicate; + } + + public override FastIterator Clone() => new WhereFastIterator(_source, _predicate); + + public override T TryGetNext(out bool success) + { + switch (_state) + { + case 1: + _enumerator = _source.GetEnumerator(); + _state = 2; + goto case 2; + + case 2: + while (true) + { + var item = _enumerator.TryGetNext(out success); + if (!success) + { + break; + } + + if (_predicate(item)) + { + return item; + } + } + break; + } + + success = false; + return default(T); + } + + public override void Dispose() => _enumerator?.Dispose(); + } + } + + public static class AsyncEnumerable + { + private static readonly Task True = Task.FromResult(true); + private static readonly Task False = Task.FromResult(false); + + public static async Task Aggregate(this IAsyncEnumerable source, R seed, Func aggregate) + { + var res = seed; + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + res = aggregate(res, e.Current); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return res; + } + + public static async Task Aggregate(this IAsyncEnumerable source, R seed, Func> aggregate) + { + var res = seed; + + var e = source.GetAsyncEnumerator(); + + try + { + while (true) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + res = await aggregate(res, e.Current).ConfigureAwait(false); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return res; + } + + public static IAsyncEnumerable Empty() => EmptyIterator.Instance; + + public static async Task ForEachAsync(this IAsyncEnumerable source, Func next) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var item = e.Current; + await next(item).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + public static IAsyncEnumerable Range(int start, int count) => new RangeIterator(start, count); + + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func selector) => new SelectIterator(source, selector); + + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => new SelectIteratorWithTask(source, selector); + + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func predicate) => new WhereIterator(source, predicate); + + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => new WhereIteratorWithTask(source, predicate); + + private sealed class EmptyIterator : IAsyncEnumerable, IAsyncEnumerator + { + public static readonly EmptyIterator Instance = new EmptyIterator(); + + public T Current => default(T); + + public Task DisposeAsync() => Task.CompletedTask; + + public IAsyncEnumerator GetAsyncEnumerator() => this; + + public Task MoveNextAsync() => False; + } + + private sealed class RangeIterator : AsyncIterator + { + private readonly int _start; + private readonly int _end; + private int _next; + + public RangeIterator(int start, int count) + { + _start = start; + _end = start + count; + } + + public override AsyncIterator Clone() => new RangeIterator(_start, _end - _start); + + public override Task MoveNextAsync() + { + switch (_state) + { + case 1: + _next = _start; + _state = 2; + goto case 2; + + case 2: + if (_next < _end) + { + _current = _next++; + return True; + } + break; + } + + return False; + } + } + + private sealed class SelectIterator : AsyncIterator + { + private readonly IAsyncEnumerable _source; + private readonly Func _selector; + private IAsyncEnumerator _enumerator; + + public SelectIterator(IAsyncEnumerable source, Func selector) + { + _source = source; + _selector = selector; + } + + public override AsyncIterator Clone() => new SelectIterator(_source, _selector); + + public override async Task MoveNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _selector(_enumerator.Current); + return true; + } + break; + } + + return false; + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + } + + private sealed class SelectIteratorWithTask : AsyncIterator + { + private readonly IAsyncEnumerable _source; + private readonly Func> _selector; + private IAsyncEnumerator _enumerator; + + public SelectIteratorWithTask(IAsyncEnumerable source, Func> selector) + { + _source = source; + _selector = selector; + } + + public override AsyncIterator Clone() => new SelectIteratorWithTask(_source, _selector); + + public override async Task MoveNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = await _selector(_enumerator.Current).ConfigureAwait(false); + return true; + } + break; + } + + return false; + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + } + + private sealed class WhereIterator : AsyncIterator + { + private readonly IAsyncEnumerable _source; + private readonly Func _predicate; + private IAsyncEnumerator _enumerator; + + public WhereIterator(IAsyncEnumerable source, Func predicate) + { + _source = source; + _predicate = predicate; + } + + public override AsyncIterator Clone() => new WhereIterator(_source, _predicate); + + public override async Task MoveNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + + if (_predicate(item)) + { + _current = item; + return true; + } + } + break; + } + + return false; + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + } + + private sealed class WhereIteratorWithTask : AsyncIterator + { + private readonly IAsyncEnumerable _source; + private readonly Func> _predicate; + private IAsyncEnumerator _enumerator; + + public WhereIteratorWithTask(IAsyncEnumerable source, Func> predicate) + { + _source = source; + _predicate = predicate; + } + + public override AsyncIterator Clone() => new WhereIteratorWithTask(_source, _predicate); + + public override async Task MoveNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + + if (await _predicate(item).ConfigureAwait(false)) + { + _current = item; + return true; + } + } + break; + } + + return false; + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + } + } + + public static class AsyncFastEnumerable + { + private static readonly Task True = Task.FromResult(true); + private static readonly Task False = Task.FromResult(false); + + public static async Task Aggregate(this IAsyncFastEnumerable source, R seed, Func aggregate) + { + var res = seed; + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.WaitForNextAsync().ConfigureAwait(false)) + { + while (true) + { + var item = e.TryGetNext(out var success); + + if (!success) + { + break; + } + + res = aggregate(res, item); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return res; + } + + public static async Task Aggregate(this IAsyncFastEnumerable source, R seed, Func> aggregate) + { + var res = seed; + + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.WaitForNextAsync().ConfigureAwait(false)) + { + while (true) + { + var item = e.TryGetNext(out var success); + + if (!success) + { + break; + } + + res = await aggregate(res, item).ConfigureAwait(false); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return res; + } + + public static IAsyncFastEnumerable Empty() => EmptyIterator.Instance; + + public static async Task ForEachAsync(this IAsyncFastEnumerable source, Func next) + { + var e = source.GetAsyncEnumerator(); + + try + { + while (await e.WaitForNextAsync().ConfigureAwait(false)) + { + while (true) + { + var item = e.TryGetNext(out var success); + + if (!success) + { + break; + } + + await next(item).ConfigureAwait(false); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + public static IAsyncFastEnumerable Range(int start, int count) => new RangeIterator(start, count); + + public static IAsyncFastEnumerable Select(this IAsyncFastEnumerable source, Func selector) => new SelectFastIterator(source, selector); + + public static IAsyncFastEnumerable Select(this IAsyncFastEnumerable source, Func> selector) => new SelectFastIteratorWithTask(source, selector); + + public static IAsyncFastEnumerable ToAsyncFastEnumerable(this IAsyncEnumerable source) => new AsyncEnumerableToAsyncFastEnumerable(source); + + public static IAsyncEnumerable ToAsyncEnumerable(this IAsyncFastEnumerable source) => new AsyncFastEnumerableToAsyncEnumerable(source); + + public static IAsyncFastEnumerable Where(this IAsyncFastEnumerable source, Func predicate) => new WhereFastIterator(source, predicate); + + public static IAsyncFastEnumerable Where(this IAsyncFastEnumerable source, Func> predicate) => new WhereFastIteratorWithTask(source, predicate); + + private sealed class EmptyIterator : IAsyncFastEnumerable, IAsyncFastEnumerator + { + public static readonly EmptyIterator Instance = new EmptyIterator(); + + public Task DisposeAsync() => Task.CompletedTask; + + public IAsyncFastEnumerator GetAsyncEnumerator() => this; + + public T TryGetNext(out bool success) + { + success = false; + return default(T); + } + + public Task WaitForNextAsync() => False; + } + + private sealed class AsyncEnumerableToAsyncFastEnumerable : AsyncFastIterator + { + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; + private bool _hasNext; + + public AsyncEnumerableToAsyncFastEnumerable(IAsyncEnumerable source) + { + _source = source; + } + + public override AsyncFastIterator Clone() => new AsyncEnumerableToAsyncFastEnumerable(_source); + + public override T TryGetNext(out bool success) + { + success = _hasNext; + _hasNext = false; + + return success ? _enumerator.Current : default(T); + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + + public override async Task WaitForNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + _hasNext = await _enumerator.MoveNextAsync().ConfigureAwait(false); + return _hasNext; + } + + return false; + } + } + + private sealed class AsyncFastEnumerableToAsyncEnumerable : AsyncIterator + { + private readonly IAsyncFastEnumerable _source; + private IAsyncFastEnumerator _enumerator; + + public AsyncFastEnumerableToAsyncEnumerable(IAsyncFastEnumerable source) + { + _source = source; + } + + public override AsyncIterator Clone() => new AsyncFastEnumerableToAsyncEnumerable(_source); + + public override async Task MoveNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + do + { + while (true) + { + var item = _enumerator.TryGetNext(out var success); + + if (!success) + { + break; + } + else + { + _current = item; + return true; + } + } + } while (await _enumerator.WaitForNextAsync().ConfigureAwait(false)); + + break; + } + + return false; + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + } + + private sealed class RangeIterator : AsyncFastIterator + { + private readonly int _start; + private readonly int _end; + private int _next; + + public RangeIterator(int start, int count) + { + _start = start; + _end = start + count; + } + + public override AsyncFastIterator Clone() => new RangeIterator(_start, _end - _start); + + public override int TryGetNext(out bool success) + { + if (_state == 2 && _next < _end) + { + success = true; + return _next++; + } + + success = false; + return default(int); + } + + public override Task WaitForNextAsync() + { + switch (_state) + { + case 1: + _next = _start; + _state = 2; + goto case 2; + + case 2: + if (_next < _end) + { + return True; + } + break; + } + + return False; + } + } + + private sealed class SelectFastIterator : AsyncFastIterator + { + private readonly IAsyncFastEnumerable _source; + private readonly Func _selector; + private IAsyncFastEnumerator _enumerator; + + public SelectFastIterator(IAsyncFastEnumerable source, Func selector) + { + _source = source; + _selector = selector; + } + + public override AsyncFastIterator Clone() => new SelectFastIterator(_source, _selector); + + public override R TryGetNext(out bool success) + { + if (_enumerator != null) + { + var item = _enumerator.TryGetNext(out success); + if (success) + { + return _selector(item); + } + } + + success = false; + return default(R); + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + + public override Task WaitForNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + return _enumerator.WaitForNextAsync(); + } + + return False; + } + } + + private sealed class SelectFastIteratorWithTask : AsyncFastIterator + { + private readonly IAsyncFastEnumerable _source; + private readonly Func> _selector; + private IAsyncFastEnumerator _enumerator; + private bool _hasNext; + private R _next; + + public SelectFastIteratorWithTask(IAsyncFastEnumerable source, Func> selector) + { + _source = source; + _selector = selector; + } + + public override AsyncFastIterator Clone() => new SelectFastIteratorWithTask(_source, _selector); + + public override R TryGetNext(out bool success) + { + success = _hasNext; + _hasNext = false; + + return success ? _next : default(R); + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + + public override async Task WaitForNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + do + { + while (true) + { + var item = _enumerator.TryGetNext(out var success); + + if (!success) + { + break; + } + else + { + _hasNext = true; + _next = await _selector(item).ConfigureAwait(false); + return true; + } + } + } + while (await _enumerator.WaitForNextAsync().ConfigureAwait(false)); + + break; + } + + _hasNext = false; + _next = default(R); + + return false; + } + } + + private sealed class WhereFastIterator : AsyncFastIterator + { + private readonly IAsyncFastEnumerable _source; + private readonly Func _predicate; + private IAsyncFastEnumerator _enumerator; + + public WhereFastIterator(IAsyncFastEnumerable source, Func predicate) + { + _source = source; + _predicate = predicate; + } + + public override AsyncFastIterator Clone() => new WhereFastIterator(_source, _predicate); + + public override T TryGetNext(out bool success) + { + if (_enumerator != null) + { + while (true) + { + var item = _enumerator.TryGetNext(out success); + if (!success) + { + break; + } + + if (_predicate(item)) + { + return item; + } + } + } + + success = false; + return default(T); + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + + public override Task WaitForNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + return _enumerator.WaitForNextAsync(); + } + + return False; + } + } + + private sealed class WhereFastIteratorWithTask : AsyncFastIterator + { + private readonly IAsyncFastEnumerable _source; + private readonly Func> _predicate; + private IAsyncFastEnumerator _enumerator; + private bool _hasNext; + private T _next; + + public WhereFastIteratorWithTask(IAsyncFastEnumerable source, Func> predicate) + { + _source = source; + _predicate = predicate; + } + + public override AsyncFastIterator Clone() => new WhereFastIteratorWithTask(_source, _predicate); + + public override T TryGetNext(out bool success) + { + success = _hasNext; + _hasNext = false; + + return success ? _next : default(T); + } + + public override Task DisposeAsync() => _enumerator?.DisposeAsync() ?? Task.CompletedTask; + + public override async Task WaitForNextAsync() + { + switch (_state) + { + case 1: + _enumerator = _source.GetAsyncEnumerator(); + _state = 2; + goto case 2; + + case 2: + do + { + while (true) + { + var item = _enumerator.TryGetNext(out var success); + + if (!success) + { + break; + } + else + { + if (await _predicate(item).ConfigureAwait(false)) + { + _hasNext = true; + _next = item; + return true; + } + } + } + } + while (await _enumerator.WaitForNextAsync().ConfigureAwait(false)); + + break; + } + + _hasNext = false; + _next = default(T); + + return false; + } + } + } +} diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index 49ca6aa248..b1e1e7760c 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -51,6 +51,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers.Tests", "System.Interactive.Async.Providers.Tests\System.Interactive.Async.Providers.Tests.csproj", "{974056C0-91BD-4EB6-8431-E30A614FD1D4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FasterLinq", "FasterLinq\FasterLinq.csproj", "{1C966C34-0AA1-44D8-9E7D-C7866958F2D6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -295,6 +297,22 @@ Global {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x64.Build.0 = Release|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.ActiveCfg = Release|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.Build.0 = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|ARM.ActiveCfg = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|ARM.Build.0 = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x64.ActiveCfg = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x64.Build.0 = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x86.Build.0 = Debug|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|Any CPU.Build.0 = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|ARM.ActiveCfg = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|ARM.Build.0 = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x64.ActiveCfg = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x64.Build.0 = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x86.ActiveCfg = Release|Any CPU + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -314,6 +332,7 @@ Global {2E23D7AD-0B21-4725-87C4-BD43271260A1} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {134E9066-6217-4AF0-B408-47D92AB595BD} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {974056C0-91BD-4EB6-8431-E30A614FD1D4} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} + {1C966C34-0AA1-44D8-9E7D-C7866958F2D6} = {61683064-A120-44A7-A174-E19154F6D84F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} From d4dde5f89a54b5a7e14a6c1b71a9423bed06e2c4 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:41:23 -0400 Subject: [PATCH 366/862] Update extras --- Ix.NET/Source/global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index 43a4970c3c..eca09e09aa 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "MSBuild.Sdk.Extras": "1.6.30-preview" + "MSBuild.Sdk.Extras": "1.6.55" } } \ No newline at end of file From b96977dd15702ef9086b79d57f1e1f78014f3318 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:43:15 -0400 Subject: [PATCH 367/862] update tools --- Ix.NET/Source/Directory.build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index 0ce3e435d3..ca448ed5e1 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -20,8 +20,8 @@ - - + + From c279f09ea5963db60bb9448fe2ef5d00c0400dd1 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:43:36 -0400 Subject: [PATCH 368/862] remove extra config --- Ix.NET/Source/version.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Ix.NET/Source/version.json b/Ix.NET/Source/version.json index e7f88e00b7..22bb3a922a 100644 --- a/Ix.NET/Source/version.json +++ b/Ix.NET/Source/version.json @@ -6,10 +6,5 @@ ], "nugetPackageVersion":{ "semVer": 2 - }, - "cloudBuild": { - "buildNumber": { - "enabled": false - } } } From 42508755ae0c0223b6889e73b542e40af2a994f9 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:49:31 -0400 Subject: [PATCH 369/862] remove aptca --- Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs b/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs index 640bf10dbe..ba897511a0 100644 --- a/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs +++ b/Ix.NET/Source/System.Linq.Async/Properties/AssemblyInfo.cs @@ -5,16 +5,9 @@ using System; using System.Resources; using System.Runtime.InteropServices; -using System.Security; [assembly: NeutralResourcesLanguage("en-US")] -#if !PLIB [assembly: ComVisible(false)] -#endif [assembly: CLSCompliant(true)] - -#if HAS_APTCA && NO_CODECOVERAGE -[assembly: AllowPartiallyTrustedCallers] -#endif From 8a8afbe06e89440703b424e5ffc7efa4eed3ada6 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:49:42 -0400 Subject: [PATCH 370/862] use correct pipelines --- Ix.NET/Source/Ix.NET.sln | 110 +-------------------------------------- 1 file changed, 2 insertions(+), 108 deletions(-) diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index fe65936aa9..cfd446e16e 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -7,9 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{87534290-A EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B733D97A-F1ED-4FC3-BF8E-9AC47A89DE96}" ProjectSection(SolutionItems) = preProject - ..\..\.vsts.ix-ci.yml = ..\..\.vsts.ix-ci.yml - ..\..\.vsts.ix-pr.yml = ..\..\.vsts.ix-pr.yml - ..\..\.vsts.ix-shared.yml = ..\..\.vsts.ix-shared.yml + ..\..\azure-pipelines.ix.yml = ..\..\azure-pipelines.ix.yml CodeCoverage.runsettings = CodeCoverage.runsettings Directory.build.props = Directory.build.props Directory.build.targets = Directory.build.targets @@ -47,6 +45,7 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers.Tests", "System.Interactive.Async.Providers.Tests\System.Interactive.Async.Providers.Tests.csproj", "{974056C0-91BD-4EB6-8431-E30A614FD1D4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FasterLinq", "FasterLinq\FasterLinq.csproj", "{1C966C34-0AA1-44D8-9E7D-C7866958F2D6}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Refs", "Refs", "{A3D72E6E-4ADA-42E0-8B2A-055B1F244281}" ProjectSection(SolutionItems) = preProject refs\Directory.build.props = refs\Directory.build.props @@ -88,140 +87,38 @@ Global {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.Build.0 = Release|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|ARM.ActiveCfg = Release|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|ARM.Build.0 = Release|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|x64.ActiveCfg = Release|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|x64.Build.0 = Release|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|x86.ActiveCfg = Release|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|x86.Build.0 = Release|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|ARM.ActiveCfg = Debug|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|ARM.Build.0 = Debug|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x64.ActiveCfg = Debug|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x64.Build.0 = Debug|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x86.ActiveCfg = Debug|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|x86.Build.0 = Debug|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.Build.0 = Release|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|ARM.ActiveCfg = Release|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|ARM.Build.0 = Release|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x64.ActiveCfg = Release|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x64.Build.0 = Release|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x86.ActiveCfg = Release|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|x86.Build.0 = Release|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|ARM.ActiveCfg = Debug|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|ARM.Build.0 = Debug|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x64.ActiveCfg = Debug|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x64.Build.0 = Debug|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x86.ActiveCfg = Debug|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|x86.Build.0 = Debug|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.ActiveCfg = Release|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.Build.0 = Release|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|ARM.ActiveCfg = Release|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|ARM.Build.0 = Release|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x64.ActiveCfg = Release|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x64.Build.0 = Release|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x86.ActiveCfg = Release|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|x86.Build.0 = Release|Any CPU {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|ARM.ActiveCfg = Debug|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|ARM.Build.0 = Debug|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x64.ActiveCfg = Debug|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x64.Build.0 = Debug|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x86.ActiveCfg = Debug|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Debug|x86.Build.0 = Debug|Any CPU {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|Any CPU.ActiveCfg = Release|Any CPU {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|Any CPU.Build.0 = Release|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|ARM.ActiveCfg = Release|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|ARM.Build.0 = Release|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x64.ActiveCfg = Release|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x64.Build.0 = Release|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x86.ActiveCfg = Release|Any CPU - {CFDA4685-B2AF-46FE-81C1-55A291B9B1B0}.Release|x86.Build.0 = Release|Any CPU {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|ARM.ActiveCfg = Debug|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|ARM.Build.0 = Debug|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x64.ActiveCfg = Debug|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x64.Build.0 = Debug|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x86.ActiveCfg = Debug|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Debug|x86.Build.0 = Debug|Any CPU {792093F9-83E4-4630-9652-4328FDAED15F}.Release|Any CPU.ActiveCfg = Release|Any CPU {792093F9-83E4-4630-9652-4328FDAED15F}.Release|Any CPU.Build.0 = Release|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Release|ARM.ActiveCfg = Release|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Release|ARM.Build.0 = Release|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x64.ActiveCfg = Release|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x64.Build.0 = Release|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x86.ActiveCfg = Release|Any CPU - {792093F9-83E4-4630-9652-4328FDAED15F}.Release|x86.Build.0 = Release|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|ARM.ActiveCfg = Debug|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|ARM.Build.0 = Debug|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x64.ActiveCfg = Debug|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x64.Build.0 = Debug|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|x86.Build.0 = Debug|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.Build.0 = Release|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|ARM.ActiveCfg = Release|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|ARM.Build.0 = Release|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x64.ActiveCfg = Release|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x64.Build.0 = Release|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x86.ActiveCfg = Release|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|x86.Build.0 = Release|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|ARM.ActiveCfg = Debug|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|ARM.Build.0 = Debug|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x64.ActiveCfg = Debug|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x64.Build.0 = Debug|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x86.ActiveCfg = Debug|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|x86.Build.0 = Debug|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.Build.0 = Release|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|ARM.ActiveCfg = Release|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|ARM.Build.0 = Release|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x64.ActiveCfg = Release|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x64.Build.0 = Release|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.ActiveCfg = Release|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|x86.Build.0 = Release|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|ARM.ActiveCfg = Debug|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|ARM.Build.0 = Debug|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x64.ActiveCfg = Debug|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x64.Build.0 = Debug|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x86.ActiveCfg = Debug|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|x86.Build.0 = Debug|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.Build.0 = Release|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|ARM.ActiveCfg = Release|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|ARM.Build.0 = Release|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x64.ActiveCfg = Release|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x64.Build.0 = Release|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.ActiveCfg = Release|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|x86.Build.0 = Release|Any CPU {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|ARM.ActiveCfg = Debug|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|ARM.Build.0 = Debug|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x64.ActiveCfg = Debug|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x64.Build.0 = Debug|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x86.ActiveCfg = Debug|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Debug|x86.Build.0 = Debug|Any CPU {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|Any CPU.Build.0 = Release|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|ARM.ActiveCfg = Release|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|ARM.Build.0 = Release|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x64.ActiveCfg = Release|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x64.Build.0 = Release|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x86.ActiveCfg = Release|Any CPU - {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|x86.Build.0 = Release|Any CPU {2EC0C302-B029-4DDB-AC91-000BF11006AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2EC0C302-B029-4DDB-AC91-000BF11006AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {2EC0C302-B029-4DDB-AC91-000BF11006AD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -243,7 +140,6 @@ Global {A9F6D09B-15B9-4CE8-867F-6F3383C5F247} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} {CA7B7136-13EE-4F01-BC22-722875EE8569} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} - {ED118703-9773-4193-BC2A-966C29BC1A46} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {AFD2E6EC-C5B0-4276-A14A-467D786D0DDA} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {172BD8C4-5C3E-4928-9D3F-746CF336FFEC} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} @@ -254,8 +150,6 @@ Global {134E9066-6217-4AF0-B408-47D92AB595BD} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {974056C0-91BD-4EB6-8431-E30A614FD1D4} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {1C966C34-0AA1-44D8-9E7D-C7866958F2D6} = {61683064-A120-44A7-A174-E19154F6D84F} - {AFD2E6EC-C5B0-4276-A14A-467D786D0DDA} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} {2EC0C302-B029-4DDB-AC91-000BF11006AD} = {A3D72E6E-4ADA-42E0-8B2A-055B1F244281} {5DF341BE-B369-4250-AFD4-604DE8C95E45} = {A3D72E6E-4ADA-42E0-8B2A-055B1F244281} EndGlobalSection From 5845aec5d371ce9682cfc551d075e40c0c45a337 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:52:47 -0400 Subject: [PATCH 371/862] Update to 1.4 --- Ix.NET/Source/Directory.build.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 919ba0264b..365cfa55c9 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -4,7 +4,7 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION - + $(DefineConstants);NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION From 46cea986597b8b0723aafbe7bdc40ceeabec2764 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:53:08 -0400 Subject: [PATCH 372/862] Add netstandard2.0 target --- Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 2851661d8a..3859625730 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -1,7 +1,7 @@ - + - net46;netstandard1.4 + net46;netstandard1.4;netstandard2.0 @@ -37,8 +37,4 @@ - - - - From c2d08404e8ea3b7c08b3a829b87cf3aa0d4ffa19 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 14:59:36 -0400 Subject: [PATCH 373/862] Don't build ref assms directly in the sln level --- Ix.NET/Source/Ix.NET.sln | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index cfd446e16e..5f90d1b479 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -120,13 +120,9 @@ Global {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {1C966C34-0AA1-44D8-9E7D-C7866958F2D6}.Release|Any CPU.Build.0 = Release|Any CPU {2EC0C302-B029-4DDB-AC91-000BF11006AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2EC0C302-B029-4DDB-AC91-000BF11006AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {2EC0C302-B029-4DDB-AC91-000BF11006AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2EC0C302-B029-4DDB-AC91-000BF11006AD}.Release|Any CPU.Build.0 = Release|Any CPU {5DF341BE-B369-4250-AFD4-604DE8C95E45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5DF341BE-B369-4250-AFD4-604DE8C95E45}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DF341BE-B369-4250-AFD4-604DE8C95E45}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5DF341BE-B369-4250-AFD4-604DE8C95E45}.Release|Any CPU.Build.0 = Release|Any CPU {3285529A-8227-4D40-B524-1A1F919F0E7B}.Debug|Any CPU.ActiveCfg = Current Sources|Any CPU {3285529A-8227-4D40-B524-1A1F919F0E7B}.Debug|Any CPU.Build.0 = Current Sources|Any CPU {3285529A-8227-4D40-B524-1A1F919F0E7B}.Release|Any CPU.ActiveCfg = Current Sources|Any CPU From 6bbf23237ba35eb7203705081569c2d8c2049dda Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 15:19:03 -0400 Subject: [PATCH 374/862] TFM updates. ArrayEmpty --- Ix.NET/Source/ApiCompare/ApiCompare.csproj | 4 ++-- Ix.NET/Source/ApiCompare/Program.cs | 2 +- Ix.NET/Source/Directory.build.targets | 2 +- Ix.NET/Source/FasterLinq/FasterLinq.csproj | 4 ++-- Ix.NET/Source/Playground/Playground.csproj | 4 ++-- ...System.Interactive.Async.Providers.Tests.csproj | 14 ++++---------- .../System.Interactive.Async.Providers.csproj | 6 +----- .../System.Interactive.Async.Tests.csproj | 8 ++++---- .../System.Interactive.Async.csproj | 11 +++-------- .../System.Interactive.Tests.csproj | 8 ++++---- .../System/Linq/Operators/SkipLast.cs | 2 ++ .../System/Linq/Operators/TakeLast.cs | 2 ++ .../System.Linq.Async.Queryable.Tests.csproj | 10 ++++------ .../System.Linq.Async.Queryable.csproj | 8 ++------ .../System.Linq.Async.Tests.csproj | 10 ++++------ .../System.Linq.Async/System.Linq.Async.csproj | 2 +- .../System/Linq/AsyncEnumerablePartition.cs | 4 ++++ .../System/Linq/AsyncListPartition.cs | 8 +++++++- .../System/Linq/Operators/Empty.cs | 8 +++++++- Ix.NET/Source/refs/Directory.build.props | 2 ++ 20 files changed, 59 insertions(+), 60 deletions(-) diff --git a/Ix.NET/Source/ApiCompare/ApiCompare.csproj b/Ix.NET/Source/ApiCompare/ApiCompare.csproj index 57c9f373de..18e24b63a0 100644 --- a/Ix.NET/Source/ApiCompare/ApiCompare.csproj +++ b/Ix.NET/Source/ApiCompare/ApiCompare.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp1.1 + netcoreapp2.1 diff --git a/Ix.NET/Source/ApiCompare/Program.cs b/Ix.NET/Source/ApiCompare/Program.cs index 689084710a..8ea0effd56 100644 --- a/Ix.NET/Source/ApiCompare/Program.cs +++ b/Ix.NET/Source/ApiCompare/Program.cs @@ -314,7 +314,7 @@ private static Type GetAsyncVariant(Type type) { var ret = typeof(Task<>).MakeGenericType(args.Last()); - return Expression.GetFuncType(args.SkipLast(1).Append(ret).ToArray()); + return Expression.GetFuncType(Enumerable.SkipLast(args, 1).Append(ret).ToArray()); } else { diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 365cfa55c9..e43257ab08 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -8,7 +8,7 @@ $(DefineConstants);NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION - $(DefineConstants);NO_ARRAY_EMPTY + $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION diff --git a/Ix.NET/Source/FasterLinq/FasterLinq.csproj b/Ix.NET/Source/FasterLinq/FasterLinq.csproj index abb9969a56..c130f44d18 100644 --- a/Ix.NET/Source/FasterLinq/FasterLinq.csproj +++ b/Ix.NET/Source/FasterLinq/FasterLinq.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp1.1 + netcoreapp2.1 diff --git a/Ix.NET/Source/Playground/Playground.csproj b/Ix.NET/Source/Playground/Playground.csproj index 57c9f373de..18e24b63a0 100644 --- a/Ix.NET/Source/Playground/Playground.csproj +++ b/Ix.NET/Source/Playground/Playground.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp1.1 + netcoreapp2.1 diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj index ad450d908b..d5d26b5a1e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp1.1;net461 + netcoreapp2.1;net461 $(NoWarn);CS0618 @@ -19,13 +19,11 @@ - - + + - - - + @@ -35,10 +33,6 @@ - - - - True diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index 08c20d218a..a305d2f244 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -3,8 +3,7 @@ Interactive Extensions Async Providers Library used to build query providers and express queries over async enumerable sequences. Interactive Extensions - Async Providers Library - net46;netstandard1.4 - net45;netstandard1.0;netstandard2.0 + net45;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous @@ -26,7 +25,4 @@ - - - diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index f30ebaa2a3..774634f815 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;netcoreapp1.1;net461 + netcoreapp2.1;net461 $(NoWarn);CS0618 @@ -19,11 +19,11 @@ - - + + - + diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index c346e94539..3e60c50a47 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -2,9 +2,8 @@ Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. - Interactive Extensions - Async Library - net46;netstandard1.4 - net45;net46;netstandard1.0;netstandard1.3;netstandard2.0 + Interactive Extensions - Async Library + net45;net46;netstandard1.4;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous @@ -15,9 +14,5 @@ - - - - - + diff --git a/Ix.NET/Source/System.Interactive.Tests/System.Interactive.Tests.csproj b/Ix.NET/Source/System.Interactive.Tests/System.Interactive.Tests.csproj index c097552c60..4234e637df 100644 --- a/Ix.NET/Source/System.Interactive.Tests/System.Interactive.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Tests/System.Interactive.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;netcoreapp1.1;net461 + netcoreapp2.1;net461 $(NoWarn);CS0618 @@ -17,11 +17,11 @@ - - + + - + diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs index b793526e89..1484f0d172 100644 --- a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/SkipLast.cs @@ -8,6 +8,7 @@ namespace Tests { +#if !NETCOREAPP2_1 public class SkipLast : Tests { [Fact] @@ -41,4 +42,5 @@ public void SkipLast_Part() Assert.True(Enumerable.SequenceEqual(r, e.Take(2))); } } +#endif } diff --git a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs index ff865bbec1..af21962701 100644 --- a/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/TakeLast.cs @@ -8,6 +8,7 @@ namespace Tests { +#if !NETCOREAPP2_1 public class TakeLast : Tests { [Fact] @@ -49,4 +50,5 @@ public void TakeLast_Part() Assert.True(Enumerable.SequenceEqual(r, e.Skip(2))); } } +#endif } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj index 476bc1779b..41a7f60df2 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp1.1;net461 + netcoreapp2.1;net461 $(NoWarn);CS0618 @@ -18,13 +18,11 @@ - - + + - - - + diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index a969da16db..c174c290c1 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -1,17 +1,13 @@ - + - net46;netstandard1.4 + net45;net46;netstandard1.4;netstandard2.0 - - - - AsyncQueryable.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index 9cfe536513..f5119dfb4d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp1.1;net461 + netcoreapp2.1;net461 $(NoWarn);CS0618 @@ -17,13 +17,11 @@ - - + + - - - + diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 3859625730..420194de1c 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -1,7 +1,7 @@  - net46;netstandard1.4;netstandard2.0 + net45;net46;netstandard1.4;netstandard2.0 diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 8bb31f0a9b..7bf474f44a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -315,7 +315,11 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) await en.DisposeAsync().ConfigureAwait(false); } +#if NO_ARRAY_EMPTY + return EmptyArray.Value; +#else return Array.Empty(); +#endif } public async Task> ToListAsync(CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 0ee0ef5bc6..5392a1af9d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -142,7 +142,13 @@ public Task ToArrayAsync(CancellationToken cancellationToken) var count = Count; if (count == 0) { - return Task.FromResult(Array.Empty()); + return Task.FromResult( +#if NO_ARRAY_EMPTY + EmptyArray.Value +#else + Array.Empty() +#endif + ); } var array = new TSource[count]; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 1728b641ea..849d16067e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -24,7 +24,13 @@ internal sealed class EmptyAsyncIterator : IAsyncPartition, IAsy public IAsyncPartition Take(int count) => this; - public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(Array.Empty()); + public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult( +#if NO_ARRAY_EMPTY + EmptyArray.Value +#else + Array.Empty() +#endif + ); public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); diff --git a/Ix.NET/Source/refs/Directory.build.props b/Ix.NET/Source/refs/Directory.build.props index 43c81129e7..8441a3178b 100644 --- a/Ix.NET/Source/refs/Directory.build.props +++ b/Ix.NET/Source/refs/Directory.build.props @@ -5,6 +5,8 @@ 2.1 + + $(DefineConstants);REFERENCE_ASSEMBLY From 14a1dba258d4a3d414be30a49e6d3272d78d6666 Mon Sep 17 00:00:00 2001 From: akarnokd Date: Fri, 5 Oct 2018 22:26:16 +0200 Subject: [PATCH 375/862] IxCS8: Allow Share to be disposed --- .../System/Linq/Operators/Share.cs | 102 ++++++++++++------ 1 file changed, 69 insertions(+), 33 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs index 27fa31931f..be9dfa4f0b 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/Share.cs @@ -2,32 +2,35 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; namespace System.Linq { public static partial class EnumerableEx { /// - /// Creates a buffer with a shared view over the source sequence, causing each enumerator to fetch the next element - /// from the source sequence. + /// Creates a buffer with a shared view over the source sequence, causing each enumerator to fetch the next element + /// from the source sequence. /// /// Source sequence element type. /// Source sequence. /// Buffer enabling each enumerator to retrieve elements from the shared source sequence. /// - /// var rng = Enumerable.Range(0, 10).Share(); - /// var e1 = rng.GetEnumerator(); // Both e1 and e2 will consume elements from - /// var e2 = rng.GetEnumerator(); // the source sequence. - /// Assert.IsTrue(e1.MoveNext()); - /// Assert.AreEqual(0, e1.Current); - /// Assert.IsTrue(e1.MoveNext()); - /// Assert.AreEqual(1, e1.Current); - /// Assert.IsTrue(e2.MoveNext()); // e2 "steals" element 2 - /// Assert.AreEqual(2, e2.Current); - /// Assert.IsTrue(e1.MoveNext()); // e1 can't see element 2 - /// Assert.AreEqual(3, e1.Current); + /// var rng = Enumerable.Range(0, 10).Share(); + /// var e1 = rng.GetEnumerator(); // Both e1 and e2 will consume elements from + /// var e2 = rng.GetEnumerator(); // the source sequence. + /// Assert.IsTrue(e1.MoveNext()); + /// Assert.AreEqual(0, e1.Current); + /// Assert.IsTrue(e1.MoveNext()); + /// Assert.AreEqual(1, e1.Current); + /// Assert.IsTrue(e2.MoveNext()); // e2 "steals" element 2 + /// Assert.AreEqual(2, e2.Current); + /// Assert.IsTrue(e1.MoveNext()); // e1 can't see element 2 + /// Assert.AreEqual(3, e1.Current); /// public static IBuffer Share(this IEnumerable source) { @@ -38,8 +41,8 @@ public static IBuffer Share(this IEnumerable source) } /// - /// Shares the source sequence within a selector function where each enumerator can fetch the next element from the - /// source sequence. + /// Shares the source sequence within a selector function where each enumerator can fetch the next element from the + /// source sequence. /// /// Source sequence element type. /// Result sequence element type. @@ -53,10 +56,11 @@ public static IEnumerable Share(this IEnumerable selector(source.Share()).GetEnumerator()); + return Create(() => selector(source.Share()) + .GetEnumerator()); } - private sealed class SharedBuffer : IBuffer + private class SharedBuffer : IBuffer { private bool _disposed; private IEnumerator _source; @@ -71,7 +75,7 @@ public IEnumerator GetEnumerator() if (_disposed) throw new ObjectDisposedException(""); - return GetEnumeratorCore(); + return GetEnumerator_(); } IEnumerator IEnumerable.GetEnumerator() @@ -96,34 +100,66 @@ public void Dispose() } } - private IEnumerator GetEnumeratorCore() + private IEnumerator GetEnumerator_() { - while (true) + return new ShareEnumerator(this); + } + + sealed class ShareEnumerator : IEnumerator + { + readonly SharedBuffer _parent; + + T _current; + + bool _disposed; + + public ShareEnumerator(SharedBuffer parent) { - if (_disposed) - throw new ObjectDisposedException(""); + _parent = parent; + } + + public T Current => _current; + + object IEnumerator.Current => _current; - var hasValue = default(bool); - var current = default(T); + public void Dispose() + { + _disposed = true; + } - lock (_source) + public bool MoveNext() + { + if (_disposed) + { + return false; + } + if (_parent._disposed) { - hasValue = _source.MoveNext(); + throw new ObjectDisposedException(""); + } + var hasValue = false; + var src = _parent._source; + lock (src) + { + hasValue = src.MoveNext(); if (hasValue) { - current = _source.Current; + _current = src.Current; } } - if (hasValue) { - yield return current; - } - else - { - break; + return true; } + _disposed = true; + _current = default(T); + return false; + } + + public void Reset() + { + throw new NotSupportedException(); } } } From 812308825f646fd3c87a48561ff525df2d6c1373 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 16:43:18 -0400 Subject: [PATCH 376/862] Update to use latest interface spec --- .../AsyncTests.Bugs.cs | 8 ++--- .../System.Interactive.Async/AsyncIterator.cs | 6 ++-- .../System/Linq/Operators/Amb.cs | 18 +++++------ .../System/Linq/Operators/Buffer.cs | 4 +-- .../System/Linq/Operators/Catch.cs | 12 +++---- .../System/Linq/Operators/Concat.cs | 8 ++--- .../System/Linq/Operators/Distinct.cs | 8 ++--- .../Linq/Operators/DistinctUntilChanged.cs | 12 +++---- .../System/Linq/Operators/Do.cs | 8 ++--- .../System/Linq/Operators/Expand.cs | 8 ++--- .../System/Linq/Operators/Finally.cs | 8 ++--- .../System/Linq/Operators/Generate.cs | 4 +-- .../System/Linq/Operators/IgnoreElements.cs | 4 +-- .../System/Linq/Operators/Merge.cs | 14 ++++---- .../Linq/Operators/OnErrorResumeNext.cs | 4 +-- .../System/Linq/Operators/Repeat.cs | 6 ++-- .../System/Linq/Operators/Scan.cs | 16 +++++----- .../System/Linq/Operators/Throw.cs | 4 +-- .../System/Linq/Operators/Timeout.cs | 6 ++-- .../System/Linq/Operators/Using.cs | 8 ++--- .../System.Interactive.Async/TaskExt.cs | 8 ++--- .../System.Linq.Async.csproj | 4 +++ .../Collections/Generic/IAsyncEnumerator.cs | 2 +- .../System/IAsyncDisposable.cs | 2 +- .../System/Linq/AsyncEnumerable.cs | 4 +-- .../System/Linq/AsyncEnumerablePartition.cs | 4 +-- .../System/Linq/AsyncEnumerator.cs | 16 +++++----- .../System/Linq/AsyncIterator.cs | 6 ++-- .../System/Linq/AsyncListPartition.cs | 2 +- .../System/Linq/Operators/AppendPrepend.cs | 8 ++--- .../System/Linq/Operators/Concat.cs | 4 +-- .../System/Linq/Operators/Create.cs | 14 ++++---- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +-- .../System/Linq/Operators/Distinct.cs | 4 +-- .../System/Linq/Operators/Empty.cs | 4 +-- .../System/Linq/Operators/Except.cs | 6 ++-- .../System/Linq/Operators/GroupBy.cs | 24 +++++++------- .../System/Linq/Operators/GroupJoin.cs | 8 ++--- .../System/Linq/Operators/Intersect.cs | 6 ++-- .../System/Linq/Operators/Join.cs | 8 ++--- .../Linq/Operators/OrderedAsyncEnumerable.cs | 8 ++--- .../System/Linq/Operators/Range.cs | 2 +- .../System/Linq/Operators/Repeat.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 4 +-- .../System/Linq/Operators/Select.cs | 24 +++++++------- .../System/Linq/Operators/SelectMany.cs | 32 +++++++++---------- .../System/Linq/Operators/SkipLast.cs | 4 +-- .../System/Linq/Operators/SkipWhile.cs | 16 +++++----- .../System/Linq/Operators/TakeLast.cs | 4 +-- .../System/Linq/Operators/TakeWhile.cs | 16 +++++----- .../Linq/Operators/ToAsyncEnumerable.cs | 18 +++++------ .../System/Linq/Operators/ToEnumerable.cs | 3 +- .../System/Linq/Operators/ToObservable.cs | 2 +- .../System/Linq/Operators/Union.cs | 4 +-- .../System/Linq/Operators/Where.cs | 20 ++++++------ .../System/Linq/Operators/Zip.cs | 13 ++++---- .../Tasks/AsyncEnumerableExtensions.cs | 4 +-- .../System/Threading/Tasks/TaskExt.cs | 6 ++-- 58 files changed, 246 insertions(+), 240 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 4006b3dad0..f969db3b57 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -138,15 +138,15 @@ public Enumerator(DisposeCounter disposeCounter) _disposeCounter = disposeCounter; } - public Task DisposeAsync() + public ValueTask DisposeAsync() { _disposeCounter.DisposeCount++; - return Task.FromResult(true); + return new ValueTask(Task.FromResult(true)); } - public Task MoveNextAsync() + public ValueTask MoveNextAsync() { - return Task.Factory.StartNew(() => false); + return new ValueTask(Task.Factory.StartNew(() => false)); } public object Current { get; private set; } diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index b8e0bbd014..2fea47070c 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -43,7 +43,7 @@ public IAsyncEnumerator GetAsyncEnumerator() return enumerator; } - public virtual Task DisposeAsync() + public virtual ValueTask DisposeAsync() { current = default(TSource); state = AsyncIteratorState.Disposed; @@ -62,7 +62,7 @@ public TSource Current } } - public async Task MoveNextAsync() + public async ValueTask MoveNextAsync() { // Note: MoveNext *must* be implemented as an async method to ensure // that any exceptions thrown from the MoveNextCore call are handled @@ -91,7 +91,7 @@ public async Task MoveNextAsync() public abstract AsyncIterator Clone(); - protected abstract Task MoveNextCore(); + protected abstract ValueTask MoveNextCore(); protected virtual void OnGetEnumerator() { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index ea49f55c79..d634f0723b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -57,7 +57,7 @@ public override AsyncIterator Clone() return new AmbAsyncIterator(first, second); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -68,7 +68,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -76,8 +76,8 @@ protected override async Task MoveNextCore() var firstEnumerator = first.GetAsyncEnumerator(); var secondEnumerator = second.GetAsyncEnumerator(); - var firstMoveNext = firstEnumerator.MoveNextAsync(); - var secondMoveNext = secondEnumerator.MoveNextAsync(); + var firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); + var secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); var winner = await Task.WhenAny(firstMoveNext, secondMoveNext).ConfigureAwait(false); @@ -152,7 +152,7 @@ public override AsyncIterator Clone() return new AmbAsyncIteratorN(sources); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -163,7 +163,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -171,7 +171,7 @@ protected override async Task MoveNextCore() var n = sources.Length; var enumerators = new IAsyncEnumerator[n]; - var moveNexts = new Task[n]; + var moveNexts = new ValueTask[n]; for (var i = 0; i < n; i++) { @@ -181,7 +181,7 @@ protected override async Task MoveNextCore() moveNexts[i] = enumerator.MoveNextAsync(); } - var winner = await Task.WhenAny(moveNexts).ConfigureAwait(false); + var winner = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); // // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: @@ -200,7 +200,7 @@ protected override async Task MoveNextCore() { if (i != winnerIndex) { - var ignored = moveNexts[i].ContinueWith(_ => + var ignored = moveNexts[i].AsTask().ContinueWith(_ => { enumerators[i].DisposeAsync(); }); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 662657af38..c3df5bd981 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -70,7 +70,7 @@ public override AsyncIterator> Clone() return new BufferAsyncIterator(source, count, skip); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -83,7 +83,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 37f6682b3d..678554ff2e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -86,7 +86,7 @@ public override AsyncIterator Clone() return new CatchAsyncIterator(source, handler); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -97,7 +97,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -179,7 +179,7 @@ public override AsyncIterator Clone() return new CatchAsyncIteratorWithTask(source, handler); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -190,7 +190,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -271,7 +271,7 @@ public override AsyncIterator Clone() return new CatchAsyncIterator(sources); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourcesEnumerator != null) { @@ -290,7 +290,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index 8a33974be1..2309a3bd67 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -55,7 +55,7 @@ public override AsyncIterator Clone() return new ConcatEnumerableAsyncIterator(source); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (outerEnumerator != null) { @@ -80,7 +80,7 @@ public override async Task DisposeAsync() private const int State_OuterNext = 1; private const int State_While = 4; - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) @@ -145,7 +145,7 @@ public override AsyncIterator Clone() return new ConcatAsyncEnumerableAsyncIterator(source); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (outerEnumerator != null) { @@ -170,7 +170,7 @@ public override async Task DisposeAsync() private const int State_OuterNext = 1; private const int State_While = 4; - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index de152d38d5..b8fc6ef2f4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -133,7 +133,7 @@ public override AsyncIterator Clone() return new DistinctAsyncIterator(source, keySelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -145,7 +145,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -279,7 +279,7 @@ public override AsyncIterator Clone() return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -291,7 +291,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index ff6443e79f..6be807026a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -110,7 +110,7 @@ public override AsyncIterator Clone() return new DistinctUntilChangedAsyncIterator(source, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -122,7 +122,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -181,7 +181,7 @@ public override AsyncIterator Clone() return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -193,7 +193,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -252,7 +252,7 @@ public override AsyncIterator Clone() return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -264,7 +264,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index a751eef49a..ec6b57ab0b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -151,7 +151,7 @@ public override AsyncIterator Clone() return new DoAsyncIterator(source, onNext, onError, onCompleted); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -162,7 +162,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -227,7 +227,7 @@ public override AsyncIterator Clone() return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -238,7 +238,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 5daa5d91cf..e969ec6e5c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -53,7 +53,7 @@ public override AsyncIterator Clone() return new ExpandAsyncIterator(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -66,7 +66,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -143,7 +143,7 @@ public override AsyncIterator Clone() return new ExpandAsyncIteratorWithTask(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -156,7 +156,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index e9d60f308a..35f3fefb8b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -51,7 +51,7 @@ public override AsyncIterator Clone() return new FinallyAsyncIterator(source, finallyAction); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -64,7 +64,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -109,7 +109,7 @@ public override AsyncIterator Clone() return new FinallyAsyncIteratorWithTask(source, finallyAction); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -122,7 +122,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 3202f2b8c7..1facf03d43 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -58,14 +58,14 @@ public override AsyncIterator Clone() return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { currentState = default; await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index bf36cfb1b1..f5ef5ad29f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -37,7 +37,7 @@ public override AsyncIterator Clone() return new IgnoreElementsAsyncIterator(source); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -48,7 +48,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index a60c40c9ae..5e0fb414ad 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -39,7 +39,7 @@ private sealed class MergeAsyncIterator : AsyncIterator private readonly IAsyncEnumerable[] sources; private IAsyncEnumerator[] enumerators; - private Task[] moveNexts; + private ValueTask[] moveNexts; private int active; public MergeAsyncIterator(IAsyncEnumerable[] sources) @@ -54,13 +54,13 @@ public override AsyncIterator Clone() return new MergeAsyncIterator(sources); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerators != null) { var n = enumerators.Length; - var disposes = new Task[n]; + var disposes = new ValueTask[n]; for (var i = 0; i < n; i++) { @@ -68,14 +68,14 @@ public override async Task DisposeAsync() disposes[i] = dispose; } - await Task.WhenAll(disposes).ConfigureAwait(false); + await Task.WhenAll(disposes.Select(t => t.AsTask())).ConfigureAwait(false); enumerators = null; } await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -83,7 +83,7 @@ protected override async Task MoveNextCore() var n = sources.Length; enumerators = new IAsyncEnumerator[n]; - moveNexts = new Task[n]; + moveNexts = new ValueTask[n]; active = n; for (var i = 0; i < n; i++) @@ -105,7 +105,7 @@ protected override async Task MoveNextCore() // want to consider a "prefer fairness" option. // - var moveNext = await Task.WhenAny(moveNexts).ConfigureAwait(false); + var moveNext = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); var index = Array.IndexOf(moveNexts, moveNext); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index 805285ce3d..e4bf54fe6d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -60,7 +60,7 @@ public override AsyncIterator Clone() return new OnErrorResumeNextAsyncIterator(sources); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourcesEnumerator != null) { @@ -77,7 +77,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index a1ca5459f0..bb29fb72ff 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -47,7 +47,7 @@ public override AsyncIterator Clone() return new RepeatElementAsyncIterator(element); } - protected override Task MoveNextCore() + protected override ValueTask MoveNextCore() { current = element; return TaskExt.True; @@ -78,7 +78,7 @@ public override AsyncIterator Clone() return new RepeatSequenceAsyncIterator(source, count); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -89,7 +89,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 4850d8ef38..df8535d92a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -74,7 +74,7 @@ public override AsyncIterator Clone() return new ScanAsyncEnumerable(source, accumulator); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -86,7 +86,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -148,7 +148,7 @@ public override AsyncIterator Clone() return new ScanAsyncEnumerable(source, seed, accumulator); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -160,7 +160,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -212,7 +212,7 @@ public override AsyncIterator Clone() return new ScanAsyncEnumerableWithTask(source, accumulator); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -224,7 +224,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -286,7 +286,7 @@ public override AsyncIterator Clone() return new ScanAsyncEnumerableWithTask(source, seed, accumulator); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -298,7 +298,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index c54e7bb90e..4874356541 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -17,9 +17,9 @@ public static IAsyncEnumerable Throw(Exception exception) #if NO_TASK_FROMEXCEPTION var tcs = new TaskCompletionSource(); tcs.TrySetException(exception); - var moveNextThrows = tcs.Task; + var moveNextThrows = new ValueTask(tcs.Task); #else - var moveNextThrows = Task.FromException(exception); + var moveNextThrows = new ValueTask(Task.FromException(exception)); #endif return AsyncEnumerable.CreateEnumerable( diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index f2562b13f2..063140b12c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -43,7 +43,7 @@ public override AsyncIterator Clone() return new TimeoutAsyncIterator(source, timeout); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -54,7 +54,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -73,7 +73,7 @@ protected override async Task MoveNextCore() { var delay = Task.Delay(timeout, delayCts.Token); - var winner = await Task.WhenAny(moveNext, delay).ConfigureAwait(false); + var winner = await Task.WhenAny(moveNext.AsTask(), delay).ConfigureAwait(false); if (winner == delay) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index afed1c0462..4d160d231c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -53,7 +53,7 @@ public override AsyncIterator Clone() return new UsingAsyncIterator(resourceFactory, enumerableFactory); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -70,7 +70,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -125,7 +125,7 @@ public override AsyncIterator Clone() return new UsingAsyncIteratorWithTask(resourceFactory, enumerableFactory); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -142,7 +142,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index d1a2917d35..0f8caa233f 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -6,9 +6,9 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly Task True = Task.FromResult(true); - public static readonly Task False = Task.FromResult(false); - public static readonly Task Never = new TaskCompletionSource().Task; - public static readonly Task CompletedTask = True; + public static readonly ValueTask True = new ValueTask(true); + public static readonly ValueTask False = new ValueTask(false); + public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); + public static readonly ValueTask Never = new ValueTask(new TaskCompletionSource().Task); } } diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 420194de1c..1d19bf9f63 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -4,6 +4,10 @@ net45;net46;netstandard1.4;netstandard2.0 + + + + Average.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs index 1b1e3bf80f..aeaa540e0b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs @@ -27,6 +27,6 @@ public interface IAsyncEnumerator : IAsyncDisposable /// Task containing the result of the operation: true if the enumerator was successfully advanced /// to the next element; false if the enumerator has passed the end of the sequence. /// - Task MoveNextAsync(); + ValueTask MoveNextAsync(); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs b/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs index e2fa721ac2..c98144ef74 100644 --- a/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs @@ -11,6 +11,6 @@ namespace System { public interface IAsyncDisposable { - Task DisposeAsync(); + ValueTask DisposeAsync(); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index f1e22bd0f1..235d974ad4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -25,9 +25,9 @@ private static IAsyncEnumerable Throw(Exception exception) #if NO_TASK_FROMEXCEPTION var tcs = new TaskCompletionSource(); tcs.TrySetException(exception); - var moveNextThrows = tcs.Task; + var moveNextThrows = new ValueTask(tcs.Task); #else - var moveNextThrows = Task.FromException(exception); + var moveNextThrows = new ValueTask(Task.FromException(exception)); #endif return CreateEnumerable( diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 7bf474f44a..967c965f7a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -51,7 +51,7 @@ public override AsyncIterator Clone() return new AsyncEnumerablePartition(_source, _minIndexInclusive, _maxIndexInclusive); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (_enumerator != null) { @@ -102,7 +102,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell private bool hasSkipped; private int taken; - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index a386de8abe..7426162d20 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -22,7 +22,7 @@ public static class AsyncEnumerator /// The delegate implementing the property getter. /// The delegate implementing the method. /// A new enumerator instance. - public static IAsyncEnumerator Create(Func> moveNext, Func current, Func dispose) + public static IAsyncEnumerator Create(Func> moveNext, Func current, Func dispose) { if (moveNext == null) throw new ArgumentNullException(nameof(moveNext)); @@ -42,7 +42,7 @@ public static IAsyncEnumerator Create(Func> moveNext, Func c /// Task containing the result of the operation: true if the enumerator was successfully advanced /// to the next element; false if the enumerator has passed the end of the sequence. /// - public static Task MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) + public static ValueTask MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -90,7 +90,7 @@ public static IAsyncEnumerable AsEnumerable(this IAsyncEnumerator sourc return AsyncEnumerable.CreateEnumerable(() => source); } - internal static IAsyncEnumerator Create(Func, Task> moveNext, Func current, Func dispose) + internal static IAsyncEnumerator Create(Func, ValueTask> moveNext, Func current, Func dispose) { return new AnonymousAsyncIterator( async () => @@ -107,10 +107,10 @@ internal static IAsyncEnumerator Create(Func, T private sealed class AnonymousAsyncIterator : AsyncIterator { private readonly Func currentFunc; - private readonly Func> moveNext; - private Func dispose; + private readonly Func> moveNext; + private Func dispose; - public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) + public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) { Debug.Assert(moveNext != null); @@ -127,7 +127,7 @@ public override AsyncIterator Clone() throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator."); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { var dispose = Interlocked.Exchange(ref this.dispose, null); @@ -139,7 +139,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 9269a24a71..e472b6fdb4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -43,7 +43,7 @@ public IAsyncEnumerator GetAsyncEnumerator() return enumerator; } - public virtual Task DisposeAsync() + public virtual ValueTask DisposeAsync() { current = default(TSource); state = AsyncIteratorState.Disposed; @@ -62,7 +62,7 @@ public TSource Current } } - public async Task MoveNextAsync() + public async ValueTask MoveNextAsync() { // Note: MoveNext *must* be implemented as an async method to ensure // that any exceptions thrown from the MoveNextCore call are handled @@ -111,7 +111,7 @@ public virtual IAsyncEnumerable Where(Func> predica return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); } - protected abstract Task MoveNextCore(); + protected abstract ValueTask MoveNextCore(); protected virtual void OnGetEnumerator() { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 5392a1af9d..daff90ae87 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -38,7 +38,7 @@ public override AsyncIterator Clone() return new AsyncListPartition(_source, _minIndexInclusive, _maxIndexInclusive); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { if ((uint)_index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && _index < _source.Count - _minIndexInclusive) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index e90566e834..529349edd4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -75,7 +75,7 @@ protected async Task LoadFromEnumeratorAsync() return false; } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -110,7 +110,7 @@ public override AsyncIterator Clone() return new AppendPrepend1AsyncIterator(source, item, appending); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -304,7 +304,7 @@ public override AsyncIterator Clone() int mode; IEnumerator appendedEnumerator; - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (appendedEnumerator != null) { @@ -315,7 +315,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index cdf66475be..61787a5c39 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -126,7 +126,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return count; } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -137,7 +137,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { if (state == AsyncIteratorState.Allocated) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index 3785786bd9..52028b185c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -27,12 +27,12 @@ public static IAsyncEnumerable CreateEnumerable(Func(getEnumerator); } - public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Func dispose) + public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Func dispose) { return AsyncEnumerator.Create(moveNext, current, dispose); } - private static IAsyncEnumerator CreateEnumerator(Func, Task> moveNext, Func current, Func dispose) + private static IAsyncEnumerator CreateEnumerator(Func, ValueTask> moveNext, Func current, Func dispose) { return AsyncEnumerator.Create(moveNext, current, dispose); } @@ -87,7 +87,7 @@ public T Current } } - public async Task DisposeAsync() + public async ValueTask DisposeAsync() { var old = Interlocked.Exchange(ref enumerator, DisposedEnumerator.Instance); @@ -97,7 +97,7 @@ public async Task DisposeAsync() } } - public Task MoveNextAsync() + public ValueTask MoveNextAsync() { if (enumerator == null) { @@ -107,7 +107,7 @@ public Task MoveNextAsync() return enumerator.MoveNextAsync(); } - private async Task InitAndMoveNextAsync() + private async ValueTask InitAndMoveNextAsync() { try { @@ -132,9 +132,9 @@ private sealed class DisposedEnumerator : IAsyncEnumerator public T Current => throw new ObjectDisposedException("this"); - public Task DisposeAsync() => TaskExt.CompletedTask; + public ValueTask DisposeAsync() => TaskExt.CompletedTask; - public Task MoveNextAsync() => throw new ObjectDisposedException("this"); + public ValueTask MoveNextAsync() => throw new ObjectDisposedException("this"); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index a2abcda6ed..163c3a0b10 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -52,7 +52,7 @@ public override AsyncIterator Clone() return new DefaultIfEmptyAsyncIterator(source, defaultValue); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -63,7 +63,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index cab881a348..a9c35c3c86 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -67,7 +67,7 @@ public override AsyncIterator Clone() return new DistinctAsyncIterator(source, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -79,7 +79,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 849d16067e..557f20064c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -40,11 +40,11 @@ public Task ToArrayAsync(CancellationToken cancellationToken) => Task. public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe()); - public Task MoveNextAsync() => TaskExt.False; + public ValueTask MoveNextAsync() => TaskExt.False; public IAsyncEnumerator GetAsyncEnumerator() => this; - public Task DisposeAsync() => TaskExt.CompletedTask; + public ValueTask DisposeAsync() => TaskExt.CompletedTask; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index ab18a21310..11dd6a9447 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -61,7 +61,7 @@ public override AsyncIterator Clone() return new ExceptAsyncIterator(first, second, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (firstEnumerator != null) { @@ -74,7 +74,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -95,7 +95,7 @@ protected override async Task MoveNextCore() { // This is here so we don't need to call Task.WhenAll each time after the set is filled var moveNextTask = firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask, fillSetTask).ConfigureAwait(false); + await Task.WhenAll(moveNextTask.AsTask(), fillSetTask).ConfigureAwait(false); setFilled = true; moveNext = moveNextTask.Result; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index d64de87650..f39321cfdb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -247,7 +247,7 @@ public override AsyncIterator Clone() return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -259,7 +259,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -336,7 +336,7 @@ public override AsyncIterator Clone() return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -348,7 +348,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -425,7 +425,7 @@ public override AsyncIterator> Clone() return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -437,7 +437,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -514,7 +514,7 @@ public override AsyncIterator> Clone() return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -526,7 +526,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -599,7 +599,7 @@ public override AsyncIterator> Clone() { return new GroupedAsyncEnumerable(source, keySelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -611,7 +611,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -684,7 +684,7 @@ public override AsyncIterator> Clone() { return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -696,7 +696,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 04cbcf3b82..a2658a2396 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -138,7 +138,7 @@ public GroupJoinAsyncEnumerator( _comparer = comparer; } - public async Task MoveNextAsync() + public async ValueTask MoveNextAsync() { // nothing to do if (!await _outer.MoveNextAsync().ConfigureAwait(false)) @@ -163,7 +163,7 @@ public async Task MoveNextAsync() public TResult Current { get; private set; } - public Task DisposeAsync() => _outer.DisposeAsync(); + public ValueTask DisposeAsync() => _outer.DisposeAsync(); } } @@ -228,7 +228,7 @@ public GroupJoinAsyncEnumeratorWithTask( _comparer = comparer; } - public async Task MoveNextAsync() + public async ValueTask MoveNextAsync() { // nothing to do if (!await _outer.MoveNextAsync().ConfigureAwait(false)) @@ -253,7 +253,7 @@ public async Task MoveNextAsync() public TResult Current { get; private set; } - public Task DisposeAsync() => _outer.DisposeAsync(); + public ValueTask DisposeAsync() => _outer.DisposeAsync(); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index d06f8148c3..94a04e7f58 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -61,7 +61,7 @@ public override AsyncIterator Clone() return new IntersectAsyncIterator(first, second, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (firstEnumerator != null) { @@ -74,7 +74,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -96,7 +96,7 @@ protected override async Task MoveNextCore() { // This is here so we don't need to call Task.WhenAll each time after the set is filled var moveNextTask = firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask, fillSetTask).ConfigureAwait(false); + await Task.WhenAll(moveNextTask.AsTask(), fillSetTask).ConfigureAwait(false); setFilled = true; moveNext = moveNextTask.Result; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 0100755aca..993f334481 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -111,7 +111,7 @@ public override AsyncIterator Clone() return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (outerEnumerator != null) { @@ -135,7 +135,7 @@ public override async Task DisposeAsync() private const int State_For = 3; private const int State_While = 4; - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -239,7 +239,7 @@ public override AsyncIterator Clone() return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (outerEnumerator != null) { @@ -263,7 +263,7 @@ public override async Task DisposeAsync() private const int State_For = 3; private const int State_While = 4; - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 5be08e8428..7e59b73ee5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -54,7 +54,7 @@ public override AsyncIterator Clone() return new OrderedAsyncEnumerable(source, keySelector, comparer, descending, parent); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -71,7 +71,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -141,7 +141,7 @@ public override AsyncIterator Clone() return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending, parent); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -158,7 +158,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index f18e202b5d..2c55e0dd10 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -107,7 +107,7 @@ public Task> TryGetElementAsync(int index, CancellationToken cancella public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(end - 1)); - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 01cef211c1..4d97c0a634 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -58,7 +58,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index 1f6b488072..dd2e2de891 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -83,13 +83,13 @@ public override AsyncIterator Clone() return new ReverseAsyncIterator(source); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { items = null; // Just in case this ends up being long-lived, allow the memory to be reclaimed. await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 0b00653712..14548b35c4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -102,7 +102,7 @@ public override AsyncIterator Clone() return new SelectEnumerableAsyncIterator(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -118,7 +118,7 @@ public override IAsyncEnumerable Select(Func(source, CombineSelectors(this.selector, selector)); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -163,7 +163,7 @@ public override AsyncIterator Clone() return new SelectEnumerableWithIndexAsyncIterator(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -174,7 +174,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -223,7 +223,7 @@ public override AsyncIterator Clone() return new SelectIListIterator(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -289,7 +289,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -334,7 +334,7 @@ public override AsyncIterator Clone() return new SelectEnumerableAsyncIteratorWithTask(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -350,7 +350,7 @@ public override IAsyncEnumerable Select(Func(source, CombineSelectors(this.selector, selector)); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -395,7 +395,7 @@ public override AsyncIterator Clone() return new SelectEnumerableWithIndexAsyncIteratorWithTask(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -406,7 +406,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -460,7 +460,7 @@ public override AsyncIterator Clone() return new SelectIListIteratorWithTask(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -526,7 +526,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken return res; } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 3c09d78317..90488b63f0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -124,7 +124,7 @@ public override AsyncIterator Clone() return new SelectManyAsyncIterator(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -141,7 +141,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -215,7 +215,7 @@ public override AsyncIterator Clone() return new SelectManyAsyncIteratorWithTask(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -232,7 +232,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -310,7 +310,7 @@ public override AsyncIterator Clone() return new SelectManyAsyncIterator(source, collectionSelector, resultSelector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -329,7 +329,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -408,7 +408,7 @@ public override AsyncIterator Clone() return new SelectManyAsyncIteratorWithTask(source, collectionSelector, resultSelector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -427,7 +427,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -507,7 +507,7 @@ public override AsyncIterator Clone() return new SelectManyWithIndexAsyncIterator(source, collectionSelector, resultSelector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -526,7 +526,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -613,7 +613,7 @@ public override AsyncIterator Clone() return new SelectManyWithIndexAsyncIteratorWithTask(source, collectionSelector, resultSelector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -632,7 +632,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -715,7 +715,7 @@ public override AsyncIterator Clone() return new SelectManyWithIndexAsyncIterator(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -732,7 +732,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -813,7 +813,7 @@ public override AsyncIterator Clone() return new SelectManyWithIndexAsyncIteratorWithTask(source, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (sourceEnumerator != null) { @@ -830,7 +830,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 46fbbc304f..f3d8709302 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -51,7 +51,7 @@ public override AsyncIterator Clone() return new SkipLastAsyncIterator(source, count); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -65,7 +65,7 @@ public override async Task DisposeAsync() } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 81ebae134c..61bbed003b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -72,7 +72,7 @@ public override AsyncIterator Clone() return new SkipWhileAsyncIterator(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -83,7 +83,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -149,7 +149,7 @@ public override AsyncIterator Clone() return new SkipWhileWithIndexAsyncIterator(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -160,7 +160,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -231,7 +231,7 @@ public override AsyncIterator Clone() return new SkipWhileAsyncIteratorWithTask(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -242,7 +242,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -308,7 +308,7 @@ public override AsyncIterator Clone() return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -319,7 +319,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index d32713349c..07aeaafeaa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -45,7 +45,7 @@ public override AsyncIterator Clone() return new TakeLastAsyncIterator(source, count); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -58,7 +58,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 510f64d78f..6ae1d50582 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -71,7 +71,7 @@ public override AsyncIterator Clone() return new TakeWhileAsyncIterator(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -82,7 +82,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -136,7 +136,7 @@ public override AsyncIterator Clone() return new TakeWhileWithIndexAsyncIterator(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -147,7 +147,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -205,7 +205,7 @@ public override AsyncIterator Clone() return new TakeWhileAsyncIteratorWithTask(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -216,7 +216,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -270,7 +270,7 @@ public override AsyncIterator Clone() return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -281,7 +281,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 5069b132e2..5552d546c4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -49,7 +49,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task value, - () => TaskExt.True); + () => TaskExt.CompletedTask); }); } @@ -106,14 +106,14 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva tcs.TrySetException(error); } - return tcs.Task; + return new ValueTask(tcs.Task); }, () => observer.Current, () => { subscription.Dispose(); // Should we cancel in-flight operations somehow? - return TaskExt.True; + return TaskExt.CompletedTask; }); }); } @@ -136,7 +136,7 @@ public override AsyncIterator Clone() return new AsyncEnumerableAdapter(source); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -147,7 +147,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -205,7 +205,7 @@ public override AsyncIterator Clone() return new AsyncIListEnumerableAdapter(source); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -216,7 +216,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -308,7 +308,7 @@ public override AsyncIterator Clone() return new AsyncICollectionEnumerableAdapter(source); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -319,7 +319,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs index df392cee80..6d5fb16840 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs @@ -34,7 +34,8 @@ private static IEnumerable ToEnumerableCore(IAsyncEnumerable observer) var e = source.GetAsyncEnumerator(); var f = default(Action); - f = () => e.MoveNextAsync().ContinueWith( + f = () => e.MoveNextAsync().AsTask().ContinueWith( async t => { if (t.IsFaulted) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index c93ff63dfd..496a5423be 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -54,7 +54,7 @@ protected UnionAsyncIterator(IEqualityComparer comparer) _comparer = comparer; } - public sealed override async Task DisposeAsync() + public sealed override async ValueTask DisposeAsync() { if (_enumerator != null) { @@ -107,7 +107,7 @@ private async Task GetNextAsync() return false; } - protected sealed override async Task MoveNextCore() + protected sealed override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index bc78e7c897..fe733817b3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -102,7 +102,7 @@ public override AsyncIterator Clone() return new WhereEnumerableAsyncIterator(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -123,7 +123,7 @@ public override IAsyncEnumerable Where(Func predicate) return new WhereEnumerableAsyncIterator(source, CombinePredicates(this.predicate, predicate)); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -173,7 +173,7 @@ public override AsyncIterator Clone() return new WhereEnumerableWithIndexAsyncIterator(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -184,7 +184,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -237,7 +237,7 @@ public override AsyncIterator Clone() return new WhereEnumerableAsyncIteratorWithTask(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -253,7 +253,7 @@ public override IAsyncEnumerable Where(Func> predic return new WhereEnumerableAsyncIteratorWithTask(source, CombinePredicates(this.predicate, predicate)); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -303,7 +303,7 @@ public override AsyncIterator Clone() return new WhereEnumerableWithIndexAsyncIteratorWithTask(source, predicate); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -314,7 +314,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -371,7 +371,7 @@ public override AsyncIterator Clone() return new WhereSelectEnumerableAsyncIterator(source, predicate, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (enumerator != null) { @@ -387,7 +387,7 @@ public override IAsyncEnumerable Select(Func(source, predicate, CombineSelectors(this.selector, selector)); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index bc2110c56c..e842054089 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -59,7 +59,7 @@ public override AsyncIterator Clone() return new ZipAsyncIterator(first, second, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (firstEnumerator != null) { @@ -76,7 +76,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -92,7 +92,8 @@ protected override async Task MoveNextCore() // We kick these off and join so they can potentially run in parallel var ft = firstEnumerator.MoveNextAsync(); var st = secondEnumerator.MoveNextAsync(); - await Task.WhenAll(ft, st).ConfigureAwait(false); + + await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); if (ft.Result && st.Result) { @@ -133,7 +134,7 @@ public override AsyncIterator Clone() return new ZipAsyncIteratorWithTask(first, second, selector); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (firstEnumerator != null) { @@ -150,7 +151,7 @@ public override async Task DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async Task MoveNextCore() + protected override async ValueTask MoveNextCore() { switch (state) { @@ -166,7 +167,7 @@ protected override async Task MoveNextCore() // We kick these off and join so they can potentially run in parallel var ft = firstEnumerator.MoveNextAsync(); var st = secondEnumerator.MoveNextAsync(); - await Task.WhenAll(ft, st).ConfigureAwait(false); + await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); if (ft.Result && st.Result) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index 6e46ae231b..74a7f09c91 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -44,12 +44,12 @@ internal ConfiguredAsyncEnumerator(IAsyncEnumerator enumerator, bool continue _continueOnCapturedContext = continueOnCapturedContext; } - public ConfiguredTaskAwaitable MoveNextAsync() => + public ConfiguredValueTaskAwaitable MoveNextAsync() => _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); public T Current => _enumerator.Current; - public ConfiguredTaskAwaitable DisposeAsync() => + public ConfiguredValueTaskAwaitable DisposeAsync() => _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs index 0732f58206..e617a8ae12 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs @@ -6,8 +6,8 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly Task True = Task.FromResult(true); - public static readonly Task False = Task.FromResult(false); - public static readonly Task CompletedTask = True; + public static readonly ValueTask True = new ValueTask(true); + public static readonly ValueTask False = new ValueTask(false); + public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); } } From 0ae1af3798023a13f0980debbed2f014ad977975 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 17:04:30 -0400 Subject: [PATCH 377/862] Fix build error --- .../System/Linq/QueryableEx.Generated.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs index aa2a046c0c..b5cbac93ea 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs @@ -2152,7 +2152,11 @@ public static IQueryable TakeLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable TakeLast(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return null; +#else return EnumerableEx.TakeLast(source, count); +#endif } #pragma warning restore 1591 @@ -2186,7 +2190,11 @@ public static IQueryable SkipLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable SkipLast(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return null; +#else return EnumerableEx.SkipLast(source, count); +#endif } #pragma warning restore 1591 From f24aa5d9c40daa7fa835efecad62e6a084fa23dc Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 17:28:33 -0400 Subject: [PATCH 378/862] Update tests to work with ValueTask --- .../AsyncTests.Bugs.cs | 2 +- .../System.Interactive.Async.Tests.csproj | 5 + .../System/Linq/AsyncEnumerableTests.cs | 4 +- .../System/Linq/AsyncEnumeratorTests.cs | 21 ---- .../System/Linq/Operators/CreateEnumerator.cs | 4 +- .../System/Linq/Operators/ToEnumerable.cs | 2 +- .../System/Linq/Operators/ToObservable.cs | 8 +- .../Source/System.Linq.Async.Tests/TaskExt.cs | 14 +++ .../ValueTaskHelpers.cs | 111 ++++++++++++++++++ 9 files changed, 140 insertions(+), 31 deletions(-) delete mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index f969db3b57..5f9693ed9f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -63,7 +63,7 @@ public async Task DisposesUponError() var ys = xs.Select(x => { if (x == 1) throw ex; return x; }); var e = ys.GetAsyncEnumerator(); - await Assert.ThrowsAsync(() => e.MoveNextAsync()); + await AssertX.ThrowsAsync(() => e.MoveNextAsync()); var result = await disposed.Task; Assert.True(result); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index 774634f815..8efb80752f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -27,6 +27,11 @@ + + + + + AsyncQueryableExTests.Generated.cs diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index c7e32eaba0..64e1213fb5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -88,9 +88,9 @@ protected static IAsyncEnumerable Throw(Exception exception) #if NO_TASK_FROMEXCEPTION var tcs = new TaskCompletionSource(); tcs.TrySetException(exception); - var moveNextThrows = tcs.Task; + var moveNextThrows = new ValueTask(tcs.Task); #else - var moveNextThrows = Task.FromException(exception); + var moveNextThrows = new ValueTask(Task.FromException(exception)); #endif return AsyncEnumerable.CreateEnumerable( diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs deleted file mode 100644 index b438507d75..0000000000 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumeratorTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using Xunit; - -namespace Tests -{ - public class AsyncEnumeratorTests - { - [Fact] - public void MoveNextExtension_Null() - { - var en = default(IAsyncEnumerator); - - Assert.ThrowsAsync(() => en.MoveNextAsync()); - } - } -} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index 6ef0ae3e0c..cf8b0c4b18 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -15,13 +15,13 @@ public class CreateEnumerator : AsyncEnumerableTests [Fact] public void CreateEnumerator_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerator(default(Func>), () => 3, () => Task.FromResult(true))); + AssertThrows(() => AsyncEnumerable.CreateEnumerator(default(Func>), () => 3, () => TaskExt.CompletedTask)); } [Fact] public void CreateEnumerator_Throws() { - var iter = AsyncEnumerable.CreateEnumerator(() => Task.FromResult(true), () => 3, () => Task.FromResult(true)); + var iter = AsyncEnumerable.CreateEnumerator(() => TaskExt.True, () => 3, () => TaskExt.CompletedTask); var enu = (IAsyncEnumerable)iter; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs index 0e1f0250d6..aaaadbb7f0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs @@ -35,7 +35,7 @@ public void ToEnumerable3() { var ex = new Exception("Bang"); var xs = Throw(ex).ToEnumerable(); - AssertThrows(() => xs.GetEnumerator().MoveNext(), SingleInnerExceptionMatches(ex)); + Assert.Throws(() => xs.GetEnumerator().MoveNext()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index d46e08c1b0..79d0fa9f97 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -143,9 +143,9 @@ public void ToObservable_DisposesEnumeratorOnCompletion() var ae = AsyncEnumerable.CreateEnumerable( () => AsyncEnumerable.CreateEnumerator( - () => Task.FromResult(false), + () => TaskExt.False, () => { throw new InvalidOperationException(); }, - () => { evt.Set(); return Task.FromResult(true); })); + () => { evt.Set(); return TaskExt.CompletedTask; })); ae .ToObservable() @@ -186,7 +186,7 @@ public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed() () => { evt.Set(); - return Task.FromResult(true); + return TaskExt.CompletedTask; })); subscription = ae @@ -234,7 +234,7 @@ public void ToObservable_DesNotCallMoveNextAgainWhenSubscriptionIsDisposed() () => { evt.Set(); - return Task.FromResult(true); + return TaskExt.CompletedTask; })); subscription = ae diff --git a/Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs b/Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs new file mode 100644 index 0000000000..0f8caa233f --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +namespace System.Threading.Tasks +{ + internal static class TaskExt + { + public static readonly ValueTask True = new ValueTask(true); + public static readonly ValueTask False = new ValueTask(false); + public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); + public static readonly ValueTask Never = new ValueTask(new TaskCompletionSource().Task); + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs b/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs new file mode 100644 index 0000000000..239f01e74d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Xunit.Sdk; + +namespace System.Linq +{ + static class ValueTaskHelpers + { + public static void Wait(this ValueTask task, int timeOut) + { + task.AsTask().Wait(timeOut); + } + } +} + +namespace Xunit +{ + static class AssertX + { + /// + /// Verifies that the exact exception is thrown (and not a derived exception type). + /// + /// The type of the exception expected to be thrown + /// A delegate to the task to be tested + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static async Task ThrowsAsync(Func testCode) + where T : Exception + { + return (T)Throws(typeof(T), await RecordExceptionAsync(testCode)); + } + + /// + /// Verifies that the exact exception is thrown (and not a derived exception type). + /// + /// The type of the exception expected to be thrown + /// A delegate to the task to be tested + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static async Task ThrowsAsync(Func> testCode) + where T : Exception + { + return (T)Throws(typeof(T), await RecordExceptionAsync(testCode)); + } + + /// + /// Records any exception which is thrown by the given task. + /// + /// The task which may thrown an exception. + /// Returns the exception that was thrown by the code; null, otherwise. + static async Task RecordExceptionAsync(Func testCode) + { + if (testCode == null) + { + throw new ArgumentNullException(nameof(testCode)); + } + + try + { + await testCode(); + return null; + } + catch (Exception ex) + { + return ex; + } + } + + /// + /// Records any exception which is thrown by the given task. + /// + /// The task which may thrown an exception. + /// Returns the exception that was thrown by the code; null, otherwise. + static async Task RecordExceptionAsync(Func> testCode) + { + if (testCode == null) + { + throw new ArgumentNullException(nameof(testCode)); + } + + try + { + await testCode(); + return null; + } + catch (Exception ex) + { + return ex; + } + } + + static Exception Throws(Type exceptionType, Exception exception) + { + if (exceptionType == null) + { + throw new ArgumentNullException(nameof(exceptionType)); + } + + if (exception == null) + throw new ThrowsException(exceptionType); + + if (!exceptionType.Equals(exception.GetType())) + throw new ThrowsException(exceptionType, exception); + + return exception; + } + } + +} From 16aca61a4e51213c168ebbffa22424b289209453 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 17:42:49 -0400 Subject: [PATCH 379/862] Change to use Assert.Contains --- .../System/Linq/Operators/ToLookup.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index ddba84bbf9..eed324167d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -57,8 +57,8 @@ public void ToLookup1() var res = xs.ToLookup(x => x % 2).Result; Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[1].Contains(1)); + Assert.Contains(4, res[0]); + Assert.Contains(1, res[1]); Assert.True(res.Count == 2); } @@ -69,9 +69,9 @@ public void ToLookup2() var res = xs.ToLookup(x => x % 2).Result; Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[0].Contains(2)); - Assert.True(res[1].Contains(1)); + Assert.Contains(4, res[0]); + Assert.Contains(2, res[0]); + Assert.Contains(1, res[1]); Assert.True(res.Count == 2); } @@ -82,8 +82,8 @@ public void ToLookup3() var res = xs.ToLookup(x => x % 2, x => x + 1).Result; Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(5)); - Assert.True(res[1].Contains(2)); + Assert.Contains(5, res[0]); + Assert.Contains(2, res[1]); Assert.True(res.Count == 2); } @@ -94,9 +94,9 @@ public void ToLookup4() var res = xs.ToLookup(x => x % 2, x => x + 1).Result; Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(5)); - Assert.True(res[0].Contains(3)); - Assert.True(res[1].Contains(2)); + Assert.Contains(5, res[0]); + Assert.Contains(3, res[0]); + Assert.Contains(2, res[1]); Assert.True(res.Count == 2); } @@ -107,8 +107,8 @@ public void ToLookup5() var res = xs.ToLookup(x => x % 2, new Eq()).Result; Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[1].Contains(1)); + Assert.Contains(4, res[0]); + Assert.Contains(1, res[1]); Assert.True(res.Count == 2); } @@ -119,9 +119,9 @@ public void ToLookup6() var res = xs.ToLookup(x => x % 2, new Eq()).Result; Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[0].Contains(2)); - Assert.True(res[1].Contains(1)); + Assert.Contains(4, res[0]); + Assert.Contains(2, res[0]); + Assert.Contains(1, res[1]); Assert.True(res.Count == 2); } @@ -152,9 +152,9 @@ public void ToLookup9() var res = xs.ToLookup(x => x % 2, x => x, new Eq()).Result; Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); - Assert.True(res[0].Contains(4)); - Assert.True(res[0].Contains(2)); - Assert.True(res[1].Contains(1)); + Assert.Contains(4, res[0]); + Assert.Contains(2, res[0]); + Assert.Contains(1, res[1]); Assert.True(res.Count == 2); } From e3135050d09545a2605ca3ab888f145ef017aee2 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 17:45:44 -0400 Subject: [PATCH 380/862] Fix doc comments --- .../System.Linq.Async/System/Linq/IAsyncPartition.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs index b3af5c8cee..fa99b30a83 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs @@ -16,14 +16,14 @@ internal interface IAsyncPartition : IAsyncIListProvider /// Creates a new partition that skips the specified number of elements from this sequence. /// /// The number of elements to skip. - /// An with the first items removed. + /// An with the first items removed. IAsyncPartition Skip(int count); /// /// Creates a new partition that takes the specified number of elements from this sequence. /// /// The number of elements to take. - /// An with only the first items. + /// An with only the first items. IAsyncPartition Take(int count); /// @@ -31,21 +31,21 @@ internal interface IAsyncPartition : IAsyncIListProvider /// /// The 0-based index to access. /// Token to observe for cancellation requests. - /// The element if found, otherwise, the default value of . + /// The element if found, otherwise, the default value of . Task> TryGetElementAsync(int index, CancellationToken cancellationToken); /// /// Gets the first item in this sequence. /// /// Token to observe for cancellation requests. - /// The element if found, otherwise, the default value of . + /// The element if found, otherwise, the default value of . Task> TryGetFirstAsync(CancellationToken cancellationToken); /// /// Gets the last item in this sequence. /// /// Token to observe for cancellation requests. - /// The element if found, otherwise, the default value of . + /// The element if found, otherwise, the default value of . Task> TryGetLastAsync(CancellationToken cancellationToken); } } From 6612f584d4f2e96a62d4c9dc019b56c68c2d5ae4 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 17:50:02 -0400 Subject: [PATCH 381/862] Remove unused variable --- Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs index 60f488cfeb..16c0163ebc 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs @@ -14,9 +14,7 @@ internal sealed class Set { private readonly IEqualityComparer _comparer; private int[] _buckets; -#if DEBUG - private bool _haveRemoved; -#endif + private Slot[] _slots; public Set(IEqualityComparer comparer) @@ -31,9 +29,6 @@ public Set(IEqualityComparer comparer) // If value is not in set, add it and return true; otherwise return false public bool Add(TElement value) { -#if DEBUG - Debug.Assert(!_haveRemoved, "This class is optimised for never calling Add after Remove. If your changes need to do so, undo that optimization."); -#endif var hashCode = InternalGetHashCode(value); for (var i = _buckets[hashCode%_buckets.Length] - 1; i >= 0; i = _slots[i]._next) { From d18ec867ec42c9ec9ae143e0942beebc2027e9d4 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 17:55:13 -0400 Subject: [PATCH 382/862] Update code coverage filter --- Ix.NET/Source/CodeCoverage.runsettings | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/CodeCoverage.runsettings b/Ix.NET/Source/CodeCoverage.runsettings index 1ed0e7dc69..4c70486f0d 100644 --- a/Ix.NET/Source/CodeCoverage.runsettings +++ b/Ix.NET/Source/CodeCoverage.runsettings @@ -19,9 +19,10 @@ Included items must then not match any entries in the exclude list to remain inc .*Interactive.* + .*System.Linq.Async.dll$ - .*Tests.* + .*Tests.dll$ From 3b702456cbcb1199a1eb10dafd2a64051e109a71 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 17:59:25 -0400 Subject: [PATCH 383/862] Pack all the packages --- Ix.NET/Source/Ix.NET.sln | 1 + azure-pipelines.ix.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/Ix.NET.sln b/Ix.NET/Source/Ix.NET.sln index 5f90d1b479..54482728a0 100644 --- a/Ix.NET/Source/Ix.NET.sln +++ b/Ix.NET/Source/Ix.NET.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.build.props = Directory.build.props Directory.build.targets = Directory.build.targets NuGet.Config = NuGet.Config + version.json = version.json EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive", "System.Interactive\System.Interactive.csproj", "{FF97CD0F-8108-4B66-8A34-42190B459180}" diff --git a/azure-pipelines.ix.yml b/azure-pipelines.ix.yml index b4ddb97d9e..878761f32d 100644 --- a/azure-pipelines.ix.yml +++ b/azure-pipelines.ix.yml @@ -31,7 +31,7 @@ steps: - task: DotNetCoreCLI@2 inputs: command: pack - packagesToPack: Ix.NET/Source/**/System.Interactive*.csproj;!Ix.NET/Source/**/*.Tests*.csproj;!Ix.NET/Source/refs/** + packagesToPack: Ix.NET/Source/**/System.Interactive*.csproj;Ix.NET/Source/**/System.Linq.*.csproj;!Ix.NET/Source/**/*.Tests*.csproj;!Ix.NET/Source/refs/** configuration: $(BuildConfiguration) packDirectory: $(Build.ArtifactStagingDirectory)\artifacts verbosityPack: Minimal From 6991d850467b6ec07227584c8556f5cfdfd90c11 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Fri, 5 Oct 2018 18:23:08 -0400 Subject: [PATCH 384/862] Remove service guid's --- .../System.Interactive.Async.Tests.csproj | 4 ---- .../System.Linq.Async.Queryable.Tests.csproj | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index 8efb80752f..19d98d9516 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -40,10 +40,6 @@ - - - - True diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj index 41a7f60df2..387c637782 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -32,10 +32,6 @@ - - - - True From 271688e42173b010b6ed44c30b06c47595067a6e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 6 Nov 2018 12:27:43 -0800 Subject: [PATCH 385/862] Adapting to GetAsyncEnumerator(CancellationToken) interface change. --- .../AsyncTests.Bugs.cs | 2 +- .../System.Interactive.Async/AsyncIterator.cs | 12 ++-- .../System/Linq/Operators/Amb.cs | 11 ++-- .../System/Linq/Operators/Buffer.cs | 5 +- .../System/Linq/Operators/Catch.cs | 17 +++--- .../System/Linq/Operators/Concat.cs | 11 ++-- .../System/Linq/Operators/Defer.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 16 ++--- .../Linq/Operators/DistinctUntilChanged.cs | 13 ++-- .../System/Linq/Operators/Do.cs | 9 +-- .../System/Linq/Operators/Expand.cs | 9 +-- .../System/Linq/Operators/Finally.cs | 9 +-- .../System/Linq/Operators/Generate.cs | 3 +- .../System/Linq/Operators/IgnoreElements.cs | 5 +- .../System/Linq/Operators/Max.cs | 2 +- .../System/Linq/Operators/Merge.cs | 5 +- .../System/Linq/Operators/Min.cs | 2 +- .../System/Linq/Operators/MinBy.cs | 4 +- .../Linq/Operators/OnErrorResumeNext.cs | 5 +- .../System/Linq/Operators/Repeat.cs | 9 ++- .../System/Linq/Operators/Scan.cs | 17 +++--- .../System/Linq/Operators/Timeout.cs | 4 +- .../System/Linq/Operators/Using.cs | 15 +++-- .../System/Linq/AsyncEnumerableQuery.cs | 5 +- .../Collections/Generic/IAsyncEnumerable.cs | 5 +- .../System/Linq/AsyncEnumerableHelpers.cs | 6 +- .../System/Linq/AsyncEnumerablePartition.cs | 32 +++++----- .../System/Linq/AsyncEnumerator.cs | 4 +- .../System/Linq/AsyncIterator.cs | 12 ++-- .../System/Linq/AsyncListPartition.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 16 ++--- .../System/Linq/Operators/All.cs | 8 +-- .../System/Linq/Operators/Any.cs | 12 ++-- .../System/Linq/Operators/AppendPrepend.cs | 28 ++++----- .../System/Linq/Operators/Average.cs | 60 +++++++++---------- .../System/Linq/Operators/Concat.cs | 10 ++-- .../System/Linq/Operators/Create.cs | 38 ++++++++---- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 6 +- .../System/Linq/Operators/ElementAt.cs | 4 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/Empty.cs | 2 +- .../System/Linq/Operators/Except.cs | 5 +- .../System/Linq/Operators/First.cs | 4 +- .../System/Linq/Operators/FirstOrDefault.cs | 4 +- .../System/Linq/Operators/ForEach.cs | 8 +-- .../System/Linq/Operators/GroupBy.cs | 14 ++--- .../System/Linq/Operators/GroupJoin.cs | 29 +++++---- .../System/Linq/Operators/Grouping.cs | 3 +- .../System/Linq/Operators/Intersect.cs | 5 +- .../System/Linq/Operators/Join.cs | 13 ++-- .../System/Linq/Operators/Last.cs | 4 +- .../System/Linq/Operators/LastOrDefault.cs | 4 +- .../System/Linq/Operators/Max.cs | 6 +- .../System/Linq/Operators/Min.cs | 6 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 27 +++++---- .../System/Linq/Operators/Range.cs | 2 +- .../System/Linq/Operators/Repeat.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/Select.cs | 20 +++---- .../System/Linq/Operators/SelectMany.cs | 49 +++++++-------- .../System/Linq/Operators/SequenceEqual.cs | 4 +- .../System/Linq/Operators/Single.cs | 6 +- .../System/Linq/Operators/SingleOrDefault.cs | 6 +- .../System/Linq/Operators/SkipLast.cs | 5 +- .../System/Linq/Operators/SkipWhile.cs | 17 +++--- .../System/Linq/Operators/TakeLast.cs | 5 +- .../System/Linq/Operators/TakeWhile.cs | 17 +++--- .../Linq/Operators/ToAsyncEnumerable.cs | 6 +- .../System/Linq/Operators/ToEnumerable.cs | 2 +- .../System/Linq/Operators/ToLookup.cs | 32 +++++----- .../System/Linq/Operators/ToObservable.cs | 2 +- .../System/Linq/Operators/Union.cs | 8 +-- .../System/Linq/Operators/Where.cs | 21 +++---- .../System/Linq/Operators/Zip.cs | 13 ++-- .../System.Linq.Async/System/Linq/Set.cs | 5 +- .../Tasks/AsyncEnumerableExtensions.cs | 4 +- 77 files changed, 437 insertions(+), 370 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 5f9693ed9f..00eff30d79 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -124,7 +124,7 @@ private class DisposeCounter : IAsyncEnumerable { public int DisposeCount { get; private set; } - public IAsyncEnumerator GetAsyncEnumerator() + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { return new Enumerator(this); } diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 2fea47070c..8d86eb2fc1 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -16,23 +16,25 @@ internal abstract class AsyncIterator : IAsyncEnumerable, IAsy internal TSource current; internal AsyncIteratorState state = AsyncIteratorState.New; + internal CancellationToken token; protected AsyncIterator() { threadId = Environment.CurrentManagedThreadId; } - public IAsyncEnumerator GetAsyncEnumerator() + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) { var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? this : Clone(); enumerator.state = AsyncIteratorState.Allocated; + enumerator.token = token; try { - enumerator.OnGetEnumerator(); + enumerator.OnGetEnumerator(token); } catch { @@ -75,7 +77,7 @@ public async ValueTask MoveNextAsync() try { - var result = await MoveNextCore().ConfigureAwait(false); + var result = await MoveNextCore(token).ConfigureAwait(false); currentIsInvalid = !result; // if move next is false, invalid otherwise valid @@ -91,9 +93,9 @@ public async ValueTask MoveNextAsync() public abstract AsyncIterator Clone(); - protected abstract ValueTask MoveNextCore(); + protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); - protected virtual void OnGetEnumerator() + protected virtual void OnGetEnumerator(CancellationToken cancellationToken) { } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index d634f0723b..e0ce937dfc 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -68,13 +69,13 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - var firstEnumerator = first.GetAsyncEnumerator(); - var secondEnumerator = second.GetAsyncEnumerator(); + var firstEnumerator = first.GetAsyncEnumerator(cancellationToken); + var secondEnumerator = second.GetAsyncEnumerator(cancellationToken); var firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); var secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); @@ -163,7 +164,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -175,7 +176,7 @@ protected override async ValueTask MoveNextCore() for (var i = 0; i < n; i++) { - var enumerator = sources[i].GetAsyncEnumerator(); + var enumerator = sources[i].GetAsyncEnumerator(cancellationToken); enumerators[i] = enumerator; moveNexts[i] = enumerator.MoveNextAsync(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index c3df5bd981..c8ada8d024 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -83,12 +84,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); buffers = new Queue>(); index = 0; stopped = false; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 678554ff2e..1116993e12 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.ExceptionServices; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -97,12 +98,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); isDone = false; state = AsyncIteratorState.Iterating; @@ -127,7 +128,7 @@ protected override async ValueTask MoveNextCore() // invoking the handler, but we use this order to preserve // current behavior var inner = handler(ex); - var err = inner.GetAsyncEnumerator(); + var err = inner.GetAsyncEnumerator(cancellationToken); if (enumerator != null) { @@ -190,12 +191,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); isDone = false; state = AsyncIteratorState.Iterating; @@ -220,7 +221,7 @@ protected override async ValueTask MoveNextCore() // invoking the handler, but we use this order to preserve // current behavior var inner = await handler(ex).ConfigureAwait(false); - var err = inner.GetAsyncEnumerator(); + var err = inner.GetAsyncEnumerator(cancellationToken); if (enumerator != null) { @@ -290,7 +291,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -313,7 +314,7 @@ protected override async ValueTask MoveNextCore() } error = null; - enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(); + enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); } try diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index 2309a3bd67..c71755a09d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -80,7 +81,7 @@ public override async ValueTask DisposeAsync() private const int State_OuterNext = 1; private const int State_While = 4; - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) @@ -103,7 +104,7 @@ protected override async ValueTask MoveNextCore() await currentEnumerator.DisposeAsync().ConfigureAwait(false); } - currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); + currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); mode = State_While; goto case State_While; @@ -170,13 +171,13 @@ public override async ValueTask DisposeAsync() private const int State_OuterNext = 1; private const int State_While = 4; - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = source.GetAsyncEnumerator(); + outerEnumerator = source.GetAsyncEnumerator(cancellationToken); mode = State_OuterNext; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -193,7 +194,7 @@ protected override async ValueTask MoveNextCore() await currentEnumerator.DisposeAsync().ConfigureAwait(false); } - currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(); + currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); mode = State_While; goto case State_While; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index b7d5b7667f..c47b0ca7ab 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -15,7 +15,7 @@ public static IAsyncEnumerable Defer(Func factory().GetAsyncEnumerator()); + return CreateEnumerable(ct => factory().GetAsyncEnumerator(ct)); } public static IAsyncEnumerable Defer(Func>> factory) @@ -23,7 +23,7 @@ public static IAsyncEnumerable Defer(Func (await factory().ConfigureAwait(false)).GetAsyncEnumerator()); + return CreateEnumerable(async ct => (await factory().ConfigureAwait(false)).GetAsyncEnumerator(ct)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index b8fc6ef2f4..a07f25b2f2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -107,7 +107,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell var count = 0; var s = new Set(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { @@ -145,12 +145,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -189,7 +189,7 @@ private async Task> FillSetAsync(CancellationToken cancellationTok var s = new Set(comparer); var r = new List(); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { @@ -253,7 +253,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell var count = 0; var s = new Set(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { @@ -291,12 +291,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -335,7 +335,7 @@ private async Task> FillSetAsync(CancellationToken cancellationTok var s = new Set(comparer); var r = new List(); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 6be807026a..75d9f6f114 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -122,12 +123,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -193,12 +194,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -264,12 +265,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index ec6b57ab0b..c373e929af 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -162,12 +163,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -238,12 +239,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index e969ec6e5c..0e1c9a34f1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -66,7 +67,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -91,7 +92,7 @@ protected override async ValueTask MoveNextCore() await enumerator.DisposeAsync().ConfigureAwait(false); } - enumerator = src.GetAsyncEnumerator(); + enumerator = src.GetAsyncEnumerator(cancellationToken); continue; // loop } @@ -156,7 +157,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -181,7 +182,7 @@ protected override async ValueTask MoveNextCore() await enumerator.DisposeAsync().ConfigureAwait(false); } - enumerator = src.GetAsyncEnumerator(); + enumerator = src.GetAsyncEnumerator(cancellationToken); continue; // loop } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 35f3fefb8b..96454bf525 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -64,12 +65,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -122,12 +123,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 1facf03d43..a777d61ae4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -65,7 +66,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index f5ef5ad29f..19c0cb3a02 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -48,12 +49,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index dd786f1a10..31f6dc69bd 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -32,7 +32,7 @@ public static Task Max(this IAsyncEnumerable source, private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 5e0fb414ad..7be67bdc90 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -75,7 +76,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -88,7 +89,7 @@ protected override async ValueTask MoveNextCore() for (var i = 0; i < n; i++) { - var enumerator = sources[i].GetAsyncEnumerator(); + var enumerator = sources[i].GetAsyncEnumerator(cancellationToken); enumerators[i] = enumerator; moveNexts[i] = enumerator.MoveNextAsync(); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index c0485f2297..18f0d28973 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -32,7 +32,7 @@ public static Task Min(this IAsyncEnumerable source, private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 83fef303de..7f849d3d3f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -112,7 +112,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -152,7 +152,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index e4bf54fe6d..08c4bc1d8f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -77,7 +78,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -97,7 +98,7 @@ protected override async ValueTask MoveNextCore() break; // while -- done, nothing else to do } - enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(); + enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); } try diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index bb29fb72ff..ec0bc14f1c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -47,8 +48,10 @@ public override AsyncIterator Clone() return new RepeatElementAsyncIterator(element); } - protected override ValueTask MoveNextCore() + protected override ValueTask MoveNextCore(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + current = element; return TaskExt.True; } @@ -89,7 +92,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -104,7 +107,7 @@ protected override async ValueTask MoveNextCore() if (!isInfinite && currentCount-- == 0) break; - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index df8535d92a..9070aebfee 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -86,12 +87,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); hasSeed = false; accumulated = default(TSource); @@ -160,12 +161,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); accumulated = seed; state = AsyncIteratorState.Iterating; @@ -224,12 +225,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); hasSeed = false; accumulated = default(TSource); @@ -298,12 +299,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); accumulated = seed; state = AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index 063140b12c..bc07518ad4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -54,12 +54,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 4d160d231c..14f2f59dfe 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -70,12 +71,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = enumerable.GetAsyncEnumerator(); + enumerator = enumerable.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -93,12 +94,14 @@ protected override async ValueTask MoveNextCore() return false; } - protected override void OnGetEnumerator() + protected override void OnGetEnumerator(CancellationToken cancellationToken) { + // REVIEW: Wire cancellation to the functions. + resource = resourceFactory(); enumerable = enumerableFactory(resource); - base.OnGetEnumerator(); + base.OnGetEnumerator(cancellationToken); } } @@ -142,7 +145,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -150,7 +153,7 @@ protected override async ValueTask MoveNextCore() resource = await resourceFactory().ConfigureAwait(false); enumerable = await enumerableFactory(resource).ConfigureAwait(false); - enumerator = enumerable.GetAsyncEnumerator(); + enumerator = enumerable.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs index c6cd1c1d97..c22f813221 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs @@ -144,8 +144,9 @@ Task IAsyncQueryProvider.ExecuteAsync(Expression expression, C /// /// Gets an enumerator to enumerate the elements in the sequence. /// + /// Cancellation token used to cancel the enumeration. /// A new enumerator instance used to enumerate the elements in the sequence. - public IAsyncEnumerator GetAsyncEnumerator() + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) { if (_enumerable == null) { @@ -153,7 +154,7 @@ public IAsyncEnumerator GetAsyncEnumerator() _enumerable = expression.Compile()(); } - return _enumerable.GetAsyncEnumerator(); + return _enumerable.GetAsyncEnumerator(token); } /// diff --git a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs index 4cc0d075b8..e3f49b713c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs @@ -5,6 +5,8 @@ // See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface // and the design rationale. (8/30/2017) +using System.Threading; + namespace System.Collections.Generic { /// @@ -16,7 +18,8 @@ public interface IAsyncEnumerable /// /// Gets an asynchronous enumerator over the sequence. /// + /// Cancellation token used to cancel the enumeration. /// Enumerator for asynchronous enumeration over the sequence. - IAsyncEnumerator GetAsyncEnumerator(); + IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index d387823301..853724b716 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -42,18 +42,18 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer } else { - var en = source.GetAsyncEnumerator(); + var en = source.GetAsyncEnumerator(cancellationToken); try { - if (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await en.MoveNextAsync().ConfigureAwait(false)) { const int DefaultCapacity = 4; var arr = new T[DefaultCapacity]; arr[0] = en.Current; var count = 1; - while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await en.MoveNextAsync().ConfigureAwait(false)) { if (count == arr.Length) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 967c965f7a..026824f503 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -76,7 +76,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return Math.Max(await _source.Count(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); } - var en = _source.GetAsyncEnumerator(); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -102,12 +102,12 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell private bool hasSkipped; private int taken; - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); hasSkipped = false; taken = 0; @@ -217,13 +217,13 @@ public async Task> TryGetElementAsync(int index, CancellationToke // If the index is negative or >= our max count, return early. if (index >= 0 && (!HasLimit || index < Limit)) { - var en = _source.GetAsyncEnumerator(); + var en = _source.GetAsyncEnumerator(cancellationToken); try { Debug.Assert(_minIndexInclusive + index >= 0, $"Adding {nameof(index)} caused {nameof(_minIndexInclusive)} to overflow."); - if (await SkipBeforeAsync(_minIndexInclusive + index, en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await SkipBeforeAsync(_minIndexInclusive + index, en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { return new Maybe(en.Current); } @@ -239,11 +239,11 @@ public async Task> TryGetElementAsync(int index, CancellationToke public async Task> TryGetFirstAsync(CancellationToken cancellationToken) { - var en = _source.GetAsyncEnumerator(); + var en = _source.GetAsyncEnumerator(cancellationToken); try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { return new Maybe(en.Current); } @@ -258,11 +258,11 @@ public async Task> TryGetFirstAsync(CancellationToken cancellatio public async Task> TryGetLastAsync(CancellationToken cancellationToken) { - var en = _source.GetAsyncEnumerator(); + var en = _source.GetAsyncEnumerator(cancellationToken); try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { var remaining = Limit - 1; // Max number of items left, not counting the current element. var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. @@ -288,11 +288,11 @@ public async Task> TryGetLastAsync(CancellationToken cancellation public async Task ToArrayAsync(CancellationToken cancellationToken) { - var en = _source.GetAsyncEnumerator(); + var en = _source.GetAsyncEnumerator(cancellationToken); try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { var remaining = Limit - 1; // Max number of items left, not counting the current element. var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. @@ -305,7 +305,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) remaining--; builder.Add(en.Current); } - while (remaining >= comparand && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)); + while (remaining >= comparand && await en.MoveNextAsync().ConfigureAwait(false)); return builder.ToArray(); } @@ -326,11 +326,11 @@ public async Task> ToListAsync(CancellationToken cancellationToken { var list = new List(); - var en = _source.GetAsyncEnumerator(); + var en = _source.GetAsyncEnumerator(cancellationToken); try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { var remaining = Limit - 1; // Max number of items left, not counting the current element. var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. @@ -340,7 +340,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken remaining--; list.Add(en.Current); } - while (remaining >= comparand && await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)); + while (remaining >= comparand && await en.MoveNextAsync().ConfigureAwait(false)); } } finally @@ -371,7 +371,7 @@ private static async Task SkipAndCountAsync(uint index, IAsyncEnumerator> moveNext, Func currentFun this.dispose = dispose; // Explicit call to initialize enumerator mode - GetAsyncEnumerator(); + GetAsyncEnumerator(default); } public override AsyncIterator Clone() @@ -139,7 +139,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index e472b6fdb4..542915461e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -16,23 +16,25 @@ internal abstract class AsyncIterator : IAsyncEnumerable, IAsy internal TSource current; internal AsyncIteratorState state = AsyncIteratorState.New; + internal CancellationToken cancellationToken; protected AsyncIterator() { threadId = Environment.CurrentManagedThreadId; } - public IAsyncEnumerator GetAsyncEnumerator() + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId ? this : Clone(); enumerator.state = AsyncIteratorState.Allocated; + enumerator.cancellationToken = cancellationToken; try { - enumerator.OnGetEnumerator(); + enumerator.OnGetEnumerator(cancellationToken); } catch { @@ -75,7 +77,7 @@ public async ValueTask MoveNextAsync() try { - var result = await MoveNextCore().ConfigureAwait(false); + var result = await MoveNextCore(cancellationToken).ConfigureAwait(false); currentIsInvalid = !result; // if move next is false, invalid otherwise valid @@ -111,9 +113,9 @@ public virtual IAsyncEnumerable Where(Func> predica return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); } - protected abstract ValueTask MoveNextCore(); + protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); - protected virtual void OnGetEnumerator() + protected virtual void OnGetEnumerator(CancellationToken cancellationToken) { } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index daff90ae87..86e6f537ac 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -38,7 +38,7 @@ public override AsyncIterator Clone() return new AsyncListPartition(_source, _minIndexInclusive, _maxIndexInclusive); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { if ((uint)_index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && _index < _source.Count - _minIndexInclusive) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 2444da0d12..f260d43518 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -142,11 +142,11 @@ private static async Task AggregateCore( { var acc = seed; - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { acc = accumulator(acc, e.Current); } @@ -164,11 +164,11 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore( { var acc = seed; - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { acc = await accumulator(acc, e.Current).ConfigureAwait(false); } @@ -211,11 +211,11 @@ private static async Task AggregateCore(IAsyncEnumerable All(this IAsyncEnumerable source, Fun private static async Task AllCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { if (!predicate(e.Current)) return false; @@ -72,11 +72,11 @@ private static async Task AllCore(IAsyncEnumerable sourc private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { if (!await predicate(e.Current).ConfigureAwait(false)) return false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index a0158f9480..f4c223784f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -63,11 +63,11 @@ public static async Task Any(this IAsyncEnumerable sourc if (source == null) throw new ArgumentNullException(nameof(source)); - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - return await e.MoveNextAsync(cancellationToken).ConfigureAwait(false); + return await e.MoveNextAsync().ConfigureAwait(false); } finally { @@ -77,11 +77,11 @@ public static async Task Any(this IAsyncEnumerable sourc private static async Task AnyCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { if (predicate(e.Current)) return true; @@ -97,11 +97,11 @@ private static async Task AnyCore(IAsyncEnumerable sourc private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { if (await predicate(e.Current).ConfigureAwait(false)) return true; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 529349edd4..3f75aa801c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -49,10 +49,10 @@ protected AppendPrependAsyncIterator(IAsyncEnumerable source) this.source = source; } - protected void GetSourceEnumerator() + protected void GetSourceEnumerator(CancellationToken cancellationToken) { Debug.Assert(enumerator == null); - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); } public abstract AppendPrependAsyncIterator Append(TSource item); @@ -110,7 +110,7 @@ public override AsyncIterator Clone() return new AppendPrepend1AsyncIterator(source, item, appending); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -128,7 +128,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (!hasEnumerator) { - GetSourceEnumerator(); + GetSourceEnumerator(cancellationToken); hasEnumerator = true; } @@ -204,11 +204,11 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } else { - var en = source.GetAsyncEnumerator(); + var en = source.GetAsyncEnumerator(cancellationToken); try { - while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await en.MoveNextAsync().ConfigureAwait(false)) { array[index] = en.Current; ++index; @@ -239,11 +239,11 @@ public override async Task> ToListAsync(CancellationToken cancella } - var en = source.GetAsyncEnumerator(); + var en = source.GetAsyncEnumerator(cancellationToken); try { - while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await en.MoveNextAsync().ConfigureAwait(false)) { list.Add(en.Current); } @@ -315,7 +315,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -340,7 +340,7 @@ protected override async ValueTask MoveNextCore() return true; } - GetSourceEnumerator(); + GetSourceEnumerator(cancellationToken); mode = 3; goto case 3; @@ -410,11 +410,11 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } else { - var en = source.GetAsyncEnumerator(); + var en = source.GetAsyncEnumerator(cancellationToken); try { - while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await en.MoveNextAsync().ConfigureAwait(false)) { array[index] = en.Current; ++index; @@ -445,11 +445,11 @@ public override async Task> ToListAsync(CancellationToken cancella list.Add(n.Item); } - var en = source.GetAsyncEnumerator(); + var en = source.GetAsyncEnumerator(cancellationToken); try { - while (await en.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await en.MoveNextAsync().ConfigureAwait(false)) { list.Add(en.Current); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index 4d7b052227..97eed323a3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -12,11 +12,11 @@ public static partial class AsyncEnumerable { private static async Task AverageCore(this IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } @@ -25,7 +25,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; ++count; @@ -42,11 +42,11 @@ private static async Task AverageCore(this IAsyncEnumerable source, private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -55,7 +55,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -80,11 +80,11 @@ private static async Task AverageCore(this IAsyncEnumerable source, private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } @@ -93,7 +93,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; ++count; @@ -110,11 +110,11 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -123,7 +123,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -148,18 +148,18 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is // ever NaN then the result will always be NaN. Assuming that this case is @@ -178,11 +178,11 @@ private static async Task AverageCore(IAsyncEnumerable source, C private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -191,7 +191,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -216,18 +216,18 @@ private static async Task AverageCore(IAsyncEnumerable source, C private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } double sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; ++count; @@ -243,11 +243,11 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) @@ -256,7 +256,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can long count = 1; checked { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; if (v.HasValue) @@ -281,18 +281,18 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var sum = e.Current; long count = 1; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; ++count; @@ -308,18 +308,18 @@ private static async Task AverageCore(IAsyncEnumerable source, private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var v = e.Current; if (v.HasValue) { var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; if (v.HasValue) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 61787a5c39..a50db1b6b5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -83,11 +83,11 @@ public async Task> ToListAsync(CancellationToken cancellationToken break; } - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { list.Add(e.Current); } @@ -137,11 +137,11 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { if (state == AsyncIteratorState.Allocated) { - enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator(); + enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; counter = 2; } @@ -161,7 +161,7 @@ protected override async ValueTask MoveNextCore() if (next != null) { await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = next.GetAsyncEnumerator(); + enumerator = next.GetAsyncEnumerator(cancellationToken); continue; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index 52028b185c..8ab72d6b8d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -12,6 +12,14 @@ namespace System.Linq public static partial class AsyncEnumerable { public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) + { + if (getEnumerator == null) + throw new ArgumentNullException(nameof(getEnumerator)); + + return new AnonymousAsyncEnumerable(_ => getEnumerator()); + } + + public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) { if (getEnumerator == null) throw new ArgumentNullException(nameof(getEnumerator)); @@ -20,6 +28,14 @@ public static IAsyncEnumerable CreateEnumerable(Func> } public static IAsyncEnumerable CreateEnumerable(Func>> getEnumerator) + { + if (getEnumerator == null) + throw new ArgumentNullException(nameof(getEnumerator)); + + return new AnonymousAsyncEnumerableWithTask(_ => getEnumerator()); + } + + public static IAsyncEnumerable CreateEnumerable(Func>> getEnumerator) { if (getEnumerator == null) throw new ArgumentNullException(nameof(getEnumerator)); @@ -39,41 +55,43 @@ private static IAsyncEnumerator CreateEnumerator(Func : IAsyncEnumerable { - private readonly Func> getEnumerator; + private readonly Func> getEnumerator; - public AnonymousAsyncEnumerable(Func> getEnumerator) + public AnonymousAsyncEnumerable(Func> getEnumerator) { Debug.Assert(getEnumerator != null); this.getEnumerator = getEnumerator; } - public IAsyncEnumerator GetAsyncEnumerator() => getEnumerator(); + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => getEnumerator(cancellationToken); } private sealed class AnonymousAsyncEnumerableWithTask : IAsyncEnumerable { - private readonly Func>> getEnumerator; + private readonly Func>> getEnumerator; - public AnonymousAsyncEnumerableWithTask(Func>> getEnumerator) + public AnonymousAsyncEnumerableWithTask(Func>> getEnumerator) { Debug.Assert(getEnumerator != null); this.getEnumerator = getEnumerator; } - public IAsyncEnumerator GetAsyncEnumerator() => new Enumerator(getEnumerator); + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new Enumerator(getEnumerator, cancellationToken); private sealed class Enumerator : IAsyncEnumerator { - private Func>> getEnumerator; + private Func>> getEnumerator; + private readonly CancellationToken cancellationToken; private IAsyncEnumerator enumerator; - public Enumerator(Func>> getEnumerator) + public Enumerator(Func>> getEnumerator, CancellationToken cancellationToken) { Debug.Assert(getEnumerator != null); this.getEnumerator = getEnumerator; + this.cancellationToken = cancellationToken; } public T Current @@ -111,11 +129,11 @@ private async ValueTask InitAndMoveNextAsync() { try { - enumerator = await getEnumerator().ConfigureAwait(false); + enumerator = await getEnumerator(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { - enumerator = Throw(ex).GetAsyncEnumerator(); + enumerator = Throw(ex).GetAsyncEnumerator(cancellationToken); throw; } finally diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 163c3a0b10..f62d1113cb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -63,12 +63,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { current = enumerator.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index a9c35c3c86..71531d4880 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -79,12 +79,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); @@ -121,7 +121,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke { var s = new Set(comparer); - await s.UnionWithAsync(source); + await s.UnionWithAsync(source, cancellationToken); return s; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index dd0dc6ed66..d3758138ab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -52,11 +52,11 @@ private static async Task ElementAtCore(IAsyncEnumerable ElementAtOrDefaultCore(IAsyncEnumera } else { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { if (index == 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 557f20064c..a2944a59ef 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -42,7 +42,7 @@ public Task ToArrayAsync(CancellationToken cancellationToken) => Task. public ValueTask MoveNextAsync() => TaskExt.False; - public IAsyncEnumerator GetAsyncEnumerator() => this; + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => this; public ValueTask DisposeAsync() => TaskExt.CompletedTask; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 11dd6a9447..cca4c5c0ec 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -74,12 +75,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(); + firstEnumerator = first.GetAsyncEnumerator(cancellationToken); set = new Set(comparer); setFilled = false; fillSetTask = FillSetAsync(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index e2b0c68a89..281aeaa51d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -86,11 +86,11 @@ private static async Task FirstCore(IAsyncEnumerable } else { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await e.MoveNextAsync().ConfigureAwait(false)) { return e.Current; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 9e23d5a9c9..9cce97e7ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -86,11 +86,11 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< } else { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await e.MoveNextAsync().ConfigureAwait(false)) { return e.Current; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index d1ca0f2f45..59cd74e51b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -154,11 +154,11 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { var index = 0; - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { action(e.Current, checked(index++)); } @@ -173,11 +173,11 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { var index = 0; - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { await action(e.Current, checked(index++), cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index f39321cfdb..c4fd5ce839 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -259,7 +259,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -348,13 +348,13 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - enumerator = lookup.Select(async g => await resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(); + enumerator = lookup.Select(async g => await resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -437,7 +437,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -526,7 +526,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -611,7 +611,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -696,7 +696,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index a2658a2396..aedb0073e0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -102,14 +103,15 @@ public GroupJoinAsyncEnumerable( _comparer = comparer; } - public IAsyncEnumerator GetAsyncEnumerator() + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new GroupJoinAsyncEnumerator( - _outer.GetAsyncEnumerator(), + _outer.GetAsyncEnumerator(cancellationToken), _inner, _outerKeySelector, _innerKeySelector, _resultSelector, - _comparer); + _comparer, + cancellationToken); private sealed class GroupJoinAsyncEnumerator : IAsyncEnumerator { @@ -119,6 +121,7 @@ private sealed class GroupJoinAsyncEnumerator : IAsyncEnumerator private readonly IAsyncEnumerator _outer; private readonly Func _outerKeySelector; private readonly Func, TResult> _resultSelector; + private readonly CancellationToken _cancellationToken; private Internal.Lookup _lookup; @@ -128,7 +131,8 @@ public GroupJoinAsyncEnumerator( Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector, - IEqualityComparer comparer) + IEqualityComparer comparer, + CancellationToken cancellationToken) { _outer = outer; _inner = inner; @@ -136,6 +140,7 @@ public GroupJoinAsyncEnumerator( _innerKeySelector = innerKeySelector; _resultSelector = resultSelector; _comparer = comparer; + _cancellationToken = cancellationToken; } public async ValueTask MoveNextAsync() @@ -148,7 +153,7 @@ public async ValueTask MoveNextAsync() if (_lookup == null) { - _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } var item = _outer.Current; @@ -192,14 +197,15 @@ public GroupJoinAsyncEnumerableWithTask( _comparer = comparer; } - public IAsyncEnumerator GetAsyncEnumerator() + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new GroupJoinAsyncEnumeratorWithTask( - _outer.GetAsyncEnumerator(), + _outer.GetAsyncEnumerator(cancellationToken), _inner, _outerKeySelector, _innerKeySelector, _resultSelector, - _comparer); + _comparer, + cancellationToken); private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator { @@ -209,6 +215,7 @@ private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator _outer; private readonly Func> _outerKeySelector; private readonly Func, Task> _resultSelector; + private readonly CancellationToken _cancellationToken; private Internal.LookupWithTask _lookup; @@ -218,7 +225,8 @@ public GroupJoinAsyncEnumeratorWithTask( Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector, - IEqualityComparer comparer) + IEqualityComparer comparer, + CancellationToken cancellationToken) { _outer = outer; _inner = inner; @@ -226,6 +234,7 @@ public GroupJoinAsyncEnumeratorWithTask( _innerKeySelector = innerKeySelector; _resultSelector = resultSelector; _comparer = comparer; + _cancellationToken = cancellationToken; } public async ValueTask MoveNextAsync() @@ -238,7 +247,7 @@ public async ValueTask MoveNextAsync() if (_lookup == null) { - _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } var item = _outer.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs index 77bdd9b354..5cb14ea4d0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.Generic; +using System.Threading; // Note: The type here has to be internal as System.Linq has it's own public copy we're not using @@ -103,6 +104,6 @@ internal void Trim() } } - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator() => this.ToAsyncEnumerable().GetAsyncEnumerator(); + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => this.ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 94a04e7f58..88dfebe759 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -74,12 +75,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(); + firstEnumerator = first.GetAsyncEnumerator(cancellationToken); set = new Set(comparer); setFilled = false; fillSetTask = FillSet(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 993f334481..2ce92359f7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -135,12 +136,12 @@ public override async ValueTask DisposeAsync() private const int State_For = 3; private const int State_While = 4; - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = outer.GetAsyncEnumerator(); + outerEnumerator = outer.GetAsyncEnumerator(cancellationToken); mode = State_If; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -151,7 +152,7 @@ protected override async ValueTask MoveNextCore() case State_If: if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { - lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer).ConfigureAwait(false); + lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); if (lookup.Count != 0) { @@ -263,12 +264,12 @@ public override async ValueTask DisposeAsync() private const int State_For = 3; private const int State_While = 4; - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = outer.GetAsyncEnumerator(); + outerEnumerator = outer.GetAsyncEnumerator(cancellationToken); mode = State_If; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -279,7 +280,7 @@ protected override async ValueTask MoveNextCore() case State_If: if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { - lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer).ConfigureAwait(false); + lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); if (lookup.Count != 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 81e228d9fe..724965ccb9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -90,11 +90,11 @@ private static async Task LastCore(IAsyncEnumerable s var last = default(TSource); var hasLast = false; - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { hasLast = true; last = e.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 5e7aa030d4..b9ab5b9da7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -90,11 +90,11 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable Max(this IAsyncEnumerable private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); var max = e.Current; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var cur = e.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 278c1fca46..defb09972c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -69,16 +69,16 @@ public static Task Min(this IAsyncEnumerable private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); var min = e.Current; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var cur = e.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 7e59b73ee5..448c5d6de0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -23,7 +24,7 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending, this); } - internal abstract Task Initialize(); + internal abstract Task Initialize(CancellationToken cancellationToken); } internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnumerable @@ -71,13 +72,13 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - await Initialize().ConfigureAwait(false); + await Initialize(cancellationToken).ConfigureAwait(false); enumerator = enumerable.GetEnumerator(); state = AsyncIteratorState.Iterating; @@ -97,17 +98,17 @@ protected override async ValueTask MoveNextCore() return false; } - internal override async Task Initialize() + internal override async Task Initialize(CancellationToken cancellationToken) { if (parent == null) { - var buffer = await source.ToList().ConfigureAwait(false); + var buffer = await source.ToList(cancellationToken).ConfigureAwait(false); enumerable = (!@descending ? buffer.OrderBy(keySelector, comparer) : buffer.OrderByDescending(keySelector, comparer)); } else { - parentEnumerator = parent.GetAsyncEnumerator(); - await parent.Initialize().ConfigureAwait(false); + parentEnumerator = parent.GetAsyncEnumerator(cancellationToken); + await parent.Initialize(cancellationToken).ConfigureAwait(false); enumerable = parent.enumerable.CreateOrderedEnumerable(keySelector, comparer, @descending); } } @@ -158,13 +159,13 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - await Initialize().ConfigureAwait(false); + await Initialize(cancellationToken).ConfigureAwait(false); enumerator = enumerable.GetEnumerator(); state = AsyncIteratorState.Iterating; @@ -184,17 +185,17 @@ protected override async ValueTask MoveNextCore() return false; } - internal override async Task Initialize() + internal override async Task Initialize(CancellationToken cancellationToken) { if (parent == null) { - var buffer = await source.ToList().ConfigureAwait(false); + var buffer = await source.ToList(cancellationToken).ConfigureAwait(false); enumerable = (!@descending ? buffer.OrderByAsync(keySelector, comparer) : buffer.OrderByDescendingAsync(keySelector, comparer)); } else { - parentEnumerator = parent.GetAsyncEnumerator(); - await parent.Initialize().ConfigureAwait(false); + parentEnumerator = parent.GetAsyncEnumerator(cancellationToken); + await parent.Initialize(cancellationToken).ConfigureAwait(false); enumerable = parent.enumerable.CreateOrderedEnumerableAsync(keySelector, comparer, @descending); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 2c55e0dd10..ea6d57220b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -107,7 +107,7 @@ public Task> TryGetElementAsync(int index, CancellationToken cancella public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(end - 1)); - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 4d97c0a634..5258ffacfc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -58,7 +58,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index dd2e2de891..58a8146f2c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -89,7 +89,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 14548b35c4..a53ecaf7d5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -118,12 +118,12 @@ public override IAsyncEnumerable Select(Func(source, CombineSelectors(this.selector, selector)); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -174,12 +174,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -289,7 +289,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -350,12 +350,12 @@ public override IAsyncEnumerable Select(Func(source, CombineSelectors(this.selector, selector)); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -406,12 +406,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -526,7 +526,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken return res; } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 90488b63f0..b0057e64c3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -141,12 +142,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -163,7 +164,7 @@ protected override async ValueTask MoveNextCore() } var inner = selector(sourceEnumerator.Current); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; @@ -232,12 +233,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -254,7 +255,7 @@ protected override async ValueTask MoveNextCore() } var inner = await selector(sourceEnumerator.Current).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; @@ -329,12 +330,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -352,7 +353,7 @@ protected override async ValueTask MoveNextCore() currentSource = sourceEnumerator.Current; var inner = collectionSelector(currentSource); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; @@ -427,12 +428,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -450,7 +451,7 @@ protected override async ValueTask MoveNextCore() currentSource = sourceEnumerator.Current; var inner = await collectionSelector(currentSource).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; @@ -526,12 +527,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; mode = State_Source; state = AsyncIteratorState.Iterating; @@ -556,7 +557,7 @@ protected override async ValueTask MoveNextCore() } var inner = collectionSelector(currentSource, index); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; @@ -632,12 +633,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; mode = State_Source; state = AsyncIteratorState.Iterating; @@ -662,7 +663,7 @@ protected override async ValueTask MoveNextCore() } var inner = await collectionSelector(currentSource, index).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; @@ -732,12 +733,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; mode = State_Source; state = AsyncIteratorState.Iterating; @@ -760,7 +761,7 @@ protected override async ValueTask MoveNextCore() } var inner = selector(sourceEnumerator.Current, index); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; @@ -830,12 +831,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(); + sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; mode = State_Source; state = AsyncIteratorState.Iterating; @@ -858,7 +859,7 @@ protected override async ValueTask MoveNextCore() } var inner = await selector(sourceEnumerator.Current, index).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(); + resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); mode = State_Result; goto case State_Result; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index a2b0bc0b66..d065679bcc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -88,11 +88,11 @@ private static async Task SequenceEqualCore(IAsyncEnumerable SingleCore(IAsyncEnumerable throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { throw new InvalidOperationException(Strings.NO_ELEMENTS); } var result = e.Current; - if (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (await e.MoveNextAsync().ConfigureAwait(false)) { throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 33d80f02b5..53420f2a39 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -79,17 +79,17 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { return default(TSource); } var result = e.Current; - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { return result; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index f3d8709302..410cee585d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -65,12 +66,12 @@ public override async ValueTask DisposeAsync() } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); queue = new Queue(); state = AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 61bbed003b..0d70eca12f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -83,12 +84,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); // skip elements as requested while (await enumerator.MoveNextAsync().ConfigureAwait(false)) @@ -160,12 +161,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; // skip elements as requested @@ -242,12 +243,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); // skip elements as requested while (await enumerator.MoveNextAsync().ConfigureAwait(false)) @@ -319,12 +320,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; // skip elements as requested diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 07aeaafeaa..2696a9dcc2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -58,12 +59,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); queue = new Queue(); isDone = false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 6ae1d50582..7f806eb27b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -82,12 +83,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -147,12 +148,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -216,12 +217,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -281,12 +282,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 5552d546c4..3cd19ed1bc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -147,7 +147,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -216,7 +216,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -319,7 +319,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs index 6d5fb16840..e5221c30c1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs @@ -18,7 +18,7 @@ public static IEnumerable ToEnumerable(this IAsyncEnumerable ToEnumerableCore(IAsyncEnumerable source) { - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(default); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 8d1f569bd5..0ca9bdd491 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -293,11 +293,11 @@ public IEnumerable ApplyResultSelector(Func(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var key = keySelector(enu.Current); var group = lookup.GetGrouping(key, create: true); @@ -321,11 +321,11 @@ public IEnumerable ApplyResultSelector(Func(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var key = keySelector(enu.Current); lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -339,11 +339,11 @@ public IEnumerable ApplyResultSelector(Func> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { var lookup = new Lookup(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { @@ -474,9 +474,9 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT return Task.FromResult(Count); } - IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator() + IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) { - return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(); + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); } Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) @@ -579,11 +579,11 @@ public IEnumerator> GetEnumerator() var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var key = await keySelector(enu.Current).ConfigureAwait(false); var group = lookup.GetGrouping(key, create: true); @@ -607,11 +607,11 @@ public IEnumerator> GetEnumerator() var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var key = await keySelector(enu.Current).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -625,11 +625,11 @@ public IEnumerator> GetEnumerator() return lookup; } - internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(); + var enu = source.GetAsyncEnumerator(cancellationToken); try { @@ -760,9 +760,9 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT return Task.FromResult(Count); } - IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator() + IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) { - return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(); + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); } Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index f55bf5591b..94939fb6b0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -28,7 +28,7 @@ public ToObservableObservable(IAsyncEnumerable source) public IDisposable Subscribe(IObserver observer) { var ctd = new CancellationTokenDisposable(); - var e = source.GetAsyncEnumerator(); + var e = source.GetAsyncEnumerator(ctd.Token); var f = default(Action); f = () => e.MoveNextAsync().AsTask().ContinueWith( diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 496a5423be..b11a8c5529 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -107,7 +107,7 @@ private async Task GetNextAsync() return false; } - protected sealed override async ValueTask MoveNextCore() + protected sealed override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { @@ -118,7 +118,7 @@ protected sealed override async ValueTask MoveNextCore() { ++_index; - var enumerator = enumerable.GetAsyncEnumerator(); + var enumerator = enumerable.GetAsyncEnumerator(cancellationToken); if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -146,7 +146,7 @@ protected sealed override async ValueTask MoveNextCore() break; } - await SetEnumeratorAsync(enumerable.GetAsyncEnumerator()).ConfigureAwait(false); + await SetEnumeratorAsync(enumerable.GetAsyncEnumerator(cancellationToken)).ConfigureAwait(false); ++_index; } @@ -169,7 +169,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } - await set.UnionWithAsync(enumerable); + await set.UnionWithAsync(enumerable, cancellationToken); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index fe733817b3..a13523f42c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -123,12 +124,12 @@ public override IAsyncEnumerable Where(Func predicate) return new WhereEnumerableAsyncIterator(source, CombinePredicates(this.predicate, predicate)); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -184,12 +185,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -253,12 +254,12 @@ public override IAsyncEnumerable Where(Func> predic return new WhereEnumerableAsyncIteratorWithTask(source, CombinePredicates(this.predicate, predicate)); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -314,12 +315,12 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -387,12 +388,12 @@ public override IAsyncEnumerable Select(Func(source, predicate, CombineSelectors(this.selector, selector)); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(); + enumerator = source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index e842054089..57b2e3375b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -76,13 +77,13 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(); - secondEnumerator = second.GetAsyncEnumerator(); + firstEnumerator = first.GetAsyncEnumerator(cancellationToken); + secondEnumerator = second.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -151,13 +152,13 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore() + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(); - secondEnumerator = second.GetAsyncEnumerator(); + firstEnumerator = first.GetAsyncEnumerator(cancellationToken); + secondEnumerator = second.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index efade65a6d..0e9a1c84f1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -144,9 +145,9 @@ private void Resize() _slots = newSlots; } - public async Task UnionWithAsync(IAsyncEnumerable other) + public async Task UnionWithAsync(IAsyncEnumerable other, CancellationToken cancellationToken) { - var enu = other.GetAsyncEnumerator(); + var enu = other.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index 74a7f09c91..5de431395a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -30,8 +30,8 @@ internal ConfiguredAsyncEnumerable(IAsyncEnumerable enumerable, bool continue _continueOnCapturedContext = continueOnCapturedContext; } - public ConfiguredAsyncEnumerator GetAsyncEnumerator() => - new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(), _continueOnCapturedContext); + public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => + new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); public struct ConfiguredAsyncEnumerator { From e2b5a524e1a0b5ff764aace50ab068daa3886842 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 6 Nov 2018 15:08:20 -0800 Subject: [PATCH 386/862] Some stylistic changes. --- .../AsyncTests.Bugs.cs | 4 +- .../System/Linq/Operators/Repeat.cs | 48 +- .../Linq/Operators/ToAsyncEnumerable.cs | 4 +- .../System/Linq/AsyncEnumerator.cs | 18 +- .../System/Linq/AsyncIterator.cs | 14 +- .../System/Linq/Operators/AppendPrepend.cs | 133 +++-- .../System/Linq/Operators/Join.cs | 168 +++--- .../Linq/Operators/OrderedAsyncEnumerable.cs | 100 ++-- .../System/Linq/Operators/SelectMany.cs | 480 +++++++++--------- 9 files changed, 484 insertions(+), 485 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 00eff30d79..9b96363503 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -98,7 +98,7 @@ public void SelectManyDisposeInvokedOnlyOnce() var result = new[] { 1 }.ToAsyncEnumerable().SelectMany(i => disposeCounter).Select(i => i).ToList().Result; - Assert.Equal(0, result.Count); + Assert.Empty(result); Assert.Equal(1, disposeCounter.DisposeCount); } @@ -109,7 +109,7 @@ public void SelectManyInnerDispose() var result = AsyncEnumerable.Range(0, 10).SelectMany(i => disposes[i]).Select(i => i).ToList().Result; - Assert.Equal(0, result.Count); + Assert.Empty(result); Assert.True(disposes.All(d => d.DisposeCount == 1)); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index ec0bc14f1c..6a1a8c6628 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -36,57 +36,57 @@ public static IAsyncEnumerable Repeat(this IAsyncEnumerable : AsyncIterator { - private readonly TResult element; + private readonly TResult _element; public RepeatElementAsyncIterator(TResult element) { - this.element = element; + _element = element; } public override AsyncIterator Clone() { - return new RepeatElementAsyncIterator(element); + return new RepeatElementAsyncIterator(_element); } protected override ValueTask MoveNextCore(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - current = element; + current = _element; return TaskExt.True; } } private sealed class RepeatSequenceAsyncIterator : AsyncIterator { - private readonly int count; - private readonly bool isInfinite; - private readonly IAsyncEnumerable source; + private readonly int _count; + private readonly bool _isInfinite; + private readonly IAsyncEnumerable _source; - private int currentCount; - private IAsyncEnumerator enumerator; + private int _currentCount; + private IAsyncEnumerator _enumerator; public RepeatSequenceAsyncIterator(IAsyncEnumerable source, int count) { Debug.Assert(source != null); - this.source = source; - this.count = count; - isInfinite = count < 0; - currentCount = count; + _source = source; + _count = count; + _isInfinite = count < 0; + _currentCount = count; } public override AsyncIterator Clone() { - return new RepeatSequenceAsyncIterator(source, count); + return new RepeatSequenceAsyncIterator(_source, _count); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -98,24 +98,24 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella { case AsyncIteratorState.Allocated: - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - if (!isInfinite && currentCount-- == 0) + if (!_isInfinite && _currentCount-- == 0) break; - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index e7a41ae964..621c222313 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -262,7 +262,7 @@ public void ToAsyncEnumerable_With_Canceled_Task() private sealed class MyObservable : IObservable { - private Func, IDisposable> _subscribe; + private readonly Func, IDisposable> _subscribe; public MyObservable(Func, IDisposable> subscribe) { @@ -277,7 +277,7 @@ public IDisposable Subscribe(IObserver observer) private sealed class MyDisposable : IDisposable { - private Action _dispose; + private readonly Action _dispose; public MyDisposable(Action dispose) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 913e0abf16..ff5f212d79 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -106,17 +106,17 @@ internal static IAsyncEnumerator Create(Func, V private sealed class AnonymousAsyncIterator : AsyncIterator { - private readonly Func currentFunc; - private readonly Func> moveNext; - private Func dispose; + private readonly Func _currentFunc; + private readonly Func> _moveNext; + private Func _dispose; public AnonymousAsyncIterator(Func> moveNext, Func currentFunc, Func dispose) { Debug.Assert(moveNext != null); - this.moveNext = moveNext; - this.currentFunc = currentFunc; - this.dispose = dispose; + _moveNext = moveNext; + _currentFunc = currentFunc; + _dispose = dispose; // Explicit call to initialize enumerator mode GetAsyncEnumerator(default); @@ -129,7 +129,7 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - var dispose = Interlocked.Exchange(ref this.dispose, null); + var dispose = Interlocked.Exchange(ref this._dispose, null); if (dispose != null) { @@ -148,9 +148,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await moveNext().ConfigureAwait(false)) + if (await _moveNext().ConfigureAwait(false)) { - current = currentFunc(); + current = _currentFunc(); return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 542915461e..65f37e82c8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -10,9 +10,9 @@ namespace System.Linq { internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator { - private readonly int threadId; + private readonly int _threadId; - private bool currentIsInvalid = true; + private bool _currentIsInvalid = true; internal TSource current; internal AsyncIteratorState state = AsyncIteratorState.New; @@ -20,12 +20,12 @@ internal abstract class AsyncIterator : IAsyncEnumerable, IAsy protected AsyncIterator() { - threadId = Environment.CurrentManagedThreadId; + _threadId = Environment.CurrentManagedThreadId; } public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { - var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId + var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); @@ -57,7 +57,7 @@ public TSource Current { get { - if (currentIsInvalid) + if (_currentIsInvalid) throw new InvalidOperationException("Enumerator is in an invalid state"); return current; @@ -79,13 +79,13 @@ public async ValueTask MoveNextAsync() { var result = await MoveNextCore(cancellationToken).ConfigureAwait(false); - currentIsInvalid = !result; // if move next is false, invalid otherwise valid + _currentIsInvalid = !result; // if move next is false, invalid otherwise valid return result; } catch { - currentIsInvalid = true; + _currentIsInvalid = true; await DisposeAsync().ConfigureAwait(false); throw; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 3f75aa801c..3c79e27c3b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -93,21 +93,21 @@ public override async ValueTask DisposeAsync() private sealed class AppendPrepend1AsyncIterator : AppendPrependAsyncIterator { - private readonly TSource item; - private readonly bool appending; + private readonly TSource _item; + private readonly bool _appending; - bool hasEnumerator; + bool _hasEnumerator; public AppendPrepend1AsyncIterator(IAsyncEnumerable source, TSource item, bool appending) : base(source) { - this.item = item; - this.appending = appending; + _item = item; + _appending = appending; } public override AsyncIterator Clone() { - return new AppendPrepend1AsyncIterator(source, item, appending); + return new AppendPrepend1AsyncIterator(source, _item, _appending); } protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) @@ -115,21 +115,21 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - hasEnumerator = false; + _hasEnumerator = false; state = AsyncIteratorState.Iterating; - if (!appending) + if (!_appending) { - current = item; + current = _item; return true; } goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (!hasEnumerator) + if (!_hasEnumerator) { GetSourceEnumerator(cancellationToken); - hasEnumerator = true; + _hasEnumerator = true; } if (enumerator != null) @@ -140,9 +140,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return true; } - if (appending) + if (_appending) { - current = item; + current = _item; return true; } } @@ -156,25 +156,25 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public override AppendPrependAsyncIterator Append(TSource element) { - if (appending) + if (_appending) { - return new AppendPrependNAsyncIterator(source, null, new SingleLinkedNode(item).Add(element), prependCount: 0, appendCount: 2); + return new AppendPrependNAsyncIterator(source, null, new SingleLinkedNode(_item).Add(element), prependCount: 0, appendCount: 2); } else { - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(item), new SingleLinkedNode(element), prependCount: 1, appendCount: 1); + return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(_item), new SingleLinkedNode(element), prependCount: 1, appendCount: 1); } } public override AppendPrependAsyncIterator Prepend(TSource element) { - if (appending) + if (_appending) { - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(element), new SingleLinkedNode(item), prependCount: 1, appendCount: 1); + return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(element), new SingleLinkedNode(_item), prependCount: 1, appendCount: 1); } else { - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(item).Add(element), null, prependCount: 2, appendCount: 0); + return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(_item).Add(element), null, prependCount: 2, appendCount: 0); } } @@ -188,13 +188,13 @@ public override async Task ToArrayAsync(CancellationToken cancellatio var array = new TSource[count]; int index; - if (appending) + if (_appending) { index = 0; } else { - array[0] = item; + array[0] = _item; index = 1; } @@ -220,9 +220,9 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } } - if (appending) + if (_appending) { - array[array.Length - 1] = item; + array[array.Length - 1] = _item; } return array; @@ -233,9 +233,9 @@ public override async Task> ToListAsync(CancellationToken cancella var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); var list = count == -1 ? new List() : new List(count); - if (!appending) + if (!_appending) { - list.Add(item); + list.Add(_item); } @@ -253,9 +253,9 @@ public override async Task> ToListAsync(CancellationToken cancella await en.DisposeAsync().ConfigureAwait(false); } - if (appending) + if (_appending) { - list.Add(item); + list.Add(_item); } return list; @@ -275,11 +275,13 @@ public override async Task GetCountAsync(bool onlyIfCheap, CancellationToke private sealed class AppendPrependNAsyncIterator : AppendPrependAsyncIterator { - private readonly SingleLinkedNode prepended; - private readonly SingleLinkedNode appended; - private readonly int prependCount; - private readonly int appendCount; - private SingleLinkedNode node; + private readonly SingleLinkedNode _prepended; + private readonly SingleLinkedNode _appended; + private readonly int _prependCount; + private readonly int _appendCount; + private SingleLinkedNode _node; + private int _mode; + private IEnumerator _appendedEnumerator; public AppendPrependNAsyncIterator(IAsyncEnumerable source, SingleLinkedNode prepended, SingleLinkedNode appended, int prependCount, int appendCount) : base(source) @@ -290,26 +292,23 @@ public AppendPrependNAsyncIterator(IAsyncEnumerable source, SingleLinke Debug.Assert((prepended?.GetCount() ?? 0) == prependCount); Debug.Assert((appended?.GetCount() ?? 0) == appendCount); - this.prepended = prepended; - this.appended = appended; - this.prependCount = prependCount; - this.appendCount = appendCount; + this._prepended = prepended; + this._appended = appended; + this._prependCount = prependCount; + this._appendCount = appendCount; } public override AsyncIterator Clone() { - return new AppendPrependNAsyncIterator(source, prepended, appended, prependCount, appendCount); + return new AppendPrependNAsyncIterator(source, _prepended, _appended, _prependCount, _appendCount); } - int mode; - IEnumerator appendedEnumerator; - public override async ValueTask DisposeAsync() { - if (appendedEnumerator != null) + if (_appendedEnumerator != null) { - appendedEnumerator.Dispose(); - appendedEnumerator = null; + _appendedEnumerator.Dispose(); + _appendedEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -320,28 +319,28 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - mode = 1; + _mode = 1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case 1: - node = prepended; - mode = 2; + _node = _prepended; + _mode = 2; goto case 2; case 2: - if (node != null) + if (_node != null) { - current = node.Item; - node = node.Linked; + current = _node.Item; + _node = _node.Linked; return true; } GetSourceEnumerator(cancellationToken); - mode = 3; + _mode = 3; goto case 3; case 3: @@ -350,10 +349,10 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return true; } - if (appended != null) + if (_appended != null) { - appendedEnumerator = appended.GetEnumerator(appendCount); - mode = 4; + _appendedEnumerator = _appended.GetEnumerator(_appendCount); + _mode = 4; goto case 4; } @@ -361,9 +360,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case 4: - if (appendedEnumerator.MoveNext()) + if (_appendedEnumerator.MoveNext()) { - current = appendedEnumerator.Current; + current = _appendedEnumerator.Current; return true; } break; @@ -378,14 +377,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public override AppendPrependAsyncIterator Append(TSource item) { - var res = appended != null ? appended.Add(item) : new SingleLinkedNode(item); - return new AppendPrependNAsyncIterator(source, prepended, res, prependCount, appendCount + 1); + var res = _appended != null ? _appended.Add(item) : new SingleLinkedNode(item); + return new AppendPrependNAsyncIterator(source, _prepended, res, _prependCount, _appendCount + 1); } public override AppendPrependAsyncIterator Prepend(TSource item) { - var res = prepended != null ? prepended.Add(item) : new SingleLinkedNode(item); - return new AppendPrependNAsyncIterator(source, res, appended, prependCount + 1, appendCount); + var res = _prepended != null ? _prepended.Add(item) : new SingleLinkedNode(item); + return new AppendPrependNAsyncIterator(source, res, _appended, _prependCount + 1, _appendCount); } public override async Task ToArrayAsync(CancellationToken cancellationToken) @@ -398,7 +397,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio var array = new TSource[count]; var index = 0; - for (var n = prepended; n != null; n = n.Linked) + for (var n = _prepended; n != null; n = n.Linked) { array[index] = n.Item; ++index; @@ -427,7 +426,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio } index = array.Length; - for (var n = appended; n != null; n = n.Linked) + for (var n = _appended; n != null; n = n.Linked) { --index; array[index] = n.Item; @@ -440,7 +439,7 @@ public override async Task> ToListAsync(CancellationToken cancella { var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); var list = count == -1 ? new List() : new List(count); - for (var n = prepended; n != null; n = n.Linked) + for (var n = _prepended; n != null; n = n.Linked) { list.Add(n.Item); } @@ -459,9 +458,9 @@ public override async Task> ToListAsync(CancellationToken cancella await en.DisposeAsync().ConfigureAwait(false); } - if (appended != null) + if (_appended != null) { - using (var en2 = appended.GetEnumerator(appendCount)) + using (var en2 = _appended.GetEnumerator(_appendCount)) { while (en2.MoveNext()) { @@ -478,10 +477,10 @@ public override async Task GetCountAsync(bool onlyIfCheap, CancellationToke if (source is IAsyncIListProvider listProv) { var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); - return count == -1 ? -1 : count + appendCount + prependCount; + return count == -1 ? -1 : count + _appendCount + _prependCount; } - return !onlyIfCheap || source is ICollection ? await source.Count(cancellationToken).ConfigureAwait(false) + appendCount + prependCount : -1; + return !onlyIfCheap || source is ICollection ? await source.Count(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 2ce92359f7..3d494d3e7e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -81,14 +81,14 @@ public static IAsyncEnumerable Join(this internal sealed class JoinAsyncIterator : AsyncIterator { - private readonly IAsyncEnumerable outer; - private readonly IAsyncEnumerable inner; - private readonly Func outerKeySelector; - private readonly Func innerKeySelector; - private readonly Func resultSelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _outer; + private readonly IAsyncEnumerable _inner; + private readonly Func _outerKeySelector; + private readonly Func _innerKeySelector; + private readonly Func _resultSelector; + private readonly IEqualityComparer _comparer; - private IAsyncEnumerator outerEnumerator; + private IAsyncEnumerator _outerEnumerator; public JoinAsyncIterator(IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector, IEqualityComparer comparer) { @@ -99,37 +99,37 @@ public JoinAsyncIterator(IAsyncEnumerable outer, IAsyncEnumerable Clone() { - return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + return new JoinAsyncIterator(_outer, _inner, _outerKeySelector, _innerKeySelector, _resultSelector, _comparer); } public override async ValueTask DisposeAsync() { - if (outerEnumerator != null) + if (_outerEnumerator != null) { - await outerEnumerator.DisposeAsync().ConfigureAwait(false); - outerEnumerator = null; + await _outerEnumerator.DisposeAsync().ConfigureAwait(false); + _outerEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); } // State machine vars - private Internal.Lookup lookup; - private int count; - private TInner[] elements; - private int index; - private TOuter item; - private int mode; + private Internal.Lookup _lookup; + private int _count; + private TInner[] _elements; + private int _index; + private TOuter _item; + private int _mode; private const int State_If = 1; private const int State_DoLoop = 2; @@ -141,22 +141,22 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = outer.GetAsyncEnumerator(cancellationToken); - mode = State_If; + _outerEnumerator = _outer.GetAsyncEnumerator(cancellationToken); + _mode = State_If; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_If: - if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { - lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, cancellationToken).ConfigureAwait(false); - if (lookup.Count != 0) + if (_lookup.Count != 0) { - mode = State_DoLoop; + _mode = State_DoLoop; goto case State_DoLoop; } } @@ -164,33 +164,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; case State_DoLoop: - item = outerEnumerator.Current; - var g = lookup.GetGrouping(outerKeySelector(item), create: false); + _item = _outerEnumerator.Current; + var g = _lookup.GetGrouping(_outerKeySelector(_item), create: false); if (g != null) { - count = g._count; - elements = g._elements; - index = 0; - mode = State_For; + _count = g._count; + _elements = g._elements; + _index = 0; + _mode = State_For; goto case State_For; } // advance to while - mode = State_While; + _mode = State_While; goto case State_While; case State_For: - current = resultSelector(item, elements[index]); - index++; - if (index == count) + current = _resultSelector(_item, _elements[_index]); + _index++; + if (_index == _count) { - mode = State_While; + _mode = State_While; } return true; case State_While: - var hasNext = await outerEnumerator.MoveNextAsync().ConfigureAwait(false); + var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; @@ -209,14 +209,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class JoinAsyncIteratorWithTask : AsyncIterator { - private readonly IAsyncEnumerable outer; - private readonly IAsyncEnumerable inner; - private readonly Func> outerKeySelector; - private readonly Func> innerKeySelector; - private readonly Func> resultSelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _outer; + private readonly IAsyncEnumerable _inner; + private readonly Func> _outerKeySelector; + private readonly Func> _innerKeySelector; + private readonly Func> _resultSelector; + private readonly IEqualityComparer _comparer; - private IAsyncEnumerator outerEnumerator; + private IAsyncEnumerator _outerEnumerator; public JoinAsyncIteratorWithTask(IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { @@ -227,37 +227,37 @@ public JoinAsyncIteratorWithTask(IAsyncEnumerable outer, IAsyncEnumerabl Debug.Assert(resultSelector != null); Debug.Assert(comparer != null); - this.outer = outer; - this.inner = inner; - this.outerKeySelector = outerKeySelector; - this.innerKeySelector = innerKeySelector; - this.resultSelector = resultSelector; - this.comparer = comparer; + _outer = outer; + _inner = inner; + _outerKeySelector = outerKeySelector; + _innerKeySelector = innerKeySelector; + _resultSelector = resultSelector; + _comparer = comparer; } public override AsyncIterator Clone() { - return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + return new JoinAsyncIteratorWithTask(_outer, _inner, _outerKeySelector, _innerKeySelector, _resultSelector, _comparer); } public override async ValueTask DisposeAsync() { - if (outerEnumerator != null) + if (_outerEnumerator != null) { - await outerEnumerator.DisposeAsync().ConfigureAwait(false); - outerEnumerator = null; + await _outerEnumerator.DisposeAsync().ConfigureAwait(false); + _outerEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); } // State machine vars - private Internal.LookupWithTask lookup; - private int count; - private TInner[] elements; - private int index; - private TOuter item; - private int mode; + private Internal.LookupWithTask _lookup; + private int _count; + private TInner[] _elements; + private int _index; + private TOuter _item; + private int _mode; private const int State_If = 1; private const int State_DoLoop = 2; @@ -269,22 +269,22 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = outer.GetAsyncEnumerator(cancellationToken); - mode = State_If; + _outerEnumerator = _outer.GetAsyncEnumerator(cancellationToken); + _mode = State_If; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_If: - if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { - lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, cancellationToken).ConfigureAwait(false); - if (lookup.Count != 0) + if (_lookup.Count != 0) { - mode = State_DoLoop; + _mode = State_DoLoop; goto case State_DoLoop; } } @@ -292,33 +292,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; case State_DoLoop: - item = outerEnumerator.Current; - var g = lookup.GetGrouping(await outerKeySelector(item).ConfigureAwait(false), create: false); + _item = _outerEnumerator.Current; + var g = _lookup.GetGrouping(await _outerKeySelector(_item).ConfigureAwait(false), create: false); if (g != null) { - count = g._count; - elements = g._elements; - index = 0; - mode = State_For; + _count = g._count; + _elements = g._elements; + _index = 0; + _mode = State_For; goto case State_For; } // advance to while - mode = State_While; + _mode = State_While; goto case State_While; case State_For: - current = await resultSelector(item, elements[index]).ConfigureAwait(false); - index++; - if (index == count) + current = await _resultSelector(_item, _elements[_index]).ConfigureAwait(false); + _index++; + if (_index == _count) { - mode = State_While; + _mode = State_While; } return true; case State_While: - var hasNext = await outerEnumerator.MoveNextAsync().ConfigureAwait(false); + var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 448c5d6de0..a091ca3bb6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -29,13 +29,13 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnumerable { - private readonly IComparer comparer; - private readonly bool descending; - private readonly Func keySelector; - private readonly OrderedAsyncEnumerable parent; + private readonly IComparer _comparer; + private readonly bool _descending; + private readonly Func _keySelector; + private readonly OrderedAsyncEnumerable _parent; - private IEnumerator enumerator; - private IAsyncEnumerator parentEnumerator; + private IEnumerator _enumerator; + private IAsyncEnumerator _parentEnumerator; public OrderedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) { @@ -44,29 +44,29 @@ public OrderedAsyncEnumerable(IAsyncEnumerable source, Func Clone() { - return new OrderedAsyncEnumerable(source, keySelector, comparer, descending, parent); + return new OrderedAsyncEnumerable(source, _keySelector, _comparer, _descending, _parent); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; + _enumerator.Dispose(); + _enumerator = null; } - if (parentEnumerator != null) + if (_parentEnumerator != null) { - await parentEnumerator.DisposeAsync().ConfigureAwait(false); - parentEnumerator = null; + await _parentEnumerator.DisposeAsync().ConfigureAwait(false); + _parentEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -80,14 +80,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella await Initialize(cancellationToken).ConfigureAwait(false); - enumerator = enumerable.GetEnumerator(); + _enumerator = enumerable.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -100,29 +100,29 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal override async Task Initialize(CancellationToken cancellationToken) { - if (parent == null) + if (_parent == null) { var buffer = await source.ToList(cancellationToken).ConfigureAwait(false); - enumerable = (!@descending ? buffer.OrderBy(keySelector, comparer) : buffer.OrderByDescending(keySelector, comparer)); + enumerable = (!_descending ? buffer.OrderBy(_keySelector, _comparer) : buffer.OrderByDescending(_keySelector, _comparer)); } else { - parentEnumerator = parent.GetAsyncEnumerator(cancellationToken); - await parent.Initialize(cancellationToken).ConfigureAwait(false); - enumerable = parent.enumerable.CreateOrderedEnumerable(keySelector, comparer, @descending); + _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken); + await _parent.Initialize(cancellationToken).ConfigureAwait(false); + enumerable = _parent.enumerable.CreateOrderedEnumerable(_keySelector, _comparer, _descending); } } } internal sealed class OrderedAsyncEnumerableWithTask : OrderedAsyncEnumerable { - private readonly IComparer comparer; - private readonly bool descending; - private readonly Func> keySelector; - private readonly OrderedAsyncEnumerable parent; + private readonly IComparer _comparer; + private readonly bool _descending; + private readonly Func> _keySelector; + private readonly OrderedAsyncEnumerable _parent; - private IEnumerator enumerator; - private IAsyncEnumerator parentEnumerator; + private IEnumerator _enumerator; + private IAsyncEnumerator _parentEnumerator; public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) { @@ -131,29 +131,29 @@ public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func Clone() { - return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending, parent); + return new OrderedAsyncEnumerableWithTask(source, _keySelector, _comparer, _descending, _parent); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; + _enumerator.Dispose(); + _enumerator = null; } - if (parentEnumerator != null) + if (_parentEnumerator != null) { - await parentEnumerator.DisposeAsync().ConfigureAwait(false); - parentEnumerator = null; + await _parentEnumerator.DisposeAsync().ConfigureAwait(false); + _parentEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -167,14 +167,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella await Initialize(cancellationToken).ConfigureAwait(false); - enumerator = enumerable.GetEnumerator(); + _enumerator = enumerable.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -187,16 +187,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal override async Task Initialize(CancellationToken cancellationToken) { - if (parent == null) + if (_parent == null) { var buffer = await source.ToList(cancellationToken).ConfigureAwait(false); - enumerable = (!@descending ? buffer.OrderByAsync(keySelector, comparer) : buffer.OrderByDescendingAsync(keySelector, comparer)); + enumerable = (!_descending ? buffer.OrderByAsync(_keySelector, _comparer) : buffer.OrderByDescendingAsync(_keySelector, _comparer)); } else { - parentEnumerator = parent.GetAsyncEnumerator(cancellationToken); - await parent.Initialize(cancellationToken).ConfigureAwait(false); - enumerable = parent.enumerable.CreateOrderedEnumerableAsync(keySelector, comparer, @descending); + _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken); + await _parent.Initialize(cancellationToken).ConfigureAwait(false); + enumerable = _parent.enumerable.CreateOrderedEnumerableAsync(_keySelector, _comparer, _descending); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index b0057e64c3..cc29569573 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -104,39 +104,39 @@ private sealed class SelectManyAsyncIterator : AsyncIterator> selector; - private readonly IAsyncEnumerable source; + private readonly Func> _selector; + private readonly IAsyncEnumerable _source; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyAsyncIterator(IAsyncEnumerable source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectManyAsyncIterator(source, selector); + return new SelectManyAsyncIterator(_source, _selector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -147,38 +147,38 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - var inner = selector(sourceEnumerator.Current); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + var inner = _selector(_sourceEnumerator.Current); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = resultEnumerator.Current; + current = _resultEnumerator.Current; return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } @@ -195,39 +195,39 @@ private sealed class SelectManyAsyncIteratorWithTask : AsyncIt private const int State_Source = 1; private const int State_Result = 2; - private readonly Func>> selector; - private readonly IAsyncEnumerable source; + private readonly Func>> _selector; + private readonly IAsyncEnumerable _source; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectManyAsyncIteratorWithTask(source, selector); + return new SelectManyAsyncIteratorWithTask(_source, _selector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -238,38 +238,38 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - var inner = await selector(sourceEnumerator.Current).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + var inner = await _selector(_sourceEnumerator.Current).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = resultEnumerator.Current; + current = _resultEnumerator.Current; return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } @@ -286,14 +286,14 @@ private sealed class SelectManyAsyncIterator : As private const int State_Source = 1; private const int State_Result = 2; - private readonly Func> collectionSelector; - private readonly Func resultSelector; - private readonly IAsyncEnumerable source; + private readonly Func> _collectionSelector; + private readonly Func _resultSelector; + private readonly IAsyncEnumerable _source; - private TSource currentSource; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private TSource _currentSource; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyAsyncIterator(IAsyncEnumerable source, Func> collectionSelector, Func resultSelector) { @@ -301,31 +301,31 @@ public SelectManyAsyncIterator(IAsyncEnumerable source, Func Clone() { - return new SelectManyAsyncIterator(source, collectionSelector, resultSelector); + return new SelectManyAsyncIterator(_source, _collectionSelector, _resultSelector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } - currentSource = default(TSource); + _currentSource = default(TSource); await base.DisposeAsync().ConfigureAwait(false); } @@ -335,39 +335,39 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - currentSource = sourceEnumerator.Current; - var inner = collectionSelector(currentSource); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _currentSource = _sourceEnumerator.Current; + var inner = _collectionSelector(_currentSource); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = resultSelector(currentSource, resultEnumerator.Current); + current = _resultSelector(_currentSource, _resultEnumerator.Current); return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } @@ -384,14 +384,14 @@ private sealed class SelectManyAsyncIteratorWithTask>> collectionSelector; - private readonly Func> resultSelector; - private readonly IAsyncEnumerable source; + private readonly Func>> _collectionSelector; + private readonly Func> _resultSelector; + private readonly IAsyncEnumerable _source; - private TSource currentSource; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private TSource _currentSource; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { @@ -399,31 +399,31 @@ public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() { - return new SelectManyAsyncIteratorWithTask(source, collectionSelector, resultSelector); + return new SelectManyAsyncIteratorWithTask(_source, _collectionSelector, _resultSelector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } - currentSource = default(TSource); + _currentSource = default(TSource); await base.DisposeAsync().ConfigureAwait(false); } @@ -433,39 +433,39 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - currentSource = sourceEnumerator.Current; - var inner = await collectionSelector(currentSource).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _currentSource = _sourceEnumerator.Current; + var inner = await _collectionSelector(_currentSource).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = await resultSelector(currentSource, resultEnumerator.Current).ConfigureAwait(false); + current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false); return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } @@ -482,15 +482,15 @@ private sealed class SelectManyWithIndexAsyncIterator> collectionSelector; - private readonly Func resultSelector; - private readonly IAsyncEnumerable source; + private readonly Func> _collectionSelector; + private readonly Func _resultSelector; + private readonly IAsyncEnumerable _source; - private TSource currentSource; - private int index; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private TSource _currentSource; + private int _index; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyWithIndexAsyncIterator(IAsyncEnumerable source, Func> collectionSelector, Func resultSelector) { @@ -498,31 +498,31 @@ public SelectManyWithIndexAsyncIterator(IAsyncEnumerable source, Func Clone() { - return new SelectManyWithIndexAsyncIterator(source, collectionSelector, resultSelector); + return new SelectManyWithIndexAsyncIterator(_source, _collectionSelector, _resultSelector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } - currentSource = default(TSource); + _currentSource = default(TSource); await base.DisposeAsync().ConfigureAwait(false); } @@ -532,46 +532,46 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - currentSource = sourceEnumerator.Current; + _currentSource = _sourceEnumerator.Current; checked { - index++; + _index++; } - var inner = collectionSelector(currentSource, index); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + var inner = _collectionSelector(_currentSource, _index); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = resultSelector(currentSource, resultEnumerator.Current); + current = _resultSelector(_currentSource, _resultEnumerator.Current); return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } @@ -588,15 +588,15 @@ private sealed class SelectManyWithIndexAsyncIteratorWithTask>> collectionSelector; - private readonly Func> resultSelector; - private readonly IAsyncEnumerable source; + private readonly Func>> _collectionSelector; + private readonly Func> _resultSelector; + private readonly IAsyncEnumerable _source; - private TSource currentSource; - private int index; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private TSource _currentSource; + private int _index; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { @@ -604,31 +604,31 @@ public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source Debug.Assert(collectionSelector != null); Debug.Assert(resultSelector != null); - this.source = source; - this.collectionSelector = collectionSelector; - this.resultSelector = resultSelector; + _source = source; + _collectionSelector = collectionSelector; + _resultSelector = resultSelector; } public override AsyncIterator Clone() { - return new SelectManyWithIndexAsyncIteratorWithTask(source, collectionSelector, resultSelector); + return new SelectManyWithIndexAsyncIteratorWithTask(_source, _collectionSelector, _resultSelector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } - currentSource = default(TSource); + _currentSource = default(TSource); await base.DisposeAsync().ConfigureAwait(false); } @@ -638,46 +638,46 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - currentSource = sourceEnumerator.Current; + _currentSource = _sourceEnumerator.Current; checked { - index++; + _index++; } - var inner = await collectionSelector(currentSource, index).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + var inner = await _collectionSelector(_currentSource, _index).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = await resultSelector(currentSource, resultEnumerator.Current).ConfigureAwait(false); + current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false); return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } @@ -694,40 +694,40 @@ private sealed class SelectManyWithIndexAsyncIterator : AsyncI private const int State_Source = 1; private const int State_Result = 2; - private readonly Func> selector; - private readonly IAsyncEnumerable source; + private readonly Func> _selector; + private readonly IAsyncEnumerable _source; - private int index; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private int _index; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyWithIndexAsyncIterator(IAsyncEnumerable source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectManyWithIndexAsyncIterator(source, selector); + return new SelectManyWithIndexAsyncIterator(_source, _selector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -738,44 +738,44 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } checked { - index++; + _index++; } - var inner = selector(sourceEnumerator.Current, index); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + var inner = _selector(_sourceEnumerator.Current, _index); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = resultEnumerator.Current; + current = _resultEnumerator.Current; return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } @@ -792,40 +792,40 @@ private sealed class SelectManyWithIndexAsyncIteratorWithTask private const int State_Source = 1; private const int State_Result = 2; - private readonly Func>> selector; - private readonly IAsyncEnumerable source; + private readonly Func>> _selector; + private readonly IAsyncEnumerable _source; - private int index; - private int mode; - private IAsyncEnumerator resultEnumerator; - private IAsyncEnumerator sourceEnumerator; + private int _index; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectManyWithIndexAsyncIteratorWithTask(source, selector); + return new SelectManyWithIndexAsyncIteratorWithTask(_source, _selector); } public override async ValueTask DisposeAsync() { - if (sourceEnumerator != null) + if (_sourceEnumerator != null) { - await sourceEnumerator.DisposeAsync().ConfigureAwait(false); - sourceEnumerator = null; + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; } - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); - resultEnumerator = null; + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -836,44 +836,44 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourceEnumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; - mode = State_Source; + _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; + _mode = State_Source; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_Source: - if (await sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) { - if (resultEnumerator != null) + if (_resultEnumerator != null) { - await resultEnumerator.DisposeAsync().ConfigureAwait(false); + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } checked { - index++; + _index++; } - var inner = await selector(sourceEnumerator.Current, index).ConfigureAwait(false); - resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + var inner = await _selector(_sourceEnumerator.Current, _index).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); - mode = State_Result; + _mode = State_Result; goto case State_Result; } break; case State_Result: - if (await resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = resultEnumerator.Current; + current = _resultEnumerator.Current; return true; } - mode = State_Source; + _mode = State_Source; goto case State_Source; // loop } From 4847c395211c536ac5c76b7afd1ae6f769ec027c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 6 Nov 2018 15:17:21 -0800 Subject: [PATCH 387/862] Modernize some code. --- .../AsyncTests.Bugs.cs | 4 +- .../System/Linq/Operators/Catch.cs | 8 +-- .../System/Linq/Operators/Distinct.cs | 2 +- .../Linq/Operators/DistinctUntilChanged.cs | 6 +-- .../System/Linq/Operators/Do.cs | 20 ++++---- .../System/Linq/Operators/Generate.cs | 6 +-- .../System/Linq/Operators/IsEmpty.cs | 4 +- .../System/Linq/Operators/Max.cs | 8 +-- .../System/Linq/Operators/MaxBy.cs | 2 +- .../System/Linq/Operators/Min.cs | 8 +-- .../System/Linq/Operators/MinBy.cs | 2 +- .../Linq/Operators/OnErrorResumeNext.cs | 6 +-- .../System/Linq/Operators/Retry.cs | 4 +- .../System/Linq/Operators/SelectMany.cs | 4 +- .../System/Linq/Operators/StartWith.cs | 4 +- .../System/Linq/Operators/Using.cs | 4 +- .../System.Interactive.Async/AsyncIterator.cs | 2 +- .../Linq/Operators/DistinctUntilChanged.cs | 6 +-- .../System/Linq/Operators/Scan.cs | 12 ++--- .../System/Linq/Operators/Using.cs | 4 +- .../System.Linq.Async.Queryable/Reflection.cs | 4 +- .../System/Linq/Operators/Aggregate.cs | 20 ++++---- .../System/Linq/Operators/All.cs | 4 +- .../System/Linq/Operators/Any.cs | 8 +-- .../System/Linq/Operators/Append.cs | 2 +- .../System/Linq/Operators/Cast.cs | 2 +- .../System/Linq/Operators/Concat.cs | 4 +- .../System/Linq/Operators/Contains.cs | 8 +-- .../System/Linq/Operators/Count.cs | 8 +-- .../System/Linq/Operators/CreateEnumerator.cs | 2 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 6 +-- .../System/Linq/Operators/ElementAt.cs | 4 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/Except.cs | 8 +-- .../System/Linq/Operators/First.cs | 8 +-- .../System/Linq/Operators/FirstOrDefault.cs | 8 +-- .../System/Linq/Operators/ForEachAsync.cs | 8 +-- .../System/Linq/Operators/GroupBy.cs | 50 +++++++++---------- .../System/Linq/Operators/GroupJoin.cs | 24 ++++----- .../System/Linq/Operators/Intersect.cs | 10 ++-- .../System/Linq/Operators/Join.cs | 30 +++++------ .../System/Linq/Operators/Last.cs | 8 +-- .../System/Linq/Operators/LastOrDefault.cs | 8 +-- .../System/Linq/Operators/LongCount.cs | 8 +-- .../System/Linq/Operators/OfType.cs | 2 +- .../System/Linq/Operators/OrderBy.cs | 24 ++++----- .../System/Linq/Operators/Prepend.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/Select.cs | 4 +- .../System/Linq/Operators/SelectMany.cs | 12 ++--- .../System/Linq/Operators/SequenceEqual.cs | 18 +++---- .../System/Linq/Operators/Single.cs | 8 +-- .../System/Linq/Operators/SingleOrDefault.cs | 8 +-- .../System/Linq/Operators/Skip.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 4 +- .../System/Linq/Operators/Take.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 4 +- .../System/Linq/Operators/Throw.cs | 2 +- .../System/Linq/Operators/ToArray.cs | 4 +- .../System/Linq/Operators/ToDictionary.cs | 36 ++++++------- .../System/Linq/Operators/ToHashSet.cs | 8 +-- .../System/Linq/Operators/ToList.cs | 4 +- .../System/Linq/Operators/ToLookup.cs | 36 ++++++------- .../System/Linq/Operators/Union.cs | 10 ++-- .../System/Linq/Operators/Where.cs | 4 +- .../System/Linq/Operators/Zip.cs | 4 +- .../ValueTaskHelpers.cs | 10 ++-- .../System/Linq/AsyncEnumerator.cs | 2 +- .../System/Linq/AsyncIterator.cs | 2 +- .../System/Linq/Operators/AppendPrepend.cs | 10 ++-- .../System/Linq/Operators/Concat.cs | 17 +++---- .../Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/Empty.cs | 2 +- .../System/Linq/Operators/FirstOrDefault.cs | 2 +- .../System/Linq/Operators/LastOrDefault.cs | 2 +- .../System/Linq/Operators/Range.cs | 40 +++++++-------- .../System/Linq/Operators/SelectMany.cs | 8 +-- .../System/Linq/Operators/SingleOrDefault.cs | 4 +- .../System/Linq/Operators/ToLookup.cs | 8 +-- 80 files changed, 337 insertions(+), 338 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 9b96363503..c4057907fe 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -69,7 +69,7 @@ public async Task DisposesUponError() Assert.True(result); } - static IEnumerable Blocking(ManualResetEvent evt, ManualResetEvent blockingStarted) + private static IEnumerable Blocking(ManualResetEvent evt, ManualResetEvent blockingStarted) { blockingStarted.Set(); evt.WaitOne(); @@ -154,7 +154,7 @@ public ValueTask MoveNextAsync() } } - static class MyExt + internal static class MyExt { public static IEnumerable WithDispose(this IEnumerable source, Action a) { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs index 6e66600a8d..96d51746bd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -15,12 +15,12 @@ public class Catch : AsyncEnumerableExTests [Fact] public void Catch_Null() { - AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Catch(default, x => default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.Catch(Return42, default(Func>))); - AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable), Return42)); - AssertThrows(() => AsyncEnumerableEx.Catch(Return42, default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Catch(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerableEx.Catch(default, Return42)); + AssertThrows(() => AsyncEnumerableEx.Catch(Return42, default)); + AssertThrows(() => AsyncEnumerableEx.Catch(default)); AssertThrows(() => AsyncEnumerableEx.Catch(default(IEnumerable>))); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index 319296439b..319f90a210 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -22,7 +22,7 @@ public void Distinct_Null() AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs index 154285224c..0ba87cfbc7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -17,15 +17,15 @@ public void DistinctUntilChanged_Null() { AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default)); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func))); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index 3e1aef2311..4c01c05ca6 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -15,23 +15,23 @@ public class Do : AsyncEnumerableExTests [Fact] public void Do_Null() { - AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { })); + AssertThrows(() => AsyncEnumerableEx.Do(default, x => { })); AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action), () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(default, x => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default, () => { })); AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, ex => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action), ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(default, x => { }, ex => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default, ex => { })); AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), x => { }, ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action), ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action), () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, ex => { }, default(Action))); + AssertThrows(() => AsyncEnumerableEx.Do(default, x => { }, ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, default, ex => { }, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default, () => { })); + AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, ex => { }, default)); - AssertThrows(() => AsyncEnumerableEx.Do(default(IAsyncEnumerable), new MyObs())); + AssertThrows(() => AsyncEnumerableEx.Do(default, new MyObs())); AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(IObserver))); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs index 751f45065e..60dc0bb9c3 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs @@ -14,9 +14,9 @@ public class Generate : AsyncEnumerableExTests [Fact] public void Generate_Null() { - AssertThrows(() => AsyncEnumerableEx.Generate(0, default(Func), x => x, x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, default(Func), x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, default(Func))); + AssertThrows(() => AsyncEnumerableEx.Generate(0, default, x => x, x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, default, x => x)); + AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs index 1b3cc968f4..c1ce5a71fb 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs @@ -16,8 +16,8 @@ public class IsEmpty : AsyncEnumerableExTests [Fact] public async Task IsEmpty_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs index 873bb23e8d..abcfd7bbd2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs @@ -16,11 +16,11 @@ public class Max : AsyncEnumerableExTests [Fact] public async Task Max_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index 9dd9c9f641..a59aa074da 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -28,7 +28,7 @@ public async Task MaxBy_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, x => x, default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, x => x, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs index bd56968c0f..111a9d17f9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs @@ -16,11 +16,11 @@ public class Min : AsyncEnumerableExTests [Fact] public async Task Min_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default(IAsyncEnumerable), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index bd38ccddfd..f4af0f8ddb 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -28,7 +28,7 @@ public async Task MinBy_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, x => x, default(IComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, x => x, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs index 8127c41759..40b664a9f2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -15,9 +15,9 @@ public class OnErrorResumeNext : AsyncEnumerableExTests [Fact] public void OnErrorResumeNext_Null() { - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable), Return42)); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(Return42, default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IAsyncEnumerable[]))); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default, Return42)); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(Return42, default)); + AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default)); AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IEnumerable>))); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs index 4dd420cdab..ea0d528943 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs @@ -14,9 +14,9 @@ public class Retry : AsyncEnumerableExTests [Fact] public void Retry_Null() { - AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Retry(default)); - AssertThrows(() => AsyncEnumerableEx.Retry(default(IAsyncEnumerable), 1)); + AssertThrows(() => AsyncEnumerableEx.Retry(default, 1)); AssertThrows(() => AsyncEnumerableEx.Retry(Return42, -1)); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs index d4d5c1e58b..977b60f177 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -14,8 +14,8 @@ public class SelectMany : AsyncEnumerableExTests [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerableEx.SelectMany(default(IAsyncEnumerable), Return42)); - AssertThrows(() => AsyncEnumerableEx.SelectMany(Return42, default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.SelectMany(default, Return42)); + AssertThrows(() => AsyncEnumerableEx.SelectMany(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index 51ee32d6d5..90279ba874 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -14,8 +14,8 @@ public class StartWith : AsyncEnumerableExTests [Fact] public void StartWith_Null() { - AssertThrows(() => AsyncEnumerableEx.StartWith(default(IAsyncEnumerable), new[] { 1 })); - AssertThrows(() => AsyncEnumerableEx.StartWith(Return42, default(int[]))); + AssertThrows(() => AsyncEnumerableEx.StartWith(default, new[] { 1 })); + AssertThrows(() => AsyncEnumerableEx.StartWith(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index fbcac3a17d..1052310c53 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -15,8 +15,8 @@ public class Using : AsyncEnumerableExTests [Fact] public void Using_Null() { - AssertThrows(() => AsyncEnumerableEx.Using(default(Func), _ => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Using(() => new MyD(null), default(Func>))); + AssertThrows(() => AsyncEnumerableEx.Using(default, _ => default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerableEx.Using(() => new MyD(null), default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 8d86eb2fc1..d24676a8bd 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -47,7 +47,7 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) public virtual ValueTask DisposeAsync() { - current = default(TSource); + current = default; state = AsyncIteratorState.Disposed; return TaskExt.CompletedTask; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 75d9f6f114..6dfbdba68b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -117,7 +117,7 @@ public override async ValueTask DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - currentValue = default(TSource); + currentValue = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -188,7 +188,7 @@ public override async ValueTask DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - currentKeyValue = default(TKey); + currentKeyValue = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -259,7 +259,7 @@ public override async ValueTask DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - currentKeyValue = default(TKey); + currentKeyValue = default; } await base.DisposeAsync().ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 9070aebfee..08a93924dc 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -81,7 +81,7 @@ public override async ValueTask DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - accumulated = default(TSource); + accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -94,7 +94,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(cancellationToken); hasSeed = false; - accumulated = default(TSource); + accumulated = default; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -155,7 +155,7 @@ public override async ValueTask DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - accumulated = default(TAccumulate); + accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -219,7 +219,7 @@ public override async ValueTask DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - accumulated = default(TSource); + accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -232,7 +232,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Allocated: enumerator = source.GetAsyncEnumerator(cancellationToken); hasSeed = false; - accumulated = default(TSource); + accumulated = default; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -293,7 +293,7 @@ public override async ValueTask DisposeAsync() { await enumerator.DisposeAsync().ConfigureAwait(false); enumerator = null; - accumulated = default(TAccumulate); + accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 14f2f59dfe..6e3be337f5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -65,7 +65,7 @@ public override async ValueTask DisposeAsync() if (resource != null) { resource.Dispose(); - resource = default(TResource); + resource = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -139,7 +139,7 @@ public override async ValueTask DisposeAsync() if (resource != null) { resource.Dispose(); - resource = default(TResource); + resource = default; } await base.DisposeAsync().ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs b/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs index 70b0599d3d..1094f74f82 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs @@ -21,7 +21,7 @@ internal enum BindingFlags namespace System { - static class TypeExtensions + internal static class TypeExtensions { public static bool IsNestedPrivate(this Type t) { @@ -90,7 +90,7 @@ private static bool IsVisible(MethodInfo method, BindingFlags flags) namespace System { - static class TypeExtensions + internal static class TypeExtensions { public static bool IsNestedPrivate(this Type t) { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index fe1a6a143f..6357b08107 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -16,25 +16,25 @@ public class Aggregate : AsyncEnumerableTests [Fact] public async Task Aggregate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, (x, y) => x + y)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, (x, y) => x + y, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default(IAsyncEnumerable), 0, (x, y) => x + y, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 05e48666d1..11490dca18 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -16,10 +16,10 @@ public class All : AsyncEnumerableTests [Fact] public async Task All_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.All(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 1c9770c8f2..019aafcdee 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -16,12 +16,12 @@ public class Any : AsyncEnumerableTests [Fact] public async Task Any_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs index 76be4296d5..beb97e7b3b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs @@ -15,7 +15,7 @@ public class Append : AsyncEnumerableTests [Fact] public void Append_Null() { - AssertThrows(() => AsyncEnumerable.Append(default(IAsyncEnumerable), 42)); + AssertThrows(() => AsyncEnumerable.Append(default, 42)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs index 67e069d086..79fba3b75a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs @@ -14,7 +14,7 @@ public class Cast : AsyncEnumerableTests [Fact] public void Cast_Null() { - AssertThrows(() => AsyncEnumerable.Cast(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Cast(default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 11d0cb90e4..49e76ce4b7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -15,8 +15,8 @@ public class Concat : AsyncEnumerableTests [Fact] public void Concat_Null() { - AssertThrows(() => AsyncEnumerable.Concat(default(IAsyncEnumerable), Return42)); - AssertThrows(() => AsyncEnumerable.Concat(Return42, default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Concat(default, Return42)); + AssertThrows(() => AsyncEnumerable.Concat(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index c03eed5193..51280f9fb8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -16,12 +16,12 @@ public class Contains : AsyncEnumerableTests [Fact] public async Task Contains_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(Return42, 42, null)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default(IAsyncEnumerable), 42, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(Return42, 42, null, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 60f167d2e6..8b294c77cb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -16,12 +16,12 @@ public class Count : AsyncEnumerableTests [Fact] public async Task Count_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index cf8b0c4b18..4161a29a13 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -15,7 +15,7 @@ public class CreateEnumerator : AsyncEnumerableTests [Fact] public void CreateEnumerator_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerator(default(Func>), () => 3, () => TaskExt.CompletedTask)); + AssertThrows(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => TaskExt.CompletedTask)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index fbd2a99749..1dba99e51e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -15,8 +15,8 @@ public class DefaultIfEmpty : AsyncEnumerableTests [Fact] public void DefaultIfEmpty_Null() { - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default(IAsyncEnumerable), 42)); + AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default)); + AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default, 42)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index 9726089f0e..b7769376bc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -15,9 +15,9 @@ public class Distinct : AsyncEnumerableTests [Fact] public void Distinct_Null() { - AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerable.Distinct(default(IAsyncEnumerable), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Distinct(Return42, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Distinct(default)); + AssertThrows(() => AsyncEnumerable.Distinct(default, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Distinct(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index 22dd661321..ce122152c1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -16,10 +16,10 @@ public class ElementAt : AsyncEnumerableTests [Fact] public async Task ElementAt_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default(IAsyncEnumerable), 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default, 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default(IAsyncEnumerable), 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default, 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index 21a7f0df37..692b0cd5e6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -16,10 +16,10 @@ public class ElementAtOrDefault : AsyncEnumerableTests [Fact] public async Task ElementAtOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default(IAsyncEnumerable), 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default, 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(Return42, -1)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default(IAsyncEnumerable), 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default, 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(Return42, -1, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs index cce6bb310c..b6d4749b72 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs @@ -15,12 +15,12 @@ public class Except : AsyncEnumerableTests [Fact] public void Except_Null() { - AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), Return42)); - AssertThrows(() => AsyncEnumerable.Except(Return42, default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Except(default, Return42)); + AssertThrows(() => AsyncEnumerable.Except(Return42, default)); - AssertThrows(() => AsyncEnumerable.Except(default(IAsyncEnumerable), Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Except(default, Return42, new Eq())); AssertThrows(() => AsyncEnumerable.Except(Return42, null, new Eq())); - AssertThrows(() => AsyncEnumerable.Except(Return42, Return42, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Except(Return42, Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 8e1bf08b90..8bd21cfe8d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -16,12 +16,12 @@ public class First : AsyncEnumerableTests [Fact] public async Task First_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index f031ad73b2..a587888afe 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -16,12 +16,12 @@ public class FirstOrDefault : AsyncEnumerableTests [Fact] public async Task FirstOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 36338c293a..30791dcae4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -16,14 +16,14 @@ public class ForEachAsync : AsyncEnumerableTests [Fact] public async Task ForEachAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), x => { })); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, x => { })); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), (x, i) => { })); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (x, i) => { })); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), x => { }, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, x => { }, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default(IAsyncEnumerable), (x, i) => { }, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (x, i) => { }, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 4b880e0fd7..1b21c10ed2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -15,41 +15,41 @@ public class GroupBy : AsyncEnumerableTests [Fact] public void GroupBy_Null() { - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func))); - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>))); - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, (x, ys) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, (x, ys) => x, default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default(Func, int>))); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), x => x, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, (x, ys) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, (x, ys) => x, default)); } [Fact] @@ -226,7 +226,7 @@ public void GroupBy6() } - static IEnumerable GetXs() + private static IEnumerable GetXs() { yield return 42; yield return 43; @@ -857,14 +857,14 @@ public Kvp(string key, int item) public bool Equals(Kvp other) { - if (ReferenceEquals(null, other)) return false; + if (other is null) return false; if (ReferenceEquals(this, other)) return true; return string.Equals(Key, other.Key) && Item == other.Item; } public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; + if (obj is null) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != GetType()) return false; return Equals((Kvp)obj); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index 3f83b4f673..a01ba4c037 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -14,18 +14,18 @@ public class GroupJoin : AsyncEnumerableTests [Fact] public void GroupJoin_Null() { - AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default(Func), x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default(Func), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default(Func, int>))); - - AssertThrows(() => AsyncEnumerable.GroupJoin(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default(Func), x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default(Func), (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, (x, y) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default)); + + AssertThrows(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, (x, y) => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs index 95bdaeecda..afe6a150b8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs @@ -15,12 +15,12 @@ public class Intersect : AsyncEnumerableTests [Fact] public void Intersect_Null() { - AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), Return42)); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Intersect(default, Return42)); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, default)); - AssertThrows(() => AsyncEnumerable.Intersect(default(IAsyncEnumerable), Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, default(IAsyncEnumerable), new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, Return42, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Intersect(default, Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, default, new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index cc0eca6334..01ba0eced2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -15,18 +15,18 @@ public class Join : AsyncEnumerableTests [Fact] public void Join_Null() { - AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default(Func), x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default(Func), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default(Func))); - - AssertThrows(() => AsyncEnumerable.Join(default(IAsyncEnumerable), Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, default(IAsyncEnumerable), x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default(Func), x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default(Func), (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, (x, y) => x, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default)); + + AssertThrows(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, (x, y) => x, default)); } [Fact] @@ -248,16 +248,16 @@ public class CustomerOrder : IEquatable public bool Equals(CustomerOrder other) { - if (ReferenceEquals(null, other)) return false; + if (other is null) return false; if (ReferenceEquals(this, other)) return true; return OrderId == other.OrderId && string.Equals(CustomerId, other.CustomerId); } public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; + if (obj is null) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; + if (obj.GetType() != GetType()) return false; return Equals((CustomerOrder)obj); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index e99cdc1d68..0c857fc9b9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -16,12 +16,12 @@ public class Last : AsyncEnumerableTests [Fact] public async Task Last_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index daaa15f0d9..14b04b834e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -16,12 +16,12 @@ public class LastOrDefault : AsyncEnumerableTests [Fact] public async Task LastOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 455b06c162..1dbde20dad 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -16,12 +16,12 @@ public class LongCount : AsyncEnumerableTests [Fact] public async Task LongCount_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs index fcd682aacd..9986a61c08 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs @@ -14,7 +14,7 @@ public class OfType : AsyncEnumerableTests [Fact] public void OfType_Null() { - AssertThrows(() => AsyncEnumerable.OfType(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.OfType(default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index c4dd1d9f6d..12a41476b8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -15,35 +15,35 @@ public class OrderBy : AsyncEnumerableTests [Fact] public void OrderBy_Null() { - AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.OrderBy(default, x => x)); AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.OrderBy(default(IAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderBy(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(Return42, x => x, default(IComparer))); + AssertThrows(() => AsyncEnumerable.OrderBy(Return42, x => x, default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x)); AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.OrderByDescending(default(IAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, x => x, default(IComparer))); + AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, x => x, default)); var xs = Return42.OrderBy(x => x); - AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.ThenBy(default, x => x)); AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); - AssertThrows(() => AsyncEnumerable.ThenBy(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenBy(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, x => x, default(IComparer))); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, x => x, default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x)); AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); - AssertThrows(() => AsyncEnumerable.ThenByDescending(default(IOrderedAsyncEnumerable), x => x, Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, x => x, default(IComparer))); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs index dd827a262a..312e1e7ae8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs @@ -15,7 +15,7 @@ public class Prepend : AsyncEnumerableTests [Fact] public void Prepend_Null() { - AssertThrows(() => AsyncEnumerable.Prepend(default(IAsyncEnumerable), 42)); + AssertThrows(() => AsyncEnumerable.Prepend(default, 42)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index a6d3f75970..c90eb90487 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -15,7 +15,7 @@ public class Reverse : AsyncEnumerableTests [Fact] public void Reverse_Null() { - AssertThrows(() => AsyncEnumerable.Reverse(default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Reverse(default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index eaf5d72f6c..2528839843 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -15,8 +15,8 @@ public class Select : AsyncEnumerableTests [Fact] public void Select_Null() { - AssertThrows(() => AsyncEnumerable.Select(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerable.Select(default(IAsyncEnumerable), (x, i) => x)); + AssertThrows(() => AsyncEnumerable.Select(default, x => x)); + AssertThrows(() => AsyncEnumerable.Select(default, (x, i) => x)); AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index df45777bed..aea42b7c9c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -15,17 +15,17 @@ public class SelectMany : AsyncEnumerableTests [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(default(IAsyncEnumerable), default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, x => default(IAsyncEnumerable), default(Func))); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, (x, i) => default(IAsyncEnumerable), default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, x => default, default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, (x, i) => default, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 69bae9c9fd..8b9a6160e0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -16,19 +16,19 @@ public class SequenceEqual : AsyncEnumerableTests [Fact] public async Task SequenceEqual_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable), new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq())); await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, Return42, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default(IAsyncEnumerable), Return42, new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default(IAsyncEnumerable), new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, Return42, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, Return42, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index c80b9d8c73..e9e0a117f7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -16,12 +16,12 @@ public class Single : AsyncEnumerableTests [Fact] public async Task Single_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index bab4add363..877fa5a6f0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -16,12 +16,12 @@ public class SingleOrDefault : AsyncEnumerableTests [Fact] public async Task SingleOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default(IAsyncEnumerable), x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func), CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index db7f44383b..f8f84a7560 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -15,7 +15,7 @@ public class Skip : AsyncEnumerableTests [Fact] public void Skip_Null() { - AssertThrows(() => AsyncEnumerable.Skip(default(IAsyncEnumerable), 5)); + AssertThrows(() => AsyncEnumerable.Skip(default, 5)); } //[Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index 9725a3fd46..904ee2716f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -15,8 +15,8 @@ public class SkipWhile : AsyncEnumerableTests [Fact] public void SkipWhile_Null() { - AssertThrows(() => AsyncEnumerable.SkipWhile(default(IAsyncEnumerable), x => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(default(IAsyncEnumerable), (x, i) => true)); + AssertThrows(() => AsyncEnumerable.SkipWhile(default, x => true)); + AssertThrows(() => AsyncEnumerable.SkipWhile(default, (x, i) => true)); AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index 35b86faf9a..6a3c1f3d69 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -15,7 +15,7 @@ public class Take : AsyncEnumerableTests [Fact] public void Take_Null() { - AssertThrows(() => AsyncEnumerable.Take(default(IAsyncEnumerable), 5)); + AssertThrows(() => AsyncEnumerable.Take(default, 5)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index 4ec8dd7ffc..1b1a7f0f06 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -15,8 +15,8 @@ public class TakeWhile : AsyncEnumerableTests [Fact] public void TakeWhile_Null() { - AssertThrows(() => AsyncEnumerable.TakeWhile(default(IAsyncEnumerable), x => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(default(IAsyncEnumerable), (x, i) => true)); + AssertThrows(() => AsyncEnumerable.TakeWhile(default, x => true)); + AssertThrows(() => AsyncEnumerable.TakeWhile(default, (x, i) => true)); AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index 20f719056d..3d63a4c48b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -13,7 +13,7 @@ public class Throw : AsyncEnumerableTests [Fact] public void Throw_Null() { - AssertThrows(() => Throw(default(Exception))); + AssertThrows(() => Throw(default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index bb96b50106..11336bdce2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -16,8 +16,8 @@ public class ToArray : AsyncEnumerableTests [Fact] public async Task ToArray_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index 7850236075..fef0d62b99 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -16,37 +16,37 @@ public class ToDictionary : AsyncEnumerableTests [Fact] public async Task ToDictionary_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, x => 0, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index cb60af8342..9754076fa2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -16,11 +16,11 @@ public class ToHashSet : AsyncEnumerableTests [Fact] public async Task ToHashSet_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(Return42, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(Return42, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index 5ac4482740..ff3401ae88 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -16,8 +16,8 @@ public class ToList : AsyncEnumerableTests [Fact] public async Task ToList_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index eed324167d..09bf974bbd 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -17,37 +17,37 @@ public class ToLookup : AsyncEnumerableTests [Fact] public async Task ToLookup_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, x => 0, default(IEqualityComparer))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default(IAsyncEnumerable), x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, x => 0, default(IEqualityComparer), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, x => 0, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs index 475969c454..039c5ecf49 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -14,12 +14,12 @@ public class Union : AsyncEnumerableTests [Fact] public void Union_Null() { - AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), Return42)); - AssertThrows(() => AsyncEnumerable.Union(Return42, default(IAsyncEnumerable))); + AssertThrows(() => AsyncEnumerable.Union(default, Return42)); + AssertThrows(() => AsyncEnumerable.Union(Return42, default)); - AssertThrows(() => AsyncEnumerable.Union(default(IAsyncEnumerable), Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Union(Return42, default(IAsyncEnumerable), new Eq())); - AssertThrows(() => AsyncEnumerable.Union(Return42, Return42, default(IEqualityComparer))); + AssertThrows(() => AsyncEnumerable.Union(default, Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Union(Return42, default, new Eq())); + AssertThrows(() => AsyncEnumerable.Union(Return42, Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index c74fadecee..46ee636431 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -15,8 +15,8 @@ public class Where : AsyncEnumerableTests [Fact] public void Where_Null() { - AssertThrows(() => AsyncEnumerable.Where(default(IAsyncEnumerable), x => true)); - AssertThrows(() => AsyncEnumerable.Where(default(IAsyncEnumerable), (x, i) => true)); + AssertThrows(() => AsyncEnumerable.Where(default, x => true)); + AssertThrows(() => AsyncEnumerable.Where(default, (x, i) => true)); AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index 98e7bcff32..1c3c32f5c8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -15,8 +15,8 @@ public class Zip : AsyncEnumerableTests [Fact] public void Zip_Null() { - AssertThrows(() => AsyncEnumerable.Zip(default(IAsyncEnumerable), Return42, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(Return42, default(IAsyncEnumerable), (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(default, Return42, (x, y) => x + y)); + AssertThrows(() => AsyncEnumerable.Zip(Return42, default, (x, y) => x + y)); AssertThrows(() => AsyncEnumerable.Zip(Return42, Return42, default(Func))); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs b/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs index 239f01e74d..5726bc09e6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs @@ -6,7 +6,7 @@ namespace System.Linq { - static class ValueTaskHelpers + internal static class ValueTaskHelpers { public static void Wait(this ValueTask task, int timeOut) { @@ -17,7 +17,7 @@ public static void Wait(this ValueTask task, int timeOut) namespace Xunit { - static class AssertX + internal static class AssertX { /// /// Verifies that the exact exception is thrown (and not a derived exception type). @@ -50,7 +50,7 @@ public static async Task ThrowsAsync(Func> testCode) /// /// The task which may thrown an exception. /// Returns the exception that was thrown by the code; null, otherwise. - static async Task RecordExceptionAsync(Func testCode) + private static async Task RecordExceptionAsync(Func testCode) { if (testCode == null) { @@ -73,7 +73,7 @@ static async Task RecordExceptionAsync(Func testCode) /// /// The task which may thrown an exception. /// Returns the exception that was thrown by the code; null, otherwise. - static async Task RecordExceptionAsync(Func> testCode) + private static async Task RecordExceptionAsync(Func> testCode) { if (testCode == null) { @@ -91,7 +91,7 @@ static async Task RecordExceptionAsync(Func> testCode } } - static Exception Throws(Type exceptionType, Exception exception) + private static Exception Throws(Type exceptionType, Exception exception) { if (exceptionType == null) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index ff5f212d79..a9a973c301 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -129,7 +129,7 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - var dispose = Interlocked.Exchange(ref this._dispose, null); + var dispose = Interlocked.Exchange(ref _dispose, null); if (dispose != null) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 65f37e82c8..df06c8c7e2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -47,7 +47,7 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati public virtual ValueTask DisposeAsync() { - current = default(TSource); + current = default; state = AsyncIteratorState.Disposed; return TaskExt.CompletedTask; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 3c79e27c3b..74e195a745 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -96,7 +96,7 @@ private sealed class AppendPrepend1AsyncIterator : AppendPrependAsyncIt private readonly TSource _item; private readonly bool _appending; - bool _hasEnumerator; + private bool _hasEnumerator; public AppendPrepend1AsyncIterator(IAsyncEnumerable source, TSource item, bool appending) : base(source) @@ -292,10 +292,10 @@ public AppendPrependNAsyncIterator(IAsyncEnumerable source, SingleLinke Debug.Assert((prepended?.GetCount() ?? 0) == prependCount); Debug.Assert((appended?.GetCount() ?? 0) == appendCount); - this._prepended = prepended; - this._appended = appended; - this._prependCount = prependCount; - this._appendCount = appendCount; + _prepended = prepended; + _appended = appended; + _prependCount = prependCount; + _appendCount = appendCount; } public override AsyncIterator Clone() diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index a50db1b6b5..2ab1bfb0aa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -18,29 +18,28 @@ public static IAsyncEnumerable Concat(this IAsyncEnumerable; - return concatFirst != null ? + return first is ConcatAsyncIterator concatFirst ? concatFirst.Concat(second) : new Concat2AsyncIterator(first, second); } private sealed class Concat2AsyncIterator : ConcatAsyncIterator { - private readonly IAsyncEnumerable first; - private readonly IAsyncEnumerable second; + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; internal Concat2AsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second) { Debug.Assert(first != null); Debug.Assert(second != null); - this.first = first; - this.second = second; + _first = first; + _second = second; } public override AsyncIterator Clone() { - return new Concat2AsyncIterator(first, second); + return new Concat2AsyncIterator(_first, _second); } internal override ConcatAsyncIterator Concat(IAsyncEnumerable next) @@ -53,9 +52,9 @@ internal override IAsyncEnumerable GetAsyncEnumerable(int index) switch (index) { case 0: - return first; + return _first; case 1: - return second; + return _second; default: return null; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 1f33440fe4..e4ab1de030 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -68,7 +68,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera } } - return default(TSource); + return default; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index a2944a59ef..3f17a47fa4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -16,7 +16,7 @@ internal sealed class EmptyAsyncIterator : IAsyncPartition, IAsy { public static readonly EmptyAsyncIterator Instance = new EmptyAsyncIterator(); - public TValue Current => default(TValue); + public TValue Current => default; public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(0); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 9cce97e7ae..dde0aebb9e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -101,7 +101,7 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< } } - return default(TSource); + return default; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index b9ab5b9da7..ed907401e9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -111,7 +111,7 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable Range(int start, int count) private sealed class RangeAsyncIterator : AsyncIterator, IAsyncPartition { - private readonly int start; - private readonly int end; + private readonly int _start; + private readonly int _end; public RangeAsyncIterator(int start, int count) { Debug.Assert(count > 0); - this.start = start; - this.end = start + count; + _start = start; + _end = start + count; } - public override AsyncIterator Clone() => new RangeAsyncIterator(start, end - start); + public override AsyncIterator Clone() => new RangeAsyncIterator(_start, _end - _start); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(end - start); + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_end - _start); public IAsyncPartition Skip(int count) { - var n = end - start; + var n = _end - _start; if (count >= n) { return EmptyAsyncIterator.Instance; } - return new RangeAsyncIterator(start + count, n - count); + return new RangeAsyncIterator(_start + count, n - count); } public IAsyncPartition Take(int count) { - var n = end - start; + var n = _end - _start; if (count >= n) { return this; } - return new RangeAsyncIterator(start, count); + return new RangeAsyncIterator(_start, count); } public Task ToArrayAsync(CancellationToken cancellationToken) { - var res = new int[end - start]; + var res = new int[_end - _start]; - var value = start; + var value = _start; for (var i = 0; i < res.Length; i++) { @@ -83,9 +83,9 @@ public Task ToArrayAsync(CancellationToken cancellationToken) public Task> ToListAsync(CancellationToken cancellationToken) { - var res = new List(end - start); + var res = new List(_end - _start); - for (var value = start; value < end; value++) + for (var value = _start; value < _end; value++) { res.Add(value); } @@ -95,24 +95,24 @@ public Task> ToListAsync(CancellationToken cancellationToken) public Task> TryGetElementAsync(int index, CancellationToken cancellationToken) { - if ((uint)index < (uint)(end - start)) + if ((uint)index < (uint)(_end - _start)) { - return Task.FromResult(new Maybe(start + index)); + return Task.FromResult(new Maybe(_start + index)); } return Task.FromResult(new Maybe()); } - public Task> TryGetFirstAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(start)); + public Task> TryGetFirstAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(_start)); - public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(end - 1)); + public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(_end - 1)); protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { switch (state) { case AsyncIteratorState.Allocated: - current = start; + current = _start; state = AsyncIteratorState.Iterating; return true; @@ -120,7 +120,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: current++; - if (current != end) + if (current != _end) { return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index cc29569573..2692af7d0b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -325,7 +325,7 @@ public override async ValueTask DisposeAsync() _resultEnumerator = null; } - _currentSource = default(TSource); + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); } @@ -423,7 +423,7 @@ public override async ValueTask DisposeAsync() _resultEnumerator = null; } - _currentSource = default(TSource); + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); } @@ -522,7 +522,7 @@ public override async ValueTask DisposeAsync() _resultEnumerator = null; } - _currentSource = default(TSource); + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); } @@ -628,7 +628,7 @@ public override async ValueTask DisposeAsync() _resultEnumerator = null; } - _currentSource = default(TSource); + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 53420f2a39..7f67c563b5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -72,7 +72,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable { switch (list.Count) { - case 0: return default(TSource); + case 0: return default; case 1: return list[0]; } @@ -85,7 +85,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - return default(TSource); + return default; } var result = e.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 0ca9bdd491..a24dc4ffb5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -285,7 +285,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -314,7 +314,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -571,7 +571,7 @@ public IEnumerator> GetEnumerator() } } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -600,7 +600,7 @@ public IEnumerator> GetEnumerator() return lookup; } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default(CancellationToken)) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { Debug.Assert(source != null); Debug.Assert(keySelector != null); From b53998f1d6c61e6feb10081c5cc2e5498b389ae5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 6 Nov 2018 17:44:25 -0800 Subject: [PATCH 388/862] More code cleanup. --- .../System.Interactive.Async/AsyncIterator.cs | 14 +- .../System/Linq/Operators/Amb.cs | 58 ++-- .../System/Linq/Operators/Buffer.cs | 64 ++--- .../System/Linq/Operators/Catch.cs | 136 ++++----- .../System/Linq/Operators/Concat.cs | 90 +++--- .../System/Linq/Operators/Distinct.cs | 108 +++---- .../Linq/Operators/DistinctUntilChanged.cs | 132 ++++----- .../System/Linq/Operators/Do.cs | 82 +++--- .../System/Linq/Operators/Expand.cs | 100 +++---- .../System/Linq/Operators/Finally.cs | 52 ++-- .../System/Linq/Operators/Generate.cs | 38 +-- .../System/Linq/Operators/IgnoreElements.cs | 18 +- .../System/Linq/Operators/Merge.cs | 48 ++-- .../Linq/Operators/OnErrorResumeNext.cs | 38 +-- .../System/Linq/Operators/Scan.cs | 164 +++++------ .../System/Linq/Operators/Timeout.cs | 26 +- .../System/Linq/Operators/Using.cs | 76 ++--- .../System/Linq/AsyncEnumerableHelpers.cs | 24 +- .../System/Linq/AsyncEnumerablePartition.cs | 16 +- .../System/Linq/Disposables.cs | 8 +- .../System/Linq/Operators/Concat.cs | 54 ++-- .../System/Linq/Operators/Create.cs | 44 +-- .../System/Linq/Operators/DefaultIfEmpty.cs | 48 ++-- .../System/Linq/Operators/Distinct.cs | 42 +-- .../System/Linq/Operators/Except.cs | 56 ++-- .../System/Linq/Operators/GroupBy.cs | 264 +++++++++--------- .../System/Linq/Operators/Intersect.cs | 56 ++-- .../System/Linq/Operators/Repeat.cs | 34 +-- .../System/Linq/Operators/Reverse.cs | 32 +-- .../System/Linq/Operators/Select.cs | 188 ++++++------- .../System/Linq/Operators/SingleLinkedNode.cs | 12 +- .../System/Linq/Operators/SkipLast.cs | 36 +-- .../System/Linq/Operators/SkipWhile.cs | 172 ++++++------ .../System/Linq/Operators/TakeLast.cs | 54 ++-- .../System/Linq/Operators/TakeWhile.cs | 116 ++++---- .../Linq/Operators/ToAsyncEnumerable.cs | 127 ++++----- .../System/Linq/Operators/ToObservable.cs | 6 +- .../System/Linq/Operators/Where.cs | 156 +++++------ .../System/Linq/Operators/Zip.cs | 80 +++--- 39 files changed, 1434 insertions(+), 1435 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index d24676a8bd..2c0e7b8dd8 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -10,9 +10,9 @@ namespace System.Linq { internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator { - private readonly int threadId; + private readonly int _threadId; - private bool currentIsInvalid = true; + private bool _currentIsInvalid = true; internal TSource current; internal AsyncIteratorState state = AsyncIteratorState.New; @@ -20,12 +20,12 @@ internal abstract class AsyncIterator : IAsyncEnumerable, IAsy protected AsyncIterator() { - threadId = Environment.CurrentManagedThreadId; + _threadId = Environment.CurrentManagedThreadId; } public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) { - var enumerator = state == AsyncIteratorState.New && threadId == Environment.CurrentManagedThreadId + var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); @@ -57,7 +57,7 @@ public TSource Current { get { - if (currentIsInvalid) + if (_currentIsInvalid) throw new InvalidOperationException("Enumerator is in an invalid state"); return current; @@ -79,13 +79,13 @@ public async ValueTask MoveNextAsync() { var result = await MoveNextCore(token).ConfigureAwait(false); - currentIsInvalid = !result; // if move next is false, invalid otherwise valid + _currentIsInvalid = !result; // if move next is false, invalid otherwise valid return result; } catch { - currentIsInvalid = true; + _currentIsInvalid = true; await DisposeAsync().ConfigureAwait(false); throw; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index e0ce937dfc..9ba5dee14e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -39,31 +39,31 @@ public static IAsyncEnumerable Amb(this IEnumerable : AsyncIterator { - private readonly IAsyncEnumerable first; - private readonly IAsyncEnumerable second; + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public AmbAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second) { Debug.Assert(first != null); Debug.Assert(second != null); - this.first = first; - this.second = second; + _first = first; + _second = second; } public override AsyncIterator Clone() { - return new AmbAsyncIterator(first, second); + return new AmbAsyncIterator(_first, _second); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -74,8 +74,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - var firstEnumerator = first.GetAsyncEnumerator(cancellationToken); - var secondEnumerator = second.GetAsyncEnumerator(cancellationToken); + var firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); + var secondEnumerator = _second.GetAsyncEnumerator(cancellationToken); var firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); var secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); @@ -93,7 +93,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella if (winner == firstMoveNext) { - enumerator = firstEnumerator; + _enumerator = firstEnumerator; var ignored = secondMoveNext.ContinueWith(_ => { @@ -102,7 +102,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella } else { - enumerator = secondEnumerator; + _enumerator = secondEnumerator; var ignored = firstMoveNext.ContinueWith(_ => { @@ -114,16 +114,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella if (await winner.ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } break; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -137,28 +137,28 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class AmbAsyncIteratorN : AsyncIterator { - private readonly IAsyncEnumerable[] sources; + private readonly IAsyncEnumerable[] _sources; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public AmbAsyncIteratorN(IAsyncEnumerable[] sources) { Debug.Assert(sources != null); - this.sources = sources; + _sources = sources; } public override AsyncIterator Clone() { - return new AmbAsyncIteratorN(sources); + return new AmbAsyncIteratorN(_sources); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -169,14 +169,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - var n = sources.Length; + var n = _sources.Length; var enumerators = new IAsyncEnumerator[n]; var moveNexts = new ValueTask[n]; for (var i = 0; i < n; i++) { - var enumerator = sources[i].GetAsyncEnumerator(cancellationToken); + var enumerator = _sources[i].GetAsyncEnumerator(cancellationToken); enumerators[i] = enumerator; moveNexts[i] = enumerator.MoveNextAsync(); @@ -195,7 +195,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella var winnerIndex = Array.IndexOf(moveNexts, winner); - enumerator = enumerators[winnerIndex]; + _enumerator = enumerators[winnerIndex]; for (var i = 0; i < n; i++) { @@ -212,16 +212,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella if (await winner.ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } break; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index c8ada8d024..b2b26ac962 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -48,38 +48,38 @@ public static IAsyncEnumerable> Buffer(this IAsyncEnumer private sealed class BufferAsyncIterator : AsyncIterator> { - private readonly int count; - private readonly int skip; - private readonly IAsyncEnumerable source; + private readonly int _count; + private readonly int _skip; + private readonly IAsyncEnumerable _source; - private Queue> buffers; - private IAsyncEnumerator enumerator; - private int index; - private bool stopped; + private Queue> _buffers; + private IAsyncEnumerator _enumerator; + private int _index; + private bool _stopped; public BufferAsyncIterator(IAsyncEnumerable source, int count, int skip) { Debug.Assert(source != null); - this.source = source; - this.count = count; - this.skip = skip; + _source = source; + _count = count; + _skip = skip; } public override AsyncIterator> Clone() { - return new BufferAsyncIterator(source, count, skip); + return new BufferAsyncIterator(_source, _count, _skip); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - buffers = null; + _buffers = null; await base.DisposeAsync().ConfigureAwait(false); } @@ -89,10 +89,10 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - buffers = new Queue>(); - index = 0; - stopped = false; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _buffers = new Queue>(); + _index = 0; + _stopped = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -100,40 +100,40 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (!stopped) + if (!_stopped) { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (index++ % skip == 0) + var item = _enumerator.Current; + if (_index++ % _skip == 0) { - buffers.Enqueue(new List(count)); + _buffers.Enqueue(new List(_count)); } - foreach (var buffer in buffers) + foreach (var buffer in _buffers) { buffer.Add(item); } - if (buffers.Count > 0 && buffers.Peek().Count == count) + if (_buffers.Count > 0 && _buffers.Peek().Count == _count) { - current = buffers.Dequeue(); + current = _buffers.Dequeue(); return true; } continue; // loop } - stopped = true; - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + _stopped = true; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; continue; // loop } - if (buffers.Count > 0) + if (_buffers.Count > 0) { - current = buffers.Dequeue(); + current = _buffers.Dequeue(); return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 1116993e12..e1e5944e50 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -67,32 +67,32 @@ private static IAsyncEnumerable CatchCore(IEnumerable : AsyncIterator where TException : Exception { - private readonly Func> handler; - private readonly IAsyncEnumerable source; + private readonly Func> _handler; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private bool isDone; + private IAsyncEnumerator _enumerator; + private bool _isDone; public CatchAsyncIterator(IAsyncEnumerable source, Func> handler) { Debug.Assert(source != null); Debug.Assert(handler != null); - this.source = source; - this.handler = handler; + _source = source; + _handler = handler; } public override AsyncIterator Clone() { - return new CatchAsyncIterator(source, handler); + return new CatchAsyncIterator(_source, _handler); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -103,8 +103,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - isDone = false; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _isDone = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -112,13 +112,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (!isDone) + if (!_isDone) { try { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } } @@ -127,23 +127,23 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella // Note: Ideally we'd dipose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - var inner = handler(ex); + var inner = _handler(ex); var err = inner.GetAsyncEnumerator(cancellationToken); - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); + await _enumerator.DisposeAsync().ConfigureAwait(false); } - enumerator = err; - isDone = true; + _enumerator = err; + _isDone = true; continue; // loop so we hit the catch state } } - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -160,32 +160,32 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class CatchAsyncIteratorWithTask : AsyncIterator where TException : Exception { - private readonly Func>> handler; - private readonly IAsyncEnumerable source; + private readonly Func>> _handler; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private bool isDone; + private IAsyncEnumerator _enumerator; + private bool _isDone; public CatchAsyncIteratorWithTask(IAsyncEnumerable source, Func>> handler) { Debug.Assert(source != null); Debug.Assert(handler != null); - this.source = source; - this.handler = handler; + _source = source; + _handler = handler; } public override AsyncIterator Clone() { - return new CatchAsyncIteratorWithTask(source, handler); + return new CatchAsyncIteratorWithTask(_source, _handler); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -196,8 +196,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - isDone = false; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _isDone = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -205,13 +205,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (!isDone) + if (!_isDone) { try { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } } @@ -220,23 +220,23 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella // Note: Ideally we'd dipose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - var inner = await handler(ex).ConfigureAwait(false); + var inner = await _handler(ex).ConfigureAwait(false); var err = inner.GetAsyncEnumerator(cancellationToken); - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); + await _enumerator.DisposeAsync().ConfigureAwait(false); } - enumerator = err; - isDone = true; + _enumerator = err; + _isDone = true; continue; // loop so we hit the catch state } } - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -253,40 +253,40 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class CatchAsyncIterator : AsyncIterator { - private readonly IEnumerable> sources; + private readonly IEnumerable> _sources; - private IAsyncEnumerator enumerator; - private ExceptionDispatchInfo error; + private IAsyncEnumerator _enumerator; + private ExceptionDispatchInfo _error; - private IEnumerator> sourcesEnumerator; + private IEnumerator> _sourcesEnumerator; public CatchAsyncIterator(IEnumerable> sources) { Debug.Assert(sources != null); - this.sources = sources; + _sources = sources; } public override AsyncIterator Clone() { - return new CatchAsyncIterator(sources); + return new CatchAsyncIterator(_sources); } public override async ValueTask DisposeAsync() { - if (sourcesEnumerator != null) + if (_sourcesEnumerator != null) { - sourcesEnumerator.Dispose(); - sourcesEnumerator = null; + _sourcesEnumerator.Dispose(); + _sourcesEnumerator = null; } - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - error = null; + _error = null; await base.DisposeAsync().ConfigureAwait(false); } @@ -296,7 +296,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourcesEnumerator = sources.GetEnumerator(); + _sourcesEnumerator = _sources.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -304,33 +304,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (enumerator == null) + if (_enumerator == null) { - if (!sourcesEnumerator.MoveNext()) + if (!_sourcesEnumerator.MoveNext()) { // only throw if we have an error on the last one - error?.Throw(); + _error?.Throw(); break; // done, nothing else to do } - error = null; - enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _error = null; + _enumerator = _sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); } try { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } } catch (Exception ex) { // Done with the current one, go to the next - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - error = ExceptionDispatchInfo.Capture(ex); + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _error = ExceptionDispatchInfo.Capture(ex); continue; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index c71755a09d..65c4e972c0 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -42,79 +42,78 @@ private static IAsyncEnumerable ConcatCore(IEnumerable : AsyncIterator { - private readonly IEnumerable> source; + private readonly IEnumerable> _source; public ConcatEnumerableAsyncIterator(IEnumerable> source) { Debug.Assert(source != null); - this.source = source; + _source = source; } public override AsyncIterator Clone() { - return new ConcatEnumerableAsyncIterator(source); + return new ConcatEnumerableAsyncIterator(_source); } public override async ValueTask DisposeAsync() { - if (outerEnumerator != null) + if (_outerEnumerator != null) { - outerEnumerator.Dispose(); - outerEnumerator = null; + _outerEnumerator.Dispose(); + _outerEnumerator = null; } - if (currentEnumerator != null) + if (_currentEnumerator != null) { - await currentEnumerator.DisposeAsync().ConfigureAwait(false); - currentEnumerator = null; + await _currentEnumerator.DisposeAsync().ConfigureAwait(false); + _currentEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); } // State machine vars - private IEnumerator> outerEnumerator; - private IAsyncEnumerator currentEnumerator; - private int mode; + private IEnumerator> _outerEnumerator; + private IAsyncEnumerator _currentEnumerator; + private int _mode; private const int State_OuterNext = 1; private const int State_While = 4; protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { - switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = source.GetEnumerator(); - mode = State_OuterNext; + _outerEnumerator = _source.GetEnumerator(); + _mode = State_OuterNext; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_OuterNext: - if (outerEnumerator.MoveNext()) + if (_outerEnumerator.MoveNext()) { // make sure we dispose the previous one if we're about to replace it - if (currentEnumerator != null) + if (_currentEnumerator != null) { - await currentEnumerator.DisposeAsync().ConfigureAwait(false); + await _currentEnumerator.DisposeAsync().ConfigureAwait(false); } - currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _currentEnumerator = _outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); - mode = State_While; + _mode = State_While; goto case State_While; } break; case State_While: - if (await currentEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _currentEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = currentEnumerator.Current; + current = _currentEnumerator.Current; return true; } @@ -132,79 +131,78 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class ConcatAsyncEnumerableAsyncIterator : AsyncIterator { - private readonly IAsyncEnumerable> source; + private readonly IAsyncEnumerable> _source; public ConcatAsyncEnumerableAsyncIterator(IAsyncEnumerable> source) { Debug.Assert(source != null); - this.source = source; + _source = source; } public override AsyncIterator Clone() { - return new ConcatAsyncEnumerableAsyncIterator(source); + return new ConcatAsyncEnumerableAsyncIterator(_source); } public override async ValueTask DisposeAsync() { - if (outerEnumerator != null) + if (_outerEnumerator != null) { - await outerEnumerator.DisposeAsync().ConfigureAwait(false); - outerEnumerator = null; + await _outerEnumerator.DisposeAsync().ConfigureAwait(false); + _outerEnumerator = null; } - if (currentEnumerator != null) + if (_currentEnumerator != null) { - await currentEnumerator.DisposeAsync().ConfigureAwait(false); - currentEnumerator = null; + await _currentEnumerator.DisposeAsync().ConfigureAwait(false); + _currentEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); } // State machine vars - private IAsyncEnumerator> outerEnumerator; - private IAsyncEnumerator currentEnumerator; - private int mode; + private IAsyncEnumerator> _outerEnumerator; + private IAsyncEnumerator _currentEnumerator; + private int _mode; private const int State_OuterNext = 1; private const int State_While = 4; protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { - switch (state) { case AsyncIteratorState.Allocated: - outerEnumerator = source.GetAsyncEnumerator(cancellationToken); - mode = State_OuterNext; + _outerEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _mode = State_OuterNext; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - switch (mode) + switch (_mode) { case State_OuterNext: - if (await outerEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { // make sure we dispose the previous one if we're about to replace it - if (currentEnumerator != null) + if (_currentEnumerator != null) { - await currentEnumerator.DisposeAsync().ConfigureAwait(false); + await _currentEnumerator.DisposeAsync().ConfigureAwait(false); } - currentEnumerator = outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _currentEnumerator = _outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); - mode = State_While; + _mode = State_While; goto case State_While; } break; case State_While: - if (await currentEnumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _currentEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = currentEnumerator.Current; + current = _currentEnumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index a07f25b2f2..2f09a8372a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -67,12 +67,12 @@ private static IAsyncEnumerable DistinctCore(IAsyncEnume private sealed class DistinctAsyncIterator : AsyncIterator, IAsyncIListProvider { - private readonly IEqualityComparer comparer; - private readonly Func keySelector; - private readonly IAsyncEnumerable source; + private readonly IEqualityComparer _comparer; + private readonly Func _keySelector; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private Set set; + private IAsyncEnumerator _enumerator; + private Set _set; public DistinctAsyncIterator(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { @@ -80,9 +80,9 @@ public DistinctAsyncIterator(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) @@ -105,16 +105,16 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } var count = 0; - var s = new Set(comparer); + var s = new Set(_comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { var item = enu.Current; - if (s.Add(keySelector(item))) + if (s.Add(_keySelector(item))) { count++; } @@ -130,16 +130,16 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell public override AsyncIterator Clone() { - return new DistinctAsyncIterator(source, keySelector, comparer); + return new DistinctAsyncIterator(_source, _keySelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - set = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _set = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -150,27 +150,27 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); - if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (!await _enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); return false; } - var element = enumerator.Current; - set = new Set(comparer); - set.Add(keySelector(element)); + var element = _enumerator.Current; + _set = new Set(_comparer); + _set.Add(_keySelector(element)); current = element; state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - element = enumerator.Current; - if (set.Add(keySelector(element))) + element = _enumerator.Current; + if (_set.Add(_keySelector(element))) { current = element; return true; @@ -186,17 +186,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private async Task> FillSetAsync(CancellationToken cancellationToken) { - var s = new Set(comparer); + var s = new Set(_comparer); var r = new List(); - var enu = source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var item = enu.Current; - if (s.Add(keySelector(item))) + if (s.Add(_keySelector(item))) { r.Add(item); } @@ -213,12 +213,12 @@ private async Task> FillSetAsync(CancellationToken cancellationTok private sealed class DistinctAsyncIteratorWithTask : AsyncIterator, IAsyncIListProvider { - private readonly IEqualityComparer comparer; - private readonly Func> keySelector; - private readonly IAsyncEnumerable source; + private readonly IEqualityComparer _comparer; + private readonly Func> _keySelector; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private Set set; + private IAsyncEnumerator _enumerator; + private Set _set; public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { @@ -226,9 +226,9 @@ public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) @@ -251,16 +251,16 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } var count = 0; - var s = new Set(comparer); + var s = new Set(_comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { var item = enu.Current; - if (s.Add(await keySelector(item).ConfigureAwait(false))) + if (s.Add(await _keySelector(item).ConfigureAwait(false))) { count++; } @@ -276,16 +276,16 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell public override AsyncIterator Clone() { - return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); + return new DistinctAsyncIteratorWithTask(_source, _keySelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - set = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _set = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -296,27 +296,27 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); - if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (!await _enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); return false; } - var element = enumerator.Current; - set = new Set(comparer); - set.Add(await keySelector(element).ConfigureAwait(false)); + var element = _enumerator.Current; + _set = new Set(_comparer); + _set.Add(await _keySelector(element).ConfigureAwait(false)); current = element; state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - element = enumerator.Current; - if (set.Add(await keySelector(element).ConfigureAwait(false))) + element = _enumerator.Current; + if (_set.Add(await _keySelector(element).ConfigureAwait(false))) { current = element; return true; @@ -332,17 +332,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private async Task> FillSetAsync(CancellationToken cancellationToken) { - var s = new Set(comparer); + var s = new Set(_comparer); var r = new List(); - var enu = source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) { var item = enu.Current; - if (s.Add(await keySelector(item).ConfigureAwait(false))) + if (s.Add(await _keySelector(item).ConfigureAwait(false))) { r.Add(item); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 6dfbdba68b..9db131e6e9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -90,34 +90,34 @@ private static IAsyncEnumerable DistinctUntilChangedCore private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator { - private readonly IEqualityComparer comparer; - private readonly IAsyncEnumerable source; + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _source; - private TSource currentValue; - private IAsyncEnumerator enumerator; - private bool hasCurrentValue; + private TSource _currentValue; + private IAsyncEnumerator _enumerator; + private bool _hasCurrentValue; public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, IEqualityComparer comparer) { Debug.Assert(comparer != null); Debug.Assert(source != null); - this.source = source; - this.comparer = comparer; + _source = source; + _comparer = comparer; } public override AsyncIterator Clone() { - return new DistinctUntilChangedAsyncIterator(source, comparer); + return new DistinctUntilChangedAsyncIterator(_source, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - currentValue = default; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _currentValue = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -128,25 +128,25 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; + var item = _enumerator.Current; var comparerEquals = false; - if (hasCurrentValue) + if (_hasCurrentValue) { - comparerEquals = comparer.Equals(currentValue, item); + comparerEquals = _comparer.Equals(_currentValue, item); } - if (!hasCurrentValue || !comparerEquals) + if (!_hasCurrentValue || !comparerEquals) { - hasCurrentValue = true; - currentValue = item; + _hasCurrentValue = true; + _currentValue = item; current = item; return true; } @@ -162,33 +162,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator { - private readonly IEqualityComparer comparer; - private readonly Func keySelector; - private readonly IAsyncEnumerable source; - private TKey currentKeyValue; + private readonly IEqualityComparer _comparer; + private readonly Func _keySelector; + private readonly IAsyncEnumerable _source; + private TKey _currentKeyValue; - private IAsyncEnumerator enumerator; - private bool hasCurrentKey; + private IAsyncEnumerator _enumerator; + private bool _hasCurrentKey; public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { - this.source = source; - this.keySelector = keySelector; - this.comparer = comparer; + _source = source; + _keySelector = keySelector; + _comparer = comparer; } public override AsyncIterator Clone() { - return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); + return new DistinctUntilChangedAsyncIterator(_source, _keySelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - currentKeyValue = default; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _currentKeyValue = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -199,25 +199,25 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - var key = keySelector(item); + var item = _enumerator.Current; + var key = _keySelector(item); var comparerEquals = false; - if (hasCurrentKey) + if (_hasCurrentKey) { - comparerEquals = comparer.Equals(currentKeyValue, key); + comparerEquals = _comparer.Equals(_currentKeyValue, key); } - if (!hasCurrentKey || !comparerEquals) + if (!_hasCurrentKey || !comparerEquals) { - hasCurrentKey = true; - currentKeyValue = key; + _hasCurrentKey = true; + _currentKeyValue = key; current = item; return true; } @@ -233,33 +233,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class DistinctUntilChangedAsyncIteratorWithTask : AsyncIterator { - private readonly IEqualityComparer comparer; - private readonly Func> keySelector; - private readonly IAsyncEnumerable source; - private TKey currentKeyValue; + private readonly IEqualityComparer _comparer; + private readonly Func> _keySelector; + private readonly IAsyncEnumerable _source; + private TKey _currentKeyValue; - private IAsyncEnumerator enumerator; - private bool hasCurrentKey; + private IAsyncEnumerator _enumerator; + private bool _hasCurrentKey; public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { - this.source = source; - this.keySelector = keySelector; - this.comparer = comparer; + _source = source; + _keySelector = keySelector; + _comparer = comparer; } public override AsyncIterator Clone() { - return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); + return new DistinctUntilChangedAsyncIteratorWithTask(_source, _keySelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - currentKeyValue = default; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _currentKeyValue = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -270,25 +270,25 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - var key = await keySelector(item).ConfigureAwait(false); + var item = _enumerator.Current; + var key = await _keySelector(item).ConfigureAwait(false); var comparerEquals = false; - if (hasCurrentKey) + if (_hasCurrentKey) { - comparerEquals = comparer.Equals(currentKeyValue, key); + comparerEquals = _comparer.Equals(_currentKeyValue, key); } - if (!hasCurrentKey || !comparerEquals) + if (!_hasCurrentKey || !comparerEquals) { - hasCurrentKey = true; - currentKeyValue = key; + _hasCurrentKey = true; + _currentKeyValue = key; current = item; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index c373e929af..0ff6673cc8 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -129,35 +129,35 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable : AsyncIterator { - private readonly Action onCompleted; - private readonly Action onError; - private readonly Action onNext; - private readonly IAsyncEnumerable source; + private readonly Action _onCompleted; + private readonly Action _onError; + private readonly Action _onNext; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public DoAsyncIterator(IAsyncEnumerable source, Action onNext, Action onError, Action onCompleted) { Debug.Assert(source != null); Debug.Assert(onNext != null); - this.source = source; - this.onNext = onNext; - this.onError = onError; - this.onCompleted = onCompleted; + _source = source; + _onNext = onNext; + _onError = onError; + _onCompleted = onCompleted; } public override AsyncIterator Clone() { - return new DoAsyncIterator(source, onNext, onError, onCompleted); + return new DoAsyncIterator(_source, _onNext, _onError, _onCompleted); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -168,17 +168,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: try { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; - onNext(current); + current = _enumerator.Current; + _onNext(current); return true; } @@ -187,13 +187,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella { throw; } - catch (Exception ex) when (onError != null) + catch (Exception ex) when (_onError != null) { - onError(ex); + _onError(ex); throw; } - onCompleted?.Invoke(); + _onCompleted?.Invoke(); await DisposeAsync().ConfigureAwait(false); break; @@ -205,35 +205,35 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class DoAsyncIteratorWithTask : AsyncIterator { - private readonly Func onCompleted; - private readonly Func onError; - private readonly Func onNext; - private readonly IAsyncEnumerable source; + private readonly Func _onCompleted; + private readonly Func _onError; + private readonly Func _onNext; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public DoAsyncIteratorWithTask(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) { Debug.Assert(source != null); Debug.Assert(onNext != null); - this.source = source; - this.onNext = onNext; - this.onError = onError; - this.onCompleted = onCompleted; + _source = source; + _onNext = onNext; + _onError = onError; + _onCompleted = onCompleted; } public override AsyncIterator Clone() { - return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); + return new DoAsyncIteratorWithTask(_source, _onNext, _onError, _onCompleted); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -244,17 +244,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: try { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; - await onNext(current).ConfigureAwait(false); + current = _enumerator.Current; + await _onNext(current).ConfigureAwait(false); return true; } @@ -263,15 +263,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella { throw; } - catch (Exception ex) when (onError != null) + catch (Exception ex) when (_onError != null) { - await onError(ex).ConfigureAwait(false); + await _onError(ex).ConfigureAwait(false); throw; } - if (onCompleted != null) + if (_onCompleted != null) { - await onCompleted().ConfigureAwait(false); + await _onCompleted().ConfigureAwait(false); } await DisposeAsync().ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 0e1c9a34f1..342dd640d1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -33,36 +33,36 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable : AsyncIterator { - private readonly Func> selector; - private readonly IAsyncEnumerable source; + private readonly Func> _selector; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; - private Queue> queue; + private Queue> _queue; public ExpandAsyncIterator(IAsyncEnumerable source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new ExpandAsyncIterator(source, selector); + return new ExpandAsyncIterator(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - queue = null; + _queue = null; await base.DisposeAsync().ConfigureAwait(false); } @@ -72,8 +72,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - queue = new Queue>(); - queue.Enqueue(source); + _queue = new Queue>(); + _queue.Enqueue(_source); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -81,18 +81,18 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (enumerator == null) + if (_enumerator == null) { - if (queue.Count > 0) + if (_queue.Count > 0) { - var src = queue.Dequeue(); + var src = _queue.Dequeue(); - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); + await _enumerator.DisposeAsync().ConfigureAwait(false); } - enumerator = src.GetAsyncEnumerator(cancellationToken); + _enumerator = src.GetAsyncEnumerator(cancellationToken); continue; // loop } @@ -100,17 +100,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; // while } - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - var next = selector(item); - queue.Enqueue(next); + var item = _enumerator.Current; + var next = _selector(item); + _queue.Enqueue(next); current = item; return true; } - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } break; // case @@ -123,36 +123,36 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class ExpandAsyncIteratorWithTask : AsyncIterator { - private readonly Func>> selector; - private readonly IAsyncEnumerable source; + private readonly Func>> _selector; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; - private Queue> queue; + private Queue> _queue; public ExpandAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new ExpandAsyncIteratorWithTask(source, selector); + return new ExpandAsyncIteratorWithTask(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - queue = null; + _queue = null; await base.DisposeAsync().ConfigureAwait(false); } @@ -162,8 +162,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - queue = new Queue>(); - queue.Enqueue(source); + _queue = new Queue>(); + _queue.Enqueue(_source); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -171,18 +171,18 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (enumerator == null) + if (_enumerator == null) { - if (queue.Count > 0) + if (_queue.Count > 0) { - var src = queue.Dequeue(); + var src = _queue.Dequeue(); - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); + await _enumerator.DisposeAsync().ConfigureAwait(false); } - enumerator = src.GetAsyncEnumerator(cancellationToken); + _enumerator = src.GetAsyncEnumerator(cancellationToken); continue; // loop } @@ -190,17 +190,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; // while } - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - var next = await selector(item).ConfigureAwait(false); - queue.Enqueue(next); + var item = _enumerator.Current; + var next = await _selector(item).ConfigureAwait(false); + _queue.Enqueue(next); current = item; return true; } - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } break; // case diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 96454bf525..354e585b6b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -33,33 +33,33 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable : AsyncIterator { - private readonly Action finallyAction; - private readonly IAsyncEnumerable source; + private readonly Action _finallyAction; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public FinallyAsyncIterator(IAsyncEnumerable source, Action finallyAction) { Debug.Assert(source != null); Debug.Assert(finallyAction != null); - this.source = source; - this.finallyAction = finallyAction; + _source = source; + _finallyAction = finallyAction; } public override AsyncIterator Clone() { - return new FinallyAsyncIterator(source, finallyAction); + return new FinallyAsyncIterator(_source, _finallyAction); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; - finallyAction(); + _finallyAction(); } await base.DisposeAsync().ConfigureAwait(false); @@ -70,14 +70,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -91,33 +91,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class FinallyAsyncIteratorWithTask : AsyncIterator { - private readonly Func finallyAction; - private readonly IAsyncEnumerable source; + private readonly Func _finallyAction; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public FinallyAsyncIteratorWithTask(IAsyncEnumerable source, Func finallyAction) { Debug.Assert(source != null); Debug.Assert(finallyAction != null); - this.source = source; - this.finallyAction = finallyAction; + _source = source; + _finallyAction = finallyAction; } public override AsyncIterator Clone() { - return new FinallyAsyncIteratorWithTask(source, finallyAction); + return new FinallyAsyncIteratorWithTask(_source, _finallyAction); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; - await finallyAction().ConfigureAwait(false); + await _finallyAction().ConfigureAwait(false); } await base.DisposeAsync().ConfigureAwait(false); @@ -128,14 +128,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index a777d61ae4..bb1f10f147 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -33,14 +33,14 @@ public static IAsyncEnumerable Generate(TState initial private sealed class GenerateAsyncIterator : AsyncIterator { - private readonly Func condition; - private readonly TState initialState; - private readonly Func iterate; - private readonly Func resultSelector; + private readonly Func _condition; + private readonly TState _initialState; + private readonly Func _iterate; + private readonly Func _resultSelector; - private TState currentState; + private TState _currentState; - private bool started; + private bool _started; public GenerateAsyncIterator(TState initialState, Func condition, Func iterate, Func resultSelector) { @@ -48,20 +48,20 @@ public GenerateAsyncIterator(TState initialState, Func condition, Debug.Assert(iterate != null); Debug.Assert(resultSelector != null); - this.initialState = initialState; - this.condition = condition; - this.iterate = iterate; - this.resultSelector = resultSelector; + _initialState = initialState; + _condition = condition; + _iterate = iterate; + _resultSelector = resultSelector; } public override AsyncIterator Clone() { - return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); + return new GenerateAsyncIterator(_initialState, _condition, _iterate, _resultSelector); } public override async ValueTask DisposeAsync() { - currentState = default; + _currentState = default; await base.DisposeAsync().ConfigureAwait(false); } @@ -71,23 +71,23 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - started = false; - currentState = initialState; + _started = false; + _currentState = _initialState; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (started) + if (_started) { - currentState = iterate(currentState); + _currentState = _iterate(_currentState); } - started = true; + _started = true; - if (condition(currentState)) + if (_condition(_currentState)) { - current = resultSelector(currentState); + current = _resultSelector(_currentState); return true; } break; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index 19c0cb3a02..3879828290 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -23,27 +23,27 @@ public static IAsyncEnumerable IgnoreElements(this IAsyncEnume private sealed class IgnoreElementsAsyncIterator : AsyncIterator { - private readonly IAsyncEnumerable source; - private IAsyncEnumerator enumerator; + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; public IgnoreElementsAsyncIterator(IAsyncEnumerable source) { Debug.Assert(source != null); - this.source = source; + _source = source; } public override AsyncIterator Clone() { - return new IgnoreElementsAsyncIterator(source); + return new IgnoreElementsAsyncIterator(_source); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -54,12 +54,12 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 7be67bdc90..0b75a63f07 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -37,40 +37,40 @@ public static IAsyncEnumerable Merge(this IAsyncEnumerable : AsyncIterator { - private readonly IAsyncEnumerable[] sources; + private readonly IAsyncEnumerable[] _sources; - private IAsyncEnumerator[] enumerators; - private ValueTask[] moveNexts; - private int active; + private IAsyncEnumerator[] _enumerators; + private ValueTask[] _moveNexts; + private int _active; public MergeAsyncIterator(IAsyncEnumerable[] sources) { Debug.Assert(sources != null); - this.sources = sources; + _sources = sources; } public override AsyncIterator Clone() { - return new MergeAsyncIterator(sources); + return new MergeAsyncIterator(_sources); } public override async ValueTask DisposeAsync() { - if (enumerators != null) + if (_enumerators != null) { - var n = enumerators.Length; + var n = _enumerators.Length; var disposes = new ValueTask[n]; for (var i = 0; i < n; i++) { - var dispose = enumerators[i].DisposeAsync(); + var dispose = _enumerators[i].DisposeAsync(); disposes[i] = dispose; } await Task.WhenAll(disposes.Select(t => t.AsTask())).ConfigureAwait(false); - enumerators = null; + _enumerators = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -81,24 +81,24 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - var n = sources.Length; + var n = _sources.Length; - enumerators = new IAsyncEnumerator[n]; - moveNexts = new ValueTask[n]; - active = n; + _enumerators = new IAsyncEnumerator[n]; + _moveNexts = new ValueTask[n]; + _active = n; for (var i = 0; i < n; i++) { - var enumerator = sources[i].GetAsyncEnumerator(cancellationToken); - enumerators[i] = enumerator; - moveNexts[i] = enumerator.MoveNextAsync(); + var enumerator = _sources[i].GetAsyncEnumerator(cancellationToken); + _enumerators[i] = enumerator; + _moveNexts[i] = enumerator.MoveNextAsync(); } state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (active > 0) + while (_active > 0) { // // REVIEW: This approach does have a bias towards giving sources on the left @@ -106,20 +106,20 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella // want to consider a "prefer fairness" option. // - var moveNext = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); + var moveNext = await Task.WhenAny(_moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); - var index = Array.IndexOf(moveNexts, moveNext); + var index = Array.IndexOf(_moveNexts, moveNext); if (!await moveNext.ConfigureAwait(false)) { - moveNexts[index] = TaskExt.Never; - active--; + _moveNexts[index] = TaskExt.Never; + _active--; } else { - var enumerator = enumerators[index]; + var enumerator = _enumerators[index]; current = enumerator.Current; - moveNexts[index] = enumerator.MoveNextAsync(); + _moveNexts[index] = enumerator.MoveNextAsync(); return true; } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index 08c4bc1d8f..2bf820f122 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -44,35 +44,35 @@ private static IAsyncEnumerable OnErrorResumeNextCore(IEnumera private sealed class OnErrorResumeNextAsyncIterator : AsyncIterator { - private readonly IEnumerable> sources; + private readonly IEnumerable> _sources; - private IAsyncEnumerator enumerator; - private IEnumerator> sourcesEnumerator; + private IAsyncEnumerator _enumerator; + private IEnumerator> _sourcesEnumerator; public OnErrorResumeNextAsyncIterator(IEnumerable> sources) { Debug.Assert(sources != null); - this.sources = sources; + _sources = sources; } public override AsyncIterator Clone() { - return new OnErrorResumeNextAsyncIterator(sources); + return new OnErrorResumeNextAsyncIterator(_sources); } public override async ValueTask DisposeAsync() { - if (sourcesEnumerator != null) + if (_sourcesEnumerator != null) { - sourcesEnumerator.Dispose(); - sourcesEnumerator = null; + _sourcesEnumerator.Dispose(); + _sourcesEnumerator = null; } - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -83,7 +83,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - sourcesEnumerator = sources.GetEnumerator(); + _sourcesEnumerator = _sources.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -91,21 +91,21 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (enumerator == null) + if (_enumerator == null) { - if (!sourcesEnumerator.MoveNext()) + if (!_sourcesEnumerator.MoveNext()) { break; // while -- done, nothing else to do } - enumerator = sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _enumerator = _sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); } try { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } } @@ -115,8 +115,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella } // Done with the current one, go to the next - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } break; // case diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 08a93924dc..079bb86eed 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -53,35 +53,35 @@ public static IAsyncEnumerable Scan(this IAsy private sealed class ScanAsyncEnumerable : AsyncIterator { - private readonly Func accumulator; - private readonly IAsyncEnumerable source; + private readonly Func _accumulator; + private readonly IAsyncEnumerable _source; - private TSource accumulated; - private IAsyncEnumerator enumerator; + private TSource _accumulated; + private IAsyncEnumerator _enumerator; - private bool hasSeed; + private bool _hasSeed; public ScanAsyncEnumerable(IAsyncEnumerable source, Func accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); - this.source = source; - this.accumulator = accumulator; + _source = source; + _accumulator = accumulator; } public override AsyncIterator Clone() { - return new ScanAsyncEnumerable(source, accumulator); + return new ScanAsyncEnumerable(_source, _accumulator); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - accumulated = default; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -92,27 +92,27 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - hasSeed = false; - accumulated = default; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _hasSeed = false; + _accumulated = default; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (!hasSeed) + var item = _enumerator.Current; + if (!_hasSeed) { - hasSeed = true; - accumulated = item; + _hasSeed = true; + _accumulated = item; continue; // loop } - accumulated = accumulator(accumulated, item); - current = accumulated; + _accumulated = _accumulator(_accumulated, item); + current = _accumulated; return true; } @@ -127,35 +127,35 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class ScanAsyncEnumerable : AsyncIterator { - private readonly Func accumulator; - private readonly TAccumulate seed; - private readonly IAsyncEnumerable source; + private readonly Func _accumulator; + private readonly TAccumulate _seed; + private readonly IAsyncEnumerable _source; - private TAccumulate accumulated; - private IAsyncEnumerator enumerator; + private TAccumulate _accumulated; + private IAsyncEnumerator _enumerator; public ScanAsyncEnumerable(IAsyncEnumerable source, TAccumulate seed, Func accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); - this.source = source; - this.seed = seed; - this.accumulator = accumulator; + _source = source; + _seed = seed; + _accumulator = accumulator; } public override AsyncIterator Clone() { - return new ScanAsyncEnumerable(source, seed, accumulator); + return new ScanAsyncEnumerable(_source, _seed, _accumulator); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - accumulated = default; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -166,18 +166,18 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - accumulated = seed; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _accumulated = _seed; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - accumulated = accumulator(accumulated, item); - current = accumulated; + var item = _enumerator.Current; + _accumulated = _accumulator(_accumulated, item); + current = _accumulated; return true; } @@ -191,35 +191,35 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class ScanAsyncEnumerableWithTask : AsyncIterator { - private readonly Func> accumulator; - private readonly IAsyncEnumerable source; + private readonly Func> _accumulator; + private readonly IAsyncEnumerable _source; - private TSource accumulated; - private IAsyncEnumerator enumerator; + private TSource _accumulated; + private IAsyncEnumerator _enumerator; - private bool hasSeed; + private bool _hasSeed; public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, Func> accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); - this.source = source; - this.accumulator = accumulator; + _source = source; + _accumulator = accumulator; } public override AsyncIterator Clone() { - return new ScanAsyncEnumerableWithTask(source, accumulator); + return new ScanAsyncEnumerableWithTask(_source, _accumulator); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - accumulated = default; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -230,27 +230,27 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - hasSeed = false; - accumulated = default; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _hasSeed = false; + _accumulated = default; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (!hasSeed) + var item = _enumerator.Current; + if (!_hasSeed) { - hasSeed = true; - accumulated = item; + _hasSeed = true; + _accumulated = item; continue; // loop } - accumulated = await accumulator(accumulated, item).ConfigureAwait(false); - current = accumulated; + _accumulated = await _accumulator(_accumulated, item).ConfigureAwait(false); + current = _accumulated; return true; } @@ -265,35 +265,35 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class ScanAsyncEnumerableWithTask : AsyncIterator { - private readonly Func> accumulator; - private readonly TAccumulate seed; - private readonly IAsyncEnumerable source; + private readonly Func> _accumulator; + private readonly TAccumulate _seed; + private readonly IAsyncEnumerable _source; - private TAccumulate accumulated; - private IAsyncEnumerator enumerator; + private TAccumulate _accumulated; + private IAsyncEnumerator _enumerator; public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); - this.source = source; - this.seed = seed; - this.accumulator = accumulator; + _source = source; + _seed = seed; + _accumulator = accumulator; } public override AsyncIterator Clone() { - return new ScanAsyncEnumerableWithTask(source, seed, accumulator); + return new ScanAsyncEnumerableWithTask(_source, _seed, _accumulator); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - accumulated = default; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -304,18 +304,18 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - accumulated = seed; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _accumulated = _seed; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - accumulated = await accumulator(accumulated, item).ConfigureAwait(false); - current = accumulated; + var item = _enumerator.Current; + _accumulated = await _accumulator(_accumulated, item).ConfigureAwait(false); + current = _accumulated; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index bc07518ad4..8d108db4c3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -25,30 +25,30 @@ public static IAsyncEnumerable Timeout(this IAsyncEnumerable : AsyncIterator { - private readonly IAsyncEnumerable source; - private readonly TimeSpan timeout; + private readonly IAsyncEnumerable _source; + private readonly TimeSpan _timeout; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public TimeoutAsyncIterator(IAsyncEnumerable source, TimeSpan timeout) { Debug.Assert(source != null); - this.source = source; - this.timeout = timeout; + _source = source; + _timeout = timeout; } public override AsyncIterator Clone() { - return new TimeoutAsyncIterator(source, timeout); + return new TimeoutAsyncIterator(_source, _timeout); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -59,19 +59,19 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - var moveNext = enumerator.MoveNextAsync(); + var moveNext = _enumerator.MoveNextAsync(); if (!moveNext.IsCompleted) { using (var delayCts = new CancellationTokenSource()) { - var delay = Task.Delay(timeout, delayCts.Token); + var delay = Task.Delay(_timeout, delayCts.Token); var winner = await Task.WhenAny(moveNext.AsTask(), delay).ConfigureAwait(false); @@ -86,7 +86,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella if (await moveNext.ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 6e3be337f5..529ba05bed 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -33,39 +33,39 @@ public static IAsyncEnumerable Using(Func : AsyncIterator where TResource : IDisposable { - private readonly Func> enumerableFactory; - private readonly Func resourceFactory; + private readonly Func> _enumerableFactory; + private readonly Func _resourceFactory; - private IAsyncEnumerable enumerable; - private IAsyncEnumerator enumerator; - private TResource resource; + private IAsyncEnumerable _enumerable; + private IAsyncEnumerator _enumerator; + private TResource _resource; public UsingAsyncIterator(Func resourceFactory, Func> enumerableFactory) { Debug.Assert(resourceFactory != null); Debug.Assert(enumerableFactory != null); - this.resourceFactory = resourceFactory; - this.enumerableFactory = enumerableFactory; + _resourceFactory = resourceFactory; + _enumerableFactory = enumerableFactory; } public override AsyncIterator Clone() { - return new UsingAsyncIterator(resourceFactory, enumerableFactory); + return new UsingAsyncIterator(_resourceFactory, _enumerableFactory); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - if (resource != null) + if (_resource != null) { - resource.Dispose(); - resource = default; + _resource.Dispose(); + _resource = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -76,14 +76,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = enumerable.GetAsyncEnumerator(cancellationToken); + _enumerator = _enumerable.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -98,8 +98,8 @@ protected override void OnGetEnumerator(CancellationToken cancellationToken) { // REVIEW: Wire cancellation to the functions. - resource = resourceFactory(); - enumerable = enumerableFactory(resource); + _resource = _resourceFactory(); + _enumerable = _enumerableFactory(_resource); base.OnGetEnumerator(cancellationToken); } @@ -107,39 +107,39 @@ protected override void OnGetEnumerator(CancellationToken cancellationToken) private sealed class UsingAsyncIteratorWithTask : AsyncIterator where TResource : IDisposable { - private readonly Func>> enumerableFactory; - private readonly Func> resourceFactory; + private readonly Func>> _enumerableFactory; + private readonly Func> _resourceFactory; - private IAsyncEnumerable enumerable; - private IAsyncEnumerator enumerator; - private TResource resource; + private IAsyncEnumerable _enumerable; + private IAsyncEnumerator _enumerator; + private TResource _resource; public UsingAsyncIteratorWithTask(Func> resourceFactory, Func>> enumerableFactory) { Debug.Assert(resourceFactory != null); Debug.Assert(enumerableFactory != null); - this.resourceFactory = resourceFactory; - this.enumerableFactory = enumerableFactory; + _resourceFactory = resourceFactory; + _enumerableFactory = enumerableFactory; } public override AsyncIterator Clone() { - return new UsingAsyncIteratorWithTask(resourceFactory, enumerableFactory); + return new UsingAsyncIteratorWithTask(_resourceFactory, _enumerableFactory); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - if (resource != null) + if (_resource != null) { - resource.Dispose(); - resource = default; + _resource.Dispose(); + _resource = default; } await base.DisposeAsync().ConfigureAwait(false); @@ -150,17 +150,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - resource = await resourceFactory().ConfigureAwait(false); - enumerable = await enumerableFactory(resource).ConfigureAwait(false); + _resource = await _resourceFactory().ConfigureAwait(false); + _enumerable = await _enumerableFactory(_resource).ConfigureAwait(false); - enumerator = enumerable.GetAsyncEnumerator(cancellationToken); + _enumerator = _enumerable.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 853724b716..3990701122 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -14,8 +14,8 @@ internal static class AsyncEnumerableHelpers internal static async Task ToArray(IAsyncEnumerable source, CancellationToken cancellationToken) { var result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false); - Array.Resize(ref result.array, result.length); - return result.array; + Array.Resize(ref result.Array, result.Length); + return result.Array; } internal static async Task> ToArrayWithLength(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -34,9 +34,9 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer // exception from overrunning the array (if the size went up) or we could end up not filling as many // items as 'count' suggests (if the size went down). This is only an issue for concurrent collections // that implement ICollection, which as of .NET 4.6 is just ConcurrentDictionary. - result.array = new T[count]; - ic.CopyTo(result.array, 0); - result.length = count; + result.Array = new T[count]; + ic.CopyTo(result.Array, 0); + result.Length = count; return result; } } @@ -86,8 +86,8 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer arr[count++] = en.Current; } - result.length = count; - result.array = arr; + result.Length = count; + result.Array = arr; return result; } } @@ -97,19 +97,19 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer } } - result.length = 0; + result.Length = 0; #if NO_ARRAY_EMPTY - result.array = EmptyArray.Value; + result.Array = EmptyArray.Value; #else - result.array = Array.Empty(); + result.Array = Array.Empty(); #endif return result; } internal struct ArrayWithLength { - public T[] array; - public int length; + public T[] Array; + public int Length; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 026824f503..9f45ed801e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -99,8 +99,8 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell } } - private bool hasSkipped; - private int taken; + private bool _hasSkipped; + private int _taken; protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { @@ -108,14 +108,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella { case AsyncIteratorState.Allocated: _enumerator = _source.GetAsyncEnumerator(cancellationToken); - hasSkipped = false; - taken = 0; + _hasSkipped = false; + _taken = 0; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (!hasSkipped) + if (!_hasSkipped) { if (!await SkipBeforeFirstAsync(_enumerator, CancellationToken.None).ConfigureAwait(false)) { @@ -123,17 +123,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; } - hasSkipped = true; + _hasSkipped = true; } - if ((!HasLimit || taken < Limit) && await _enumerator.MoveNextAsync().ConfigureAwait(false)) + if ((!HasLimit || _taken < Limit) && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { if (HasLimit) { // If we are taking an unknown number of elements, it's important not to increment _state. // _state - 3 may eventually end up overflowing & we'll hit the Dispose branch even though // we haven't finished enumerating. - taken++; + _taken++; } current = _enumerator.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs index ecfeae8ad1..d5fee14f94 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs @@ -8,15 +8,15 @@ namespace System.Linq { internal sealed class CancellationTokenDisposable : IDisposable { - private readonly CancellationTokenSource cts = new CancellationTokenSource(); + private readonly CancellationTokenSource _cts = new CancellationTokenSource(); - public CancellationToken Token => cts.Token; + public CancellationToken Token => _cts.Token; public void Dispose() { - if (!cts.IsCancellationRequested) + if (!_cts.IsCancellationRequested) { - cts.Cancel(); + _cts.Cancel(); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 2ab1bfb0aa..c976266f15 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -63,8 +63,8 @@ internal override IAsyncEnumerable GetAsyncEnumerable(int index) private abstract class ConcatAsyncIterator : AsyncIterator, IAsyncIListProvider { - private int counter; - private IAsyncEnumerator enumerator; + private int _counter; + private IAsyncEnumerator _enumerator; public Task ToArrayAsync(CancellationToken cancellationToken) { @@ -127,10 +127,10 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -140,27 +140,27 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella { if (state == AsyncIteratorState.Allocated) { - enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator(cancellationToken); + _enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; - counter = 2; + _counter = 2; } if (state == AsyncIteratorState.Iterating) { while (true) { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } // note, this is simply to match the logic of // https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/system.linq/src/system/linq/concatenate.cs#L173-L173 - var next = GetAsyncEnumerable(counter++ - 1); + var next = GetAsyncEnumerable(_counter++ - 1); if (next != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = next.GetAsyncEnumerator(cancellationToken); + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = next.GetAsyncEnumerator(cancellationToken); continue; } @@ -185,9 +185,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella // a much better memory profile and without much additional run-time cost. private sealed class ConcatNAsyncIterator : ConcatAsyncIterator { - private readonly IAsyncEnumerable next; - private readonly int nextIndex; - private readonly ConcatAsyncIterator previousConcat; + private readonly IAsyncEnumerable _next; + private readonly int _nextIndex; + private readonly ConcatAsyncIterator _previousConcat; internal ConcatNAsyncIterator(ConcatAsyncIterator previousConcat, IAsyncEnumerable next, int nextIndex) { @@ -195,19 +195,19 @@ internal ConcatNAsyncIterator(ConcatAsyncIterator previousConcat, IAsyn Debug.Assert(next != null); Debug.Assert(nextIndex >= 2); - this.previousConcat = previousConcat; - this.next = next; - this.nextIndex = nextIndex; + _previousConcat = previousConcat; + _next = next; + _nextIndex = nextIndex; } public override AsyncIterator Clone() { - return new ConcatNAsyncIterator(previousConcat, next, nextIndex); + return new ConcatNAsyncIterator(_previousConcat, _next, _nextIndex); } internal override ConcatAsyncIterator Concat(IAsyncEnumerable next) { - if (nextIndex == int.MaxValue - 2) + if (_nextIndex == int.MaxValue - 2) { // In the unlikely case of this many concatenations, if we produced a ConcatNIterator // with int.MaxValue then state would overflow before it matched it's index. @@ -215,12 +215,12 @@ internal override ConcatAsyncIterator Concat(IAsyncEnumerable return new Concat2AsyncIterator(this, next); } - return new ConcatNAsyncIterator(this, next, nextIndex + 1); + return new ConcatNAsyncIterator(this, next, _nextIndex + 1); } internal override IAsyncEnumerable GetAsyncEnumerable(int index) { - if (index > nextIndex) + if (index > _nextIndex) { return null; } @@ -232,20 +232,20 @@ internal override IAsyncEnumerable GetAsyncEnumerable(int index) var current = this; while (true) { - if (index == current.nextIndex) + if (index == current._nextIndex) { - return current.next; + return current._next; } - if (current.previousConcat is ConcatNAsyncIterator prevN) + if (current._previousConcat is ConcatNAsyncIterator prevN) { current = prevN; continue; } - Debug.Assert(current.previousConcat is Concat2AsyncIterator); + Debug.Assert(current._previousConcat is Concat2AsyncIterator); Debug.Assert(index == 0 || index == 1); - return current.previousConcat.GetAsyncEnumerable(index); + return current._previousConcat.GetAsyncEnumerable(index); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index 8ab72d6b8d..d3fe1cf08b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -55,93 +55,93 @@ private static IAsyncEnumerator CreateEnumerator(Func : IAsyncEnumerable { - private readonly Func> getEnumerator; + private readonly Func> _getEnumerator; public AnonymousAsyncEnumerable(Func> getEnumerator) { Debug.Assert(getEnumerator != null); - this.getEnumerator = getEnumerator; + _getEnumerator = getEnumerator; } - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => getEnumerator(cancellationToken); + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => _getEnumerator(cancellationToken); } private sealed class AnonymousAsyncEnumerableWithTask : IAsyncEnumerable { - private readonly Func>> getEnumerator; + private readonly Func>> _getEnumerator; public AnonymousAsyncEnumerableWithTask(Func>> getEnumerator) { Debug.Assert(getEnumerator != null); - this.getEnumerator = getEnumerator; + _getEnumerator = getEnumerator; } - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new Enumerator(getEnumerator, cancellationToken); + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new Enumerator(_getEnumerator, cancellationToken); private sealed class Enumerator : IAsyncEnumerator { - private Func>> getEnumerator; - private readonly CancellationToken cancellationToken; - private IAsyncEnumerator enumerator; + private Func>> _getEnumerator; + private readonly CancellationToken _cancellationToken; + private IAsyncEnumerator _enumerator; public Enumerator(Func>> getEnumerator, CancellationToken cancellationToken) { Debug.Assert(getEnumerator != null); - this.getEnumerator = getEnumerator; - this.cancellationToken = cancellationToken; + _getEnumerator = getEnumerator; + _cancellationToken = cancellationToken; } public T Current { get { - if (enumerator == null) + if (_enumerator == null) throw new InvalidOperationException(); - return enumerator.Current; + return _enumerator.Current; } } public async ValueTask DisposeAsync() { - var old = Interlocked.Exchange(ref enumerator, DisposedEnumerator.Instance); + var old = Interlocked.Exchange(ref _enumerator, DisposedEnumerator.Instance); - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); + await _enumerator.DisposeAsync().ConfigureAwait(false); } } public ValueTask MoveNextAsync() { - if (enumerator == null) + if (_enumerator == null) { return InitAndMoveNextAsync(); } - return enumerator.MoveNextAsync(); + return _enumerator.MoveNextAsync(); } private async ValueTask InitAndMoveNextAsync() { try { - enumerator = await getEnumerator(cancellationToken).ConfigureAwait(false); + _enumerator = await _getEnumerator(_cancellationToken).ConfigureAwait(false); } catch (Exception ex) { - enumerator = Throw(ex).GetAsyncEnumerator(cancellationToken); + _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); throw; } finally { - getEnumerator = null; + _getEnumerator = null; } - return await enumerator.MoveNextAsync().ConfigureAwait(false); + return await _enumerator.MoveNextAsync().ConfigureAwait(false); } private sealed class DisposedEnumerator : IAsyncEnumerator diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index f62d1113cb..edda4adfa7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -34,30 +34,30 @@ public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnume private sealed class DefaultIfEmptyAsyncIterator : AsyncIterator, IAsyncIListProvider { - private readonly IAsyncEnumerable source; - private readonly TSource defaultValue; + private readonly IAsyncEnumerable _source; + private readonly TSource _defaultValue; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public DefaultIfEmptyAsyncIterator(IAsyncEnumerable source, TSource defaultValue) { Debug.Assert(source != null); - this.source = source; - this.defaultValue = defaultValue; + _source = source; + _defaultValue = defaultValue; } public override AsyncIterator Clone() { - return new DefaultIfEmptyAsyncIterator(source, defaultValue); + return new DefaultIfEmptyAsyncIterator(_source, _defaultValue); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -68,26 +68,26 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; state = AsyncIteratorState.Iterating; } else { - current = defaultValue; - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + current = _defaultValue; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; state = AsyncIteratorState.Disposed; } return true; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } break; @@ -99,16 +99,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public async Task ToArrayAsync(CancellationToken cancellationToken) { - var array = await source.ToArray(cancellationToken).ConfigureAwait(false); - return array.Length == 0 ? new[] { defaultValue } : array; + var array = await _source.ToArray(cancellationToken).ConfigureAwait(false); + return array.Length == 0 ? new[] { _defaultValue } : array; } public async Task> ToListAsync(CancellationToken cancellationToken) { - var list = await source.ToList(cancellationToken).ConfigureAwait(false); + var list = await _source.ToList(cancellationToken).ConfigureAwait(false); if (list.Count == 0) { - list.Add(defaultValue); + list.Add(_defaultValue); } return list; @@ -117,13 +117,13 @@ public async Task> ToListAsync(CancellationToken cancellationToken public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { int count; - if (!onlyIfCheap || source is ICollection || source is ICollection) + if (!onlyIfCheap || _source is ICollection || _source is ICollection) { - count = await source.Count(cancellationToken).ConfigureAwait(false); + count = await _source.Count(cancellationToken).ConfigureAwait(false); } else { - var listProv = source as IAsyncIListProvider; + var listProv = _source as IAsyncIListProvider; count = listProv == null ? -1 : await listProv.GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 71531d4880..9c759d099e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -31,18 +31,18 @@ public static IAsyncEnumerable Distinct(this IAsyncEnumerable< private sealed class DistinctAsyncIterator : AsyncIterator, IAsyncIListProvider { - private readonly IEqualityComparer comparer; - private readonly IAsyncEnumerable source; + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private Set set; + private IAsyncEnumerator _enumerator; + private Set _set; public DistinctAsyncIterator(IAsyncEnumerable source, IEqualityComparer comparer) { Debug.Assert(source != null); - this.source = source; - this.comparer = comparer; + _source = source; + _comparer = comparer; } public async Task ToArrayAsync(CancellationToken cancellationToken) @@ -64,16 +64,16 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell public override AsyncIterator Clone() { - return new DistinctAsyncIterator(source, comparer); + return new DistinctAsyncIterator(_source, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - set = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _set = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -84,26 +84,26 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - if (!await enumerator.MoveNextAsync().ConfigureAwait(false)) + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + if (!await _enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); return false; } - var element = enumerator.Current; - set = new Set(comparer); - set.Add(element); + var element = _enumerator.Current; + _set = new Set(_comparer); + _set.Add(element); current = element; state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - element = enumerator.Current; - if (set.Add(element)) + element = _enumerator.Current; + if (_set.Add(element)) { current = element; return true; @@ -119,9 +119,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private async Task> FillSetAsync(CancellationToken cancellationToken) { - var s = new Set(comparer); + var s = new Set(_comparer); - await s.UnionWithAsync(source, cancellationToken); + await s.UnionWithAsync(_source, cancellationToken); return s; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index cca4c5c0ec..5aa9f72efd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -35,16 +35,16 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable : AsyncIterator { - private readonly IEqualityComparer comparer; - private readonly IAsyncEnumerable first; - private readonly IAsyncEnumerable second; + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; - private Task fillSetTask; + private Task _fillSetTask; - private IAsyncEnumerator firstEnumerator; - private Set set; + private IAsyncEnumerator _firstEnumerator; + private Set _set; - private bool setFilled; + private bool _setFilled; public ExceptAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { @@ -52,25 +52,25 @@ public ExceptAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable Clone() { - return new ExceptAsyncIterator(first, second, comparer); + return new ExceptAsyncIterator(_first, _second, _comparer); } public override async ValueTask DisposeAsync() { - if (firstEnumerator != null) + if (_firstEnumerator != null) { - await firstEnumerator.DisposeAsync().ConfigureAwait(false); - firstEnumerator = null; + await _firstEnumerator.DisposeAsync().ConfigureAwait(false); + _firstEnumerator = null; } - set = null; + _set = null; await base.DisposeAsync().ConfigureAwait(false); } @@ -80,10 +80,10 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(cancellationToken); - set = new Set(comparer); - setFilled = false; - fillSetTask = FillSetAsync(); + _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); + _set = new Set(_comparer); + _setFilled = false; + _fillSetTask = FillSetAsync(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -92,24 +92,24 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella bool moveNext; do { - if (!setFilled) + if (!_setFilled) { // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask.AsTask(), fillSetTask).ConfigureAwait(false); + var moveNextTask = _firstEnumerator.MoveNextAsync(); + await Task.WhenAll(moveNextTask.AsTask(), _fillSetTask).ConfigureAwait(false); - setFilled = true; + _setFilled = true; moveNext = moveNextTask.Result; } else { - moveNext = await firstEnumerator.MoveNextAsync().ConfigureAwait(false); + moveNext = await _firstEnumerator.MoveNextAsync().ConfigureAwait(false); } if (moveNext) { - var item = firstEnumerator.Current; - if (set.Add(item)) + var item = _firstEnumerator.Current; + if (_set.Add(item)) { current = item; return true; @@ -126,11 +126,11 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private async Task FillSetAsync() { - var array = await second.ToArray().ConfigureAwait(false); + var array = await _second.ToArray().ConfigureAwait(false); foreach (var t in array) { - set.Add(t); + _set.Add(t); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index c4fd5ce839..a85abe4caa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -221,13 +221,13 @@ public static IAsyncEnumerable GroupBy : AsyncIterator, IAsyncIListProvider { - private readonly IAsyncEnumerable source; - private readonly Func keySelector; - private readonly Func, TResult> resultSelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _source; + private readonly Func _keySelector; + private readonly Func, TResult> _resultSelector; + private readonly IEqualityComparer _comparer; - private Internal.Lookup lookup; - private IEnumerator enumerator; + private Internal.Lookup _lookup; + private IEnumerator _enumerator; public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) { @@ -236,24 +236,24 @@ public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func Clone() { - return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); + return new GroupedResultAsyncEnumerable(_source, _keySelector, _resultSelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; - lookup = null; + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -264,15 +264,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - enumerator = lookup.ApplyResultSelector(resultSelector).GetEnumerator(); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _enumerator = _lookup.ApplyResultSelector(_resultSelector).GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -285,14 +285,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public async Task ToArrayAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return l.ToArray(resultSelector); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return l.ToArray(_resultSelector); } public async Task> ToListAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return l.ToList(resultSelector); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return l.ToList(_resultSelector); } public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) @@ -302,7 +302,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -310,13 +310,13 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell internal sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IAsyncIListProvider { - private readonly IAsyncEnumerable source; - private readonly Func> keySelector; - private readonly Func, Task> resultSelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly Func, Task> _resultSelector; + private readonly IEqualityComparer _comparer; - private Internal.LookupWithTask lookup; - private IAsyncEnumerator enumerator; + private Internal.LookupWithTask _lookup; + private IAsyncEnumerator _enumerator; public GroupedResultAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) { @@ -325,24 +325,24 @@ public GroupedResultAsyncEnumerableWithTask(IAsyncEnumerable source, Fu Debug.Assert(resultSelector != null); Debug.Assert(comparer != null); - this.source = source; - this.keySelector = keySelector; - this.resultSelector = resultSelector; - this.comparer = comparer; + _source = source; + _keySelector = keySelector; + _resultSelector = resultSelector; + _comparer = comparer; } public override AsyncIterator Clone() { - return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); + return new GroupedResultAsyncEnumerableWithTask(_source, _keySelector, _resultSelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; - lookup = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _lookup = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -353,15 +353,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - enumerator = lookup.Select(async g => await resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(cancellationToken); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -374,14 +374,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public async Task ToArrayAsync(CancellationToken cancellationToken) { - var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return await l.ToArray(resultSelector).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArray(_resultSelector).ConfigureAwait(false); } public async Task> ToListAsync(CancellationToken cancellationToken) { - var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - return await l.ToList(resultSelector).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToList(_resultSelector).ConfigureAwait(false); } public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) @@ -391,7 +391,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -399,13 +399,13 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { - private readonly IAsyncEnumerable source; - private readonly Func keySelector; - private readonly Func elementSelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _source; + private readonly Func _keySelector; + private readonly Func _elementSelector; + private readonly IEqualityComparer _comparer; - private Internal.Lookup lookup; - private IEnumerator> enumerator; + private Internal.Lookup _lookup; + private IEnumerator> _enumerator; public GroupedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { @@ -414,24 +414,24 @@ public GroupedAsyncEnumerable(IAsyncEnumerable source, Func> Clone() { - return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); + return new GroupedAsyncEnumerable(_source, _keySelector, _elementSelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; - lookup = null; + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -442,15 +442,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); - enumerator = lookup.GetEnumerator(); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer).ConfigureAwait(false); + _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)enumerator.Current; + current = (IAsyncGrouping)_enumerator.Current; return true; } @@ -463,13 +463,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -480,7 +480,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -488,13 +488,13 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { - private readonly IAsyncEnumerable source; - private readonly Func> keySelector; - private readonly Func> elementSelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly Func> _elementSelector; + private readonly IEqualityComparer _comparer; - private Internal.LookupWithTask lookup; - private IEnumerator> enumerator; + private Internal.LookupWithTask _lookup; + private IEnumerator> _enumerator; public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { @@ -503,24 +503,24 @@ public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> Clone() { - return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); + return new GroupedAsyncEnumerableWithTask(_source, _keySelector, _elementSelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; - lookup = null; + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -531,15 +531,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); - enumerator = lookup.GetEnumerator(); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer).ConfigureAwait(false); + _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)enumerator.Current; + current = (IAsyncGrouping)_enumerator.Current; return true; } @@ -552,13 +552,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -569,7 +569,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -577,12 +577,12 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { - private readonly IAsyncEnumerable source; - private readonly Func keySelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _source; + private readonly Func _keySelector; + private readonly IEqualityComparer _comparer; - private Internal.Lookup lookup; - private IEnumerator> enumerator; + private Internal.Lookup _lookup; + private IEnumerator> _enumerator; public GroupedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { @@ -590,22 +590,22 @@ public GroupedAsyncEnumerable(IAsyncEnumerable source, Func> Clone() { - return new GroupedAsyncEnumerable(source, keySelector, comparer); + return new GroupedAsyncEnumerable(_source, _keySelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; - lookup = null; + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -616,15 +616,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - enumerator = lookup.GetEnumerator(); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)enumerator.Current; + current = (IAsyncGrouping)_enumerator.Current; return true; } @@ -637,13 +637,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -654,7 +654,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); return l.Count; } @@ -662,12 +662,12 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { - private readonly IAsyncEnumerable source; - private readonly Func> keySelector; - private readonly IEqualityComparer comparer; + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly IEqualityComparer _comparer; - private Internal.LookupWithTask lookup; - private IEnumerator> enumerator; + private Internal.LookupWithTask _lookup; + private IEnumerator> _enumerator; public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { @@ -675,22 +675,22 @@ public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> Clone() { - return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); + return new GroupedAsyncEnumerableWithTask(_source, _keySelector, _comparer); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; - lookup = null; + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -701,15 +701,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); - enumerator = lookup.GetEnumerator(); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)enumerator.Current; + current = (IAsyncGrouping)_enumerator.Current; return true; } @@ -722,13 +722,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public async Task[]> ToArrayAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } public async Task>> ToListAsync(CancellationToken cancellationToken) { - IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } @@ -739,7 +739,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); return l.Count; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 88dfebe759..dde526ed90 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -35,16 +35,16 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable private sealed class IntersectAsyncIterator : AsyncIterator { - private readonly IEqualityComparer comparer; - private readonly IAsyncEnumerable first; - private readonly IAsyncEnumerable second; + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; - private Task fillSetTask; + private Task _fillSetTask; - private IAsyncEnumerator firstEnumerator; - private Set set; + private IAsyncEnumerator _firstEnumerator; + private Set _set; - private bool setFilled; + private bool _setFilled; public IntersectAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { @@ -52,25 +52,25 @@ public IntersectAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable< Debug.Assert(second != null); Debug.Assert(comparer != null); - this.first = first; - this.second = second; - this.comparer = comparer; + _first = first; + _second = second; + _comparer = comparer; } public override AsyncIterator Clone() { - return new IntersectAsyncIterator(first, second, comparer); + return new IntersectAsyncIterator(_first, _second, _comparer); } public override async ValueTask DisposeAsync() { - if (firstEnumerator != null) + if (_firstEnumerator != null) { - await firstEnumerator.DisposeAsync().ConfigureAwait(false); - firstEnumerator = null; + await _firstEnumerator.DisposeAsync().ConfigureAwait(false); + _firstEnumerator = null; } - set = null; + _set = null; await base.DisposeAsync().ConfigureAwait(false); } @@ -80,10 +80,10 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(cancellationToken); - set = new Set(comparer); - setFilled = false; - fillSetTask = FillSet(); + _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); + _set = new Set(_comparer); + _setFilled = false; + _fillSetTask = FillSet(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -93,23 +93,23 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella bool moveNext; do { - if (!setFilled) + if (!_setFilled) { // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask.AsTask(), fillSetTask).ConfigureAwait(false); - setFilled = true; + var moveNextTask = _firstEnumerator.MoveNextAsync(); + await Task.WhenAll(moveNextTask.AsTask(), _fillSetTask).ConfigureAwait(false); + _setFilled = true; moveNext = moveNextTask.Result; } else { - moveNext = await firstEnumerator.MoveNextAsync().ConfigureAwait(false); + moveNext = await _firstEnumerator.MoveNextAsync().ConfigureAwait(false); } if (moveNext) { - var item = firstEnumerator.Current; - if (set.Remove(item)) + var item = _firstEnumerator.Current; + if (_set.Remove(item)) { current = item; return true; @@ -126,10 +126,10 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private async Task FillSet() { - var array = await second.ToArray().ConfigureAwait(false); + var array = await _second.ToArray().ConfigureAwait(false); for (var i = 0; i < array.Length; i++) { - set.Add(array[i]); + _set.Add(array[i]); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 5258ffacfc..791ce0425e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -20,27 +20,27 @@ public static IAsyncEnumerable Repeat(TResult element, int cou private sealed class RepeatAsyncIterator : AsyncIterator, IAsyncIListProvider { - private readonly TResult element; - private readonly int count; - private int remaining; + private readonly TResult _element; + private readonly int _count; + private int _remaining; public RepeatAsyncIterator(TResult element, int count) { - this.element = element; - this.count = count; + _element = element; + _count = count; } - public override AsyncIterator Clone() => new RepeatAsyncIterator(element, count); + public override AsyncIterator Clone() => new RepeatAsyncIterator(_element, _count); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(count); + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_count); public Task ToArrayAsync(CancellationToken cancellationToken) { - var res = new TResult[count]; + var res = new TResult[_count]; - for (var i = 0; i < count; i++) + for (var i = 0; i < _count; i++) { - res[i] = element; + res[i] = _element; } return Task.FromResult(res); @@ -48,11 +48,11 @@ public Task ToArrayAsync(CancellationToken cancellationToken) public Task> ToListAsync(CancellationToken cancellationToken) { - var res = new List(count); + var res = new List(_count); - for (var i = 0; i < count; i++) + for (var i = 0; i < _count; i++) { - res.Add(element); + res.Add(_element); } return Task.FromResult(res); @@ -63,11 +63,11 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - remaining = count; + _remaining = _count; - if (remaining > 0) + if (_remaining > 0) { - current = element; + current = _element; } state = AsyncIteratorState.Iterating; @@ -75,7 +75,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (remaining-- != 0) + if (_remaining-- != 0) { return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index 58a8146f2c..43203885a5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -24,21 +24,21 @@ public static IAsyncEnumerable Reverse(this IAsyncEnumerable : AsyncIterator, IAsyncIListProvider { - private readonly IAsyncEnumerable source; + private readonly IAsyncEnumerable _source; - private int index; - private TSource[] items; + private int _index; + private TSource[] _items; public ReverseAsyncIterator(IAsyncEnumerable source) { Debug.Assert(source != null); - this.source = source; + _source = source; } public async Task ToArrayAsync(CancellationToken cancellationToken) { - var array = await source.ToArray(cancellationToken).ConfigureAwait(false); + var array = await _source.ToArray(cancellationToken).ConfigureAwait(false); // Array.Reverse() involves boxing for non-primitive value types, but // checking that has its own cost, so just use this approach for all types. @@ -54,7 +54,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) public async Task> ToListAsync(CancellationToken cancellationToken) { - var list = await source.ToList(cancellationToken).ConfigureAwait(false); + var list = await _source.ToList(cancellationToken).ConfigureAwait(false); list.Reverse(); return list; @@ -64,28 +64,28 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT { if (onlyIfCheap) { - if (source is IAsyncIListProvider listProv) + if (_source is IAsyncIListProvider listProv) { return listProv.GetCountAsync(true, cancellationToken); } - if (!(source is ICollection) && !(source is ICollection)) + if (!(_source is ICollection) && !(_source is ICollection)) { return Task.FromResult(-1); } } - return source.Count(cancellationToken); + return _source.Count(cancellationToken); } public override AsyncIterator Clone() { - return new ReverseAsyncIterator(source); + return new ReverseAsyncIterator(_source); } public override async ValueTask DisposeAsync() { - items = null; // Just in case this ends up being long-lived, allow the memory to be reclaimed. + _items = null; // Just in case this ends up being long-lived, allow the memory to be reclaimed. await base.DisposeAsync().ConfigureAwait(false); } @@ -94,17 +94,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - items = await source.ToArray().ConfigureAwait(false); - index = items.Length - 1; + _items = await _source.ToArray().ConfigureAwait(false); + _index = _items.Length - 1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (index != -1) + if (_index != -1) { - current = items[index]; - --index; + current = _items[_index]; + --_index; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index a53ecaf7d5..afa8688965 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -83,31 +83,31 @@ private static Func> CombineSelectors : AsyncIterator { - private readonly Func selector; - private readonly IAsyncEnumerable source; + private readonly Func _selector; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public SelectEnumerableAsyncIterator(IAsyncEnumerable source, Func selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectEnumerableAsyncIterator(source, selector); + return new SelectEnumerableAsyncIterator(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -115,7 +115,7 @@ public override async ValueTask DisposeAsync() public override IAsyncEnumerable Select(Func selector) { - return new SelectEnumerableAsyncIterator(source, CombineSelectors(this.selector, selector)); + return new SelectEnumerableAsyncIterator(_source, CombineSelectors(_selector, selector)); } protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) @@ -123,14 +123,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = selector(enumerator.Current); + current = _selector(_enumerator.Current); return true; } @@ -144,31 +144,31 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class SelectEnumerableWithIndexAsyncIterator : AsyncIterator { - private readonly Func selector; - private readonly IAsyncEnumerable source; - private IAsyncEnumerator enumerator; - private int index; + private readonly Func _selector; + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; + private int _index; public SelectEnumerableWithIndexAsyncIterator(IAsyncEnumerable source, Func selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectEnumerableWithIndexAsyncIterator(source, selector); + return new SelectEnumerableWithIndexAsyncIterator(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -179,19 +179,19 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { - index++; + _index++; } - current = selector(enumerator.Current, index); + current = _selector(_enumerator.Current, _index); return true; } @@ -205,30 +205,30 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class SelectIListIterator : AsyncIterator, IAsyncIListProvider { - private readonly Func selector; - private readonly IList source; - private IEnumerator enumerator; + private readonly Func _selector; + private readonly IList _source; + private IEnumerator _enumerator; public SelectIListIterator(IList source, Func selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectIListIterator(source, selector); + return new SelectIListIterator(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; + _enumerator.Dispose(); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -243,9 +243,9 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT var count = 0; - foreach (var item in source) + foreach (var item in _source) { - selector(item); + _selector(item); checked { @@ -258,18 +258,18 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT public override IAsyncEnumerable Select(Func selector) { - return new SelectIListIterator(source, CombineSelectors(this.selector, selector)); + return new SelectIListIterator(_source, CombineSelectors(_selector, selector)); } public Task ToArrayAsync(CancellationToken cancellationToken) { - var n = source.Count; + var n = _source.Count; var res = new TResult[n]; for (var i = 0; i < n; i++) { - res[i] = selector(source[i]); + res[i] = _selector(_source[i]); } return Task.FromResult(res); @@ -277,13 +277,13 @@ public Task ToArrayAsync(CancellationToken cancellationToken) public Task> ToListAsync(CancellationToken cancellationToken) { - var n = source.Count; + var n = _source.Count; var res = new List(n); for (var i = 0; i < n; i++) { - res.Add(selector(source[i])); + res.Add(_selector(_source[i])); } return Task.FromResult(res); @@ -294,14 +294,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + _enumerator = _source.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = selector(enumerator.Current); + current = _selector(_enumerator.Current); return true; } @@ -315,31 +315,31 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class SelectEnumerableAsyncIteratorWithTask : AsyncIterator { - private readonly Func> selector; - private readonly IAsyncEnumerable source; + private readonly Func> _selector; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public SelectEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectEnumerableAsyncIteratorWithTask(source, selector); + return new SelectEnumerableAsyncIteratorWithTask(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -347,7 +347,7 @@ public override async ValueTask DisposeAsync() public override IAsyncEnumerable Select(Func> selector) { - return new SelectEnumerableAsyncIteratorWithTask(source, CombineSelectors(this.selector, selector)); + return new SelectEnumerableAsyncIteratorWithTask(_source, CombineSelectors(_selector, selector)); } protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) @@ -355,14 +355,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = await selector(enumerator.Current).ConfigureAwait(false); + current = await _selector(_enumerator.Current).ConfigureAwait(false); return true; } @@ -376,31 +376,31 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> selector; - private readonly IAsyncEnumerable source; - private IAsyncEnumerator enumerator; - private int index; + private readonly Func> _selector; + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; + private int _index; public SelectEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectEnumerableWithIndexAsyncIteratorWithTask(source, selector); + return new SelectEnumerableWithIndexAsyncIteratorWithTask(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -411,19 +411,19 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { - index++; + _index++; } - current = await selector(enumerator.Current, index).ConfigureAwait(false); + current = await _selector(_enumerator.Current, _index).ConfigureAwait(false); return true; } @@ -442,30 +442,30 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class SelectIListIteratorWithTask : AsyncIterator, IAsyncIListProvider { - private readonly Func> selector; - private readonly IList source; - private IEnumerator enumerator; + private readonly Func> _selector; + private readonly IList _source; + private IEnumerator _enumerator; public SelectIListIteratorWithTask(IList source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); - this.source = source; - this.selector = selector; + _source = source; + _selector = selector; } public override AsyncIterator Clone() { - return new SelectIListIteratorWithTask(source, selector); + return new SelectIListIteratorWithTask(_source, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; + _enumerator.Dispose(); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -480,9 +480,9 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell var count = 0; - foreach (var item in source) + foreach (var item in _source) { - await selector(item).ConfigureAwait(false); + await _selector(item).ConfigureAwait(false); checked { @@ -495,18 +495,18 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell public override IAsyncEnumerable Select(Func> selector) { - return new SelectIListIteratorWithTask(source, CombineSelectors(this.selector, selector)); + return new SelectIListIteratorWithTask(_source, CombineSelectors(_selector, selector)); } public async Task ToArrayAsync(CancellationToken cancellationToken) { - var n = source.Count; + var n = _source.Count; var res = new TResult[n]; for (var i = 0; i < n; i++) { - res[i] = await selector(source[i]).ConfigureAwait(false); + res[i] = await _selector(_source[i]).ConfigureAwait(false); } return res; @@ -514,13 +514,13 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) public async Task> ToListAsync(CancellationToken cancellationToken) { - var n = source.Count; + var n = _source.Count; var res = new List(n); for (var i = 0; i < n; i++) { - res.Add(await selector(source[i]).ConfigureAwait(false)); + res.Add(await _selector(_source[i]).ConfigureAwait(false)); } return res; @@ -531,14 +531,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + _enumerator = _source.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = await selector(enumerator.Current).ConfigureAwait(false); + current = await _selector(_enumerator.Current).ConfigureAwait(false); return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs index e22fc6431c..0b0cc56592 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs @@ -57,8 +57,8 @@ private SingleLinkedNode(SingleLinkedNode linked, TSource item) /// public int GetCount() { - int count = 0; - for (SingleLinkedNode node = this; node != null; node = node.Linked) + var count = 0; + for (var node = this; node != null; node = node.Linked) { count++; } @@ -86,7 +86,7 @@ public SingleLinkedNode GetNode(int index) { Debug.Assert(index >= 0 && index < GetCount()); - SingleLinkedNode node = this; + var node = this; for (; index > 0; index--) { node = node.Linked; @@ -104,9 +104,9 @@ private TSource[] ToArray(int count) { Debug.Assert(count == GetCount()); - TSource[] array = new TSource[count]; - int index = count; - for (SingleLinkedNode node = this; node != null; node = node.Linked) + var array = new TSource[count]; + var index = count; + for (var node = this; node != null; node = node.Linked) { --index; array[index] = node.Item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 410cee585d..e4feec1d02 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -33,34 +33,34 @@ public static IAsyncEnumerable SkipLast(this IAsyncEnumerable< private sealed class SkipLastAsyncIterator : AsyncIterator { - private readonly int count; - private readonly IAsyncEnumerable source; + private readonly int _count; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private Queue queue; + private IAsyncEnumerator _enumerator; + private Queue _queue; public SkipLastAsyncIterator(IAsyncEnumerable source, int count) { Debug.Assert(source != null); - this.source = source; - this.count = count; + _source = source; + _count = count; } public override AsyncIterator Clone() { - return new SkipLastAsyncIterator(source, count); + return new SkipLastAsyncIterator(_source, _count); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - queue = null; // release the memory + _queue = null; // release the memory await base.DisposeAsync().ConfigureAwait(false); } @@ -71,22 +71,22 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - queue = new Queue(); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _queue = new Queue(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - queue.Enqueue(item); + var item = _enumerator.Current; + _queue.Enqueue(item); - if (queue.Count > count) + if (_queue.Count > _count) { - current = queue.Dequeue(); + current = _queue.Dequeue(); return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 0d70eca12f..60dc3fe48e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -53,32 +53,32 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable private sealed class SkipWhileAsyncIterator : AsyncIterator { - private readonly Func predicate; - private readonly IAsyncEnumerable source; + private readonly Func _predicate; + private readonly IAsyncEnumerable _source; - private bool doMoveNext; - private IAsyncEnumerator enumerator; + private bool _doMoveNext; + private IAsyncEnumerator _enumerator; public SkipWhileAsyncIterator(IAsyncEnumerable source, Func predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new SkipWhileAsyncIterator(source, predicate); + return new SkipWhileAsyncIterator(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -89,15 +89,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = enumerator.Current; - if (!predicate(element)) + var element = _enumerator.Current; + if (!_predicate(element)) { - doMoveNext = false; + _doMoveNext = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } @@ -106,16 +106,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } - if (!doMoveNext) + if (!_doMoveNext) { - current = enumerator.Current; - doMoveNext = true; + current = _enumerator.Current; + _doMoveNext = true; return true; } @@ -129,33 +129,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class SkipWhileWithIndexAsyncIterator : AsyncIterator { - private readonly Func predicate; - private readonly IAsyncEnumerable source; + private readonly Func _predicate; + private readonly IAsyncEnumerable _source; - private bool doMoveNext; - private IAsyncEnumerator enumerator; - private int index; + private bool _doMoveNext; + private IAsyncEnumerator _enumerator; + private int _index; public SkipWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new SkipWhileWithIndexAsyncIterator(source, predicate); + return new SkipWhileWithIndexAsyncIterator(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -166,21 +166,21 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { - index++; + _index++; } - var element = enumerator.Current; - if (!predicate(element, index)) + var element = _enumerator.Current; + if (!_predicate(element, _index)) { - doMoveNext = false; + _doMoveNext = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } @@ -189,16 +189,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } - if (!doMoveNext) + if (!_doMoveNext) { - current = enumerator.Current; - doMoveNext = true; + current = _enumerator.Current; + _doMoveNext = true; return true; } @@ -212,32 +212,32 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class SkipWhileAsyncIteratorWithTask : AsyncIterator { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; - private bool doMoveNext; - private IAsyncEnumerator enumerator; + private bool _doMoveNext; + private IAsyncEnumerator _enumerator; public SkipWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new SkipWhileAsyncIteratorWithTask(source, predicate); + return new SkipWhileAsyncIteratorWithTask(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -248,15 +248,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = enumerator.Current; - if (!await predicate(element).ConfigureAwait(false)) + var element = _enumerator.Current; + if (!await _predicate(element).ConfigureAwait(false)) { - doMoveNext = false; + _doMoveNext = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } @@ -265,16 +265,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } - if (!doMoveNext) + if (!_doMoveNext) { - current = enumerator.Current; - doMoveNext = true; + current = _enumerator.Current; + _doMoveNext = true; return true; } @@ -288,33 +288,33 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class SkipWhileWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; - private bool doMoveNext; - private IAsyncEnumerator enumerator; - private int index; + private bool _doMoveNext; + private IAsyncEnumerator _enumerator; + private int _index; public SkipWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); + return new SkipWhileWithIndexAsyncIteratorWithTask(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -325,21 +325,21 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; // skip elements as requested - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { - index++; + _index++; } - var element = enumerator.Current; - if (!await predicate(element, index).ConfigureAwait(false)) + var element = _enumerator.Current; + if (!await _predicate(element, _index).ConfigureAwait(false)) { - doMoveNext = false; + _doMoveNext = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } @@ -348,16 +348,16 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella break; case AsyncIteratorState.Iterating: - if (doMoveNext && await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } - if (!doMoveNext) + if (!_doMoveNext) { - current = enumerator.Current; - doMoveNext = true; + current = _enumerator.Current; + _doMoveNext = true; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 2696a9dcc2..2e79a38d1c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -26,35 +26,35 @@ public static IAsyncEnumerable TakeLast(this IAsyncEnumerable< private sealed class TakeLastAsyncIterator : AsyncIterator { - private readonly int count; - private readonly IAsyncEnumerable source; + private readonly int _count; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private bool isDone; - private Queue queue; + private IAsyncEnumerator _enumerator; + private bool _isDone; + private Queue _queue; public TakeLastAsyncIterator(IAsyncEnumerable source, int count) { Debug.Assert(source != null); - this.source = source; - this.count = count; + _source = source; + _count = count; } public override AsyncIterator Clone() { - return new TakeLastAsyncIterator(source, count); + return new TakeLastAsyncIterator(_source, _count); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - queue = null; // release the memory + _queue = null; // release the memory await base.DisposeAsync().ConfigureAwait(false); } @@ -64,9 +64,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - queue = new Queue(); - isDone = false; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _queue = new Queue(); + _isDone = false; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -75,34 +75,34 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: while (true) { - if (!isDone) + if (!_isDone) { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - if (count > 0) + if (_count > 0) { - var item = enumerator.Current; - if (queue.Count >= count) + var item = _enumerator.Current; + if (_queue.Count >= _count) { - queue.Dequeue(); + _queue.Dequeue(); } - queue.Enqueue(item); + _queue.Enqueue(item); } } else { - isDone = true; + _isDone = true; // Dispose early here as we can - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } continue; // loop until queue is drained } - if (queue.Count > 0) + if (_queue.Count > 0) { - current = queue.Dequeue(); + current = _queue.Dequeue(); return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 7f806eb27b..2551f38f32 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -53,31 +53,31 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable private sealed class TakeWhileAsyncIterator : AsyncIterator { - private readonly Func predicate; - private readonly IAsyncEnumerable source; + private readonly Func _predicate; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public TakeWhileAsyncIterator(IAsyncEnumerable source, Func predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new TakeWhileAsyncIterator(source, predicate); + return new TakeWhileAsyncIterator(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -88,17 +88,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (!predicate(item)) + var item = _enumerator.Current; + if (!_predicate(item)) { break; } @@ -117,32 +117,32 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class TakeWhileWithIndexAsyncIterator : AsyncIterator { - private readonly Func predicate; - private readonly IAsyncEnumerable source; + private readonly Func _predicate; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private int index; + private IAsyncEnumerator _enumerator; + private int _index; public TakeWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new TakeWhileWithIndexAsyncIterator(source, predicate); + return new TakeWhileWithIndexAsyncIterator(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -153,22 +153,22 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; + var item = _enumerator.Current; checked { - index++; + _index++; } - if (!predicate(item, index)) + if (!_predicate(item, _index)) { break; } @@ -187,31 +187,31 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class TakeWhileAsyncIteratorWithTask : AsyncIterator { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public TakeWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new TakeWhileAsyncIteratorWithTask(source, predicate); + return new TakeWhileAsyncIteratorWithTask(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -222,17 +222,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (!await predicate(item).ConfigureAwait(false)) + var item = _enumerator.Current; + if (!await _predicate(item).ConfigureAwait(false)) { break; } @@ -251,32 +251,32 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class TakeWhileWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private int index; + private IAsyncEnumerator _enumerator; + private int _index; public TakeWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); + return new TakeWhileWithIndexAsyncIteratorWithTask(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -287,22 +287,22 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; + var item = _enumerator.Current; checked { - index++; + _index++; } - if (!await predicate(item, index).ConfigureAwait(false)) + if (!await _predicate(item, _index).ConfigureAwait(false)) { break; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 3cd19ed1bc..79c5829de2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -120,28 +120,28 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva internal sealed class AsyncEnumerableAdapter : AsyncIterator, IAsyncIListProvider { - private readonly IEnumerable source; + private readonly IEnumerable _source; - private IEnumerator enumerator; + private IEnumerator _enumerator; public AsyncEnumerableAdapter(IEnumerable source) { Debug.Assert(source != null); - this.source = source; + _source = source; } public override AsyncIterator Clone() { - return new AsyncEnumerableAdapter(source); + return new AsyncEnumerableAdapter(_source); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; + _enumerator.Dispose(); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -152,14 +152,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + _enumerator = _source.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -174,43 +174,43 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella // and short circuit as appropriate public Task ToArrayAsync(CancellationToken cancellationToken) { - return Task.FromResult(source.ToArray()); + return Task.FromResult(_source.ToArray()); } public Task> ToListAsync(CancellationToken cancellationToken) { - return Task.FromResult(source.ToList()); + return Task.FromResult(_source.ToList()); } public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return Task.FromResult(source.Count()); + return Task.FromResult(_source.Count()); } } internal sealed class AsyncIListEnumerableAdapter : AsyncIterator, IAsyncIListProvider, IList { - private readonly IList source; - private IEnumerator enumerator; + private readonly IList _source; + private IEnumerator _enumerator; public AsyncIListEnumerableAdapter(IList source) { Debug.Assert(source != null); - this.source = source; + _source = source; } public override AsyncIterator Clone() { - return new AsyncIListEnumerableAdapter(source); + return new AsyncIListEnumerableAdapter(_source); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; + _enumerator.Dispose(); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -221,14 +221,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + _enumerator = _source.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -241,79 +241,80 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public override IAsyncEnumerable Select(Func selector) { - return new SelectIListIterator(source, selector); + return new SelectIListIterator(_source, selector); } // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize // and short circuit as appropriate public Task ToArrayAsync(CancellationToken cancellationToken) { - return Task.FromResult(source.ToArray()); + return Task.FromResult(_source.ToArray()); } public Task> ToListAsync(CancellationToken cancellationToken) { - return Task.FromResult(source.ToList()); + return Task.FromResult(_source.ToList()); } public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return Task.FromResult(source.Count); + return Task.FromResult(_source.Count); } - IEnumerator IEnumerable.GetEnumerator() => source.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => source.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); - void ICollection.Add(T item) => source.Add(item); + void ICollection.Add(T item) => _source.Add(item); - void ICollection.Clear() => source.Clear(); + void ICollection.Clear() => _source.Clear(); - bool ICollection.Contains(T item) => source.Contains(item); + bool ICollection.Contains(T item) => _source.Contains(item); - void ICollection.CopyTo(T[] array, int arrayIndex) => source.CopyTo(array, arrayIndex); + void ICollection.CopyTo(T[] array, int arrayIndex) => _source.CopyTo(array, arrayIndex); - bool ICollection.Remove(T item) => source.Remove(item); + bool ICollection.Remove(T item) => _source.Remove(item); - int ICollection.Count => source.Count; + int ICollection.Count => _source.Count; - bool ICollection.IsReadOnly => source.IsReadOnly; + bool ICollection.IsReadOnly => _source.IsReadOnly; - int IList.IndexOf(T item) => source.IndexOf(item); + int IList.IndexOf(T item) => _source.IndexOf(item); - void IList.Insert(int index, T item) => source.Insert(index, item); + void IList.Insert(int index, T item) => _source.Insert(index, item); - void IList.RemoveAt(int index) => source.RemoveAt(index); + void IList.RemoveAt(int index) => _source.RemoveAt(index); T IList.this[int index] { - get { return source[index]; } - set { source[index] = value; } + get { return _source[index]; } + set { _source[index] = value; } } } internal sealed class AsyncICollectionEnumerableAdapter : AsyncIterator, IAsyncIListProvider, ICollection { - private readonly ICollection source; - private IEnumerator enumerator; + private readonly ICollection _source; + private IEnumerator _enumerator; + public AsyncICollectionEnumerableAdapter(ICollection source) { Debug.Assert(source != null); - this.source = source; + _source = source; } public override AsyncIterator Clone() { - return new AsyncICollectionEnumerableAdapter(source); + return new AsyncICollectionEnumerableAdapter(_source); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - enumerator.Dispose(); - enumerator = null; + _enumerator.Dispose(); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -324,14 +325,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetEnumerator(); + _enumerator = _source.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - if (enumerator.MoveNext()) + if (_enumerator.MoveNext()) { - current = enumerator.Current; + current = _enumerator.Current; return true; } @@ -346,36 +347,36 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella // and short circuit as appropriate public Task ToArrayAsync(CancellationToken cancellationToken) { - return Task.FromResult(source.ToArray()); + return Task.FromResult(_source.ToArray()); } public Task> ToListAsync(CancellationToken cancellationToken) { - return Task.FromResult(source.ToList()); + return Task.FromResult(_source.ToList()); } public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return Task.FromResult(source.Count); + return Task.FromResult(_source.Count); } - IEnumerator IEnumerable.GetEnumerator() => source.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => source.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); - void ICollection.Add(T item) => source.Add(item); + void ICollection.Add(T item) => _source.Add(item); - void ICollection.Clear() => source.Clear(); + void ICollection.Clear() => _source.Clear(); - bool ICollection.Contains(T item) => source.Contains(item); + bool ICollection.Contains(T item) => _source.Contains(item); - void ICollection.CopyTo(T[] array, int arrayIndex) => source.CopyTo(array, arrayIndex); + void ICollection.CopyTo(T[] array, int arrayIndex) => _source.CopyTo(array, arrayIndex); - bool ICollection.Remove(T item) => source.Remove(item); + bool ICollection.Remove(T item) => _source.Remove(item); - int ICollection.Count => source.Count; + int ICollection.Count => _source.Count; - bool ICollection.IsReadOnly => source.IsReadOnly; + bool ICollection.IsReadOnly => _source.IsReadOnly; } private sealed class ToAsyncEnumerableObserver : IObserver diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index 94939fb6b0..6100f6e62d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -18,17 +18,17 @@ public static IObservable ToObservable(this IAsyncEnumerable : IObservable { - private readonly IAsyncEnumerable source; + private readonly IAsyncEnumerable _source; public ToObservableObservable(IAsyncEnumerable source) { - this.source = source; + _source = source; } public IDisposable Subscribe(IObserver observer) { var ctd = new CancellationTokenDisposable(); - var e = source.GetAsyncEnumerator(ctd.Token); + var e = _source.GetAsyncEnumerator(ctd.Token); var f = default(Action); f = () => e.MoveNextAsync().AsTask().ContinueWith( diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index a13523f42c..af608a1313 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -85,30 +85,30 @@ private static Func> CombinePredicates(Func : AsyncIterator { - private readonly Func predicate; - private readonly IAsyncEnumerable source; - private IAsyncEnumerator enumerator; + private readonly Func _predicate; + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; public WhereEnumerableAsyncIterator(IAsyncEnumerable source, Func predicate) { Debug.Assert(source != null); Debug.Assert(predicate != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new WhereEnumerableAsyncIterator(source, predicate); + return new WhereEnumerableAsyncIterator(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -116,12 +116,12 @@ public override async ValueTask DisposeAsync() public override IAsyncEnumerable Select(Func selector) { - return new WhereSelectEnumerableAsyncIterator(source, predicate, selector); + return new WhereSelectEnumerableAsyncIterator(_source, _predicate, selector); } public override IAsyncEnumerable Where(Func predicate) { - return new WhereEnumerableAsyncIterator(source, CombinePredicates(this.predicate, predicate)); + return new WhereEnumerableAsyncIterator(_source, CombinePredicates(_predicate, predicate)); } protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) @@ -129,15 +129,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (predicate(item)) + var item = _enumerator.Current; + if (_predicate(item)) { current = item; return true; @@ -154,32 +154,32 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class WhereEnumerableWithIndexAsyncIterator : AsyncIterator { - private readonly Func predicate; - private readonly IAsyncEnumerable source; + private readonly Func _predicate; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private int index; + private IAsyncEnumerator _enumerator; + private int _index; public WhereEnumerableWithIndexAsyncIterator(IAsyncEnumerable source, Func predicate) { Debug.Assert(source != null); Debug.Assert(predicate != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new WhereEnumerableWithIndexAsyncIterator(source, predicate); + return new WhereEnumerableWithIndexAsyncIterator(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -190,20 +190,20 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { - index++; + _index++; } - var item = enumerator.Current; - if (predicate(item, index)) + var item = _enumerator.Current; + if (_predicate(item, _index)) { current = item; return true; @@ -220,30 +220,30 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class WhereEnumerableAsyncIteratorWithTask : AsyncIterator { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; - private IAsyncEnumerator enumerator; + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; public WhereEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(source != null); Debug.Assert(predicate != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new WhereEnumerableAsyncIteratorWithTask(source, predicate); + return new WhereEnumerableAsyncIteratorWithTask(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -251,7 +251,7 @@ public override async ValueTask DisposeAsync() public override IAsyncEnumerable Where(Func> predicate) { - return new WhereEnumerableAsyncIteratorWithTask(source, CombinePredicates(this.predicate, predicate)); + return new WhereEnumerableAsyncIteratorWithTask(_source, CombinePredicates(_predicate, predicate)); } protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) @@ -259,15 +259,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (await predicate(item).ConfigureAwait(false)) + var item = _enumerator.Current; + if (await _predicate(item).ConfigureAwait(false)) { current = item; return true; @@ -284,32 +284,32 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> predicate; - private readonly IAsyncEnumerable source; + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; - private int index; + private IAsyncEnumerator _enumerator; + private int _index; public WhereEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(source != null); Debug.Assert(predicate != null); - this.source = source; - this.predicate = predicate; + _source = source; + _predicate = predicate; } public override AsyncIterator Clone() { - return new WhereEnumerableWithIndexAsyncIteratorWithTask(source, predicate); + return new WhereEnumerableWithIndexAsyncIteratorWithTask(_source, _predicate); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -320,20 +320,20 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); - index = -1; + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _index = -1; state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { checked { - index++; + _index++; } - var item = enumerator.Current; - if (await predicate(item, index).ConfigureAwait(false)) + var item = _enumerator.Current; + if (await _predicate(item, _index).ConfigureAwait(false)) { current = item; return true; @@ -350,11 +350,11 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella internal sealed class WhereSelectEnumerableAsyncIterator : AsyncIterator { - private readonly Func predicate; - private readonly Func selector; - private readonly IAsyncEnumerable source; + private readonly Func _predicate; + private readonly Func _selector; + private readonly IAsyncEnumerable _source; - private IAsyncEnumerator enumerator; + private IAsyncEnumerator _enumerator; public WhereSelectEnumerableAsyncIterator(IAsyncEnumerable source, Func predicate, Func selector) { @@ -362,22 +362,22 @@ public WhereSelectEnumerableAsyncIterator(IAsyncEnumerable source, Func Debug.Assert(predicate != null); Debug.Assert(selector != null); - this.source = source; - this.predicate = predicate; - this.selector = selector; + _source = source; + _predicate = predicate; + _selector = selector; } public override AsyncIterator Clone() { - return new WhereSelectEnumerableAsyncIterator(source, predicate, selector); + return new WhereSelectEnumerableAsyncIterator(_source, _predicate, _selector); } public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -385,7 +385,7 @@ public override async ValueTask DisposeAsync() public override IAsyncEnumerable Select(Func selector) { - return new WhereSelectEnumerableAsyncIterator(source, predicate, CombineSelectors(this.selector, selector)); + return new WhereSelectEnumerableAsyncIterator(_source, _predicate, CombineSelectors(_selector, selector)); } protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) @@ -393,17 +393,17 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - enumerator = source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - while (await enumerator.MoveNextAsync().ConfigureAwait(false)) + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = enumerator.Current; - if (predicate(item)) + var item = _enumerator.Current; + if (_predicate(item)) { - current = selector(item); + current = _selector(item); return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 57b2e3375b..25add3430b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -37,12 +37,12 @@ public static IAsyncEnumerable Zip(this IAsyn private sealed class ZipAsyncIterator : AsyncIterator { - private readonly IAsyncEnumerable first; - private readonly IAsyncEnumerable second; - private readonly Func selector; + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; + private readonly Func _selector; - private IAsyncEnumerator firstEnumerator; - private IAsyncEnumerator secondEnumerator; + private IAsyncEnumerator _firstEnumerator; + private IAsyncEnumerator _secondEnumerator; public ZipAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second, Func selector) { @@ -50,28 +50,28 @@ public ZipAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable Clone() { - return new ZipAsyncIterator(first, second, selector); + return new ZipAsyncIterator(_first, _second, _selector); } public override async ValueTask DisposeAsync() { - if (firstEnumerator != null) + if (_firstEnumerator != null) { - await firstEnumerator.DisposeAsync().ConfigureAwait(false); - firstEnumerator = null; + await _firstEnumerator.DisposeAsync().ConfigureAwait(false); + _firstEnumerator = null; } - if (secondEnumerator != null) + if (_secondEnumerator != null) { - await secondEnumerator.DisposeAsync().ConfigureAwait(false); - secondEnumerator = null; + await _secondEnumerator.DisposeAsync().ConfigureAwait(false); + _secondEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -82,8 +82,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(cancellationToken); - secondEnumerator = second.GetAsyncEnumerator(cancellationToken); + _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); + _secondEnumerator = _second.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -91,14 +91,14 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: // We kick these off and join so they can potentially run in parallel - var ft = firstEnumerator.MoveNextAsync(); - var st = secondEnumerator.MoveNextAsync(); + var ft = _firstEnumerator.MoveNextAsync(); + var st = _secondEnumerator.MoveNextAsync(); await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); if (ft.Result && st.Result) { - current = selector(firstEnumerator.Current, secondEnumerator.Current); + current = _selector(_firstEnumerator.Current, _secondEnumerator.Current); return true; } @@ -112,12 +112,12 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella private sealed class ZipAsyncIteratorWithTask : AsyncIterator { - private readonly IAsyncEnumerable first; - private readonly IAsyncEnumerable second; - private readonly Func> selector; + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; + private readonly Func> _selector; - private IAsyncEnumerator firstEnumerator; - private IAsyncEnumerator secondEnumerator; + private IAsyncEnumerator _firstEnumerator; + private IAsyncEnumerator _secondEnumerator; public ZipAsyncIteratorWithTask(IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { @@ -125,28 +125,28 @@ public ZipAsyncIteratorWithTask(IAsyncEnumerable first, IAsyncEnumerable Debug.Assert(second != null); Debug.Assert(selector != null); - this.first = first; - this.second = second; - this.selector = selector; + _first = first; + _second = second; + _selector = selector; } public override AsyncIterator Clone() { - return new ZipAsyncIteratorWithTask(first, second, selector); + return new ZipAsyncIteratorWithTask(_first, _second, _selector); } public override async ValueTask DisposeAsync() { - if (firstEnumerator != null) + if (_firstEnumerator != null) { - await firstEnumerator.DisposeAsync().ConfigureAwait(false); - firstEnumerator = null; + await _firstEnumerator.DisposeAsync().ConfigureAwait(false); + _firstEnumerator = null; } - if (secondEnumerator != null) + if (_secondEnumerator != null) { - await secondEnumerator.DisposeAsync().ConfigureAwait(false); - secondEnumerator = null; + await _secondEnumerator.DisposeAsync().ConfigureAwait(false); + _secondEnumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -157,8 +157,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - firstEnumerator = first.GetAsyncEnumerator(cancellationToken); - secondEnumerator = second.GetAsyncEnumerator(cancellationToken); + _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); + _secondEnumerator = _second.GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -166,13 +166,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: // We kick these off and join so they can potentially run in parallel - var ft = firstEnumerator.MoveNextAsync(); - var st = secondEnumerator.MoveNextAsync(); + var ft = _firstEnumerator.MoveNextAsync(); + var st = _secondEnumerator.MoveNextAsync(); await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); if (ft.Result && st.Result) { - current = await selector(firstEnumerator.Current, secondEnumerator.Current).ConfigureAwait(false); + current = await _selector(_firstEnumerator.Current, _secondEnumerator.Current).ConfigureAwait(false); return true; } From b3431216745ca04c818557eacd55d800eb0ed4f6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 6 Nov 2018 17:55:46 -0800 Subject: [PATCH 389/862] Some more naming changes. --- .../System/Linq/Operators/AppendPrepend.cs | 64 +++++++++---------- .../Linq/Operators/OrderedAsyncEnumerable.cs | 32 +++++----- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 74e195a745..271143caf3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -39,20 +39,20 @@ public static IAsyncEnumerable Prepend(this IAsyncEnumerable : AsyncIterator, IAsyncIListProvider { - protected readonly IAsyncEnumerable source; - protected IAsyncEnumerator enumerator; + protected readonly IAsyncEnumerable _source; + protected IAsyncEnumerator _enumerator; protected AppendPrependAsyncIterator(IAsyncEnumerable source) { Debug.Assert(source != null); - this.source = source; + _source = source; } protected void GetSourceEnumerator(CancellationToken cancellationToken) { - Debug.Assert(enumerator == null); - enumerator = source.GetAsyncEnumerator(cancellationToken); + Debug.Assert(_enumerator == null); + _enumerator = _source.GetAsyncEnumerator(cancellationToken); } public abstract AppendPrependAsyncIterator Append(TSource item); @@ -60,16 +60,16 @@ protected void GetSourceEnumerator(CancellationToken cancellationToken) protected async Task LoadFromEnumeratorAsync() { - if (await enumerator.MoveNextAsync().ConfigureAwait(false)) + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = enumerator.Current; + current = _enumerator.Current; return true; } - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } return false; @@ -77,10 +77,10 @@ protected async Task LoadFromEnumeratorAsync() public override async ValueTask DisposeAsync() { - if (enumerator != null) + if (_enumerator != null) { - await enumerator.DisposeAsync().ConfigureAwait(false); - enumerator = null; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } await base.DisposeAsync().ConfigureAwait(false); @@ -107,7 +107,7 @@ public AppendPrepend1AsyncIterator(IAsyncEnumerable source, TSource ite public override AsyncIterator Clone() { - return new AppendPrepend1AsyncIterator(source, _item, _appending); + return new AppendPrepend1AsyncIterator(_source, _item, _appending); } protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) @@ -132,7 +132,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella _hasEnumerator = true; } - if (enumerator != null) + if (_enumerator != null) { if (await LoadFromEnumeratorAsync() .ConfigureAwait(false)) @@ -158,11 +158,11 @@ public override AppendPrependAsyncIterator Append(TSource element) { if (_appending) { - return new AppendPrependNAsyncIterator(source, null, new SingleLinkedNode(_item).Add(element), prependCount: 0, appendCount: 2); + return new AppendPrependNAsyncIterator(_source, null, new SingleLinkedNode(_item).Add(element), prependCount: 0, appendCount: 2); } else { - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(_item), new SingleLinkedNode(element), prependCount: 1, appendCount: 1); + return new AppendPrependNAsyncIterator(_source, new SingleLinkedNode(_item), new SingleLinkedNode(element), prependCount: 1, appendCount: 1); } } @@ -170,11 +170,11 @@ public override AppendPrependAsyncIterator Prepend(TSource element) { if (_appending) { - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(element), new SingleLinkedNode(_item), prependCount: 1, appendCount: 1); + return new AppendPrependNAsyncIterator(_source, new SingleLinkedNode(element), new SingleLinkedNode(_item), prependCount: 1, appendCount: 1); } else { - return new AppendPrependNAsyncIterator(source, new SingleLinkedNode(_item).Add(element), null, prependCount: 2, appendCount: 0); + return new AppendPrependNAsyncIterator(_source, new SingleLinkedNode(_item).Add(element), null, prependCount: 2, appendCount: 0); } } @@ -198,13 +198,13 @@ public override async Task ToArrayAsync(CancellationToken cancellatio index = 1; } - if (source is ICollection sourceCollection) + if (_source is ICollection sourceCollection) { sourceCollection.CopyTo(array, index); } else { - var en = source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -239,7 +239,7 @@ public override async Task> ToListAsync(CancellationToken cancella } - var en = source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -263,13 +263,13 @@ public override async Task> ToListAsync(CancellationToken cancella public override async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - if (source is IAsyncIListProvider listProv) + if (_source is IAsyncIListProvider listProv) { var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + 1; } - return !onlyIfCheap || source is ICollection ? await source.Count(cancellationToken).ConfigureAwait(false) + 1 : -1; + return !onlyIfCheap || _source is ICollection ? await _source.Count(cancellationToken).ConfigureAwait(false) + 1 : -1; } } @@ -300,7 +300,7 @@ public AppendPrependNAsyncIterator(IAsyncEnumerable source, SingleLinke public override AsyncIterator Clone() { - return new AppendPrependNAsyncIterator(source, _prepended, _appended, _prependCount, _appendCount); + return new AppendPrependNAsyncIterator(_source, _prepended, _appended, _prependCount, _appendCount); } public override async ValueTask DisposeAsync() @@ -378,13 +378,13 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella public override AppendPrependAsyncIterator Append(TSource item) { var res = _appended != null ? _appended.Add(item) : new SingleLinkedNode(item); - return new AppendPrependNAsyncIterator(source, _prepended, res, _prependCount, _appendCount + 1); + return new AppendPrependNAsyncIterator(_source, _prepended, res, _prependCount, _appendCount + 1); } public override AppendPrependAsyncIterator Prepend(TSource item) { var res = _prepended != null ? _prepended.Add(item) : new SingleLinkedNode(item); - return new AppendPrependNAsyncIterator(source, res, _appended, _prependCount + 1, _appendCount); + return new AppendPrependNAsyncIterator(_source, res, _appended, _prependCount + 1, _appendCount); } public override async Task ToArrayAsync(CancellationToken cancellationToken) @@ -403,13 +403,13 @@ public override async Task ToArrayAsync(CancellationToken cancellatio ++index; } - if (source is ICollection sourceCollection) + if (_source is ICollection sourceCollection) { sourceCollection.CopyTo(array, index); } else { - var en = source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -444,7 +444,7 @@ public override async Task> ToListAsync(CancellationToken cancella list.Add(n.Item); } - var en = source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -474,13 +474,13 @@ public override async Task> ToListAsync(CancellationToken cancella public override async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - if (source is IAsyncIListProvider listProv) + if (_source is IAsyncIListProvider listProv) { var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + _appendCount + _prependCount; } - return !onlyIfCheap || source is ICollection ? await source.Count(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1; + return !onlyIfCheap || _source is ICollection ? await _source.Count(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index a091ca3bb6..d70c0cab9d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -11,17 +11,17 @@ namespace System.Linq { internal abstract class OrderedAsyncEnumerable : AsyncIterator, IOrderedAsyncEnumerable { - internal IOrderedEnumerable enumerable; - internal IAsyncEnumerable source; + internal IOrderedEnumerable _enumerable; + internal IAsyncEnumerable _source; IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending) { - return new OrderedAsyncEnumerable(source, keySelector, comparer, descending, this); + return new OrderedAsyncEnumerable(_source, keySelector, comparer, descending, this); } IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending) { - return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending, this); + return new OrderedAsyncEnumerableWithTask(_source, keySelector, comparer, descending, this); } internal abstract Task Initialize(CancellationToken cancellationToken); @@ -43,7 +43,7 @@ public OrderedAsyncEnumerable(IAsyncEnumerable source, Func source, Func Clone() { - return new OrderedAsyncEnumerable(source, _keySelector, _comparer, _descending, _parent); + return new OrderedAsyncEnumerable(_source, _keySelector, _comparer, _descending, _parent); } public override async ValueTask DisposeAsync() @@ -80,7 +80,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella await Initialize(cancellationToken).ConfigureAwait(false); - _enumerator = enumerable.GetEnumerator(); + _enumerator = _enumerable.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -102,14 +102,14 @@ internal override async Task Initialize(CancellationToken cancellationToken) { if (_parent == null) { - var buffer = await source.ToList(cancellationToken).ConfigureAwait(false); - enumerable = (!_descending ? buffer.OrderBy(_keySelector, _comparer) : buffer.OrderByDescending(_keySelector, _comparer)); + var buffer = await _source.ToList(cancellationToken).ConfigureAwait(false); + _enumerable = (!_descending ? buffer.OrderBy(_keySelector, _comparer) : buffer.OrderByDescending(_keySelector, _comparer)); } else { _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken); await _parent.Initialize(cancellationToken).ConfigureAwait(false); - enumerable = _parent.enumerable.CreateOrderedEnumerable(_keySelector, _comparer, _descending); + _enumerable = _parent._enumerable.CreateOrderedEnumerable(_keySelector, _comparer, _descending); } } } @@ -130,7 +130,7 @@ public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func source, Func Clone() { - return new OrderedAsyncEnumerableWithTask(source, _keySelector, _comparer, _descending, _parent); + return new OrderedAsyncEnumerableWithTask(_source, _keySelector, _comparer, _descending, _parent); } public override async ValueTask DisposeAsync() @@ -167,7 +167,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella await Initialize(cancellationToken).ConfigureAwait(false); - _enumerator = enumerable.GetEnumerator(); + _enumerator = _enumerable.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -189,14 +189,14 @@ internal override async Task Initialize(CancellationToken cancellationToken) { if (_parent == null) { - var buffer = await source.ToList(cancellationToken).ConfigureAwait(false); - enumerable = (!_descending ? buffer.OrderByAsync(_keySelector, _comparer) : buffer.OrderByDescendingAsync(_keySelector, _comparer)); + var buffer = await _source.ToList(cancellationToken).ConfigureAwait(false); + _enumerable = (!_descending ? buffer.OrderByAsync(_keySelector, _comparer) : buffer.OrderByDescendingAsync(_keySelector, _comparer)); } else { _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken); await _parent.Initialize(cancellationToken).ConfigureAwait(false); - enumerable = _parent.enumerable.CreateOrderedEnumerableAsync(_keySelector, _comparer, _descending); + _enumerable = _parent._enumerable.CreateOrderedEnumerableAsync(_keySelector, _comparer, _descending); } } } From 2f1f6b3cb57c2efa8e27ae7796ea86e14b5d4202 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 6 Nov 2018 17:59:01 -0800 Subject: [PATCH 390/862] Use a local function. --- .../System/Linq/Operators/ToObservable.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index 6100f6e62d..3b9d82b76a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -30,8 +30,7 @@ public IDisposable Subscribe(IObserver observer) var ctd = new CancellationTokenDisposable(); var e = _source.GetAsyncEnumerator(ctd.Token); - var f = default(Action); - f = () => e.MoveNextAsync().AsTask().ContinueWith( + void Core() => e.MoveNextAsync().AsTask().ContinueWith( async t => { if (t.IsFaulted) @@ -51,7 +50,7 @@ public IDisposable Subscribe(IObserver observer) if (!ctd.Token.IsCancellationRequested) { - f(); + Core(); } // In case cancellation is requested, this could only have happened @@ -66,7 +65,7 @@ public IDisposable Subscribe(IObserver observer) } }, ctd.Token); - f(); + Core(); return Disposable.Create(ctd, Disposable.Create(() => { e.DisposeAsync(); /* REVIEW: fire-and-forget? */ })); } From ee62cf2ebaf3b73ebe2031a5a782575e6223786d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 6 Nov 2018 18:02:52 -0800 Subject: [PATCH 391/862] Passing down cancellation to Lookup functionality. --- .../System/Linq/Operators/GroupBy.cs | 16 ++++++++-------- .../System/Linq/Operators/ToLookup.cs | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index a85abe4caa..b44e43e7ca 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -264,7 +264,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); _enumerator = _lookup.ApplyResultSelector(_resultSelector).GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -353,7 +353,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -442,7 +442,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -531,7 +531,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -616,7 +616,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -654,7 +654,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -701,7 +701,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -739,7 +739,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return -1; } - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index a24dc4ffb5..57062cc2aa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -173,7 +173,7 @@ public static async Task> ToLookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + var lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return lookup; } @@ -203,7 +203,7 @@ public static async Task> ToLookup.CreateAsync(source, keySelector, elementSelector, comparer).ConfigureAwait(false); + var lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); return lookup; } @@ -285,7 +285,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -314,7 +314,7 @@ internal static async Task> CreateAsync(IAsyncEn return lookup; } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -571,7 +571,7 @@ public IEnumerator> GetEnumerator() } } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -600,7 +600,7 @@ internal static async Task> CreateAsync( return lookup; } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { Debug.Assert(source != null); Debug.Assert(keySelector != null); From 6716857cb4e1d24ce063b66f337e690216ebf016 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 7 Nov 2018 18:03:12 -0800 Subject: [PATCH 392/862] Simplify ToObservable implementation. --- .../System/Linq/Operators/ToObservable.cs | 2 +- .../System/Linq/Operators/ToObservable.cs | 61 ++++++++++--------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index 79d0fa9f97..0162a21be3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -132,7 +132,7 @@ public void ToObservable4() evt.WaitOne(); Assert.False(fail); - Assert.Equal(ex1, ((AggregateException)ex_).InnerExceptions.Single()); + Assert.Equal(ex1, ex_); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index 3b9d82b76a..5e1952e2fe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -30,44 +30,49 @@ public IDisposable Subscribe(IObserver observer) var ctd = new CancellationTokenDisposable(); var e = _source.GetAsyncEnumerator(ctd.Token); - void Core() => e.MoveNextAsync().AsTask().ContinueWith( - async t => + async void Core() + { + bool hasNext; + try { - if (t.IsFaulted) - { - observer.OnError(t.Exception); - await e.DisposeAsync().ConfigureAwait(false); - } - else if (t.IsCanceled) + hasNext = await e.MoveNextAsync().ConfigureAwait(false); + } + catch (Exception ex) + { + if (!ctd.Token.IsCancellationRequested) { + observer.OnError(ex); await e.DisposeAsync().ConfigureAwait(false); } - else if (t.IsCompleted) - { - if (t.Result) - { - observer.OnNext(e.Current); - if (!ctd.Token.IsCancellationRequested) - { - Core(); - } + return; + } - // In case cancellation is requested, this could only have happened - // by disposing the returned composite disposable (see below). - // In that case, e will be disposed too, so there is no need to dispose e here. - } - else - { - observer.OnCompleted(); - await e.DisposeAsync().ConfigureAwait(false); - } + if (hasNext) + { + observer.OnNext(e.Current); + + if (!ctd.Token.IsCancellationRequested) + { + Core(); } - }, ctd.Token); + + // In case cancellation is requested, this could only have happened + // by disposing the returned composite disposable (see below). + // In that case, e will be disposed too, so there is no need to dispose e here. + } + else + { + observer.OnCompleted(); + await e.DisposeAsync().ConfigureAwait(false); + } + } Core(); - return Disposable.Create(ctd, Disposable.Create(() => { e.DisposeAsync(); /* REVIEW: fire-and-forget? */ })); + // REVIEW: Safety of concurrent dispose operation; fire-and-forget nature of dispose? + + return Disposable.Create(ctd, Disposable.Create(() => { e.DisposeAsync(); })); } } } From cb1bed1272eba79f3b856c7f0f5956c724357ee7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 7 Nov 2018 18:04:41 -0800 Subject: [PATCH 393/862] Use ValueTask in Set.UnionWithAsync. --- Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index 0e9a1c84f1..c0551af87e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -145,7 +145,7 @@ private void Resize() _slots = newSlots; } - public async Task UnionWithAsync(IAsyncEnumerable other, CancellationToken cancellationToken) + public async ValueTask UnionWithAsync(IAsyncEnumerable other, CancellationToken cancellationToken) { var enu = other.GetAsyncEnumerator(cancellationToken); From cf1dbedb42720184e3ec60b6a7be3a4ce4d5f4a1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 7 Nov 2018 18:10:20 -0800 Subject: [PATCH 394/862] Use ConfigureAwait(false) when awaiting UnionWithAsync. --- .../Source/System.Linq.Async/System/Linq/Operators/Distinct.cs | 2 +- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 9c759d099e..5f078bceea 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -121,7 +121,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke { var s = new Set(_comparer); - await s.UnionWithAsync(_source, cancellationToken); + await s.UnionWithAsync(_source, cancellationToken).ConfigureAwait(false); return s; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index b11a8c5529..0c42539802 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -169,7 +169,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } - await set.UnionWithAsync(enumerable, cancellationToken); + await set.UnionWithAsync(enumerable, cancellationToken).ConfigureAwait(false); } } From 0a64f5bcb6eb2bdc7ab61eb982488e6a8c804ef6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 7 Nov 2018 18:10:52 -0800 Subject: [PATCH 395/862] Use CreateEnumerable overloads that take in a CancellationToken. --- .../System/Linq/Operators/Never.cs | 2 +- .../System/Linq/Operators/Throw.cs | 6 +++++- .../System/Linq/AsyncEnumerableTests.cs | 2 +- .../System/Linq/Operators/CreateEnumerable.cs | 2 ++ .../System/Linq/Operators/ToObservable.cs | 6 +++--- .../System.Linq.Async/System/Linq/AsyncEnumerable.cs | 2 +- .../System.Linq.Async/System/Linq/AsyncEnumerator.cs | 2 +- .../System/Linq/Operators/ToAsyncEnumerable.cs | 9 +++++++-- 8 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index c7a81fd21d..c6886fc10b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Never() // seem correct either, given that we return a *cold* sequence. // - return AsyncEnumerable.CreateEnumerable(() => AsyncEnumerable.CreateEnumerator(() => TaskExt.Never, current: null, dispose: null)); + return AsyncEnumerable.CreateEnumerable(_ => AsyncEnumerable.CreateEnumerator(() => TaskExt.Never, current: null, dispose: null)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index 4874356541..dfbdb4a5f1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -22,8 +22,12 @@ public static IAsyncEnumerable Throw(Exception exception) var moveNextThrows = new ValueTask(Task.FromException(exception)); #endif + // + // REVIEW: Honor cancellation using conditional expression in MoveNextAsync? + // + return AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerable.CreateEnumerator( () => moveNextThrows, current: null, dispose: null) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 64e1213fb5..7d6185a3ee 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -94,7 +94,7 @@ protected static IAsyncEnumerable Throw(Exception exception) #endif return AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerable.CreateEnumerator( () => moveNextThrows, current: null, dispose: null) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs index 4029a6af72..a123dbf08c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using Xunit; namespace Tests @@ -15,6 +16,7 @@ public class CreateEnumerable : AsyncEnumerableTests public void CreateEnumerable_Null() { AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); + AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index 0162a21be3..4539d44ebd 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -142,7 +142,7 @@ public void ToObservable_DisposesEnumeratorOnCompletion() var evt = new ManualResetEvent(false); var ae = AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerable.CreateEnumerator( () => TaskExt.False, () => { throw new InvalidOperationException(); }, () => { evt.Set(); return TaskExt.CompletedTask; })); @@ -176,7 +176,7 @@ public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed() var subscriptionAssignedTcs = new TaskCompletionSource(); var ae = AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerable.CreateEnumerator( async () => { await subscriptionAssignedTcs.Task; @@ -222,7 +222,7 @@ public void ToObservable_DesNotCallMoveNextAgainWhenSubscriptionIsDisposed() var subscriptionAssignedTcs = new TaskCompletionSource(); var ae = AsyncEnumerable.CreateEnumerable( - () => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerable.CreateEnumerator( async () => { await subscriptionAssignedTcs.Task; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 235d974ad4..364667afc1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -31,7 +31,7 @@ private static IAsyncEnumerable Throw(Exception exception) #endif return CreateEnumerable( - () => CreateEnumerator( + _ => CreateEnumerator( () => moveNextThrows, current: null, dispose: null) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index a9a973c301..29635fa106 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -87,7 +87,7 @@ public static IAsyncEnumerable AsEnumerable(this IAsyncEnumerator sourc if (source == null) throw new ArgumentNullException(nameof(source)); - return AsyncEnumerable.CreateEnumerable(() => source); + return AsyncEnumerable.CreateEnumerable(_ => source); } internal static IAsyncEnumerator Create(Func, ValueTask> moveNext, Func current, Func dispose) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 79c5829de2..b1711092e8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -33,7 +33,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task + _ => { var called = 0; @@ -59,12 +59,16 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva throw new ArgumentNullException(nameof(source)); return CreateEnumerable( - () => + ct => { var observer = new ToAsyncEnumerableObserver(); var subscription = source.Subscribe(observer); + // REVIEW: Review possible concurrency issues with Dispose calls. + + var ctr = ct.Register(subscription.Dispose); + return CreateEnumerator( tcs => { @@ -111,6 +115,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva () => observer.Current, () => { + ctr.Dispose(); subscription.Dispose(); // Should we cancel in-flight operations somehow? return TaskExt.CompletedTask; From 82ca8427d8e2ac2ec3ded7dc8609c4745cb6cb19 Mon Sep 17 00:00:00 2001 From: akarnokd Date: Thu, 8 Nov 2018 10:01:16 +0100 Subject: [PATCH 396/862] Ignore JetBrains Rider-created .idea directories --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 25337ac342..e9067c266f 100644 --- a/.gitignore +++ b/.gitignore @@ -185,3 +185,7 @@ nuget.exe # dotnet local cache .dotnet + +# JetBrains Rider adds these +Ix.NET/Source/.idea +Rx.NET/Source/.idea \ No newline at end of file From 54d1575e56882d22c4ae417f161e1c9106750743 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Thu, 8 Nov 2018 08:23:04 -0500 Subject: [PATCH 397/862] allow for .idea directory anywhere --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e9067c266f..c86a769971 100644 --- a/.gitignore +++ b/.gitignore @@ -187,5 +187,4 @@ nuget.exe .dotnet # JetBrains Rider adds these -Ix.NET/Source/.idea -Rx.NET/Source/.idea \ No newline at end of file +.idea/ From e64d3c516e67f86af1e0ad14d544fe35b112378d Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Thu, 8 Nov 2018 11:33:26 -0500 Subject: [PATCH 398/862] Add pr trigger --- azure-pipelines.ix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.ix.yml b/azure-pipelines.ix.yml index 64c76a87d3..d8a67164fa 100644 --- a/azure-pipelines.ix.yml +++ b/azure-pipelines.ix.yml @@ -14,6 +14,7 @@ pr: include: - master - rel/* + - IxAsyncCSharp8 paths: include: - Ix.NET/Source/* From b33b184a220c52a431474cf2fb13212b0d33c3a3 Mon Sep 17 00:00:00 2001 From: akarnokd Date: Fri, 9 Nov 2018 13:43:56 +0100 Subject: [PATCH 399/862] AsyncIx: More reviews/fixes/proposed changes --- .../System/Linq/Operators/Finally.cs | 41 +++++++++++++++- .../System/Linq/Operators/Never.cs | 34 +++++++++++++ .../System/Linq/Operators/Finally.cs | 17 +++++++ .../System/Linq/Operators/Never.cs | 47 +++++++++++++++--- .../System/Linq/Operators/Return.cs | 49 ++++++++++++++++++- .../System/Linq/Operators/Throw.cs | 32 ++++++++++++ .../System/Linq/Operators/Timeout.cs | 17 ++++++- 7 files changed, 225 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index d0cf28e577..51ba62339d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -114,7 +114,46 @@ public async Task Finally7() var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { i++; }); await SequenceIdentity(xs); - Assert.Equal(2, i); + Assert.Equal(4, i); + } + + [Fact] + public async Task Finally7_Async() + { + var i = 0; + var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(async () => { + await Task.CompletedTask; + i++; + }); + + await SequenceIdentity(xs); + Assert.Equal(4, i); + } + + [Fact] + public async Task Finally8() + { + var i = 0; + var en = AsyncEnumerable.Range(1, 5).Finally(() => i++).GetAsyncEnumerator(); + + await en.DisposeAsync(); + + Assert.Equal(1, i); + } + + [Fact] + public async Task Finally8_Async() + { + var i = 0; + var en = AsyncEnumerable.Range(1, 5).Finally(async () => + { + await Task.CompletedTask; + i++; + }).GetAsyncEnumerator(); + + await en.DisposeAsync(); + + Assert.Equal(1, i); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs index 0ac26f3cf4..7281dcf171 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs @@ -4,6 +4,7 @@ using System; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Xunit; @@ -25,5 +26,38 @@ public async Task Never1() private void Nop(object o) { } + + [Fact] + public void CancelToken_Unblocks() + { + var cts = new CancellationTokenSource(); + + var en = AsyncEnumerableEx.Never().GetAsyncEnumerator(cts.Token); + + try + { + var t = Task.Run(async () => + { + await Task.Delay(100); + cts.Cancel(); + }); + + try + { + Assert.True(en.MoveNextAsync().AsTask().Wait(2000)); + } + catch (AggregateException ex) + { + if (!(ex.InnerException is TaskCanceledException)) + { + throw; + } + } + } + finally + { + en.DisposeAsync().AsTask().Wait(2000); + } + } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 354e585b6b..986ed6e6ed 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -38,6 +38,8 @@ private sealed class FinallyAsyncIterator : AsyncIterator private IAsyncEnumerator _enumerator; + private bool _finallyOnce; + public FinallyAsyncIterator(IAsyncEnumerable source, Action finallyAction) { Debug.Assert(source != null); @@ -59,6 +61,13 @@ public override async ValueTask DisposeAsync() await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; + } + + // Run the _finallyAction even if + // the consumer did not call MoveNextAsync + if (!_finallyOnce) + { + _finallyOnce = true; _finallyAction(); } @@ -96,6 +105,8 @@ private sealed class FinallyAsyncIteratorWithTask : AsyncIterator _enumerator; + private bool _finallyOnce; + public FinallyAsyncIteratorWithTask(IAsyncEnumerable source, Func finallyAction) { Debug.Assert(source != null); @@ -116,7 +127,13 @@ public override async ValueTask DisposeAsync() { await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; + } + // Await the _finallyAction even if + // the consumer did not call MoveNextAsync + if (!_finallyOnce) + { + _finallyOnce = true; await _finallyAction().ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index c7a81fd21d..9af467a9df 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -11,14 +13,43 @@ public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Never() { - // - // REVIEW: The C# 8.0 proposed interfaces don't allow for cancellation, so this "Never" is - // as never as never can be; it can't be interrupted *at all*, similar to the sync - // variant in Ix. Passing a *hot* CancellationToken to the Never operator doesn't - // seem correct either, given that we return a *cold* sequence. - // - - return AsyncEnumerable.CreateEnumerable(() => AsyncEnumerable.CreateEnumerator(() => TaskExt.Never, current: null, dispose: null)); + return NeverAsyncEnumerable.Instance; + } + + private sealed class NeverAsyncEnumerable : IAsyncEnumerable + { + internal static readonly NeverAsyncEnumerable Instance = new NeverAsyncEnumerable(); + + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + { + return new NeverAsyncEnumerator(cancellationToken); + } + + private sealed class NeverAsyncEnumerator : IAsyncEnumerator + { + public TValue Current => throw new InvalidOperationException(); + + private readonly CancellationToken _token; + + public NeverAsyncEnumerator(CancellationToken token) + { + _token = token; + } + + public ValueTask DisposeAsync() + { + return TaskExt.CompletedTask; + } + + public ValueTask MoveNextAsync() + { + return new ValueTask(Task.Run(async () => + { + await Task.Delay(Threading.Timeout.Infinite, _token); + return false; + }, _token)); + } + } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs index c7b70b6d47..bc8e30aff3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; namespace System.Linq { @@ -10,7 +12,52 @@ public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Return(TValue value) { - return new[] { value }.ToAsyncEnumerable(); + return new ReturnEnumerable(value); + } + + // FIXME: AsyncListPartition is internal to the project System.Linq.Async + // project, not sure how to expose it here + private sealed class ReturnEnumerable : IAsyncEnumerable + { + private readonly TValue _value; + + public ReturnEnumerable(TValue value) + { + _value = value; + } + + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + { + return new ReturnEnumerator(_value); + } + + private sealed class ReturnEnumerator : IAsyncEnumerator + { + public TValue Current { get; private set; } + + private bool _once; + + public ReturnEnumerator(TValue current) + { + Current = current; + } + + public ValueTask DisposeAsync() + { + Current = default; + return TaskExt.CompletedTask; + } + + public ValueTask MoveNextAsync() + { + if (_once) + { + return TaskExt.False; + } + _once = true; + return TaskExt.True; + } + } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index 4874356541..ecfb2e3804 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -29,5 +30,36 @@ public static IAsyncEnumerable Throw(Exception exception) dispose: null) ); } + + private sealed class ThrowEnumerable : IAsyncEnumerable, IAsyncEnumerator + { + private readonly ValueTask _moveNextThrows; + + public TValue Current => default; + + public ThrowEnumerable(ValueTask moveNextThrows) + { + _moveNextThrows = moveNextThrows; + } + + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + { + return this; + } + + public ValueTask DisposeAsync() + { + return TaskExt.CompletedTask; + } + + public ValueTask MoveNextAsync() + { + // May we let this fail over and over? + // If so, the class doesn't need extra state + // and thus can be reused without creating an + // async enumerator + return _moveNextThrows; + } + } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index 8d108db4c3..434f0bea1b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -30,6 +30,8 @@ private sealed class TimeoutAsyncIterator : AsyncIterator private IAsyncEnumerator _enumerator; + private Task _loserTask; + public TimeoutAsyncIterator(IAsyncEnumerable source, TimeSpan timeout) { Debug.Assert(source != null); @@ -45,7 +47,13 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_enumerator != null) + if (_loserTask != null) + { + await _loserTask.ConfigureAwait(false); + _loserTask = null; + _enumerator = null; + } + else if (_enumerator != null) { await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; @@ -73,10 +81,15 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella { var delay = Task.Delay(_timeout, delayCts.Token); - var winner = await Task.WhenAny(moveNext.AsTask(), delay).ConfigureAwait(false); + var next = moveNext.AsTask(); + + var winner = await Task.WhenAny(next, delay).ConfigureAwait(false); if (winner == delay) { + // we still have to wait for the "next" to complete + // before we can dispose _enumerator + _loserTask = next.ContinueWith(async (t, state) => await ((IAsyncDisposable)state).DisposeAsync(), _enumerator); throw new TimeoutException(); } From 67c4ec64a26d100128649c9eb2b213b546e36839 Mon Sep 17 00:00:00 2001 From: akarnokd Date: Fri, 9 Nov 2018 14:17:27 +0100 Subject: [PATCH 400/862] Benchmark for Return --- .../AsyncReturnBenchmark.cs | 164 ++++++++++++++++++ .../Benchmarks.System.Interactive.csproj | 4 +- .../Benchmarks.System.Interactive/Program.cs | 1 + 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs diff --git a/Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs b/Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs new file mode 100644 index 0000000000..1c521d77a1 --- /dev/null +++ b/Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs @@ -0,0 +1,164 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; + +namespace Benchmarks.System.Interactive +{ + [MemoryDiagnoser] + public class AsyncReturnBenchmark + { + [Benchmark] + public async ValueTask ToAsyncEnumerable() + { + await new[] { 1 }.ToAsyncEnumerable().ForEachAsync(v => { }).ConfigureAwait(false); + } + + [Benchmark] + public async ValueTask Direct() + { + await AsyncEnumerableEx.Return(1).ForEachAsync(v => { }).ConfigureAwait(false); + } + + [Benchmark] + public async ValueTask Iterator() + { + await new ReturnIterator(1).ForEachAsync(v => { }).ConfigureAwait(false); + } + + } + + internal sealed class ReturnIterator : AsyncIterator + { + private readonly T _value; + + public override AsyncIterator Clone() + { + return new ReturnIterator(_value); + } + + public ReturnIterator(T value) + { + _value = value; + } + + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + { + if (state == AsyncIteratorState.Allocated) + { + current = _value; + state = AsyncIteratorState.Disposed; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } + + internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator + { + private readonly int _threadId; + + private bool _currentIsInvalid = true; + + internal TSource current; + internal AsyncIteratorState state = AsyncIteratorState.New; + internal CancellationToken token; + + protected AsyncIterator() + { + _threadId = Environment.CurrentManagedThreadId; + } + + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) + { + var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId + ? this + : Clone(); + + enumerator.state = AsyncIteratorState.Allocated; + enumerator.token = token; + + try + { + enumerator.OnGetEnumerator(token); + } + catch + { + enumerator.DisposeAsync(); // REVIEW: fire-and-forget? + throw; + } + + return enumerator; + } + + public virtual ValueTask DisposeAsync() + { + current = default; + state = AsyncIteratorState.Disposed; + + return new ValueTask(); + } + + public TSource Current + { + get + { + if (_currentIsInvalid) + throw new InvalidOperationException("Enumerator is in an invalid state"); + + return current; + } + } + + public async ValueTask MoveNextAsync() + { + // Note: MoveNext *must* be implemented as an async method to ensure + // that any exceptions thrown from the MoveNextCore call are handled + // by the try/catch, whether they're sync or async + + if (state == AsyncIteratorState.Disposed) + { + return false; + } + + try + { + var result = await MoveNextCore(token).ConfigureAwait(false); + + _currentIsInvalid = !result; // if move next is false, invalid otherwise valid + + return result; + } + catch + { + _currentIsInvalid = true; + await DisposeAsync().ConfigureAwait(false); + throw; + } + } + + public abstract AsyncIterator Clone(); + + protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); + + protected virtual void OnGetEnumerator(CancellationToken cancellationToken) + { + } + } + + internal enum AsyncIteratorState + { + New = 0, + Allocated = 1, + Iterating = 2, + Disposed = -1, + } +} diff --git a/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj b/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj index 9795d9c1ec..3d55f84a63 100644 --- a/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj +++ b/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj @@ -20,7 +20,7 @@ - + @@ -32,6 +32,8 @@ + + diff --git a/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs b/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs index a2e9509058..d10daf405f 100644 --- a/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs +++ b/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs @@ -22,6 +22,7 @@ internal static void Main(string[] args) typeof(DeferBenchmark), typeof(RetryBenchmark), typeof(MinMaxBenchmark), + typeof(AsyncReturnBenchmark) }); switcher.Run(); From eb5cbb54975fec539801d6e408a97622472b64ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Fri, 9 Nov 2018 19:29:46 +0100 Subject: [PATCH 401/862] Address feedback round 1 --- .../System/Linq/Operators/Never.cs | 21 +++++++--- .../System/Linq/Operators/Return.cs | 2 +- .../System/Linq/Operators/Throw.cs | 40 ++++++++++++------- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index 9af467a9df..55271a0f15 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -20,7 +20,7 @@ private sealed class NeverAsyncEnumerable : IAsyncEnumerable { internal static readonly NeverAsyncEnumerable Instance = new NeverAsyncEnumerable(); - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { return new NeverAsyncEnumerator(cancellationToken); } @@ -31,6 +31,12 @@ private sealed class NeverAsyncEnumerator : IAsyncEnumerator private readonly CancellationToken _token; + private CancellationTokenRegistration _registration; + + private bool _once; + + private TaskCompletionSource _task; + public NeverAsyncEnumerator(CancellationToken token) { _token = token; @@ -38,16 +44,21 @@ public NeverAsyncEnumerator(CancellationToken token) public ValueTask DisposeAsync() { + _registration.Dispose(); + _task = null; return TaskExt.CompletedTask; } public ValueTask MoveNextAsync() { - return new ValueTask(Task.Run(async () => + if (_once) { - await Task.Delay(Threading.Timeout.Infinite, _token); - return false; - }, _token)); + return TaskExt.False; + } + _once = true; + _task = new TaskCompletionSource(); + _registration = _token.Register(state => ((NeverAsyncEnumerator)state)._task.SetCanceled(), this); + return new ValueTask(_task.Task); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs index bc8e30aff3..9443ae4962 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -26,7 +26,7 @@ public ReturnEnumerable(TValue value) _value = value; } - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { return new ReturnEnumerator(_value); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index ecfb2e3804..a80839b99f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -31,34 +31,44 @@ public static IAsyncEnumerable Throw(Exception exception) ); } - private sealed class ThrowEnumerable : IAsyncEnumerable, IAsyncEnumerator + private sealed class ThrowEnumerable : IAsyncEnumerable { private readonly ValueTask _moveNextThrows; - public TValue Current => default; - public ThrowEnumerable(ValueTask moveNextThrows) { _moveNextThrows = moveNextThrows; } - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { - return this; + return new ThrowEnumerator(_moveNextThrows); } - public ValueTask DisposeAsync() + private sealed class ThrowEnumerator : IAsyncEnumerator { - return TaskExt.CompletedTask; - } + private ValueTask _moveNextThrows; + + public ThrowEnumerator(ValueTask moveNextThrows) + { + _moveNextThrows = moveNextThrows; + } + + public TValue Current => default; + + public ValueTask DisposeAsync() + { + _moveNextThrows = TaskExt.False; + return TaskExt.CompletedTask; + } + + public ValueTask MoveNextAsync() + { + var result = _moveNextThrows; + _moveNextThrows = TaskExt.False; + return result; + } - public ValueTask MoveNextAsync() - { - // May we let this fail over and over? - // If so, the class doesn't need extra state - // and thus can be reused without creating an - // async enumerator - return _moveNextThrows; } } } From 955246cfb363333a08530c6997af431ff9012227 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 11:23:45 -0800 Subject: [PATCH 402/862] Minor optimizations in Aggregate. --- .../System/Linq/Operators/Aggregate.cs | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index f260d43518..ec5d414b82 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -17,7 +17,7 @@ public static Task Aggregate(this IAsyncEnumerable so if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate(source, accumulator, CancellationToken.None); + return AggregateCore(source, accumulator, CancellationToken.None); } public static Task Aggregate(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) @@ -37,7 +37,7 @@ public static Task Aggregate(this IAsyncEnumerable so if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate(source, accumulator, CancellationToken.None); + return AggregateCore(source, accumulator, CancellationToken.None); } public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) @@ -57,7 +57,7 @@ public static Task Aggregate(this IAsyncEnume if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate(source, seed, accumulator, CancellationToken.None); + return AggregateCore(source, seed, accumulator, x => x, CancellationToken.None); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken) @@ -67,7 +67,7 @@ public static Task Aggregate(this IAsyncEnume if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return source.Aggregate(seed, accumulator, x => x, cancellationToken); + return AggregateCore(source, seed, accumulator, x => x, cancellationToken); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) @@ -77,7 +77,7 @@ public static Task Aggregate(this IAsyncEnume if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return Aggregate(source, seed, accumulator, CancellationToken.None); + return AggregateCore(source, seed, accumulator, CancellationToken.None); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) @@ -87,7 +87,7 @@ public static Task Aggregate(this IAsyncEnume if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - return source.Aggregate(seed, accumulator, x => Task.FromResult(x), cancellationToken); + return AggregateCore(source, seed, accumulator, cancellationToken); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) @@ -99,7 +99,7 @@ public static Task Aggregate(this IAsync if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - return Aggregate(source, seed, accumulator, resultSelector, CancellationToken.None); + return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) @@ -123,7 +123,7 @@ public static Task Aggregate(this IAsync if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - return Aggregate(source, seed, accumulator, resultSelector, CancellationToken.None); + return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); } public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) @@ -185,6 +185,27 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) + { + var acc = seed; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return acc; + } + private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { var acc = seed; From 5eed2806dbb7aa2e5df933767f5b7d4ccba3dae5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 11:26:08 -0800 Subject: [PATCH 403/862] Minor tweaks to Any and All. --- .../System.Linq.Async/System/Linq/Operators/All.cs | 4 ++-- .../System.Linq.Async/System/Linq/Operators/Any.cs | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 2ebc0baf57..2339ed548f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -17,7 +17,7 @@ public static Task All(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return All(source, predicate, CancellationToken.None); + return AllCore(source, predicate, CancellationToken.None); } public static Task All(this IAsyncEnumerable source, Func> predicate) @@ -27,7 +27,7 @@ public static Task All(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return All(source, predicate, CancellationToken.None); + return AllCore(source, predicate, CancellationToken.None); } public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index f4c223784f..285cba0b0f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -17,7 +17,7 @@ public static Task Any(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Any(source, predicate, CancellationToken.None); + return AnyCore(source, predicate, CancellationToken.None); } public static Task Any(this IAsyncEnumerable source, Func> predicate) @@ -27,7 +27,7 @@ public static Task Any(this IAsyncEnumerable source, Fun if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Any(source, predicate, CancellationToken.None); + return AnyCore(source, predicate, CancellationToken.None); } public static Task Any(this IAsyncEnumerable source) @@ -35,7 +35,7 @@ public static Task Any(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Any(source, CancellationToken.None); + return AnyCore(source, CancellationToken.None); } public static Task Any(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -58,11 +58,16 @@ public static Task Any(this IAsyncEnumerable source, Fun return AnyCore(source, predicate, cancellationToken); } - public static async Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + return AnyCore(source, cancellationToken); + } + + private static async Task AnyCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { var e = source.GetAsyncEnumerator(cancellationToken); try From a6e71784ca248d6f9c9bbe8c729241cebc479ae8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 11:38:08 -0800 Subject: [PATCH 404/862] Cleaning up Count and LongCount. --- .../System/Linq/Operators/Count.cs | 63 ++++++++++++------- .../System/Linq/Operators/LongCount.cs | 43 ++++++++----- 2 files changed, 68 insertions(+), 38 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index edd0bc705b..6eadcb7aa4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -10,70 +10,85 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Count(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Count(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (source is ICollection collection) - { - return Task.FromResult(collection.Count); - } - - if (source is IAsyncIListProvider listProv) - { - return listProv.GetCountAsync(false, cancellationToken); - } - - return source.Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + return CountCore(source, CancellationToken.None); } - public static Task Count(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task Count(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + return CountCore(source, cancellationToken); } - public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task Count(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + return CountCore(source, predicate, CancellationToken.None); } - public static Task Count(this IAsyncEnumerable source) + public static Task Count(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return Count(source, CancellationToken.None); + return CountCore(source, predicate, cancellationToken); } - public static Task Count(this IAsyncEnumerable source, Func predicate) + public static Task Count(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Count(source, predicate, CancellationToken.None); + return CountCore(source, predicate, CancellationToken.None); } - public static Task Count(this IAsyncEnumerable source, Func> predicate) + public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Count(source, predicate, CancellationToken.None); + return CountCore(source, predicate, cancellationToken); + } + + private static Task CountCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source is ICollection collection) + { + return Task.FromResult(collection.Count); + } + + if (source is IAsyncIListProvider listProv) + { + return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken); + } + + return source.Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + } + + private static Task CountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + } + + private static Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 37339f46df..6ce2363e3e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -10,60 +10,75 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LongCount(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LongCount(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + return LongCountCore(source, CancellationToken.None); } - public static Task LongCount(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LongCount(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + return LongCountCore(source, cancellationToken); } - public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LongCount(this IAsyncEnumerable source, Func predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + return LongCountCore(source, predicate, CancellationToken.None); } - public static Task LongCount(this IAsyncEnumerable source) + public static Task LongCount(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); - return LongCount(source, CancellationToken.None); + return LongCountCore(source, predicate, cancellationToken); } - public static Task LongCount(this IAsyncEnumerable source, Func predicate) + public static Task LongCount(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return LongCount(source, predicate, CancellationToken.None); + return LongCountCore(source, predicate, CancellationToken.None); } - public static Task LongCount(this IAsyncEnumerable source, Func> predicate) + public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return LongCount(source, predicate, CancellationToken.None); + return LongCountCore(source, predicate, cancellationToken); + } + + private static Task LongCountCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + } + + private static Task LongCountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + } + + private static Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); } } } From d5e0f861addd582a2784b325170aec54c3f9d554 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 11:57:29 -0800 Subject: [PATCH 405/862] Clean up Contains. --- .../System/Linq/Operators/Contains.cs | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index a2368e37c1..bd80895e56 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -10,54 +10,45 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) + public static Task Contains(this IAsyncEnumerable source, TSource value) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } + return ContainsCore(source, value, EqualityComparer.Default, CancellationToken.None); + } + + public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); if (comparer == null) - { throw new ArgumentNullException(nameof(comparer)); - } - return Contains(source, value, comparer, CancellationToken.None); + return ContainsCore(source, value, comparer, CancellationToken.None); } - public static Task Contains(this IAsyncEnumerable source, TSource value) + public static Task Contains(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - return Contains(source, value, CancellationToken.None); + return ContainsCore(source, value, EqualityComparer.Default, cancellationToken); } public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (comparer == null) - { throw new ArgumentNullException(nameof(comparer)); - } - return source.Any(x => comparer.Equals(x, value), cancellationToken); + return ContainsCore(source, value, comparer, cancellationToken); } - public static Task Contains(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) + private static Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { - if (source == null) - { - throw new ArgumentNullException(nameof(source)); - } - - return source.Contains(value, EqualityComparer.Default, cancellationToken); + return source.Any(x => comparer.Equals(x, value), cancellationToken); } } } From daba4d8755c1fea5aff62137895f9fe68cbc6e72 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 12:01:59 -0800 Subject: [PATCH 406/862] Named parameter cosmetics. --- .../System/Linq/Operators/AppendPrepend.cs | 11 +++++------ .../System/Linq/Operators/DefaultIfEmpty.cs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 271143caf3..fa44bfb33f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -134,8 +134,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella if (_enumerator != null) { - if (await LoadFromEnumeratorAsync() - .ConfigureAwait(false)) + if (await LoadFromEnumeratorAsync().ConfigureAwait(false)) { return true; } @@ -180,7 +179,7 @@ public override AppendPrependAsyncIterator Prepend(TSource element) public override async Task ToArrayAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); if (count == -1) { return await AsyncEnumerableHelpers.ToArray(this, cancellationToken).ConfigureAwait(false); @@ -230,7 +229,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio public override async Task> ToListAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); var list = count == -1 ? new List() : new List(count); if (!_appending) @@ -389,7 +388,7 @@ public override AppendPrependAsyncIterator Prepend(TSource item) public override async Task ToArrayAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); if (count == -1) { return await AsyncEnumerableHelpers.ToArray(this, cancellationToken).ConfigureAwait(false); @@ -437,7 +436,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio public override async Task> ToListAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); var list = count == -1 ? new List() : new List(count); for (var n = _prepended; n != null; n = n.Linked) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index edda4adfa7..1ac810cf24 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -124,7 +124,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell else { var listProv = _source as IAsyncIListProvider; - count = listProv == null ? -1 : await listProv.GetCountAsync(onlyIfCheap: true, cancellationToken: cancellationToken).ConfigureAwait(false); + count = listProv == null ? -1 : await listProv.GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); } return count == 0 ? 1 : count; From f7bd7fed23c0a31da48951a8d0dd094c56b8496a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 12:10:40 -0800 Subject: [PATCH 407/862] Optimize Contains. --- .../System/Linq/Operators/Contains.cs | 61 ++++++++++++++++--- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index bd80895e56..f2ed198d0b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -15,25 +15,25 @@ public static Task Contains(this IAsyncEnumerable source if (source == null) throw new ArgumentNullException(nameof(source)); - return ContainsCore(source, value, EqualityComparer.Default, CancellationToken.None); + return ContainsCore(source, value, CancellationToken.None); } - public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) + public static Task Contains(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - return ContainsCore(source, value, comparer, CancellationToken.None); + return ContainsCore(source, value, cancellationToken); } - public static Task Contains(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) + public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); - return ContainsCore(source, value, EqualityComparer.Default, cancellationToken); + return ContainsCore(source, value, comparer, CancellationToken.None); } public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -46,9 +46,52 @@ public static Task Contains(this IAsyncEnumerable source return ContainsCore(source, value, comparer, cancellationToken); } - private static Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) + private static Task ContainsCore(IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) + { + if (source is ICollection collection) + { + return Task.FromResult(collection.Contains(value)); + } + + return ContainsCore(source, value, comparer: null, cancellationToken); + } + + private static async Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { - return source.Any(x => comparer.Equals(x, value), cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + // + // See https://github.com/dotnet/corefx/pull/25097 for the optimization here. + // + if (comparer == null) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (EqualityComparer.Default.Equals(e.Current, value)) + { + return true; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (comparer.Equals(e.Current, value)) + { + return true; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return false; } } } From 6e405617818d7cfbb6ea7a0e81a3c689a1de0468 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 12:15:06 -0800 Subject: [PATCH 408/862] Inline Count logic. --- .../System/Linq/Operators/Count.cs | 78 +++++++++++++++++-- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 6eadcb7aa4..d180367132 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -78,17 +78,85 @@ private static Task CountCore(IAsyncEnumerable source, Ca return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken); } - return source.Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + return Core(); + + async Task Core() + { + var count = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + count++; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; + } } - private static Task CountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task CountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + var count = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (predicate(e.Current)) + { + checked + { + count++; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; } - private static Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Aggregate(0, (c, _) => checked(c + 1), cancellationToken); + var count = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current).ConfigureAwait(false)) + { + checked + { + count++; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; } } } From ff4deee27ceb8b6d71e8adae18cd5f4c7a3753d6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 12:16:56 -0800 Subject: [PATCH 409/862] Inline LongCount. --- .../System/Linq/Operators/LongCount.cs | 75 +++++++++++++++++-- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 6ce2363e3e..f6e9cf14e3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -66,19 +66,82 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, predicate, cancellationToken); } - private static Task LongCountCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task LongCountCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + var count = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + count++; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; } - private static Task LongCountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task LongCountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + var count = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (predicate(e.Current)) + { + checked + { + count++; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; } - private static Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Aggregate(0L, (c, _) => checked(c + 1), cancellationToken); + var count = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current).ConfigureAwait(false)) + { + checked + { + count++; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; } } } From 7a4bdf54bc95d8e217d822554709877aacba01f9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 12:18:59 -0800 Subject: [PATCH 410/862] Support ICollection for short-circuiting Count. --- .../System/Linq/Operators/Count.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index d180367132..5bcddb543f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Collections; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -68,14 +69,14 @@ public static Task Count(this IAsyncEnumerable source, Fu private static Task CountCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - if (source is ICollection collection) + switch (source) { - return Task.FromResult(collection.Count); - } - - if (source is IAsyncIListProvider listProv) - { - return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken); + case ICollection collection: + return Task.FromResult(collection.Count); + case IAsyncIListProvider listProv: + return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken); + case ICollection collection: + return Task.FromResult(collection.Count); } return Core(); From 717ffe27aa349ff5c4dc891a456d0667d4881d70 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 12:25:26 -0800 Subject: [PATCH 411/862] Improving Sum code gen. --- .../System/Linq/Operators/Sum.Generated.cs | 240 ++++++++++++++---- .../System/Linq/Operators/Sum.Generated.tt | 24 +- 2 files changed, 209 insertions(+), 55 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index c65f159344..e78d04adc1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -15,7 +15,7 @@ public static Task Sum(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0, (x, y) => x + y, CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,7 +23,7 @@ public static Task Sum(this IAsyncEnumerable source, CancellationToken if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0, (x, y) => x + y, cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -33,7 +33,7 @@ public static Task Sum(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task Sum(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -53,7 +53,7 @@ public static Task Sum(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -63,15 +63,29 @@ public static Task Sum(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate(0, (x, y) => x + y, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0L, (x, y) => x + y, CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -79,7 +93,7 @@ public static Task Sum(this IAsyncEnumerable source, CancellationTok if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0L, (x, y) => x + y, cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -89,7 +103,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -99,7 +113,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -109,7 +123,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -119,15 +133,29 @@ public static Task Sum(this IAsyncEnumerable source, Fun if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate(0L, (x, y) => x + y, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0.0f, (x, y) => x + y, CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -135,7 +163,7 @@ public static Task Sum(this IAsyncEnumerable source, CancellationT if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0.0f, (x, y) => x + y, cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -145,7 +173,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -155,7 +183,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -165,7 +193,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -175,15 +203,29 @@ public static Task Sum(this IAsyncEnumerable source, Fu if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate(0.0f, (x, y) => x + y, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0.0, (x, y) => x + y, CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -191,7 +233,7 @@ public static Task Sum(this IAsyncEnumerable source, Cancellatio if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0.0, (x, y) => x + y, cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -201,7 +243,7 @@ public static Task Sum(this IAsyncEnumerable source, F if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -211,7 +253,7 @@ public static Task Sum(this IAsyncEnumerable source, F if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -221,7 +263,7 @@ public static Task Sum(this IAsyncEnumerable source, F if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -231,15 +273,29 @@ public static Task Sum(this IAsyncEnumerable source, F if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate(0.0, (x, y) => x + y, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0m, (x, y) => x + y, CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -247,7 +303,7 @@ public static Task Sum(this IAsyncEnumerable source, Cancellat if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(0m, (x, y) => x + y, cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -257,7 +313,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -267,7 +323,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -277,7 +333,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -287,15 +343,29 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate(0m, (x, y) => x + y, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -303,7 +373,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -313,7 +383,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -323,7 +393,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -333,7 +403,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -343,15 +413,29 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((long?)0L, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -359,7 +443,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((long?)0L, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -369,7 +453,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -379,7 +463,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -389,7 +473,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -399,15 +483,29 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate((long?)0L, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((float?)0.0f, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -415,7 +513,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((float?)0.0f, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -425,7 +523,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -435,7 +533,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -445,7 +543,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -455,15 +553,29 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate((float?)0.0f, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((double?)0.0, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -471,7 +583,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((double?)0.0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -481,7 +593,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -491,7 +603,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -501,7 +613,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -511,15 +623,29 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate((double?)0.0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } public static Task Sum(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((decimal?)0m, (x, y) => x + y.GetValueOrDefault(), CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -527,7 +653,7 @@ public static Task Sum(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate((decimal?)0m, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + return SumCore(source, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func selector) @@ -537,7 +663,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -547,7 +673,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task Sum(this IAsyncEnumerable source, Func> selector) @@ -557,7 +683,7 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -567,8 +693,22 @@ public static Task Sum(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + return source.Aggregate((decimal?)0m, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + } + + private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 696afcd483..0317aaf66f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -40,7 +40,7 @@ foreach (var o in os) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(<#=o.zero#>, (x, y) => x + y<#=n#>, CancellationToken.None); + return SumCore(source, CancellationToken.None); } public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) @@ -48,7 +48,7 @@ foreach (var o in os) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(<#=o.zero#>, (x, y) => x + y<#=n#>, cancellationToken); + return SumCore(source, cancellationToken); } public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector) @@ -58,7 +58,7 @@ foreach (var o in os) if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -68,7 +68,7 @@ foreach (var o in os) if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(cancellationToken); + return SumCore(source, selector, cancellationToken); } public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector) @@ -78,7 +78,7 @@ foreach (var o in os) if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Sum(CancellationToken.None); + return SumCore(source, selector, CancellationToken.None); } public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) @@ -88,9 +88,23 @@ foreach (var o in os) if (selector == null) throw new ArgumentNullException(nameof(selector)); + return SumCore(source, selector, cancellationToken); + } + + private static Task<<#=o.type#>> SumCore(IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + { + return source.Aggregate(<#=o.zero#>, (x, y) => x + y<#=n#>, cancellationToken); + } + + private static Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { return source.Select(selector).Sum(cancellationToken); } + private static Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + return source.Select(selector).Sum(cancellationToken); + } <# } #> From 1f6068c93cab4037a326cc1493e326ec35eb0035 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 13:34:21 -0800 Subject: [PATCH 412/862] Inline Sum implementations. --- .../System/Linq/Operators/Sum.Generated.cs | 686 ++++++++++++++++-- .../System/Linq/Operators/Sum.Generated.tt | 133 +++- 2 files changed, 743 insertions(+), 76 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index e78d04adc1..7746a1276f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -66,20 +66,82 @@ public static Task Sum(this IAsyncEnumerable source, Func return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate(0, (x, y) => x + y, cancellationToken); + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + sum += e.Current; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -136,20 +198,82 @@ public static Task Sum(this IAsyncEnumerable source, Fun return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate(0L, (x, y) => x + y, cancellationToken); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + sum += e.Current; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -206,20 +330,73 @@ public static Task Sum(this IAsyncEnumerable source, Fu return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate(0.0f, (x, y) => x + y, cancellationToken); + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -276,20 +453,73 @@ public static Task Sum(this IAsyncEnumerable source, F return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate(0.0, (x, y) => x + y, cancellationToken); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -346,20 +576,73 @@ public static Task Sum(this IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate(0m, (x, y) => x + y, cancellationToken); + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -416,20 +699,82 @@ private static Task SumCore(IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate((int?)0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + sum += e.Current.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -486,20 +831,82 @@ private static Task SumCore(IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate((long?)0L, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + sum += e.Current.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -556,20 +963,73 @@ private static Task SumCore(IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate((float?)0.0f, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -626,20 +1086,73 @@ private static Task SumCore(IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate((double?)0.0, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + public static Task Sum(this IAsyncEnumerable source) { if (source == null) @@ -696,19 +1209,72 @@ private static Task SumCore(IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - private static Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return source.Aggregate((decimal?)0m, (x, y) => x + y.GetValueOrDefault(), cancellationToken); + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 0317aaf66f..286b1dc127 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -19,16 +19,16 @@ namespace System.Linq <# var os = new[] { - new { type = "int", zero = "0" }, - new { type = "long", zero = "0L" }, - new { type = "float", zero = "0.0f" }, - new { type = "double", zero = "0.0" }, - new { type = "decimal", zero = "0m" }, - new { type = "int?", zero = "(int?)0" }, - new { type = "long?", zero = "(long?)0L" }, - new { type = "float?", zero = "(float?)0.0f" }, - new { type = "double?", zero = "(double?)0.0" }, - new { type = "decimal?", zero = "(decimal?)0m" }, + new { type = "int", zero = "0", @checked = true }, + new { type = "long", zero = "0L", @checked = true }, + new { type = "float", zero = "0.0f", @checked = false }, + new { type = "double", zero = "0.0", @checked = false }, + new { type = "decimal", zero = "0m", @checked = false }, + new { type = "int?", zero = "0", @checked = true }, + new { type = "long?", zero = "0L", @checked = true }, + new { type = "float?", zero = "0.0f", @checked = false }, + new { type = "double?", zero = "0.0", @checked = false }, + new { type = "decimal?", zero = "0m", @checked = false }, }; foreach (var o in os) @@ -91,20 +91,121 @@ foreach (var o in os) return SumCore(source, selector, cancellationToken); } - private static Task<<#=o.type#>> SumCore(IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { - return source.Aggregate(<#=o.zero#>, (x, y) => x + y<#=n#>, cancellationToken); + var sum = <#=o.zero#>; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { +<# +if (o.@checked) +{ +#> + checked + { + sum += e.Current<#=n#>; + } +<# +} +else +{ +#> + sum += e.Current<#=n#>; +<# +} +#> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = <#=o.zero#>; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + +<# +if (o.@checked) +{ +#> + checked + { + sum += value<#=n#>; + } +<# +} +else +{ +#> + sum += value<#=n#>; +<# +} +#> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } - private static Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { - return source.Select(selector).Sum(cancellationToken); + var sum = <#=o.zero#>; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + +<# +if (o.@checked) +{ +#> + checked + { + sum += value<#=n#>; + } +<# +} +else +{ +#> + sum += value<#=n#>; +<# +} +#> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; } + <# } #> From b360cc4a26a4e976f30c76124d6ab684f1ae9c9b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 13:37:52 -0800 Subject: [PATCH 413/862] Formatting Average. --- .../System/Linq/Operators/Average.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index 97eed323a3..15a31dd261 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -32,7 +32,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, } } - return (double)sum/count; + return (double)sum / count; } finally { @@ -66,7 +66,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, } } - return (double)sum/count; + return (double)sum / count; } } } @@ -100,7 +100,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can } } - return (double)sum/count; + return (double)sum / count; } finally { @@ -134,7 +134,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can } } - return (double)sum/count; + return (double)sum / count; } } } @@ -168,7 +168,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C ++count; } - return sum/count; + return sum / count; } finally { @@ -202,7 +202,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C } } - return sum/count; + return sum / count; } } } @@ -233,7 +233,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can ++count; } - return (float)(sum/count); + return (float)(sum / count); } finally { @@ -267,7 +267,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can } } - return (float)(sum/count); + return (float)(sum / count); } } } @@ -298,7 +298,7 @@ private static async Task AverageCore(IAsyncEnumerable source, ++count; } - return sum/count; + return sum / count; } finally { @@ -329,7 +329,7 @@ private static async Task AverageCore(IAsyncEnumerable source, } } - return sum/count; + return sum / count; } } } From 743e98cf906f78f69c7f664ee083eeeee7046dac Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 13:46:00 -0800 Subject: [PATCH 414/862] Using Core pattern for First, Last, Single. --- .../System/Linq/Operators/First.cs | 20 ++++++++++++++----- .../System/Linq/Operators/FirstOrDefault.cs | 20 ++++++++++++++----- .../System/Linq/Operators/Last.cs | 20 ++++++++++++++----- .../System/Linq/Operators/LastOrDefault.cs | 16 ++++++++++++--- .../System/Linq/Operators/Single.cs | 20 ++++++++++++++----- .../System/Linq/Operators/SingleOrDefault.cs | 20 ++++++++++++++----- 6 files changed, 88 insertions(+), 28 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 281aeaa51d..6fed1d6fe7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -15,7 +15,7 @@ public static Task First(this IAsyncEnumerable source if (source == null) throw new ArgumentNullException(nameof(source)); - return First(source, CancellationToken.None); + return FirstCore(source, CancellationToken.None); } public static Task First(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -33,7 +33,7 @@ public static Task First(this IAsyncEnumerable source if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return First(source, predicate, CancellationToken.None); + return FirstCore(source, predicate, CancellationToken.None); } public static Task First(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task First(this IAsyncEnumerable source if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).First(cancellationToken); + return FirstCore(source, predicate, cancellationToken); } public static Task First(this IAsyncEnumerable source, Func> predicate) @@ -53,7 +53,7 @@ public static Task First(this IAsyncEnumerable source if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return First(source, predicate, CancellationToken.None); + return FirstCore(source, predicate, CancellationToken.None); } public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -63,7 +63,7 @@ public static Task First(this IAsyncEnumerable source if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).First(cancellationToken); + return FirstCore(source, predicate, cancellationToken); } private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -103,5 +103,15 @@ private static async Task FirstCore(IAsyncEnumerable throw new InvalidOperationException(Strings.NO_ELEMENTS); } + + private static Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).First(cancellationToken); + } + + private static Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).First(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index dde0aebb9e..a542f0f31a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -15,7 +15,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -33,7 +33,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate) @@ -53,7 +53,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -63,7 +63,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -103,5 +103,15 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< return default; } + + private static Task FirstOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).FirstOrDefault(cancellationToken); + } + + private static Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).FirstOrDefault(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 724965ccb9..5ee439cce5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -15,7 +15,7 @@ public static Task Last(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Last(source, CancellationToken.None); + return LastCore(source, CancellationToken.None); } public static Task Last(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -33,7 +33,7 @@ public static Task Last(this IAsyncEnumerable source, if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Last(source, predicate, CancellationToken.None); + return LastCore(source, predicate, CancellationToken.None); } public static Task Last(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task Last(this IAsyncEnumerable source, if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Last(cancellationToken); + return LastCore(source, predicate, cancellationToken); } public static Task Last(this IAsyncEnumerable source, Func> predicate) @@ -53,7 +53,7 @@ public static Task Last(this IAsyncEnumerable source, if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Last(source, predicate, CancellationToken.None); + return LastCore(source, predicate, CancellationToken.None); } public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -63,7 +63,7 @@ public static Task Last(this IAsyncEnumerable source, if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Last(cancellationToken); + return LastCore(source, predicate, cancellationToken); } private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -113,5 +113,15 @@ private static async Task LastCore(IAsyncEnumerable s throw new InvalidOperationException(Strings.NO_ELEMENTS); } + + private static Task LastCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Last(cancellationToken); + } + + private static Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Last(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index ed907401e9..0d707b83da 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -15,7 +15,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -33,7 +33,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -53,7 +53,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -113,5 +113,15 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).LastOrDefault(cancellationToken); + } + + private static Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).LastOrDefault(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index fd5b04aa60..0ab6d93a78 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -15,7 +15,7 @@ public static Task Single(this IAsyncEnumerable sourc if (source == null) throw new ArgumentNullException(nameof(source)); - return Single(source, CancellationToken.None); + return SingleCore(source, CancellationToken.None); } public static Task Single(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -33,7 +33,7 @@ public static Task Single(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Single(source, predicate, CancellationToken.None); + return SingleCore(source, predicate, CancellationToken.None); } public static Task Single(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task Single(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Single(cancellationToken); + return SingleCore(source, predicate, cancellationToken); } public static Task Single(this IAsyncEnumerable source, Func> predicate) @@ -53,7 +53,7 @@ public static Task Single(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return Single(source, predicate, CancellationToken.None); + return SingleCore(source, predicate, CancellationToken.None); } public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -63,7 +63,7 @@ public static Task Single(this IAsyncEnumerable sourc if (predicate == null) throw new ArgumentNullException(nameof(predicate)); - return source.Where(predicate).Single(cancellationToken); + return SingleCore(source, predicate, cancellationToken); } private static async Task SingleCore(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -101,5 +101,15 @@ private static async Task SingleCore(IAsyncEnumerable await e.DisposeAsync().ConfigureAwait(false); } } + + private static Task SingleCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Single(cancellationToken); + } + + private static Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).Single(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 7f67c563b5..0aca168ade 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -15,7 +15,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -33,7 +33,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate) @@ -53,7 +53,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -63,7 +63,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) @@ -101,5 +101,15 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } + + private static Task SingleOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).SingleOrDefault(cancellationToken); + } + + private static Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + return source.Where(predicate).SingleOrDefault(cancellationToken); + } } } From 69a02b35165d1970683bd0cef546b3a28565ce8b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:02:27 -0800 Subject: [PATCH 415/862] Optimize First. --- .../System/Linq/Operators/First.cs | 54 ++++------- .../System/Linq/Operators/FirstOrDefault.cs | 95 ++++++++++++++++--- 2 files changed, 103 insertions(+), 46 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 6fed1d6fe7..99fd0735bf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -68,50 +68,38 @@ public static Task First(this IAsyncEnumerable source private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - if (source is IList list) - { - if (list.Count > 0) - { - return list[0]; - } - } - else if (source is IAsyncPartition p) - { - var first = await p.TryGetFirstAsync(cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); - if (first.HasValue) - { - return first.Value; - } - } - else + if (first.HasValue) { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (await e.MoveNextAsync().ConfigureAwait(false)) - { - return e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + return first.Value; } throw new InvalidOperationException(Strings.NO_ELEMENTS); } - private static Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).First(cancellationToken); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + if (first.HasValue) + { + return first.Value; + } + + throw new InvalidOperationException(Strings.NO_ELEMENTS); } - private static Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).First(cancellationToken); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + if (first.HasValue) + { + return first.Value; + } + + throw new InvalidOperationException(Strings.NO_ELEMENTS); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index a542f0f31a..f3df71b1e1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -67,22 +67,53 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + + if (first.HasValue) + { + return first.Value; + } + + return default; + } + + private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + if (first.HasValue) + { + return first.Value; + } + + return default; + } + + private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + if (first.HasValue) + { + return first.Value; + } + + return default; + } + + private static async Task> TryGetFirst(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { if (list.Count > 0) { - return list[0]; + return new Maybe(list[0]); } } else if (source is IAsyncPartition p) { - var first = await p.TryGetFirstAsync(cancellationToken).ConfigureAwait(false); - - if (first.HasValue) - { - return first.Value; - } + return await p.TryGetFirstAsync(cancellationToken).ConfigureAwait(false); } else { @@ -92,7 +123,7 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< { if (await e.MoveNextAsync().ConfigureAwait(false)) { - return e.Current; + return new Maybe(e.Current); } } finally @@ -101,17 +132,55 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< } } - return default; + return new Maybe(); } - private static Task FirstOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).FirstOrDefault(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = e.Current; + + if (predicate(value)) + { + return new Maybe(value); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return new Maybe(); } - private static Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).FirstOrDefault(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = e.Current; + + if (await predicate(value).ConfigureAwait(false)) + { + return new Maybe(value); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return new Maybe(); } } } From 051f53ecf5db2edb73ccfa80005f7ab6917654e6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:11:01 -0800 Subject: [PATCH 416/862] Minor simplification of the code. --- .../System/Linq/Operators/First.cs | 21 +++---------------- .../System/Linq/Operators/FirstOrDefault.cs | 21 +++---------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 99fd0735bf..31b45ea4b1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -70,36 +70,21 @@ private static async Task FirstCore(IAsyncEnumerable { var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); - if (first.HasValue) - { - return first.Value; - } - - throw new InvalidOperationException(Strings.NO_ELEMENTS); + return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); } private static async Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - if (first.HasValue) - { - return first.Value; - } - - throw new InvalidOperationException(Strings.NO_ELEMENTS); + return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); } private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - if (first.HasValue) - { - return first.Value; - } - - throw new InvalidOperationException(Strings.NO_ELEMENTS); + return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index f3df71b1e1..f4899e3a39 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -70,36 +70,21 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< { var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); - if (first.HasValue) - { - return first.Value; - } - - return default; + return first.HasValue ? first.Value : default; } private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - if (first.HasValue) - { - return first.Value; - } - - return default; + return first.HasValue ? first.Value : default; } private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - if (first.HasValue) - { - return first.Value; - } - - return default; + return first.HasValue ? first.Value : default; } private static async Task> TryGetFirst(IAsyncEnumerable source, CancellationToken cancellationToken) From c854cad6fb848461fa4d23dfb72dba18973ceb53 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:11:13 -0800 Subject: [PATCH 417/862] Optimize Last. --- .../System/Linq/Operators/Last.cs | 59 ++-------- .../System/Linq/Operators/LastOrDefault.cs | 102 +++++++++++++++--- 2 files changed, 98 insertions(+), 63 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 5ee439cce5..a9ebc3b8de 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -68,60 +68,23 @@ public static Task Last(this IAsyncEnumerable source, private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - if (source is IList list) - { - var count = list.Count; - if (count > 0) - { - return list[count - 1]; - } - } - else if (source is IAsyncPartition p) - { - var first = await p.TryGetLastAsync(cancellationToken).ConfigureAwait(false); - - if (first.HasValue) - { - return first.Value; - } - } - else - { - var last = default(TSource); - var hasLast = false; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - hasLast = true; - last = e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - if (hasLast) - { - return last; - } - } - - throw new InvalidOperationException(Strings.NO_ELEMENTS); + var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); } - private static Task LastCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task LastCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Last(cancellationToken); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); } - private static Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Last(cancellationToken); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 0d707b83da..dade3cf3e3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -43,7 +43,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate) @@ -63,27 +63,43 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : default; + } + + private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : default; + } + + private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : default; + } + + private static async Task> TryGetLast(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { var count = list.Count; if (count > 0) { - return list[count - 1]; + return new Maybe(list[count - 1]); } } else if (source is IAsyncPartition p) { - var first = await p.TryGetLastAsync(cancellationToken).ConfigureAwait(false); - - if (first.HasValue) - { - return first.Value; - } + return await p.TryGetLastAsync(cancellationToken).ConfigureAwait(false); } else { @@ -107,21 +123,77 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable(last); } } - return default; + return new Maybe(); } - private static Task LastOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task> TryGetLast(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).LastOrDefault(cancellationToken); + var last = default(TSource); + var hasLast = false; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = e.Current; + + if (predicate(value)) + { + hasLast = true; + last = value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + if (hasLast) + { + return new Maybe(last); + } + + return new Maybe(); } - private static Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).LastOrDefault(cancellationToken); + var last = default(TSource); + var hasLast = false; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = e.Current; + + if (await predicate(value).ConfigureAwait(false)) + { + hasLast = true; + last = value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + if (hasLast) + { + return new Maybe(last); + } + + return new Maybe(); } } } From 394f37e0b4fb13a4553686e94bf2c33a9c0082ea Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:37:38 -0800 Subject: [PATCH 418/862] Fix Maybe. --- Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs index 6f6d2bc74b..8044a37d18 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs @@ -10,7 +10,7 @@ internal struct Maybe : IEquatable> { public Maybe(T value) { - HasValue = false; + HasValue = true; Value = value; } From 038c04af2e0c725808633209faea336b38d3327c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:43:13 -0800 Subject: [PATCH 419/862] Fix loop in First. --- .../System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index f4899e3a39..0eb78f8827 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -126,7 +126,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< try { - if (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var value = e.Current; @@ -150,7 +150,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< try { - if (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var value = e.Current; From 526d44448d8bd0a4241df477353a2e09a02b5f8f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:45:31 -0800 Subject: [PATCH 420/862] Optimize Single. --- .../System/Linq/Operators/Single.cs | 62 ++++++++++++++++-- .../System/Linq/Operators/SingleOrDefault.cs | 63 +++++++++++++++++-- 2 files changed, 117 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 0ab6d93a78..d7f149697e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -102,14 +102,68 @@ private static async Task SingleCore(IAsyncEnumerable } } - private static Task SingleCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task SingleCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Single(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var result = e.Current; + + if (predicate(result)) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (predicate(e.Current)) + { + throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + } + } + + return result; + } + } + + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } - private static Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).Single(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var result = e.Current; + + if (await predicate(result).ConfigureAwait(false)) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current).ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + } + } + + return result; + } + } + + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 0aca168ade..b564ebdfde 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -89,6 +89,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable } var result = e.Current; + if (!await e.MoveNextAsync().ConfigureAwait(false)) { return result; @@ -102,14 +103,68 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); } - private static Task SingleOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - return source.Where(predicate).SingleOrDefault(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var result = e.Current; + + if (predicate(result)) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (predicate(e.Current)) + { + throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + } + } + + return result; + } + } + + return default; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } - private static Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - return source.Where(predicate).SingleOrDefault(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var result = e.Current; + + if (await predicate(result).ConfigureAwait(false)) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current).ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + } + } + + return result; + } + } + + return default; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } } From 8ca4d672cc3d13080c27c8e03ab21a0fb4be9160 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:50:52 -0800 Subject: [PATCH 421/862] A few small optimizations. --- .../System/Linq/Operators/FirstOrDefault.cs | 31 ++++++++------ .../System/Linq/Operators/LastOrDefault.cs | 42 ++++++++++--------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 0eb78f8827..3a5166025e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -87,37 +87,44 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< return first.HasValue ? first.Value : default; } - private static async Task> TryGetFirst(IAsyncEnumerable source, CancellationToken cancellationToken) + private static Task> TryGetFirst(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { if (list.Count > 0) { - return new Maybe(list[0]); + return Task.FromResult(new Maybe(list[0])); } } else if (source is IAsyncPartition p) { - return await p.TryGetFirstAsync(cancellationToken).ConfigureAwait(false); + return p.TryGetFirstAsync(cancellationToken); } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task> Core() { - if (await e.MoveNextAsync().ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - return new Maybe(e.Current); + if (await e.MoveNextAsync().ConfigureAwait(false)) + { + return new Maybe(e.Current); + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return new Maybe(); } } - return new Maybe(); + return Task.FromResult(new Maybe()); } private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index dade3cf3e3..2163663875 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -87,47 +87,49 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable> TryGetLast(IAsyncEnumerable source, CancellationToken cancellationToken) + private static Task> TryGetLast(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { var count = list.Count; if (count > 0) { - return new Maybe(list[count - 1]); + return Task.FromResult(new Maybe(list[count - 1])); } } else if (source is IAsyncPartition p) { - return await p.TryGetLastAsync(cancellationToken).ConfigureAwait(false); + return p.TryGetLastAsync(cancellationToken); } else { - var last = default(TSource); - var hasLast = false; + return Core(); - var e = source.GetAsyncEnumerator(cancellationToken); - - try + async Task> Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var last = default(TSource); + var hasLast = false; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - hasLast = true; - last = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + hasLast = true; + last = e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - if (hasLast) - { - return new Maybe(last); + return hasLast ? new Maybe(last) : new Maybe(); } } - return new Maybe(); + return Task.FromResult(new Maybe()); } private static async Task> TryGetLast(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) From bed77c226c14dfa0ebf86898288bc87b46752fbd Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 14:56:12 -0800 Subject: [PATCH 422/862] Minor edit to ElementAt. --- .../Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs | 2 +- .../System/Linq/Operators/ElementAtOrDefault.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index d3758138ab..f97eba0bc3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -15,7 +15,7 @@ public static Task ElementAt(this IAsyncEnumerable so if (source == null) throw new ArgumentNullException(nameof(source)); - return ElementAt(source, index, CancellationToken.None); + return ElementAtCore(source, index, CancellationToken.None); } public static Task ElementAt(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index e4ab1de030..bbd565d1ea 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -15,7 +15,7 @@ public static Task ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefault(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) From bc4b1a743e41eb8e8460e398902c725a962a06c5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 15:05:43 -0800 Subject: [PATCH 423/862] Small improvements to Min and Max. --- .../System/Linq/Operators/Max.cs | 23 +++++++++++++------ .../System/Linq/Operators/Min.cs | 23 +++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index dd263cf37e..6f3bee3b63 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -15,7 +15,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Max(source, CancellationToken.None); + return MaxCore(source, Comparer.Default, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,8 +23,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - var comparer = Comparer.Default; - return source.Aggregate((x, y) => comparer.Compare(x, y) >= 0 ? x : y, cancellationToken); + return MaxCore(source, Comparer.Default, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -34,7 +33,7 @@ public static Task Max(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Max(source, selector, CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -44,7 +43,7 @@ public static Task Max(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) @@ -54,7 +53,7 @@ public static Task Max(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Max(source, selector, CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -64,7 +63,7 @@ public static Task Max(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) @@ -95,5 +94,15 @@ private static async Task MaxCore(IAsyncEnumerable so await e.DisposeAsync().ConfigureAwait(false); } } + + private static Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + return MaxCore(source.Select(selector), Comparer.Default, cancellationToken); + } + + private static Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return MaxCore(source.Select(selector), Comparer.Default, cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index defb09972c..c6710cfed1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -15,7 +15,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return Min(source, CancellationToken.None); + return MinCore(source, Comparer.Default, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,8 +23,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - var comparer = Comparer.Default; - return source.Aggregate((x, y) => comparer.Compare(x, y) <= 0 ? x : y, cancellationToken); + return MinCore(source, Comparer.Default, cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -34,7 +33,7 @@ public static Task Min(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Min(source, selector, CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -44,7 +43,7 @@ public static Task Min(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) @@ -54,7 +53,7 @@ public static Task Min(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return Min(source, selector, CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -64,7 +63,7 @@ public static Task Min(this IAsyncEnumerable if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) @@ -95,5 +94,15 @@ private static async Task MinCore(IAsyncEnumerable so await e.DisposeAsync().ConfigureAwait(false); } } + + private static Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + return MinCore(source.Select(selector), Comparer.Default, cancellationToken); + } + + private static Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + return MinCore(source.Select(selector), Comparer.Default, cancellationToken); + } } } From bb54d8d00c7e4df8901b2287537312198804edf8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 16:12:11 -0800 Subject: [PATCH 424/862] Replace Min and Max implementations. --- .../System/Linq/Operators/Max.Generic.cs | 208 +++ .../System/Linq/Operators/Max.Primitive.cs | 1372 +++++++++++++++++ .../System/Linq/Operators/Max.cs | 43 +- .../System/Linq/Operators/Min.Generic.cs | 208 +++ .../System/Linq/Operators/Min.Primitive.cs | 1186 ++++++++++++++ .../System/Linq/Operators/Min.cs | 43 +- .../System/Linq/Operators/MinMax.Generated.cs | 459 +++--- .../System/Linq/Operators/MinMax.Generated.tt | 82 +- 8 files changed, 3205 insertions(+), 396 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs new file mode 100644 index 0000000000..3cae3cee02 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs @@ -0,0 +1,208 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TSource); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TResult); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TResult); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs new file mode 100644 index 0000000000..929fce02b6 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs @@ -0,0 +1,1372 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive + // or mostly-positive integer values are quite common in real-world + // uses, it's only been done in this direction for int? and long?. + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + + // As described in a comment on Min(IAsyncEnumerable) NaN is ordered + // less than all other values. We need to do explicit checks to ensure this, but + // once we've found a value that is not NaN we need no longer worry about it, + // so first loop until such a value is found (or not, as the case may be). + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = e.Current; + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = e.Current; + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive + // or mostly-positive integer values are quite common in real-world + // uses, it's only been done in this direction for int? and long?. + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = selector(e.Current); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + + // As described in a comment on Min(IAsyncEnumerable) NaN is ordered + // less than all other values. We need to do explicit checks to ensure this, but + // once we've found a value that is not NaN we need no longer worry about it, + // so first loop until such a value is found (or not, as the case may be). + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = selector(e.Current); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive + // or mostly-positive integer values are quite common in real-world + // uses, it's only been done in this direction for int? and long?. + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + + // As described in a comment on Min(IAsyncEnumerable) NaN is ordered + // less than all other values. We need to do explicit checks to ensure this, but + // once we've found a value that is not NaN we need no longer worry about it, + // so first loop until such a value is found (or not, as the case may be). + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 6f3bee3b63..573e71e1e6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -15,7 +15,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return MaxCore(source, Comparer.Default, CancellationToken.None); + return MaxCore(source, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,7 +23,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return MaxCore(source, Comparer.Default, cancellationToken); + return MaxCore(source, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -65,44 +65,5 @@ public static Task Max(this IAsyncEnumerable return MaxCore(source, selector, cancellationToken); } - - private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); - - var max = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - - if (comparer.Compare(cur, max) > 0) - { - max = cur; - } - } - - return max; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - return MaxCore(source.Select(selector), Comparer.Default, cancellationToken); - } - - private static Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - return MaxCore(source.Select(selector), Comparer.Default, cancellationToken); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs new file mode 100644 index 0000000000..50a0ec3540 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs @@ -0,0 +1,208 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TSource); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TResult); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TResult); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs new file mode 100644 index 0000000000..0dd4a038de --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs @@ -0,0 +1,1186 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + else if (float.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (float.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + else if (double.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (double.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x < value) + { + value = x; + } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + else if (float.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (float.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x < value) + { + value = x; + } + else if (double.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (double.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + else if (float.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (float.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else if (double.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (double.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw new InvalidOperationException(Strings.NO_ELEMENTS); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index c6710cfed1..2b88ac6bf6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -15,7 +15,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return MinCore(source, Comparer.Default, CancellationToken.None); + return MinCore(source, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,7 +23,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return MinCore(source, Comparer.Default, cancellationToken); + return MinCore(source, cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -65,44 +65,5 @@ public static Task Min(this IAsyncEnumerable return MinCore(source, selector, cancellationToken); } - - private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); - - var min = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - - if (comparer.Compare(cur, min) < 0) - { - min = cur; - } - } - - return min; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - return MinCore(source.Select(selector), Comparer.Default, cancellationToken); - } - - private static Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - return MinCore(source.Select(selector), Comparer.Default, cancellationToken); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 4350291874..1347553e97 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -1,6 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Threading; @@ -15,7 +15,7 @@ public static Task Max(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,7 +23,7 @@ public static Task Max(this IAsyncEnumerable source, CancellationToken if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), cancellationToken); + return MaxCore(source, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -33,7 +33,7 @@ public static Task Max(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task Max(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) @@ -53,7 +53,7 @@ public static Task Max(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -63,455 +63,455 @@ public static Task Max(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Max), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), new Func(NullableMax), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), new Func(NullableMax), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), new Func(NullableMax), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), new Func(NullableMax), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), new Func(NullableMax), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), new Func(NullableMax), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task Max(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), new Func(NullableMax), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), new Func(NullableMax), cancellationToken); + return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } public static Task Max(this IAsyncEnumerable source) @@ -519,7 +519,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), new Func(NullableMax), CancellationToken.None); + return MaxCore(source, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -527,7 +527,7 @@ public static Task Max(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), new Func(NullableMax), cancellationToken); + return MaxCore(source, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func selector) @@ -537,7 +537,7 @@ public static Task Max(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -547,7 +547,7 @@ public static Task Max(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } public static Task Max(this IAsyncEnumerable source, Func> selector) @@ -557,7 +557,7 @@ public static Task Max(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(CancellationToken.None); + return MaxCore(source, selector, CancellationToken.None); } public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -567,7 +567,7 @@ public static Task Max(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Max(cancellationToken); + return MaxCore(source, selector, cancellationToken); } public static Task Min(this IAsyncEnumerable source) @@ -575,7 +575,7 @@ public static Task Min(this IAsyncEnumerable source) if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), CancellationToken.None); + return MinCore(source, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -583,7 +583,7 @@ public static Task Min(this IAsyncEnumerable source, CancellationToken if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), cancellationToken); + return MinCore(source, cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -593,7 +593,7 @@ public static Task Min(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -603,7 +603,7 @@ public static Task Min(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) @@ -613,7 +613,7 @@ public static Task Min(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -623,455 +623,455 @@ public static Task Min(this IAsyncEnumerable source, Func if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(new Func(Math.Min), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), new Func(NullableMin), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(int?), new Func(NullableMin), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), new Func(NullableMin), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(long?), new Func(NullableMin), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), new Func(NullableMin), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(float?), new Func(NullableMin), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task Min(this IAsyncEnumerable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), new Func(NullableMin), CancellationToken.None); + return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(double?), new Func(NullableMin), cancellationToken); + return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } public static Task Min(this IAsyncEnumerable source) @@ -1079,7 +1079,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), new Func(NullableMin), CancellationToken.None); + return MinCore(source, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -1087,7 +1087,7 @@ public static Task Min(this IAsyncEnumerable source, if (source == null) throw new ArgumentNullException(nameof(source)); - return source.Aggregate(default(decimal?), new Func(NullableMin), cancellationToken); + return MinCore(source, cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func selector) @@ -1097,7 +1097,7 @@ public static Task Min(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -1107,7 +1107,7 @@ public static Task Min(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); + return MinCore(source, selector, cancellationToken); } public static Task Min(this IAsyncEnumerable source, Func> selector) @@ -1117,7 +1117,7 @@ public static Task Min(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(CancellationToken.None); + return MinCore(source, selector, CancellationToken.None); } public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -1127,31 +1127,8 @@ public static Task Min(this IAsyncEnumerable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).Min(cancellationToken); - } - - private static T? NullableMax(T? x, T? y) - where T : struct, IComparable - { - if (!x.HasValue) - return y; - if (!y.HasValue) - return x; - if (x.Value.CompareTo(y.Value) >= 0) - return x; - return y; + return MinCore(source, selector, cancellationToken); } - private static T? NullableMin(T? x, T? y) - where T : struct, IComparable - { - if (!x.HasValue) - return y; - if (!y.HasValue) - return x; - if (x.Value.CompareTo(y.Value) <= 0) - return x; - return y; - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 86e1f60cb1..4a248aa680 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -5,8 +5,8 @@ <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> // Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Threading; @@ -17,45 +17,17 @@ namespace System.Linq public static partial class AsyncEnumerable { <# -var ts = new[] -{ - "int", - "long", - "float", - "double", - "decimal", - "int?", - "long?", - "float?", - "double?", - "decimal?", -}; - foreach (var m in new[] { "Max", "Min" }) { - foreach (var t in ts) + foreach (var t in new[] { "int", "int?", "long", "long?", "float", "float?", "double", "double?", "decimal", "decimal?" }) { - var n = t.EndsWith("?"); #> public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source) { if (source == null) throw new ArgumentNullException(nameof(source)); -<# -if (n) -{ -#> - return source.Aggregate(default(<#=t#>), new Func<<#=t#>, <#=t#>, <#=t#>>(Nullable<#=m#>), CancellationToken.None); -<# -} -else -{ -#> - return source.Aggregate(new Func<<#=t#>, <#=t#>, <#=t#>>(Math.<#=m#>), CancellationToken.None); -<# -} -#> + return <#=m#>Core(source, CancellationToken.None); } public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken) @@ -63,20 +35,7 @@ else if (source == null) throw new ArgumentNullException(nameof(source)); -<# -if (n) -{ -#> - return source.Aggregate(default(<#=t#>), new Func<<#=t#>, <#=t#>, <#=t#>>(Nullable<#=m#>), cancellationToken); -<# -} -else -{ -#> - return source.Aggregate(new Func<<#=t#>, <#=t#>, <#=t#>>(Math.<#=m#>), cancellationToken); -<# -} -#> + return <#=m#>Core(source, cancellationToken); } public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector) @@ -86,7 +45,7 @@ else if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).<#=m#>(CancellationToken.None); + return <#=m#>Core(source, selector, CancellationToken.None); } public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -96,7 +55,7 @@ else if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).<#=m#>(cancellationToken); + return <#=m#>Core(source, selector, cancellationToken); } public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector) @@ -106,7 +65,7 @@ else if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).<#=m#>(CancellationToken.None); + return <#=m#>Core(source, selector, CancellationToken.None); } public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) @@ -116,35 +75,12 @@ else if (selector == null) throw new ArgumentNullException(nameof(selector)); - return source.Select(selector).<#=m#>(cancellationToken); + return <#=m#>Core(source, selector, cancellationToken); } <# } } #> - private static T? NullableMax(T? x, T? y) - where T : struct, IComparable - { - if (!x.HasValue) - return y; - if (!y.HasValue) - return x; - if (x.Value.CompareTo(y.Value) >= 0) - return x; - return y; - } - - private static T? NullableMin(T? x, T? y) - where T : struct, IComparable - { - if (!x.HasValue) - return y; - if (!y.HasValue) - return x; - if (x.Value.CompareTo(y.Value) <= 0) - return x; - return y; - } } } From 751176ba4e0e79e23dc264c7bbdc404095cc276b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 17:19:03 -0800 Subject: [PATCH 425/862] Clean up ForEachAsync stuff. --- .../System/Linq/Operators/ForEach.cs | 100 ++++++++---------- 1 file changed, 47 insertions(+), 53 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 59cd74e51b..efcb7ed9f6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -13,59 +13,39 @@ public static partial class AsyncEnumerable public static Task ForEachAsync(this IAsyncEnumerable source, Action action) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } - return ForEachAsync(source, action, CancellationToken.None); + return ForEachAsyncCore(source, action, CancellationToken.None); } - public static Task ForEachAsync(this IAsyncEnumerable source, Action action) + public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } - return ForEachAsync(source, action, CancellationToken.None); + return ForEachAsyncCore(source, action, cancellationToken); } - public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Action action) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } - return source.ForEachAsync((x, i) => action(x), cancellationToken); + return ForEachAsyncCore(source, action, CancellationToken.None); } public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } return ForEachAsyncCore(source, action, cancellationToken); } @@ -73,61 +53,41 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Func action) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } - return ForEachAsync(source, action, CancellationToken.None); + return ForEachAsyncCore(source, (x, ct) => action(x), CancellationToken.None); } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } - return ForEachAsync(source, action, CancellationToken.None); + return ForEachAsyncCore(source, (x, ct) => action(x), cancellationToken); } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } - return source.ForEachAsync((x, i, ct) => action(x), cancellationToken); + return ForEachAsyncCore(source, action, cancellationToken); } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (action == null) - { throw new ArgumentNullException(nameof(action)); - } - return source.ForEachAsync((x, i, ct) => action(x, ct), cancellationToken); + return ForEachAsyncCore(source, (x, i, ct) => action(x, i), CancellationToken.None); } public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) @@ -137,7 +97,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, if (action == null) throw new ArgumentNullException(nameof(action)); - return source.ForEachAsync((x, i, ct) => action(x, i), cancellationToken); + return ForEachAsyncCore(source, (x, i, ct) => action(x, i), cancellationToken); } public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) @@ -150,6 +110,40 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return ForEachAsyncCore(source, action, cancellationToken); } + private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + action(e.Current); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + await action(e.Current, cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { var index = 0; From 117625f92fcdc524f9b1a234187c84459261f8b2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 17:39:01 -0800 Subject: [PATCH 426/862] Optimize ToDictionary. --- .../System/Linq/Operators/ToDictionary.cs | 98 +++++++++++++------ 1 file changed, 67 insertions(+), 31 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 237709fa15..946d260a6f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -17,7 +17,7 @@ public static Task> ToDictionary(this I if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return ToDictionary(source, keySelector, CancellationToken.None); + return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, CancellationToken.None); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) @@ -27,7 +27,7 @@ public static Task> ToDictionary(this I if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.ToDictionary(keySelector, x => x, EqualityComparer.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector) @@ -37,7 +37,7 @@ public static Task> ToDictionary(this I if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return ToDictionary(source, keySelector, CancellationToken.None); + return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, CancellationToken.None); } public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) @@ -47,7 +47,7 @@ public static Task> ToDictionary(this I if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return source.ToDictionary(keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -59,7 +59,7 @@ public static Task> ToDictionary(this I if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return ToDictionary(source, keySelector, comparer, CancellationToken.None); + return ToDictionaryCore(source, keySelector, x => x, comparer, CancellationToken.None); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -71,7 +71,7 @@ public static Task> ToDictionary(this I if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.ToDictionary(keySelector, x => x, comparer, cancellationToken); + return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -83,7 +83,7 @@ public static Task> ToDictionary(this I if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return ToDictionary(source, keySelector, comparer, CancellationToken.None); + return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None); } public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -95,7 +95,7 @@ public static Task> ToDictionary(this I if (comparer == null) throw new ArgumentNullException(nameof(comparer)); - return source.ToDictionary(keySelector, x => Task.FromResult(x), comparer, cancellationToken); + return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector) @@ -107,7 +107,7 @@ public static Task> ToDictionary.Default, CancellationToken.None); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) @@ -119,7 +119,7 @@ public static Task> ToDictionary.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) @@ -131,7 +131,7 @@ public static Task> ToDictionary.Default, CancellationToken.None); } public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) @@ -143,7 +143,7 @@ public static Task> ToDictionary.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) @@ -157,7 +157,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -171,15 +171,7 @@ public static Task> ToDictionary(comparer), - (d, x) => - { - d.Add(keySelector(x), elementSelector(x)); - return d; - }, - cancellationToken - ); + return ToDictionaryCore(source, keySelector, elementSelector, comparer, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) @@ -193,7 +185,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -207,15 +199,59 @@ public static Task> ToDictionary(comparer), - async (d, x) => + return ToDictionaryCore(source, keySelector, elementSelector, comparer, cancellationToken); + } + + private static async Task> ToDictionaryCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + var d = new Dictionary(comparer); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + + var key = keySelector(x); + var value = elementSelector(x); + + d.Add(key, value); + } + + return d; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + var d = new Dictionary(comparer); + + while (await e.MoveNextAsync().ConfigureAwait(false)) { - d.Add(await keySelector(x).ConfigureAwait(false), await elementSelector(x).ConfigureAwait(false)); - return d; - }, - cancellationToken - ); + var x = e.Current; + + var key = await keySelector(x).ConfigureAwait(false); + var value = await elementSelector(x).ConfigureAwait(false); + + d.Add(key, value); + } + + return d; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } } From 8a22b4d819bbc8e8070e513dba29fab2c6c102fb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 17:41:46 -0800 Subject: [PATCH 427/862] Optimize ToList. --- .../System/Linq/Operators/ToList.cs | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 9034830b54..d90223abf8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -15,7 +15,7 @@ public static Task> ToList(this IAsyncEnumerable if (source == null) throw new ArgumentNullException(nameof(source)); - return ToList(source, CancellationToken.None); + return ToListCore(source, CancellationToken.None); } public static Task> ToList(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,18 +23,36 @@ public static Task> ToList(this IAsyncEnumerable if (source == null) throw new ArgumentNullException(nameof(source)); + return ToListCore(source, cancellationToken); + } + + private static Task> ToListCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { if (source is IAsyncIListProvider listProvider) return listProvider.ToListAsync(cancellationToken); - return source.Aggregate( - new List(), - (list, x) => + return Core(); + + async Task> Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - list.Add(x); + var list = new List(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + list.Add(e.Current); + } + return list; - }, - cancellationToken - ); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } } } From 91ba295ed93a3774de1276dcad51815f19ea5dc3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 17:44:05 -0800 Subject: [PATCH 428/862] Optimize ToHashSet. --- .../System/Linq/Operators/ToHashSet.cs | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index ee23899192..7f3f60f58d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -15,7 +15,7 @@ public static Task> ToHashSet(this IAsyncEnumerable.Default, CancellationToken.None); + return ToHashSetCore(source, EqualityComparer.Default, CancellationToken.None); } public static Task> ToHashSet(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,7 +23,7 @@ public static Task> ToHashSet(this IAsyncEnumerable.Default, cancellationToken); + return ToHashSetCore(source, EqualityComparer.Default, cancellationToken); } public static Task> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer) @@ -33,7 +33,7 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -43,15 +43,28 @@ public static Task> ToHashSet(this IAsyncEnumerable(comparer), - (set, x) => + return ToHashSetCore(source, comparer, cancellationToken); + } + + private static async Task> ToHashSetCore(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + var set = new HashSet(comparer); + + while (await e.MoveNextAsync().ConfigureAwait(false)) { - set.Add(x); - return set; - }, - cancellationToken - ); + set.Add(e.Current); + } + + return set; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } } From 8bf4a3307ddd607eb6f24d1392cbe3c88bf49f46 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 17:47:54 -0800 Subject: [PATCH 429/862] Adding #if checks for interfaces in BCL. --- .../System/Collections/Generic/IAsyncEnumerable.cs | 4 ++++ .../System/Collections/Generic/IAsyncEnumerator.cs | 4 ++++ Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs index e3f49b713c..5a45f12e90 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerable.cs @@ -5,6 +5,8 @@ // See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface // and the design rationale. (8/30/2017) +#if !HAS_ASYNCENUMERABLE + using System.Threading; namespace System.Collections.Generic @@ -23,3 +25,5 @@ public interface IAsyncEnumerable IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default); } } + +#endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs index aeaa540e0b..f87cf78f41 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Collections/Generic/IAsyncEnumerator.cs @@ -5,6 +5,8 @@ // See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface // and the design rationale. (8/30/2017) +#if !HAS_ASYNCENUMERABLE + using System.Threading.Tasks; namespace System.Collections.Generic @@ -30,3 +32,5 @@ public interface IAsyncEnumerator : IAsyncDisposable ValueTask MoveNextAsync(); } } + +#endif diff --git a/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs b/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs index c98144ef74..0e3a0bf4db 100644 --- a/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/IAsyncDisposable.cs @@ -5,6 +5,8 @@ // See https://github.com/dotnet/csharplang/blob/master/proposals/async-streams.md for the definition of this interface // and the design rationale. (8/30/2017) +#if !HAS_ASYNCDISPOSABLE + using System.Threading.Tasks; namespace System @@ -14,3 +16,5 @@ public interface IAsyncDisposable ValueTask DisposeAsync(); } } + +#endif From cfd11d1c628d8090f897b151d72a2347a70fe551 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 18:03:22 -0800 Subject: [PATCH 430/862] Adding BCL style exception factories. --- .../Source/System.Linq.Async/System/Error.cs | 14 + .../System/Linq/AsyncEnumerable.cs | 4 +- .../System/Linq/AsyncEnumerator.cs | 8 +- .../System/Linq/Operators/Aggregate.cs | 60 +-- .../System/Linq/Operators/All.cs | 16 +- .../System/Linq/Operators/Any.cs | 20 +- .../System/Linq/Operators/AppendPrepend.cs | 4 +- .../Linq/Operators/Average.Generated.cs | 200 ++++----- .../Linq/Operators/Average.Generated.tt | 20 +- .../System/Linq/Operators/Average.cs | 10 +- .../System/Linq/Operators/Cast.cs | 2 +- .../System/Linq/Operators/Concat.cs | 4 +- .../System/Linq/Operators/Contains.cs | 12 +- .../System/Linq/Operators/Count.cs | 20 +- .../System/Linq/Operators/Create.cs | 8 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 6 +- .../System/Linq/Operators/ElementAt.cs | 10 +- .../Linq/Operators/ElementAtOrDefault.cs | 8 +- .../System/Linq/Operators/Except.cs | 10 +- .../System/Linq/Operators/First.cs | 26 +- .../System/Linq/Operators/FirstOrDefault.cs | 20 +- .../System/Linq/Operators/ForEach.cs | 40 +- .../System/Linq/Operators/GroupBy.cs | 112 ++--- .../System/Linq/Operators/GroupJoin.cs | 44 +- .../System/Linq/Operators/Grouping.cs | 2 +- .../System/Linq/Operators/Intersect.cs | 10 +- .../System/Linq/Operators/Join.cs | 44 +- .../System/Linq/Operators/Last.cs | 26 +- .../System/Linq/Operators/LastOrDefault.cs | 20 +- .../System/Linq/Operators/LongCount.cs | 20 +- .../System/Linq/Operators/Max.Generic.cs | 6 +- .../System/Linq/Operators/Max.Primitive.cs | 30 +- .../System/Linq/Operators/Max.cs | 20 +- .../System/Linq/Operators/Min.Generic.cs | 6 +- .../System/Linq/Operators/Min.Primitive.cs | 30 +- .../System/Linq/Operators/Min.cs | 20 +- .../System/Linq/Operators/MinMax.Generated.cs | 400 +++++++++--------- .../System/Linq/Operators/MinMax.Generated.tt | 20 +- .../System/Linq/Operators/OfType.cs | 2 +- .../System/Linq/Operators/OrderBy.cs | 80 ++-- .../System/Linq/Operators/Range.cs | 4 +- .../System/Linq/Operators/Repeat.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/Select.cs | 16 +- .../System/Linq/Operators/SelectMany.cs | 40 +- .../System/Linq/Operators/SequenceEqual.cs | 20 +- .../System/Linq/Operators/Single.cs | 36 +- .../System/Linq/Operators/SingleOrDefault.cs | 28 +- .../System/Linq/Operators/Skip.cs | 2 +- .../System/Linq/Operators/SkipLast.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 16 +- .../System/Linq/Operators/Sum.Generated.cs | 200 ++++----- .../System/Linq/Operators/Sum.Generated.tt | 20 +- .../System/Linq/Operators/Take.cs | 2 +- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 16 +- .../System/Linq/Operators/ToArray.cs | 4 +- .../Linq/Operators/ToAsyncEnumerable.cs | 6 +- .../System/Linq/Operators/ToDictionary.cs | 96 ++--- .../System/Linq/Operators/ToEnumerable.cs | 2 +- .../System/Linq/Operators/ToHashSet.cs | 12 +- .../System/Linq/Operators/ToList.cs | 4 +- .../System/Linq/Operators/ToLookup.cs | 96 ++--- .../System/Linq/Operators/ToObservable.cs | 2 +- .../System/Linq/Operators/Union.cs | 10 +- .../System/Linq/Operators/Where.cs | 16 +- .../System/Linq/Operators/Zip.cs | 12 +- .../System/{Linq => }/Strings.cs | 2 +- .../Tasks/AsyncEnumerableExtensions.cs | 2 +- 70 files changed, 1053 insertions(+), 1037 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Error.cs rename Ix.NET/Source/System.Linq.Async/System/{Linq => }/Strings.cs (96%) diff --git a/Ix.NET/Source/System.Linq.Async/System/Error.cs b/Ix.NET/Source/System.Linq.Async/System/Error.cs new file mode 100644 index 0000000000..b88c939870 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Error.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +namespace System +{ + internal static class Error + { + public static Exception ArgumentNull(string paramName) => new ArgumentNullException(paramName); + public static Exception ArgumentOutOfRange(string paramName) => new ArgumentOutOfRangeException(paramName); + public static Exception NoElements() => new InvalidOperationException(Strings.NO_ELEMENTS); + public static Exception MoreThanOneElement() => new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 364667afc1..0de4fdac19 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -12,7 +12,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return source.Select(x => x); } @@ -20,7 +20,7 @@ public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEn private static IAsyncEnumerable Throw(Exception exception) { if (exception == null) - throw new ArgumentNullException(nameof(exception)); + throw Error.ArgumentNull(nameof(exception)); #if NO_TASK_FROMEXCEPTION var tcs = new TaskCompletionSource(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 29635fa106..95eb65ec3a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -25,7 +25,7 @@ public static class AsyncEnumerator public static IAsyncEnumerator Create(Func> moveNext, Func current, Func dispose) { if (moveNext == null) - throw new ArgumentNullException(nameof(moveNext)); + throw Error.ArgumentNull(nameof(moveNext)); // Note: Many methods pass null in for the second two params. We're assuming // That the caller is responsible and knows what they're doing @@ -45,7 +45,7 @@ public static IAsyncEnumerator Create(Func> moveNext, Func public static ValueTask MoveNextAsync(this IAsyncEnumerator source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); cancellationToken.ThrowIfCancellationRequested(); @@ -63,7 +63,7 @@ public static ValueTask MoveNextAsync(this IAsyncEnumerator source, public static IAsyncEnumerator WithCancellation(this IAsyncEnumerator source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return new AnonymousAsyncIterator( moveNext: () => @@ -85,7 +85,7 @@ public static IAsyncEnumerator WithCancellation(this IAsyncEnumerator s public static IAsyncEnumerable AsEnumerable(this IAsyncEnumerator source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AsyncEnumerable.CreateEnumerable(_ => source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index ec5d414b82..1a83841dc4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -13,9 +13,9 @@ public static partial class AsyncEnumerable public static Task Aggregate(this IAsyncEnumerable source, Func accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, accumulator, CancellationToken.None); } @@ -23,9 +23,9 @@ public static Task Aggregate(this IAsyncEnumerable so public static Task Aggregate(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, accumulator, cancellationToken); } @@ -33,9 +33,9 @@ public static Task Aggregate(this IAsyncEnumerable so public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, accumulator, CancellationToken.None); } @@ -43,9 +43,9 @@ public static Task Aggregate(this IAsyncEnumerable so public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, accumulator, cancellationToken); } @@ -53,9 +53,9 @@ public static Task Aggregate(this IAsyncEnumerable so public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, seed, accumulator, x => x, CancellationToken.None); } @@ -63,9 +63,9 @@ public static Task Aggregate(this IAsyncEnume public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, seed, accumulator, x => x, cancellationToken); } @@ -73,9 +73,9 @@ public static Task Aggregate(this IAsyncEnume public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, seed, accumulator, CancellationToken.None); } @@ -83,9 +83,9 @@ public static Task Aggregate(this IAsyncEnume public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return AggregateCore(source, seed, accumulator, cancellationToken); } @@ -93,11 +93,11 @@ public static Task Aggregate(this IAsyncEnume public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); } @@ -105,11 +105,11 @@ public static Task Aggregate(this IAsync public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } @@ -117,11 +117,11 @@ public static Task Aggregate(this IAsync public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); } @@ -129,11 +129,11 @@ public static Task Aggregate(this IAsync public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } @@ -180,7 +180,7 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable All(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AllCore(source, predicate, CancellationToken.None); } @@ -23,9 +23,9 @@ public static Task All(this IAsyncEnumerable source, Fun public static Task All(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AllCore(source, predicate, CancellationToken.None); } @@ -33,9 +33,9 @@ public static Task All(this IAsyncEnumerable source, Fun public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AllCore(source, predicate, cancellationToken); } @@ -43,9 +43,9 @@ public static Task All(this IAsyncEnumerable source, Fun public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AllCore(source, predicate, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 285cba0b0f..04f16fd53f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -13,9 +13,9 @@ public static partial class AsyncEnumerable public static Task Any(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AnyCore(source, predicate, CancellationToken.None); } @@ -23,9 +23,9 @@ public static Task Any(this IAsyncEnumerable source, Fun public static Task Any(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AnyCore(source, predicate, CancellationToken.None); } @@ -33,7 +33,7 @@ public static Task Any(this IAsyncEnumerable source, Fun public static Task Any(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AnyCore(source, CancellationToken.None); } @@ -41,9 +41,9 @@ public static Task Any(this IAsyncEnumerable source) public static Task Any(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AnyCore(source, predicate, cancellationToken); } @@ -51,9 +51,9 @@ public static Task Any(this IAsyncEnumerable source, Fun public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return AnyCore(source, predicate, cancellationToken); } @@ -61,7 +61,7 @@ public static Task Any(this IAsyncEnumerable source, Fun public static Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AnyCore(source, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index fa44bfb33f..13c0c57612 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Append(this IAsyncEnumerable source, TSource element) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (source is AppendPrependAsyncIterator appendable) { @@ -27,7 +27,7 @@ public static IAsyncEnumerable Append(this IAsyncEnumerable Prepend(this IAsyncEnumerable source, TSource element) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (source is AppendPrependAsyncIterator appendable) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 601636d8a7..576ab7a3d1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Average(this IAsyncEnumerable source) public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Average(this IAsyncEnumerable source, Cancellati public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -49,9 +49,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -69,7 +69,7 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -77,7 +77,7 @@ public static Task Average(this IAsyncEnumerable source) public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -85,9 +85,9 @@ public static Task Average(this IAsyncEnumerable source, Cancellat public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -95,9 +95,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -105,9 +105,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -115,9 +115,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -125,7 +125,7 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -133,7 +133,7 @@ public static Task Average(this IAsyncEnumerable source) public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -141,9 +141,9 @@ public static Task Average(this IAsyncEnumerable source, Cancellat public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -151,9 +151,9 @@ public static Task Average(this IAsyncEnumerable source public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -161,9 +161,9 @@ public static Task Average(this IAsyncEnumerable source public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -171,9 +171,9 @@ public static Task Average(this IAsyncEnumerable source public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -181,7 +181,7 @@ public static Task Average(this IAsyncEnumerable source public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -189,7 +189,7 @@ public static Task Average(this IAsyncEnumerable source) public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -197,9 +197,9 @@ public static Task Average(this IAsyncEnumerable source, Cancell public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -207,9 +207,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -217,9 +217,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -227,9 +227,9 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -237,7 +237,7 @@ public static Task Average(this IAsyncEnumerable sourc public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -245,7 +245,7 @@ public static Task Average(this IAsyncEnumerable source) public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -253,9 +253,9 @@ public static Task Average(this IAsyncEnumerable source, Cance public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -263,9 +263,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -273,9 +273,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -283,9 +283,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -293,7 +293,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -301,7 +301,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -309,9 +309,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -319,9 +319,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -329,9 +329,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -339,9 +339,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -349,7 +349,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -357,7 +357,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -365,9 +365,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -375,9 +375,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -385,9 +385,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -395,9 +395,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -405,7 +405,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -413,7 +413,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -421,9 +421,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -431,9 +431,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -441,9 +441,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -451,9 +451,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -461,7 +461,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -469,7 +469,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -477,9 +477,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -487,9 +487,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -497,9 +497,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -507,9 +507,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -517,7 +517,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -525,7 +525,7 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -533,9 +533,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -543,9 +543,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -553,9 +553,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -563,9 +563,9 @@ public static Task Average(this IAsyncEnumerable sour public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 1bd2bb7cfe..8cc4c4a6f1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -38,7 +38,7 @@ foreach (var o in os) public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, CancellationToken.None); } @@ -46,7 +46,7 @@ foreach (var o in os) public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return AverageCore(source, cancellationToken); } @@ -54,9 +54,9 @@ foreach (var o in os) public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -64,9 +64,9 @@ foreach (var o in os) public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } @@ -74,9 +74,9 @@ foreach (var o in os) public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(CancellationToken.None); } @@ -84,9 +84,9 @@ foreach (var o in os) public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return source.Select(selector).Average(cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index 15a31dd261..1a74989598 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -18,7 +18,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } long sum = e.Current; @@ -86,7 +86,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } var sum = e.Current; @@ -154,7 +154,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } var sum = e.Current; @@ -222,7 +222,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } double sum = e.Current; @@ -287,7 +287,7 @@ private static async Task AverageCore(IAsyncEnumerable source, { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } var sum = e.Current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index 7c576f4645..b0296bbe7d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Cast(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); // Check to see if it already is and short-circuit if (source is IAsyncEnumerable typedSource) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index c976266f15..784e0377ab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Concat(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); return first is ConcatAsyncIterator concatFirst ? concatFirst.Concat(second) : diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index f2ed198d0b..fd696696c4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Contains(this IAsyncEnumerable source, TSource value) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ContainsCore(source, value, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Contains(this IAsyncEnumerable source public static Task Contains(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ContainsCore(source, value, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Contains(this IAsyncEnumerable source public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ContainsCore(source, value, comparer, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Contains(this IAsyncEnumerable source public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ContainsCore(source, value, comparer, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 5bcddb543f..3c75999834 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerable public static Task Count(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return CountCore(source, CancellationToken.None); } @@ -22,7 +22,7 @@ public static Task Count(this IAsyncEnumerable source) public static Task Count(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return CountCore(source, cancellationToken); } @@ -30,9 +30,9 @@ public static Task Count(this IAsyncEnumerable source, Ca public static Task Count(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return CountCore(source, predicate, CancellationToken.None); } @@ -40,9 +40,9 @@ public static Task Count(this IAsyncEnumerable source, Fu public static Task Count(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return CountCore(source, predicate, cancellationToken); } @@ -50,9 +50,9 @@ public static Task Count(this IAsyncEnumerable source, Fu public static Task Count(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return CountCore(source, predicate, CancellationToken.None); } @@ -60,9 +60,9 @@ public static Task Count(this IAsyncEnumerable source, Fu public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return CountCore(source, predicate, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index d3fe1cf08b..b147827ceb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) { if (getEnumerator == null) - throw new ArgumentNullException(nameof(getEnumerator)); + throw Error.ArgumentNull(nameof(getEnumerator)); return new AnonymousAsyncEnumerable(_ => getEnumerator()); } @@ -22,7 +22,7 @@ public static IAsyncEnumerable CreateEnumerable(Func> public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) { if (getEnumerator == null) - throw new ArgumentNullException(nameof(getEnumerator)); + throw Error.ArgumentNull(nameof(getEnumerator)); return new AnonymousAsyncEnumerable(getEnumerator); } @@ -30,7 +30,7 @@ public static IAsyncEnumerable CreateEnumerable(Func CreateEnumerable(Func>> getEnumerator) { if (getEnumerator == null) - throw new ArgumentNullException(nameof(getEnumerator)); + throw Error.ArgumentNull(nameof(getEnumerator)); return new AnonymousAsyncEnumerableWithTask(_ => getEnumerator()); } @@ -38,7 +38,7 @@ public static IAsyncEnumerable CreateEnumerable(Func CreateEnumerable(Func>> getEnumerator) { if (getEnumerator == null) - throw new ArgumentNullException(nameof(getEnumerator)); + throw Error.ArgumentNull(nameof(getEnumerator)); return new AnonymousAsyncEnumerableWithTask(getEnumerator); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 1ac810cf24..9d7f99317a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -16,7 +16,7 @@ public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnume { if (source == null) { - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); } return new DefaultIfEmptyAsyncIterator(source, defaultValue); @@ -26,7 +26,7 @@ public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnume { if (source == null) { - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); } return DefaultIfEmpty(source, default); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 5f078bceea..586f2f2fc9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Distinct(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return source.Distinct(EqualityComparer.Default); } @@ -22,9 +22,9 @@ public static IAsyncEnumerable Distinct(this IAsyncEnumerable< public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new DistinctAsyncIterator(source, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index f97eba0bc3..dd44edf105 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task ElementAt(this IAsyncEnumerable source, int index) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ElementAtCore(source, index, CancellationToken.None); } @@ -21,9 +21,9 @@ public static Task ElementAt(this IAsyncEnumerable so public static Task ElementAt(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); + throw Error.ArgumentOutOfRange(nameof(index)); return ElementAtCore(source, index, cancellationToken); } @@ -47,7 +47,7 @@ private static async Task ElementAtCore(IAsyncEnumerable ElementAtCore(IAsyncEnumerable ElementAtOrDefault(this IAsyncEnumerable source, int index) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); + if (index < 0) + throw Error.ArgumentOutOfRange(nameof(index)); return ElementAtOrDefaultCore(source, index, CancellationToken.None); } @@ -21,9 +23,9 @@ public static Task ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefault(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); + throw Error.ArgumentOutOfRange(nameof(index)); return ElementAtOrDefaultCore(source, index, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 5aa9f72efd..ceaa29afc0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Except(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); return first.Except(second, EqualityComparer.Default); } @@ -24,11 +24,11 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable Except(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new ExceptAsyncIterator(first, second, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 31b45ea4b1..61bce80290 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task First(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return FirstCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task First(this IAsyncEnumerable source public static Task First(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return FirstCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task First(this IAsyncEnumerable source public static Task First(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstCore(source, predicate, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task First(this IAsyncEnumerable source public static Task First(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstCore(source, predicate, cancellationToken); } @@ -49,9 +49,9 @@ public static Task First(this IAsyncEnumerable source public static Task First(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstCore(source, predicate, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task First(this IAsyncEnumerable source public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstCore(source, predicate, cancellationToken); } @@ -70,21 +70,21 @@ private static async Task FirstCore(IAsyncEnumerable { var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); - return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); + return first.HasValue ? first.Value : throw Error.NoElements(); } private static async Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); + return first.HasValue ? first.Value : throw Error.NoElements(); } private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - return first.HasValue ? first.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); + return first.HasValue ? first.Value : throw Error.NoElements(); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 3a5166025e..fb4a4bf2e8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task FirstOrDefault(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return FirstOrDefaultCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return FirstOrDefaultCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstOrDefaultCore(source, predicate, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstOrDefaultCore(source, predicate, cancellationToken); } @@ -49,9 +49,9 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstOrDefaultCore(source, predicate, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return FirstOrDefaultCore(source, predicate, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index efcb7ed9f6..0c6beac147 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -13,9 +13,9 @@ public static partial class AsyncEnumerable public static Task ForEachAsync(this IAsyncEnumerable source, Action action) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, action, CancellationToken.None); } @@ -23,9 +23,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, action, cancellationToken); } @@ -33,9 +33,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Action action) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, action, CancellationToken.None); } @@ -43,9 +43,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, action, cancellationToken); } @@ -53,9 +53,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Func action) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, (x, ct) => action(x), CancellationToken.None); } @@ -63,9 +63,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, (x, ct) => action(x), cancellationToken); } @@ -73,9 +73,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, action, cancellationToken); } @@ -83,9 +83,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Func action) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, (x, i, ct) => action(x, i), CancellationToken.None); } @@ -93,9 +93,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, (x, i, ct) => action(x, i), cancellationToken); } @@ -103,9 +103,9 @@ public static Task ForEachAsync(this IAsyncEnumerable source, public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (action == null) - throw new ArgumentNullException(nameof(action)); + throw Error.ArgumentNull(nameof(action)); return ForEachAsyncCore(source, action, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index b44e43e7ca..3926edcb87 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return new GroupedAsyncEnumerable(source, keySelector, EqualityComparer.Default); } @@ -24,11 +24,11 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupedAsyncEnumerable(source, keySelector, comparer); } @@ -36,9 +36,9 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return new GroupedAsyncEnumerableWithTask(source, keySelector, EqualityComparer.Default); } @@ -46,11 +46,11 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); } @@ -58,11 +58,11 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default); } @@ -70,13 +70,13 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); } @@ -84,11 +84,11 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default); } @@ -96,13 +96,13 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); } @@ -110,11 +110,11 @@ public static IAsyncEnumerable> GroupBy GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); } @@ -122,13 +122,13 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); } @@ -136,11 +136,11 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); } @@ -148,13 +148,13 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); } @@ -162,13 +162,13 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default).Select(g => resultSelector(g.Key, g)); } @@ -176,15 +176,15 @@ public static IAsyncEnumerable GroupBy GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); } @@ -192,13 +192,13 @@ public static IAsyncEnumerable GroupBy GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, Task> resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return source.GroupBy(keySelector, elementSelector, EqualityComparer.Default).Select(g => resultSelector(g.Key, g)); } @@ -206,15 +206,15 @@ public static IAsyncEnumerable GroupBy GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, Task> resultSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index aedb0073e0..2f8e179ed0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -13,15 +13,15 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } @@ -29,17 +29,17 @@ public static IAsyncEnumerable GroupJoin public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } @@ -47,15 +47,15 @@ public static IAsyncEnumerable GroupJoin public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } @@ -63,17 +63,17 @@ public static IAsyncEnumerable GroupJoin public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs index 5cb14ea4d0..e1b12b5f7d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs @@ -76,7 +76,7 @@ TElement IList.this[int index] { if (index < 0 || index >= _count) { - throw new ArgumentOutOfRangeException(nameof(index)); + throw Error.ArgumentOutOfRange(nameof(index)); } return _elements[index]; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index dde526ed90..f6ec04b523 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); return first.Intersect(second, EqualityComparer.Default); } @@ -24,11 +24,11 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new IntersectAsyncIterator(first, second, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 3d494d3e7e..bc01b53b97 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -14,15 +14,15 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } @@ -30,17 +30,17 @@ public static IAsyncEnumerable Join(this public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } @@ -48,15 +48,15 @@ public static IAsyncEnumerable Join(this public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); } @@ -64,17 +64,17 @@ public static IAsyncEnumerable Join(this public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) - throw new ArgumentNullException(nameof(outer)); + throw Error.ArgumentNull(nameof(outer)); if (inner == null) - throw new ArgumentNullException(nameof(inner)); + throw Error.ArgumentNull(nameof(inner)); if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); + throw Error.ArgumentNull(nameof(outerKeySelector)); if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); + throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index a9ebc3b8de..ad8d404609 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Last(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return LastCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Last(this IAsyncEnumerable source) public static Task Last(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return LastCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Last(this IAsyncEnumerable source, public static Task Last(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastCore(source, predicate, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Last(this IAsyncEnumerable source, public static Task Last(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastCore(source, predicate, cancellationToken); } @@ -49,9 +49,9 @@ public static Task Last(this IAsyncEnumerable source, public static Task Last(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastCore(source, predicate, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task Last(this IAsyncEnumerable source, public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastCore(source, predicate, cancellationToken); } @@ -70,21 +70,21 @@ private static async Task LastCore(IAsyncEnumerable s { var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); - return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); + return last.HasValue ? last.Value : throw Error.NoElements(); } private static async Task LastCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); - return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); + return last.HasValue ? last.Value : throw Error.NoElements(); } private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); - return last.HasValue ? last.Value : throw new InvalidOperationException(Strings.NO_ELEMENTS); + return last.HasValue ? last.Value : throw Error.NoElements(); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 2163663875..19251cd5e7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task LastOrDefault(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return LastOrDefaultCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return LastOrDefaultCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastOrDefaultCore(source, predicate, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastOrDefaultCore(source, predicate, cancellationToken); } @@ -49,9 +49,9 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastOrDefaultCore(source, predicate, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LastOrDefaultCore(source, predicate, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index f6e9cf14e3..85c6e7b177 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task LongCount(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return LongCountCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task LongCount(this IAsyncEnumerable sourc public static Task LongCount(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return LongCountCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task LongCount(this IAsyncEnumerable sourc public static Task LongCount(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LongCountCore(source, predicate, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task LongCount(this IAsyncEnumerable sourc public static Task LongCount(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LongCountCore(source, predicate, cancellationToken); } @@ -49,9 +49,9 @@ public static Task LongCount(this IAsyncEnumerable sourc public static Task LongCount(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LongCountCore(source, predicate, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task LongCount(this IAsyncEnumerable sourc public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return LongCountCore(source, predicate, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs index 3cae3cee02..7e13ef9e8a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs @@ -53,7 +53,7 @@ private static async Task MaxCore(IAsyncEnumerable so { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -118,7 +118,7 @@ private static async Task MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable source, Cancellatio { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -115,7 +115,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -204,7 +204,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -306,7 +306,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -403,7 +403,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Can { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -473,7 +473,7 @@ private static async Task MaxCore(IAsyncEnumerable source { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -568,7 +568,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -657,7 +657,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -754,7 +754,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -856,7 +856,7 @@ private static async Task MaxCore(IAsyncEnumerable so { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -926,7 +926,7 @@ private static async Task MaxCore(IAsyncEnumerable source { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -1021,7 +1021,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -1110,7 +1110,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -1207,7 +1207,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -1309,7 +1309,7 @@ private static async Task MaxCore(IAsyncEnumerable so { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 573e71e1e6..e1caec504d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Max(this IAsyncEnumerable source) public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Max(this IAsyncEnumerable public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -49,9 +49,9 @@ public static Task Max(this IAsyncEnumerable public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task Max(this IAsyncEnumerable public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs index 50a0ec3540..6d7288c287 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs @@ -53,7 +53,7 @@ private static async Task MinCore(IAsyncEnumerable so { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -118,7 +118,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Cancellatio { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -97,7 +97,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -170,7 +170,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -260,7 +260,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cance { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -341,7 +341,7 @@ private static async Task MinCore(IAsyncEnumerable source, Can { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = e.Current; @@ -411,7 +411,7 @@ private static async Task MinCore(IAsyncEnumerable source { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -488,7 +488,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -561,7 +561,7 @@ private static async Task MinCore(IAsyncEnumerable sour { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -651,7 +651,7 @@ private static async Task MinCore(IAsyncEnumerable sou { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -732,7 +732,7 @@ private static async Task MinCore(IAsyncEnumerable so { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = selector(e.Current); @@ -802,7 +802,7 @@ private static async Task MinCore(IAsyncEnumerable source { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -879,7 +879,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -952,7 +952,7 @@ private static async Task MinCore(IAsyncEnumerable sour { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -1042,7 +1042,7 @@ private static async Task MinCore(IAsyncEnumerable sou { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); @@ -1123,7 +1123,7 @@ private static async Task MinCore(IAsyncEnumerable so { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } value = await selector(e.Current).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 2b88ac6bf6..a32add57cd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Min(this IAsyncEnumerable source) public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Min(this IAsyncEnumerable public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -49,9 +49,9 @@ public static Task Min(this IAsyncEnumerable public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task Min(this IAsyncEnumerable public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 1347553e97..201b5f1fbf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Max(this IAsyncEnumerable source) public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Max(this IAsyncEnumerable source, CancellationToken public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -49,9 +49,9 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -69,7 +69,7 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -77,7 +77,7 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -85,9 +85,9 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -95,9 +95,9 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -105,9 +105,9 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -115,9 +115,9 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -125,7 +125,7 @@ public static Task Max(this IAsyncEnumerable source, Func public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -133,7 +133,7 @@ public static Task Max(this IAsyncEnumerable source) public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -141,9 +141,9 @@ public static Task Max(this IAsyncEnumerable source, CancellationTok public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -151,9 +151,9 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -161,9 +161,9 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -171,9 +171,9 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -181,7 +181,7 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -189,7 +189,7 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -197,9 +197,9 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -207,9 +207,9 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -217,9 +217,9 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -227,9 +227,9 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -237,7 +237,7 @@ public static Task Max(this IAsyncEnumerable source, Fun public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -245,7 +245,7 @@ public static Task Max(this IAsyncEnumerable source) public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -253,9 +253,9 @@ public static Task Max(this IAsyncEnumerable source, CancellationT public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -263,9 +263,9 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -273,9 +273,9 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -283,9 +283,9 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -293,7 +293,7 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -301,7 +301,7 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -309,9 +309,9 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -319,9 +319,9 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -329,9 +329,9 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -339,9 +339,9 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -349,7 +349,7 @@ public static Task Max(this IAsyncEnumerable source, Fu public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -357,7 +357,7 @@ public static Task Max(this IAsyncEnumerable source) public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -365,9 +365,9 @@ public static Task Max(this IAsyncEnumerable source, Cancellatio public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -375,9 +375,9 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -385,9 +385,9 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -395,9 +395,9 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -405,7 +405,7 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -413,7 +413,7 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -421,9 +421,9 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -431,9 +431,9 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -441,9 +441,9 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -451,9 +451,9 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -461,7 +461,7 @@ public static Task Max(this IAsyncEnumerable source, F public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -469,7 +469,7 @@ public static Task Max(this IAsyncEnumerable source) public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -477,9 +477,9 @@ public static Task Max(this IAsyncEnumerable source, Cancellat public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -487,9 +487,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -497,9 +497,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -507,9 +507,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -517,7 +517,7 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, CancellationToken.None); } @@ -525,7 +525,7 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, cancellationToken); } @@ -533,9 +533,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -543,9 +543,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -553,9 +553,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, CancellationToken.None); } @@ -563,9 +563,9 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MaxCore(source, selector, cancellationToken); } @@ -573,7 +573,7 @@ public static Task Max(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -581,7 +581,7 @@ public static Task Min(this IAsyncEnumerable source) public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -589,9 +589,9 @@ public static Task Min(this IAsyncEnumerable source, CancellationToken public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -599,9 +599,9 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -609,9 +609,9 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -619,9 +619,9 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -629,7 +629,7 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -637,7 +637,7 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -645,9 +645,9 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -655,9 +655,9 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -665,9 +665,9 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -675,9 +675,9 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -685,7 +685,7 @@ public static Task Min(this IAsyncEnumerable source, Func public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -693,7 +693,7 @@ public static Task Min(this IAsyncEnumerable source) public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -701,9 +701,9 @@ public static Task Min(this IAsyncEnumerable source, CancellationTok public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -711,9 +711,9 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -721,9 +721,9 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -731,9 +731,9 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -741,7 +741,7 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -749,7 +749,7 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -757,9 +757,9 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -767,9 +767,9 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -777,9 +777,9 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -787,9 +787,9 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -797,7 +797,7 @@ public static Task Min(this IAsyncEnumerable source, Fun public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -805,7 +805,7 @@ public static Task Min(this IAsyncEnumerable source) public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -813,9 +813,9 @@ public static Task Min(this IAsyncEnumerable source, CancellationT public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -823,9 +823,9 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -833,9 +833,9 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -843,9 +843,9 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -853,7 +853,7 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -861,7 +861,7 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -869,9 +869,9 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -879,9 +879,9 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -889,9 +889,9 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -899,9 +899,9 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -909,7 +909,7 @@ public static Task Min(this IAsyncEnumerable source, Fu public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -917,7 +917,7 @@ public static Task Min(this IAsyncEnumerable source) public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -925,9 +925,9 @@ public static Task Min(this IAsyncEnumerable source, Cancellatio public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -935,9 +935,9 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -945,9 +945,9 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -955,9 +955,9 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -965,7 +965,7 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -973,7 +973,7 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -981,9 +981,9 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -991,9 +991,9 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -1001,9 +1001,9 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -1011,9 +1011,9 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -1021,7 +1021,7 @@ public static Task Min(this IAsyncEnumerable source, F public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -1029,7 +1029,7 @@ public static Task Min(this IAsyncEnumerable source) public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -1037,9 +1037,9 @@ public static Task Min(this IAsyncEnumerable source, Cancellat public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -1047,9 +1047,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -1057,9 +1057,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -1067,9 +1067,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -1077,7 +1077,7 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, CancellationToken.None); } @@ -1085,7 +1085,7 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, cancellationToken); } @@ -1093,9 +1093,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -1103,9 +1103,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } @@ -1113,9 +1113,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, CancellationToken.None); } @@ -1123,9 +1123,9 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return MinCore(source, selector, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 4a248aa680..0bdde028c4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -25,7 +25,7 @@ foreach (var m in new[] { "Max", "Min" }) public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return <#=m#>Core(source, CancellationToken.None); } @@ -33,7 +33,7 @@ foreach (var m in new[] { "Max", "Min" }) public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return <#=m#>Core(source, cancellationToken); } @@ -41,9 +41,9 @@ foreach (var m in new[] { "Max", "Min" }) public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return <#=m#>Core(source, selector, CancellationToken.None); } @@ -51,9 +51,9 @@ foreach (var m in new[] { "Max", "Min" }) public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return <#=m#>Core(source, selector, cancellationToken); } @@ -61,9 +61,9 @@ foreach (var m in new[] { "Max", "Min" }) public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return <#=m#>Core(source, selector, CancellationToken.None); } @@ -71,9 +71,9 @@ foreach (var m in new[] { "Max", "Min" }) public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return <#=m#>Core(source, selector, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index 65420ec677..1b1b0ddd13 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable OfType(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return source.Where(x => x is TType).Cast(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index d78eee1ff1..65d8b688a0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -12,9 +12,9 @@ public static partial class AsyncEnumerable public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.OrderBy(keySelector, Comparer.Default); } @@ -22,9 +22,9 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.OrderBy(keySelector, Comparer.Default); } @@ -32,22 +32,22 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); } public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); } @@ -55,9 +55,9 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.OrderByDescending(keySelector, Comparer.Default); } @@ -65,9 +65,9 @@ public static IOrderedAsyncEnumerable OrderByDescending( public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.OrderByDescending(keySelector, Comparer.Default); } @@ -75,11 +75,11 @@ public static IOrderedAsyncEnumerable OrderByDescending( public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); } @@ -87,11 +87,11 @@ public static IOrderedAsyncEnumerable OrderByDescending( public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); } @@ -99,9 +99,9 @@ public static IOrderedAsyncEnumerable OrderByDescending( public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.ThenBy(keySelector, Comparer.Default); } @@ -109,9 +109,9 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.ThenBy(keySelector, Comparer.Default); } @@ -119,11 +119,11 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } @@ -131,11 +131,11 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } @@ -143,9 +143,9 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.ThenByDescending(keySelector, Comparer.Default); } @@ -153,9 +153,9 @@ public static IOrderedAsyncEnumerable ThenByDescending(t public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.ThenByDescending(keySelector, Comparer.Default); } @@ -163,11 +163,11 @@ public static IOrderedAsyncEnumerable ThenByDescending(t public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } @@ -175,11 +175,11 @@ public static IOrderedAsyncEnumerable ThenByDescending(t public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 58c5f387eb..84645abbd9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -14,11 +14,11 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Range(int start, int count) { if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); + throw Error.ArgumentOutOfRange(nameof(count)); var end = (long)start + count - 1L; if (count < 0 || end > int.MaxValue) - throw new ArgumentOutOfRangeException(nameof(count)); + throw Error.ArgumentOutOfRange(nameof(count)); if (count == 0) return Empty(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 791ce0425e..b8166a1a9c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Repeat(TResult element, int count) { if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); + throw Error.ArgumentOutOfRange(nameof(count)); return new RepeatAsyncIterator(element, count); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index 43203885a5..317233b5e7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -16,7 +16,7 @@ public static IAsyncEnumerable Reverse(this IAsyncEnumerable(source); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index afa8688965..f29b997b16 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); if (source is AsyncIterator iterator) { @@ -34,9 +34,9 @@ public static IAsyncEnumerable Select(this IAsyncEnum public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new SelectEnumerableWithIndexAsyncIterator(source, selector); } @@ -44,9 +44,9 @@ public static IAsyncEnumerable Select(this IAsyncEnum public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); if (source is AsyncIterator iterator) { @@ -64,9 +64,9 @@ public static IAsyncEnumerable Select(this IAsyncEnum public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new SelectEnumerableWithIndexAsyncIteratorWithTask(source, selector); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 2692af7d0b..dcac5fd1a7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new SelectManyAsyncIterator(source, selector); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable SelectMany(this IAsync public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new SelectManyAsyncIteratorWithTask(source, selector); } @@ -34,9 +34,9 @@ public static IAsyncEnumerable SelectMany(this IAsync public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new SelectManyWithIndexAsyncIterator(source, selector); } @@ -44,9 +44,9 @@ public static IAsyncEnumerable SelectMany(this IAsync public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new SelectManyWithIndexAsyncIteratorWithTask(source, selector); } @@ -54,11 +54,11 @@ public static IAsyncEnumerable SelectMany(this IAsync public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return new SelectManyAsyncIterator(source, selector, resultSelector); } @@ -66,11 +66,11 @@ public static IAsyncEnumerable SelectMany SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return new SelectManyAsyncIteratorWithTask(source, selector, resultSelector); } @@ -78,11 +78,11 @@ public static IAsyncEnumerable SelectMany SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return new SelectManyWithIndexAsyncIterator(source, selector, resultSelector); } @@ -90,11 +90,11 @@ public static IAsyncEnumerable SelectMany SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return new SelectManyWithIndexAsyncIteratorWithTask(source, selector, resultSelector); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index d065679bcc..56c0550845 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -14,17 +14,17 @@ public static Task SequenceEqual(this IAsyncEnumerable f { if (first == null) { - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); } if (second == null) { - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); } if (comparer == null) { - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); } return SequenceEqual(first, second, comparer, CancellationToken.None); @@ -34,12 +34,12 @@ public static Task SequenceEqual(this IAsyncEnumerable f { if (first == null) { - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); } if (second == null) { - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); } return SequenceEqual(first, second, CancellationToken.None); @@ -50,17 +50,17 @@ public static Task SequenceEqual(this IAsyncEnumerable f { if (first == null) { - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); } if (second == null) { - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); } if (comparer == null) { - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); } return SequenceEqualCore(first, second, comparer, cancellationToken); @@ -70,12 +70,12 @@ public static Task SequenceEqual(this IAsyncEnumerable f { if (first == null) { - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); } if (second == null) { - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); } return first.SequenceEqual(second, EqualityComparer.Default, cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index d7f149697e..7a1be099f0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Single(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SingleCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Single(this IAsyncEnumerable sourc public static Task Single(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SingleCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Single(this IAsyncEnumerable sourc public static Task Single(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleCore(source, predicate, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Single(this IAsyncEnumerable sourc public static Task Single(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleCore(source, predicate, cancellationToken); } @@ -49,9 +49,9 @@ public static Task Single(this IAsyncEnumerable sourc public static Task Single(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleCore(source, predicate, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task Single(this IAsyncEnumerable sourc public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleCore(source, predicate, cancellationToken); } @@ -72,11 +72,11 @@ private static async Task SingleCore(IAsyncEnumerable { switch (list.Count) { - case 0: throw new InvalidOperationException(Strings.NO_ELEMENTS); + case 0: throw Error.NoElements(); case 1: return list[0]; } - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } var e = source.GetAsyncEnumerator(cancellationToken); @@ -85,13 +85,13 @@ private static async Task SingleCore(IAsyncEnumerable { if (!await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } var result = e.Current; if (await e.MoveNextAsync().ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } return result; @@ -118,7 +118,7 @@ private static async Task SingleCore(IAsyncEnumerable { if (predicate(e.Current)) { - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } } @@ -126,7 +126,7 @@ private static async Task SingleCore(IAsyncEnumerable } } - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } finally { @@ -150,7 +150,7 @@ private static async Task SingleCore(IAsyncEnumerable { if (await predicate(e.Current).ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } } @@ -158,7 +158,7 @@ private static async Task SingleCore(IAsyncEnumerable } } - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); } finally { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index b564ebdfde..8d2f33e2c6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task SingleOrDefault(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SingleOrDefaultCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SingleOrDefaultCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleOrDefaultCore(source, predicate, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleOrDefaultCore(source, predicate, cancellationToken); } @@ -49,9 +49,9 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleOrDefaultCore(source, predicate, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return SingleOrDefaultCore(source, predicate, cancellationToken); } @@ -76,7 +76,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable case 1: return list[0]; } - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } var e = source.GetAsyncEnumerator(cancellationToken); @@ -100,7 +100,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable await e.DisposeAsync().ConfigureAwait(false); } - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -119,7 +119,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable { if (predicate(e.Current)) { - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } } @@ -151,7 +151,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable { if (await predicate(e.Current).ConfigureAwait(false)) { - throw new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + throw Error.MoreThanOneElement(); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs index c66d391abc..ffa09fb1fc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Skip(this IAsyncEnumerable source, int count) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (count <= 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index e4feec1d02..0209339c2b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable SkipLast(this IAsyncEnumerable source, int count) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (count <= 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 60dc3fe48e..4d8c2b1bbd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new SkipWhileAsyncIterator(source, predicate); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new SkipWhileWithIndexAsyncIterator(source, predicate); } @@ -34,9 +34,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new SkipWhileAsyncIteratorWithTask(source, predicate); } @@ -44,9 +44,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 7746a1276f..f6da90f919 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Sum(this IAsyncEnumerable source) public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -29,9 +29,9 @@ public static Task Sum(this IAsyncEnumerable source, CancellationToken public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task Sum(this IAsyncEnumerable source, Func public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -49,9 +49,9 @@ public static Task Sum(this IAsyncEnumerable source, Func public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -59,9 +59,9 @@ public static Task Sum(this IAsyncEnumerable source, Func public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -145,7 +145,7 @@ private static async Task SumCore(IAsyncEnumerable source public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -153,7 +153,7 @@ public static Task Sum(this IAsyncEnumerable source) public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -161,9 +161,9 @@ public static Task Sum(this IAsyncEnumerable source, CancellationTok public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -171,9 +171,9 @@ public static Task Sum(this IAsyncEnumerable source, Fun public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -181,9 +181,9 @@ public static Task Sum(this IAsyncEnumerable source, Fun public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -191,9 +191,9 @@ public static Task Sum(this IAsyncEnumerable source, Fun public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -277,7 +277,7 @@ private static async Task SumCore(IAsyncEnumerable sourc public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -285,7 +285,7 @@ public static Task Sum(this IAsyncEnumerable source) public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -293,9 +293,9 @@ public static Task Sum(this IAsyncEnumerable source, CancellationT public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -303,9 +303,9 @@ public static Task Sum(this IAsyncEnumerable source, Fu public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -313,9 +313,9 @@ public static Task Sum(this IAsyncEnumerable source, Fu public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -323,9 +323,9 @@ public static Task Sum(this IAsyncEnumerable source, Fu public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -400,7 +400,7 @@ private static async Task SumCore(IAsyncEnumerable sour public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -408,7 +408,7 @@ public static Task Sum(this IAsyncEnumerable source) public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -416,9 +416,9 @@ public static Task Sum(this IAsyncEnumerable source, Cancellatio public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -426,9 +426,9 @@ public static Task Sum(this IAsyncEnumerable source, F public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -436,9 +436,9 @@ public static Task Sum(this IAsyncEnumerable source, F public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -446,9 +446,9 @@ public static Task Sum(this IAsyncEnumerable source, F public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -523,7 +523,7 @@ private static async Task SumCore(IAsyncEnumerable sou public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -531,7 +531,7 @@ public static Task Sum(this IAsyncEnumerable source) public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -539,9 +539,9 @@ public static Task Sum(this IAsyncEnumerable source, Cancellat public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -549,9 +549,9 @@ public static Task Sum(this IAsyncEnumerable source, public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -559,9 +559,9 @@ public static Task Sum(this IAsyncEnumerable source, public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -569,9 +569,9 @@ public static Task Sum(this IAsyncEnumerable source, public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -646,7 +646,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -654,7 +654,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -662,9 +662,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -672,9 +672,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -682,9 +682,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -692,9 +692,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -778,7 +778,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -786,7 +786,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -794,9 +794,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -804,9 +804,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -814,9 +814,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -824,9 +824,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -910,7 +910,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -918,7 +918,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -926,9 +926,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -936,9 +936,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -946,9 +946,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -956,9 +956,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -1033,7 +1033,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -1041,7 +1041,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -1049,9 +1049,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -1059,9 +1059,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -1069,9 +1069,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -1079,9 +1079,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -1156,7 +1156,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -1164,7 +1164,7 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -1172,9 +1172,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -1182,9 +1182,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -1192,9 +1192,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -1202,9 +1202,9 @@ private static async Task SumCore(IAsyncEnumerable so public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 286b1dc127..d3c9e2fe64 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -38,7 +38,7 @@ foreach (var o in os) public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, CancellationToken.None); } @@ -46,7 +46,7 @@ foreach (var o in os) public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return SumCore(source, cancellationToken); } @@ -54,9 +54,9 @@ foreach (var o in os) public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -64,9 +64,9 @@ foreach (var o in os) public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } @@ -74,9 +74,9 @@ foreach (var o in os) public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, CancellationToken.None); } @@ -84,9 +84,9 @@ foreach (var o in os) public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return SumCore(source, selector, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs index 3a8c1af852..c4335d5afd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Take.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Take(this IAsyncEnumerable source, int count) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (count <= 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 2e79a38d1c..e1db4f4579 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable TakeLast(this IAsyncEnumerable source, int count) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (count <= 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 2551f38f32..dab9997c33 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new TakeWhileAsyncIterator(source, predicate); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new TakeWhileWithIndexAsyncIterator(source, predicate); } @@ -34,9 +34,9 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new TakeWhileAsyncIteratorWithTask(source, predicate); } @@ -44,9 +44,9 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs index 1d506418be..3f660071ea 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task ToArray(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ToArray(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task ToArray(this IAsyncEnumerable so public static Task ToArray(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (source is IAsyncIListProvider arrayProvider) return arrayProvider.ToArrayAsync(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index b1711092e8..e861b6acf4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -15,7 +15,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable ToAsyncEnumerable(this IEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); // optimize these adapters for lists and collections if (source is IList list) @@ -30,7 +30,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IEnumera public static IAsyncEnumerable ToAsyncEnumerable(this Task task) { if (task == null) - throw new ArgumentNullException(nameof(task)); + throw Error.ArgumentNull(nameof(task)); return CreateEnumerable( _ => @@ -56,7 +56,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task ToAsyncEnumerable(this IObservable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return CreateEnumerable( ct => diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 946d260a6f..adb527afe5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -13,9 +13,9 @@ public static partial class AsyncEnumerable public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, CancellationToken.None); } @@ -23,9 +23,9 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); } @@ -33,9 +33,9 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, CancellationToken.None); } @@ -43,9 +43,9 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); } @@ -53,11 +53,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => x, comparer, CancellationToken.None); } @@ -65,11 +65,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); } @@ -77,11 +77,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None); } @@ -89,11 +89,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken); } @@ -101,11 +101,11 @@ public static Task> ToDictionary(this I public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); } @@ -113,11 +113,11 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } @@ -125,11 +125,11 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); } @@ -137,11 +137,11 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } @@ -149,13 +149,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } @@ -163,13 +163,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, elementSelector, comparer, cancellationToken); } @@ -177,13 +177,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } @@ -191,13 +191,13 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, elementSelector, comparer, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs index e5221c30c1..876efe1c3a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerable public static IEnumerable ToEnumerable(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ToEnumerableCore(source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 7f3f60f58d..d1001f40a8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task> ToHashSet(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ToHashSetCore(source, EqualityComparer.Default, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToHashSet(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ToHashSetCore(source, EqualityComparer.Default, cancellationToken); } @@ -29,9 +29,9 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToHashSetCore(source, comparer, CancellationToken.None); } @@ -39,9 +39,9 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToHashSetCore(source, comparer, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index d90223abf8..e29c2ebcee 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerable public static Task> ToList(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ToListCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task> ToList(this IAsyncEnumerable public static Task> ToList(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return ToListCore(source, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 57062cc2aa..26ec0b9942 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -15,9 +15,9 @@ public static partial class AsyncEnumerable public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return ToLookup(source, keySelector, CancellationToken.None); } @@ -25,9 +25,9 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.ToLookup(keySelector, x => x, EqualityComparer.Default, cancellationToken); } @@ -35,9 +35,9 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return ToLookup(source, keySelector, CancellationToken.None); } @@ -45,9 +45,9 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return source.ToLookup(keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); } @@ -55,11 +55,11 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToLookup(source, keySelector, comparer, CancellationToken.None); } @@ -67,11 +67,11 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.ToLookup(keySelector, x => x, comparer, cancellationToken); } @@ -79,11 +79,11 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToLookup(source, keySelector, comparer, CancellationToken.None); } @@ -91,11 +91,11 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return source.ToLookup(keySelector, x => Task.FromResult(x), comparer, cancellationToken); } @@ -103,11 +103,11 @@ public static Task> ToLookup(this IAsyncEn public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return ToLookup(source, keySelector, elementSelector, CancellationToken.None); } @@ -115,11 +115,11 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return source.ToLookup(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } @@ -127,11 +127,11 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return ToLookup(source, keySelector, elementSelector, CancellationToken.None); } @@ -139,11 +139,11 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); return source.ToLookup(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } @@ -151,13 +151,13 @@ public static Task> ToLookup(th public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); } @@ -165,13 +165,13 @@ public static Task> ToLookup(th public static async Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); var lookup = await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); @@ -181,13 +181,13 @@ public static async Task> ToLookup> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); } @@ -195,13 +195,13 @@ public static Task> ToLookup(th public static async Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + throw Error.ArgumentNull(nameof(elementSelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); var lookup = await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index 5e1952e2fe..f2e74d95bd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerable public static IObservable ToObservable(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return new ToObservableObservable(source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 0c42539802..92d172ea04 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); return first.Union(second, EqualityComparer.Default); } @@ -24,11 +24,11 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return first is UnionAsyncIterator union && AreEqualityComparersEqual(comparer, union._comparer) ? union.Union(second) : new UnionAsyncIterator2(first, second, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index af608a1313..f6771fe2ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -15,12 +15,12 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable iterator) @@ -36,12 +36,12 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable(source, predicate); @@ -50,9 +50,9 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); if (source is AsyncIterator iterator) { @@ -66,9 +66,9 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + throw Error.ArgumentNull(nameof(predicate)); return new WhereEnumerableWithIndexAsyncIteratorWithTask(source, predicate); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 25add3430b..c4b188d091 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -14,11 +14,11 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func selector) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new ZipAsyncIterator(first, second, selector); } @@ -26,11 +26,11 @@ public static IAsyncEnumerable Zip(this IAsyn public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new ZipAsyncIteratorWithTask(first, second, selector); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Strings.cs b/Ix.NET/Source/System.Linq.Async/System/Strings.cs similarity index 96% rename from Ix.NET/Source/System.Linq.Async/System/Linq/Strings.cs rename to Ix.NET/Source/System.Linq.Async/System/Strings.cs index 755114023d..49611e32f4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Strings.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Strings.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -namespace System.Linq +namespace System { internal static class Strings { diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index 5de431395a..81f11a8432 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -14,7 +14,7 @@ public static class AsyncEnumerableExtensions public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerable enumerable, bool continueOnCapturedContext) { if (enumerable == null) - throw new ArgumentNullException(nameof(enumerable)); + throw Error.ArgumentNull(nameof(enumerable)); return new ConfiguredAsyncEnumerable(enumerable, continueOnCapturedContext); } From b5a356a74596f2069468ffdfadeea73106bfbf37 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 18:08:56 -0800 Subject: [PATCH 431/862] Remove some unnecessary cancellation token passing. --- .../System/Linq/Operators/Distinct.cs | 4 ++-- .../System.Interactive.Async/System/Linq/Operators/Max.cs | 4 ++-- .../System.Interactive.Async/System/Linq/Operators/Min.cs | 4 ++-- .../System/Linq/Operators/MinBy.cs | 8 ++++---- .../System.Linq.Async/System/Linq/AsyncListPartition.cs | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 2f09a8372a..d87ce0a44d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -193,7 +193,7 @@ private async Task> FillSetAsync(CancellationToken cancellationTok try { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var item = enu.Current; if (s.Add(_keySelector(item))) @@ -339,7 +339,7 @@ private async Task> FillSetAsync(CancellationToken cancellationTok try { - while (await enu.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await enu.MoveNextAsync().ConfigureAwait(false)) { var item = enu.Current; if (s.Add(await _keySelector(item).ConfigureAwait(false))) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 31f6dc69bd..ad3cfe2250 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -36,12 +36,12 @@ private static async Task MaxCore(IAsyncEnumerable so try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); var max = e.Current; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var cur = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 18f0d28973..4866e48cc8 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -36,12 +36,12 @@ private static async Task MinCore(IAsyncEnumerable so try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); var min = e.Current; - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var cur = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 7f849d3d3f..937b8df1fb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -116,14 +116,14 @@ private static async Task> ExtremaBy(IAsyncEnumera try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); var current = e.Current; var resKey = keySelector(current); result.Add(current); - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var cur = e.Current; var key = keySelector(cur); @@ -156,14 +156,14 @@ private static async Task> ExtremaBy(IAsyncEnumera try { - if (!await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) throw new InvalidOperationException(Strings.NO_ELEMENTS); var current = e.Current; var resKey = await keySelector(current).ConfigureAwait(false); result.Add(current); - while (await e.MoveNextAsync(cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { var cur = e.Current; var key = await keySelector(cur).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 86e6f537ac..38ca225068 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -144,11 +144,11 @@ public Task ToArrayAsync(CancellationToken cancellationToken) { return Task.FromResult( #if NO_ARRAY_EMPTY - EmptyArray.Value + EmptyArray.Value #else - Array.Empty() + Array.Empty() #endif - ); + ); } var array = new TSource[count]; From 9f00d59e695158a02f20f2ea118b3a0b5957c747 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 18:18:15 -0800 Subject: [PATCH 432/862] Some stylistic consistency. --- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 --- .../System/Linq/Operators/Reverse.cs | 2 -- .../System/Linq/Operators/SequenceEqual.cs | 26 ------------------- .../System/Linq/Operators/Where.cs | 10 ------- 4 files changed, 42 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 9d7f99317a..23f190fbef 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -15,9 +15,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source, TSource defaultValue) { if (source == null) - { throw Error.ArgumentNull(nameof(source)); - } return new DefaultIfEmptyAsyncIterator(source, defaultValue); } @@ -25,9 +23,7 @@ public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnume public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source) { if (source == null) - { throw Error.ArgumentNull(nameof(source)); - } return DefaultIfEmpty(source, default); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index 317233b5e7..0f771fd1d9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -15,9 +15,7 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Reverse(this IAsyncEnumerable source) { if (source == null) - { throw Error.ArgumentNull(nameof(source)); - } return new ReverseAsyncIterator(source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 56c0550845..0425ee1434 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -13,19 +13,11 @@ public static partial class AsyncEnumerable public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) - { throw Error.ArgumentNull(nameof(first)); - } - if (second == null) - { throw Error.ArgumentNull(nameof(second)); - } - if (comparer == null) - { throw Error.ArgumentNull(nameof(comparer)); - } return SequenceEqual(first, second, comparer, CancellationToken.None); } @@ -33,14 +25,9 @@ public static Task SequenceEqual(this IAsyncEnumerable f public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - { throw Error.ArgumentNull(nameof(first)); - } - if (second == null) - { throw Error.ArgumentNull(nameof(second)); - } return SequenceEqual(first, second, CancellationToken.None); } @@ -49,19 +36,11 @@ public static Task SequenceEqual(this IAsyncEnumerable f public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first == null) - { throw Error.ArgumentNull(nameof(first)); - } - if (second == null) - { throw Error.ArgumentNull(nameof(second)); - } - if (comparer == null) - { throw Error.ArgumentNull(nameof(comparer)); - } return SequenceEqualCore(first, second, comparer, cancellationToken); } @@ -69,14 +48,9 @@ public static Task SequenceEqual(this IAsyncEnumerable f public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) - { throw Error.ArgumentNull(nameof(first)); - } - if (second == null) - { throw Error.ArgumentNull(nameof(second)); - } return first.SequenceEqual(second, EqualityComparer.Default, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index f6771fe2ae..e268b23e53 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -14,14 +14,9 @@ public static partial class AsyncEnumerable public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func predicate) { if (source == null) - { throw Error.ArgumentNull(nameof(source)); - } - if (predicate == null) - { throw Error.ArgumentNull(nameof(predicate)); - } if (source is AsyncIterator iterator) { @@ -35,14 +30,9 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Where(this IAsyncEnumerable source, Func predicate) { if (source == null) - { throw Error.ArgumentNull(nameof(source)); - } - if (predicate == null) - { throw Error.ArgumentNull(nameof(predicate)); - } return new WhereEnumerableWithIndexAsyncIterator(source, predicate); } From 3c85a09ad42948afe48b1b1b0630fdea3a87035a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 19:45:19 -0800 Subject: [PATCH 433/862] Removal of some Create overloads. --- .../System/Linq/Operators/Defer.cs | 95 ++++++++++++++- .../System/Linq/Operators/CreateEnumerable.cs | 1 - .../System/Linq/Operators/Create.cs | 114 ------------------ 3 files changed, 94 insertions(+), 116 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index c47b0ca7ab..8e74254dc0 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; using static System.Linq.AsyncEnumerable; @@ -23,7 +25,98 @@ public static IAsyncEnumerable Defer(Func (await factory().ConfigureAwait(false)).GetAsyncEnumerator(ct)); + return new AnonymousAsyncEnumerableWithTask(async ct => (await factory().ConfigureAwait(false)).GetAsyncEnumerator(ct)); } + + private sealed class AnonymousAsyncEnumerableWithTask : IAsyncEnumerable + { + private readonly Func>> _getEnumerator; + + public AnonymousAsyncEnumerableWithTask(Func>> getEnumerator) + { + Debug.Assert(getEnumerator != null); + + _getEnumerator = getEnumerator; + } + + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new Enumerator(_getEnumerator, cancellationToken); + + private sealed class Enumerator : IAsyncEnumerator + { + private Func>> _getEnumerator; + private readonly CancellationToken _cancellationToken; + private IAsyncEnumerator _enumerator; + + public Enumerator(Func>> getEnumerator, CancellationToken cancellationToken) + { + Debug.Assert(getEnumerator != null); + + _getEnumerator = getEnumerator; + _cancellationToken = cancellationToken; + } + + public T Current + { + get + { + if (_enumerator == null) + throw new InvalidOperationException(); + + return _enumerator.Current; + } + } + + public async ValueTask DisposeAsync() + { + var old = Interlocked.Exchange(ref _enumerator, DisposedEnumerator.Instance); + + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + } + } + + public ValueTask MoveNextAsync() + { + if (_enumerator == null) + { + return InitAndMoveNextAsync(); + } + + return _enumerator.MoveNextAsync(); + } + + private async ValueTask InitAndMoveNextAsync() + { + try + { + _enumerator = await _getEnumerator(_cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); + throw; + } + finally + { + _getEnumerator = null; + } + + return await _enumerator.MoveNextAsync().ConfigureAwait(false); + } + + private sealed class DisposedEnumerator : IAsyncEnumerator + { + public static readonly DisposedEnumerator Instance = new DisposedEnumerator(); + + public T Current => throw new ObjectDisposedException("this"); + + public ValueTask DisposeAsync() => TaskExt.CompletedTask; + + public ValueTask MoveNextAsync() => throw new ObjectDisposedException("this"); + } + } + } + } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs index a123dbf08c..b047e84247 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs @@ -15,7 +15,6 @@ public class CreateEnumerable : AsyncEnumerableTests [Fact] public void CreateEnumerable_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index b147827ceb..97f0299391 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -11,14 +11,6 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) - { - if (getEnumerator == null) - throw Error.ArgumentNull(nameof(getEnumerator)); - - return new AnonymousAsyncEnumerable(_ => getEnumerator()); - } - public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) { if (getEnumerator == null) @@ -27,22 +19,6 @@ public static IAsyncEnumerable CreateEnumerable(Func(getEnumerator); } - public static IAsyncEnumerable CreateEnumerable(Func>> getEnumerator) - { - if (getEnumerator == null) - throw Error.ArgumentNull(nameof(getEnumerator)); - - return new AnonymousAsyncEnumerableWithTask(_ => getEnumerator()); - } - - public static IAsyncEnumerable CreateEnumerable(Func>> getEnumerator) - { - if (getEnumerator == null) - throw Error.ArgumentNull(nameof(getEnumerator)); - - return new AnonymousAsyncEnumerableWithTask(getEnumerator); - } - public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Func dispose) { return AsyncEnumerator.Create(moveNext, current, dispose); @@ -66,95 +42,5 @@ public AnonymousAsyncEnumerable(Func> get public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => _getEnumerator(cancellationToken); } - - private sealed class AnonymousAsyncEnumerableWithTask : IAsyncEnumerable - { - private readonly Func>> _getEnumerator; - - public AnonymousAsyncEnumerableWithTask(Func>> getEnumerator) - { - Debug.Assert(getEnumerator != null); - - _getEnumerator = getEnumerator; - } - - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new Enumerator(_getEnumerator, cancellationToken); - - private sealed class Enumerator : IAsyncEnumerator - { - private Func>> _getEnumerator; - private readonly CancellationToken _cancellationToken; - private IAsyncEnumerator _enumerator; - - public Enumerator(Func>> getEnumerator, CancellationToken cancellationToken) - { - Debug.Assert(getEnumerator != null); - - _getEnumerator = getEnumerator; - _cancellationToken = cancellationToken; - } - - public T Current - { - get - { - if (_enumerator == null) - throw new InvalidOperationException(); - - return _enumerator.Current; - } - } - - public async ValueTask DisposeAsync() - { - var old = Interlocked.Exchange(ref _enumerator, DisposedEnumerator.Instance); - - if (_enumerator != null) - { - await _enumerator.DisposeAsync().ConfigureAwait(false); - } - } - - public ValueTask MoveNextAsync() - { - if (_enumerator == null) - { - return InitAndMoveNextAsync(); - } - - return _enumerator.MoveNextAsync(); - } - - private async ValueTask InitAndMoveNextAsync() - { - try - { - _enumerator = await _getEnumerator(_cancellationToken).ConfigureAwait(false); - } - catch (Exception ex) - { - _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); - throw; - } - finally - { - _getEnumerator = null; - } - - return await _enumerator.MoveNextAsync().ConfigureAwait(false); - } - - private sealed class DisposedEnumerator : IAsyncEnumerator - { - public static readonly DisposedEnumerator Instance = new DisposedEnumerator(); - - public T Current => throw new ObjectDisposedException("this"); - - public ValueTask DisposeAsync() => TaskExt.CompletedTask; - - public ValueTask MoveNextAsync() => throw new ObjectDisposedException("this"); - } - } - } } } From 7d7fd287692aeb710b340908421fc00c5301ba2a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 20:53:38 -0800 Subject: [PATCH 434/862] Clean up test. --- .../System/Linq/Operators/CreateEnumerable.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs index b047e84247..486bd7c0d4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs @@ -3,9 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; -using System.Threading; using Xunit; namespace Tests @@ -15,7 +13,7 @@ public class CreateEnumerable : AsyncEnumerableTests [Fact] public void CreateEnumerable_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerable(default(Func>))); + AssertThrows(() => AsyncEnumerable.CreateEnumerable(default)); } } } From 0bfbcd2dcbfbf95979e2206a5cd7c9cc50ba673d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:01:33 -0800 Subject: [PATCH 435/862] Rewrite of OrderBy to properly support async. --- .../Linq/Operators/OrderedAsyncEnumerable.cs | 279 ++++++++++++------ 1 file changed, 182 insertions(+), 97 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index d70c0cab9d..917ce27e21 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -9,10 +9,14 @@ namespace System.Linq { + // TODO: Add optimizations for First, Last, and ElementAt. + internal abstract class OrderedAsyncEnumerable : AsyncIterator, IOrderedAsyncEnumerable { - internal IOrderedEnumerable _enumerable; - internal IAsyncEnumerable _source; + protected IAsyncEnumerable _source; + private TElement[] _buffer; + private int[] _indexes; + private int _index; IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending) { @@ -24,7 +28,43 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere return new OrderedAsyncEnumerableWithTask(_source, keySelector, comparer, descending, this); } - internal abstract Task Initialize(CancellationToken cancellationToken); + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + { + switch (state) + { + case AsyncIteratorState.Allocated: + _buffer = await _source.ToArray(cancellationToken).ConfigureAwait(false); + + var sorter = GetAsyncEnumerableSorter(next: null); + _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); + _index = 0; + + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (_index < _buffer.Length) + { + current = _buffer[_indexes[_index++]]; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public override async ValueTask DisposeAsync() + { + _buffer = null; + _indexes = null; + + await base.DisposeAsync().ConfigureAwait(false); + } + + internal abstract AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next); } internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnumerable @@ -34,9 +74,6 @@ internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnume private readonly Func _keySelector; private readonly OrderedAsyncEnumerable _parent; - private IEnumerator _enumerator; - private IAsyncEnumerator _parentEnumerator; - public OrderedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) { Debug.Assert(source != null); @@ -55,62 +92,16 @@ public override AsyncIterator Clone() return new OrderedAsyncEnumerable(_source, _keySelector, _comparer, _descending, _parent); } - public override async ValueTask DisposeAsync() + internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next) { - if (_enumerator != null) - { - _enumerator.Dispose(); - _enumerator = null; - } + var sorter = new SyncKeySelectorAsyncEnumerableSorter(_keySelector, _comparer, _descending, next); - if (_parentEnumerator != null) + if (_parent != null) { - await _parentEnumerator.DisposeAsync().ConfigureAwait(false); - _parentEnumerator = null; + return _parent.GetAsyncEnumerableSorter(sorter); } - await base.DisposeAsync().ConfigureAwait(false); - } - - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) - { - switch (state) - { - case AsyncIteratorState.Allocated: - - await Initialize(cancellationToken).ConfigureAwait(false); - - _enumerator = _enumerable.GetEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; - - case AsyncIteratorState.Iterating: - if (_enumerator.MoveNext()) - { - current = _enumerator.Current; - return true; - } - - await DisposeAsync().ConfigureAwait(false); - break; - } - - return false; - } - - internal override async Task Initialize(CancellationToken cancellationToken) - { - if (_parent == null) - { - var buffer = await _source.ToList(cancellationToken).ConfigureAwait(false); - _enumerable = (!_descending ? buffer.OrderBy(_keySelector, _comparer) : buffer.OrderByDescending(_keySelector, _comparer)); - } - else - { - _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken); - await _parent.Initialize(cancellationToken).ConfigureAwait(false); - _enumerable = _parent._enumerable.CreateOrderedEnumerable(_keySelector, _comparer, _descending); - } + return sorter; } } @@ -121,9 +112,6 @@ internal sealed class OrderedAsyncEnumerableWithTask : OrderedAs private readonly Func> _keySelector; private readonly OrderedAsyncEnumerable _parent; - private IEnumerator _enumerator; - private IAsyncEnumerator _parentEnumerator; - public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) { Debug.Assert(source != null); @@ -142,82 +130,179 @@ public override AsyncIterator Clone() return new OrderedAsyncEnumerableWithTask(_source, _keySelector, _comparer, _descending, _parent); } - public override async ValueTask DisposeAsync() + internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next) { - if (_enumerator != null) + var sorter = new AsyncKeySelectorAsyncEnumerableSorter(_keySelector, _comparer, _descending, next); + + if (_parent != null) { - _enumerator.Dispose(); - _enumerator = null; + return _parent.GetAsyncEnumerableSorter(sorter); } - if (_parentEnumerator != null) + return sorter; + } + } + + internal abstract class AsyncEnumerableSorter + { + internal abstract ValueTask ComputeKeys(TElement[] elements, int count); + + internal abstract int CompareKeys(int index1, int index2); + + public async ValueTask Sort(TElement[] elements, int count) + { + await ComputeKeys(elements, count).ConfigureAwait(false); + + var map = new int[count]; + + for (var i = 0; i < count; i++) { - await _parentEnumerator.DisposeAsync().ConfigureAwait(false); - _parentEnumerator = null; + map[i] = i; } - await base.DisposeAsync().ConfigureAwait(false); + QuickSort(map, 0, count - 1); + + return map; } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + private void QuickSort(int[] map, int left, int right) { - switch (state) + do { - case AsyncIteratorState.Allocated: + var i = left; + var j = right; + var x = map[i + (j - i >> 1)]; - await Initialize(cancellationToken).ConfigureAwait(false); + do + { + while (i < map.Length && CompareKeys(x, map[i]) > 0) + { + i++; + } - _enumerator = _enumerable.GetEnumerator(); - state = AsyncIteratorState.Iterating; - goto case AsyncIteratorState.Iterating; + while (j >= 0 && CompareKeys(x, map[j]) < 0) + { + j--; + } - case AsyncIteratorState.Iterating: - if (_enumerator.MoveNext()) + if (i > j) { - current = _enumerator.Current; - return true; + break; } - await DisposeAsync().ConfigureAwait(false); - break; + if (i < j) + { + var temp = map[i]; + map[i] = map[j]; + map[j] = temp; + } + + i++; + j--; + } + while (i <= j); + + if (j - left <= right - i) + { + if (left < j) + { + QuickSort(map, left, j); + } + + left = i; + } + else + { + if (i < right) + { + QuickSort(map, i, right); + } + + right = j; + } } + while (left < right); + } + } - return false; + internal abstract class AsyncEnumerableSorterBase : AsyncEnumerableSorter + { + private readonly IComparer _comparer; + private readonly bool _descending; + protected readonly AsyncEnumerableSorter _next; + protected TKey[] _keys; + + public AsyncEnumerableSorterBase(IComparer comparer, bool descending, AsyncEnumerableSorter next) + { + _comparer = comparer; + _descending = descending; + _next = next; } - internal override async Task Initialize(CancellationToken cancellationToken) + internal override int CompareKeys(int index1, int index2) { - if (_parent == null) + var c = _comparer.Compare(_keys[index1], _keys[index2]); + + if (c == 0) { - var buffer = await _source.ToList(cancellationToken).ConfigureAwait(false); - _enumerable = (!_descending ? buffer.OrderByAsync(_keySelector, _comparer) : buffer.OrderByDescendingAsync(_keySelector, _comparer)); + return _next == null ? index1 - index2 : _next.CompareKeys(index1, index2); } else { - _parentEnumerator = _parent.GetAsyncEnumerator(cancellationToken); - await _parent.Initialize(cancellationToken).ConfigureAwait(false); - _enumerable = _parent._enumerable.CreateOrderedEnumerableAsync(_keySelector, _comparer, _descending); + return (_descending != (c > 0)) ? 1 : -1; } } } - internal static class EnumerableSortingExtensions + internal sealed class SyncKeySelectorAsyncEnumerableSorter : AsyncEnumerableSorterBase { - // TODO: Implement async sorting. + private readonly Func _keySelector; - public static IOrderedEnumerable OrderByAsync(this IEnumerable source, Func> keySelector, IComparer comparer) + public SyncKeySelectorAsyncEnumerableSorter(Func keySelector, IComparer comparer, bool descending, AsyncEnumerableSorter next) + : base(comparer, descending, next) { - return source.OrderBy(key => keySelector(key).GetAwaiter().GetResult(), comparer); + _keySelector = keySelector; } - public static IOrderedEnumerable OrderByDescendingAsync(this IEnumerable source, Func> keySelector, IComparer comparer) + internal override async ValueTask ComputeKeys(TElement[] elements, int count) { - return source.OrderByDescending(key => keySelector(key).GetAwaiter().GetResult(), comparer); + _keys = new TKey[count]; + + for (var i = 0; i < count; i++) + { + _keys[i] = _keySelector(elements[i]); + } + + if (_next != null) + { + await _next.ComputeKeys(elements, count).ConfigureAwait(false); + } + } + } + + internal sealed class AsyncKeySelectorAsyncEnumerableSorter : AsyncEnumerableSorterBase + { + private readonly Func> _keySelector; + + public AsyncKeySelectorAsyncEnumerableSorter(Func> keySelector, IComparer comparer, bool descending, AsyncEnumerableSorter next) + : base(comparer, descending, next) + { + _keySelector = keySelector; } - public static IOrderedEnumerable CreateOrderedEnumerableAsync(this IOrderedEnumerable source, Func> keySelector, IComparer comparer, bool descending) + internal override async ValueTask ComputeKeys(TElement[] elements, int count) { - return source.CreateOrderedEnumerable(key => keySelector(key).GetAwaiter().GetResult(), comparer, descending); + _keys = new TKey[count]; + + for (var i = 0; i < count; i++) + { + _keys[i] = await _keySelector(elements[i]).ConfigureAwait(false); + } + + if (_next != null) + { + await _next.ComputeKeys(elements, count).ConfigureAwait(false); + } } } } From 679cfe7942cd47389def65abe3ca66e39e57bbd3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:13:20 -0800 Subject: [PATCH 436/862] Optimize OfType and Cast. --- .../System/Linq/Operators/Cast.cs | 57 ++++++++++++++++- .../System/Linq/Operators/OfType.cs | 63 ++++++++++++++++++- 2 files changed, 117 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index b0296bbe7d..78de8dd5ac 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -3,6 +3,9 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; namespace System.Linq { @@ -19,7 +22,59 @@ public static IAsyncEnumerable Cast(this IAsyncEnumerable (TResult)x); + return new CastAsyncIterator(source); + } + + internal sealed class CastAsyncIterator : AsyncIterator + { + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; + + public CastAsyncIterator(IAsyncEnumerable source) + { + Debug.Assert(source != null); + + _source = source; + } + + public override AsyncIterator Clone() + { + return new CastAsyncIterator(_source); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + { + switch (state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + current = (TResult)_enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index 1b1b0ddd13..b9fef72345 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -3,17 +3,76 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable OfType(this IAsyncEnumerable source) + public static IAsyncEnumerable OfType(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return source.Where(x => x is TType).Cast(); + return new OfTypeAsyncIterator(source); + } + + internal sealed class OfTypeAsyncIterator : AsyncIterator + { + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; + + public OfTypeAsyncIterator(IAsyncEnumerable source) + { + Debug.Assert(source != null); + + _source = source; + } + + public override AsyncIterator Clone() + { + return new OfTypeAsyncIterator(_source); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + { + switch (state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(cancellationToken); + state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + if (item is TResult res) + { + current = res; + return true; + } + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } } } } From c00e09bd0add2805c6341adeb267d5a38341ac24 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:20:15 -0800 Subject: [PATCH 437/862] Grant cancellation in Reverse. --- .../Source/System.Linq.Async/System/Linq/Operators/Reverse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index 0f771fd1d9..9655ec874e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -92,7 +92,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella switch (state) { case AsyncIteratorState.Allocated: - _items = await _source.ToArray().ConfigureAwait(false); + _items = await _source.ToArray(cancellationToken).ConfigureAwait(false); _index = _items.Length - 1; state = AsyncIteratorState.Iterating; From bc864b2525f9e3f6871f5ba01fb75ee9ec92e6da Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:23:53 -0800 Subject: [PATCH 438/862] Grant cancellation for ToArray in Except and Intersect. --- .../System.Linq.Async/System/Linq/Operators/Except.cs | 6 +++--- .../System.Linq.Async/System/Linq/Operators/Intersect.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index ceaa29afc0..ac8f34be84 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -83,7 +83,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); _set = new Set(_comparer); _setFilled = false; - _fillSetTask = FillSetAsync(); + _fillSetTask = FillSetAsync(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -124,9 +124,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return false; } - private async Task FillSetAsync() + private async Task FillSetAsync(CancellationToken cancellationToken) { - var array = await _second.ToArray().ConfigureAwait(false); + var array = await _second.ToArray(cancellationToken).ConfigureAwait(false); foreach (var t in array) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index f6ec04b523..bf95bffe2f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -83,7 +83,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); _set = new Set(_comparer); _setFilled = false; - _fillSetTask = FillSet(); + _fillSetTask = FillSet(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -124,9 +124,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return false; } - private async Task FillSet() + private async Task FillSet(CancellationToken cancellationToken) { - var array = await _second.ToArray().ConfigureAwait(false); + var array = await _second.ToArray(cancellationToken).ConfigureAwait(false); for (var i = 0; i < array.Length; i++) { _set.Add(array[i]); From 9b0e4d5cf4b5a83072deff2cfc2497fc9ed86e3a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:26:53 -0800 Subject: [PATCH 439/862] Add remark to Zip. --- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index c4b188d091..49cd5f877c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -90,6 +90,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Iterating: + // REVIEW: Do we want concurrent behavior by default? Likely not, so we should introduce ConcurrentZip + // either here or in System.Interactive.Async. + // We kick these off and join so they can potentially run in parallel var ft = _firstEnumerator.MoveNextAsync(); var st = _secondEnumerator.MoveNextAsync(); From 89484fab0a72bc5901b7e91792a10ba7d0e4cac2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:32:50 -0800 Subject: [PATCH 440/862] Clean up SequenceEqual. --- .../System/Linq/Operators/SequenceEqual.cs | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 0425ee1434..4ed72e6195 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -10,30 +10,27 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) throw Error.ArgumentNull(nameof(first)); if (second == null) throw Error.ArgumentNull(nameof(second)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); - return SequenceEqual(first, second, comparer, CancellationToken.None); + return SequenceEqualCore(first, second, EqualityComparer.Default, CancellationToken.None); } - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second) + public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) throw Error.ArgumentNull(nameof(first)); if (second == null) throw Error.ArgumentNull(nameof(second)); - return SequenceEqual(first, second, CancellationToken.None); + return SequenceEqualCore(first, second, EqualityComparer.Default, cancellationToken); } - - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -42,53 +39,60 @@ public static Task SequenceEqual(this IAsyncEnumerable f if (comparer == null) throw Error.ArgumentNull(nameof(comparer)); - return SequenceEqualCore(first, second, comparer, cancellationToken); + return SequenceEqualCore(first, second, comparer, CancellationToken.None); } - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first == null) throw Error.ArgumentNull(nameof(first)); if (second == null) throw Error.ArgumentNull(nameof(second)); + if (comparer == null) + throw Error.ArgumentNull(nameof(comparer)); - return first.SequenceEqual(second, EqualityComparer.Default, cancellationToken); + return SequenceEqualCore(first, second, comparer, cancellationToken); } - private static async Task SequenceEqualCore(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + private static Task SequenceEqualCore(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first is ICollection firstCol && second is ICollection secondCol && firstCol.Count != secondCol.Count) { - return false; + return Task.FromResult(false); } - var e1 = first.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - var e2 = second.GetAsyncEnumerator(cancellationToken); + var e1 = first.GetAsyncEnumerator(cancellationToken); try { - while (await e1.MoveNextAsync().ConfigureAwait(false)) + var e2 = second.GetAsyncEnumerator(cancellationToken); + + try { - if (!(await e2.MoveNextAsync().ConfigureAwait(false) && comparer.Equals(e1.Current, e2.Current))) + while (await e1.MoveNextAsync().ConfigureAwait(false)) { - return false; + if (!(await e2.MoveNextAsync().ConfigureAwait(false) && comparer.Equals(e1.Current, e2.Current))) + { + return false; + } } - } - return !await e2.MoveNextAsync().ConfigureAwait(false); + return !await e2.MoveNextAsync().ConfigureAwait(false); + } + finally + { + await e2.DisposeAsync().ConfigureAwait(false); + } } finally { - await e2.DisposeAsync().ConfigureAwait(false); + await e1.DisposeAsync().ConfigureAwait(false); } } - finally - { - await e1.DisposeAsync().ConfigureAwait(false); - } } } } From 67cb696b45685747b70bf5bb31f716f1d91a3f11 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:35:03 -0800 Subject: [PATCH 441/862] Clean up Grouping. --- .../Source/System.Linq.Async/System/Error.cs | 1 + .../System/Linq/Operators/Grouping.cs | 27 +++++-------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Error.cs b/Ix.NET/Source/System.Linq.Async/System/Error.cs index b88c939870..674305a59f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Error.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Error.cs @@ -10,5 +10,6 @@ internal static class Error public static Exception ArgumentOutOfRange(string paramName) => new ArgumentOutOfRangeException(paramName); public static Exception NoElements() => new InvalidOperationException(Strings.NO_ELEMENTS); public static Exception MoreThanOneElement() => new InvalidOperationException(Strings.MORE_THAN_ONE_ELEMENT); + public static Exception NotSupported() => new NotSupportedException(Strings.NOT_SUPPORTED); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs index e1b12b5f7d..be714fece9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs @@ -39,36 +39,21 @@ public IEnumerator GetEnumerator() bool ICollection.IsReadOnly => true; - void ICollection.Add(TElement item) - { - throw new NotSupportedException(Strings.NOT_SUPPORTED); - } + void ICollection.Add(TElement item) => throw Error.NotSupported(); - void ICollection.Clear() - { - throw new NotSupportedException(Strings.NOT_SUPPORTED); - } + void ICollection.Clear() => throw Error.NotSupported(); bool ICollection.Contains(TElement item) => Array.IndexOf(_elements, item, 0, _count) >= 0; void ICollection.CopyTo(TElement[] array, int arrayIndex) => Array.Copy(_elements, 0, array, arrayIndex, _count); - bool ICollection.Remove(TElement item) - { - throw new NotSupportedException(Strings.NOT_SUPPORTED); - } + bool ICollection.Remove(TElement item) => throw Error.NotSupported(); int IList.IndexOf(TElement item) => Array.IndexOf(_elements, item, 0, _count); - void IList.Insert(int index, TElement item) - { - throw new NotSupportedException(Strings.NOT_SUPPORTED); - } + void IList.Insert(int index, TElement item) => throw Error.NotSupported(); - void IList.RemoveAt(int index) - { - throw new NotSupportedException(Strings.NOT_SUPPORTED); - } + void IList.RemoveAt(int index) => throw Error.NotSupported(); TElement IList.this[int index] { @@ -82,7 +67,7 @@ TElement IList.this[int index] return _elements[index]; } - set { throw new NotSupportedException(Strings.NOT_SUPPORTED); } + set => throw Error.NotSupported(); } internal void Add(TElement element) From af725758aab96549d211832c167ed027a14e9350 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 9 Nov 2018 21:41:05 -0800 Subject: [PATCH 442/862] Remove the use of a CreateEnumerator overload. --- .../System/Linq/Operators/ToAsyncEnumerable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index e861b6acf4..1cf241d3e7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -39,7 +39,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task + async () => { if (Interlocked.CompareExchange(ref called, 1, 0) == 0) { From ed7bc623794f26c954b6e3799d54f9bdb577bd64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sat, 10 Nov 2018 09:23:02 +0100 Subject: [PATCH 443/862] Undo benchmark, undo Finally --- .../AsyncReturnBenchmark.cs | 164 ------------------ .../Benchmarks.System.Interactive.csproj | 2 - .../Benchmarks.System.Interactive/Program.cs | 3 +- .../System/Linq/Operators/Finally.cs | 41 +---- .../System/Linq/Operators/Finally.cs | 17 -- 5 files changed, 2 insertions(+), 225 deletions(-) delete mode 100644 Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs diff --git a/Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs b/Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs deleted file mode 100644 index 1c521d77a1..0000000000 --- a/Ix.NET/Source/Benchmarks.System.Interactive/AsyncReturnBenchmark.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using BenchmarkDotNet.Attributes; - -namespace Benchmarks.System.Interactive -{ - [MemoryDiagnoser] - public class AsyncReturnBenchmark - { - [Benchmark] - public async ValueTask ToAsyncEnumerable() - { - await new[] { 1 }.ToAsyncEnumerable().ForEachAsync(v => { }).ConfigureAwait(false); - } - - [Benchmark] - public async ValueTask Direct() - { - await AsyncEnumerableEx.Return(1).ForEachAsync(v => { }).ConfigureAwait(false); - } - - [Benchmark] - public async ValueTask Iterator() - { - await new ReturnIterator(1).ForEachAsync(v => { }).ConfigureAwait(false); - } - - } - - internal sealed class ReturnIterator : AsyncIterator - { - private readonly T _value; - - public override AsyncIterator Clone() - { - return new ReturnIterator(_value); - } - - public ReturnIterator(T value) - { - _value = value; - } - - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) - { - if (state == AsyncIteratorState.Allocated) - { - current = _value; - state = AsyncIteratorState.Disposed; - return true; - } - - await DisposeAsync().ConfigureAwait(false); - return false; - } - } - - internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator - { - private readonly int _threadId; - - private bool _currentIsInvalid = true; - - internal TSource current; - internal AsyncIteratorState state = AsyncIteratorState.New; - internal CancellationToken token; - - protected AsyncIterator() - { - _threadId = Environment.CurrentManagedThreadId; - } - - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) - { - var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId - ? this - : Clone(); - - enumerator.state = AsyncIteratorState.Allocated; - enumerator.token = token; - - try - { - enumerator.OnGetEnumerator(token); - } - catch - { - enumerator.DisposeAsync(); // REVIEW: fire-and-forget? - throw; - } - - return enumerator; - } - - public virtual ValueTask DisposeAsync() - { - current = default; - state = AsyncIteratorState.Disposed; - - return new ValueTask(); - } - - public TSource Current - { - get - { - if (_currentIsInvalid) - throw new InvalidOperationException("Enumerator is in an invalid state"); - - return current; - } - } - - public async ValueTask MoveNextAsync() - { - // Note: MoveNext *must* be implemented as an async method to ensure - // that any exceptions thrown from the MoveNextCore call are handled - // by the try/catch, whether they're sync or async - - if (state == AsyncIteratorState.Disposed) - { - return false; - } - - try - { - var result = await MoveNextCore(token).ConfigureAwait(false); - - _currentIsInvalid = !result; // if move next is false, invalid otherwise valid - - return result; - } - catch - { - _currentIsInvalid = true; - await DisposeAsync().ConfigureAwait(false); - throw; - } - } - - public abstract AsyncIterator Clone(); - - protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); - - protected virtual void OnGetEnumerator(CancellationToken cancellationToken) - { - } - } - - internal enum AsyncIteratorState - { - New = 0, - Allocated = 1, - Iterating = 2, - Disposed = -1, - } -} diff --git a/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj b/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj index 3d55f84a63..8701be546e 100644 --- a/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj +++ b/Ix.NET/Source/Benchmarks.System.Interactive/Benchmarks.System.Interactive.csproj @@ -32,8 +32,6 @@ - - diff --git a/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs b/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs index d10daf405f..59bb5bf0c0 100644 --- a/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs +++ b/Ix.NET/Source/Benchmarks.System.Interactive/Program.cs @@ -21,8 +21,7 @@ internal static void Main(string[] args) typeof(IgnoreElementsBenchmark), typeof(DeferBenchmark), typeof(RetryBenchmark), - typeof(MinMaxBenchmark), - typeof(AsyncReturnBenchmark) + typeof(MinMaxBenchmark) }); switcher.Run(); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index 51ba62339d..d0cf28e577 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -114,46 +114,7 @@ public async Task Finally7() var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(() => { i++; }); await SequenceIdentity(xs); - Assert.Equal(4, i); - } - - [Fact] - public async Task Finally7_Async() - { - var i = 0; - var xs = new[] { 1, 2 }.ToAsyncEnumerable().Finally(async () => { - await Task.CompletedTask; - i++; - }); - - await SequenceIdentity(xs); - Assert.Equal(4, i); - } - - [Fact] - public async Task Finally8() - { - var i = 0; - var en = AsyncEnumerable.Range(1, 5).Finally(() => i++).GetAsyncEnumerator(); - - await en.DisposeAsync(); - - Assert.Equal(1, i); - } - - [Fact] - public async Task Finally8_Async() - { - var i = 0; - var en = AsyncEnumerable.Range(1, 5).Finally(async () => - { - await Task.CompletedTask; - i++; - }).GetAsyncEnumerator(); - - await en.DisposeAsync(); - - Assert.Equal(1, i); + Assert.Equal(2, i); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 986ed6e6ed..354e585b6b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -38,8 +38,6 @@ private sealed class FinallyAsyncIterator : AsyncIterator private IAsyncEnumerator _enumerator; - private bool _finallyOnce; - public FinallyAsyncIterator(IAsyncEnumerable source, Action finallyAction) { Debug.Assert(source != null); @@ -61,13 +59,6 @@ public override async ValueTask DisposeAsync() await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; - } - - // Run the _finallyAction even if - // the consumer did not call MoveNextAsync - if (!_finallyOnce) - { - _finallyOnce = true; _finallyAction(); } @@ -105,8 +96,6 @@ private sealed class FinallyAsyncIteratorWithTask : AsyncIterator _enumerator; - private bool _finallyOnce; - public FinallyAsyncIteratorWithTask(IAsyncEnumerable source, Func finallyAction) { Debug.Assert(source != null); @@ -127,13 +116,7 @@ public override async ValueTask DisposeAsync() { await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; - } - // Await the _finallyAction even if - // the consumer did not call MoveNextAsync - if (!_finallyOnce) - { - _finallyOnce = true; await _finallyAction().ConfigureAwait(false); } From 5810ce24b96c9732a0bdab6e2508393d489feacc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:16:39 -0800 Subject: [PATCH 444/862] Clean up ToLookup. --- .../System/Linq/Operators/ToLookup.cs | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 26ec0b9942..6a4a8e1327 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -19,7 +19,7 @@ public static Task> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookup(source, keySelector, CancellationToken.None); + return ToLookupCore(source, keySelector, x => x, EqualityComparer.Default, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) @@ -29,7 +29,7 @@ public static Task> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.ToLookup(keySelector, x => x, EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector) @@ -39,7 +39,7 @@ public static Task> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookup(source, keySelector, CancellationToken.None); + return ToLookupCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) @@ -49,7 +49,7 @@ public static Task> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.ToLookup(keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -61,7 +61,7 @@ public static Task> ToLookup(this IAsyncEn if (comparer == null) throw Error.ArgumentNull(nameof(comparer)); - return ToLookup(source, keySelector, comparer, CancellationToken.None); + return ToLookupCore(source, keySelector, x => x, comparer, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -73,7 +73,7 @@ public static Task> ToLookup(this IAsyncEn if (comparer == null) throw Error.ArgumentNull(nameof(comparer)); - return source.ToLookup(keySelector, x => x, comparer, cancellationToken); + return ToLookupCore(source, keySelector, x => x, comparer, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -85,7 +85,7 @@ public static Task> ToLookup(this IAsyncEn if (comparer == null) throw Error.ArgumentNull(nameof(comparer)); - return ToLookup(source, keySelector, comparer, CancellationToken.None); + return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) @@ -97,7 +97,7 @@ public static Task> ToLookup(this IAsyncEn if (comparer == null) throw Error.ArgumentNull(nameof(comparer)); - return source.ToLookup(keySelector, x => Task.FromResult(x), comparer, cancellationToken); + return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector) @@ -109,7 +109,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return ToLookup(source, keySelector, elementSelector, CancellationToken.None); + return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) @@ -121,7 +121,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return source.ToLookup(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) @@ -133,7 +133,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return ToLookup(source, keySelector, elementSelector, CancellationToken.None); + return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) @@ -145,7 +145,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return source.ToLookup(keySelector, elementSelector, EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) @@ -159,10 +159,10 @@ public static Task> ToLookup(th if (comparer == null) throw Error.ArgumentNull(nameof(comparer)); - return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); + return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } - public static async Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -173,9 +173,7 @@ public static async Task> ToLookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); - - return lookup; + return ToLookupCore(source, keySelector, elementSelector, comparer, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) @@ -189,10 +187,10 @@ public static Task> ToLookup(th if (comparer == null) throw Error.ArgumentNull(nameof(comparer)); - return ToLookup(source, keySelector, elementSelector, comparer, CancellationToken.None); + return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } - public static async Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -203,9 +201,17 @@ public static async Task> ToLookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + return ToLookupCore(source, keySelector, elementSelector, comparer, cancellationToken); + } - return lookup; + private static async Task> ToLookupCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + return await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + } + + private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); } } } From 1776af560f3acd8afecb76c3c5da64a85c1e3c03 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:19:31 -0800 Subject: [PATCH 445/862] Move Lookup types to separate file. --- .../System/Linq/Operators/Lookup.cs | 602 ++++++++++++++++++ .../System/Linq/Operators/ToLookup.cs | 593 ----------------- 2 files changed, 602 insertions(+), 593 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs new file mode 100644 index 0000000000..e2ec58e35c --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -0,0 +1,602 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +// This is internal because System.Linq exposes a public Lookup that we cannot directly use here + +namespace System.Linq.Internal +{ + internal class Lookup : ILookup, IAsyncIListProvider> + { + private readonly IEqualityComparer _comparer; + private Grouping[] _groupings; + private Grouping _lastGrouping; + + private Lookup(IEqualityComparer comparer) + { + _comparer = comparer ?? EqualityComparer.Default; + _groupings = new Grouping[7]; + } + + public int Count { get; private set; } + + public IEnumerable this[TKey key] + { + get + { + var grouping = GetGrouping(key, create: false); + if (grouping != null) + { + return grouping; + } + +#if NO_ARRAY_EMPTY + return EmptyArray.Value; +#else + return Array.Empty(); +#endif + } + } + + public bool Contains(TKey key) + { + return GetGrouping(key, create: false) != null; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public IEnumerator> GetEnumerator() + { + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + yield return g; + } while (g != _lastGrouping); + } + } + + public IEnumerable ApplyResultSelector(Func, TResult> resultSelector) + { + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + + var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); + yield return result; + } while (g != _lastGrouping); + } + } + + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(elementSelector != null); + + var lookup = new Lookup(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = keySelector(enu.Current); + var group = lookup.GetGrouping(key, create: true); + + var element = elementSelector(enu.Current); + group.Add(element); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + + var lookup = new Lookup(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = keySelector(enu.Current); + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var lookup = new Lookup(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = keySelector(enu.Current); + if (key != null) + { + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal Grouping GetGrouping(TKey key, bool create) + { + var hashCode = InternalGetHashCode(key); + for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) + { + if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) + { + return g; + } + } + + if (create) + { + if (Count == _groupings.Length) + { + Resize(); + } + + var index = hashCode % _groupings.Length; + var g = new Grouping + { + _key = key, + _hashCode = hashCode, + _elements = new TElement[1], + _hashNext = _groupings[index] + }; + _groupings[index] = g; + if (_lastGrouping == null) + { + g._next = g; + } + else + { + g._next = _lastGrouping._next; + _lastGrouping._next = g; + } + + _lastGrouping = g; + Count++; + return g; + } + + return null; + } + + internal int InternalGetHashCode(TKey key) + { + // Handle comparer implementations that throw when passed null + return (key == null) ? 0 : _comparer.GetHashCode(key) & 0x7FFFFFFF; + } + + internal TResult[] ToArray(Func, TResult> resultSelector) + { + var array = new TResult[Count]; + var index = 0; + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + array[index] = resultSelector(g._key, g._elements.ToAsyncEnumerable()); + ++index; + } while (g != _lastGrouping); + } + + return array; + } + + internal List ToList(Func, TResult> resultSelector) + { + var list = new List(Count); + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + + var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); + list.Add(result); + } while (g != _lastGrouping); + } + + return list; + } + + private void Resize() + { + var newSize = checked((Count * 2) + 1); + var newGroupings = new Grouping[newSize]; + var g = _lastGrouping; + do + { + g = g._next; + var index = g._hashCode % newSize; + g._hashNext = newGroupings[index]; + newGroupings[index] = g; + } while (g != _lastGrouping); + + _groupings = newGroupings; + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + return Task.FromResult(Count); + } + + IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); + } + + Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) + { + var list = new List>(Count); + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + list.Add(g); + } + while (g != _lastGrouping); + } + + return Task.FromResult(list); + } + + Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) + { + var array = new IAsyncGrouping[Count]; + var index = 0; + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + array[index] = g; + ++index; + } + while (g != _lastGrouping); + } + + return Task.FromResult(array); + } + } + + internal class LookupWithTask : ILookup, IAsyncIListProvider> + { + private readonly IEqualityComparer _comparer; + private Grouping[] _groupings; + private Grouping _lastGrouping; + + private LookupWithTask(IEqualityComparer comparer) + { + _comparer = comparer ?? EqualityComparer.Default; + _groupings = new Grouping[7]; + } + + public int Count { get; private set; } + + public IEnumerable this[TKey key] + { + get + { + var grouping = GetGrouping(key, create: false); + if (grouping != null) + { + return grouping; + } + +#if NO_ARRAY_EMPTY + return EmptyArray.Value; +#else + return Array.Empty(); +#endif + } + } + + public bool Contains(TKey key) + { + return GetGrouping(key, create: false) != null; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public IEnumerator> GetEnumerator() + { + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + yield return g; + } while (g != _lastGrouping); + } + } + + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(elementSelector != null); + + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = await keySelector(enu.Current).ConfigureAwait(false); + var group = lookup.GetGrouping(key, create: true); + + var element = await elementSelector(enu.Current).ConfigureAwait(false); + group.Add(element); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = await keySelector(enu.Current).ConfigureAwait(false); + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = await keySelector(enu.Current).ConfigureAwait(false); + if (key != null) + { + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } + + internal Grouping GetGrouping(TKey key, bool create) + { + var hashCode = InternalGetHashCode(key); + for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) + { + if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) + { + return g; + } + } + + if (create) + { + if (Count == _groupings.Length) + { + Resize(); + } + + var index = hashCode % _groupings.Length; + var g = new Grouping + { + _key = key, + _hashCode = hashCode, + _elements = new TElement[1], + _hashNext = _groupings[index] + }; + _groupings[index] = g; + if (_lastGrouping == null) + { + g._next = g; + } + else + { + g._next = _lastGrouping._next; + _lastGrouping._next = g; + } + + _lastGrouping = g; + Count++; + return g; + } + + return null; + } + + internal int InternalGetHashCode(TKey key) + { + // Handle comparer implementations that throw when passed null + return (key == null) ? 0 : _comparer.GetHashCode(key) & 0x7FFFFFFF; + } + + internal async Task ToArray(Func, Task> resultSelector) + { + var array = new TResult[Count]; + var index = 0; + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); + ++index; + } while (g != _lastGrouping); + } + + return array; + } + + internal async Task> ToList(Func, Task> resultSelector) + { + var list = new List(Count); + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + + var result = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); + list.Add(result); + } while (g != _lastGrouping); + } + + return list; + } + + private void Resize() + { + var newSize = checked((Count * 2) + 1); + var newGroupings = new Grouping[newSize]; + var g = _lastGrouping; + do + { + g = g._next; + var index = g._hashCode % newSize; + g._hashNext = newGroupings[index]; + newGroupings[index] = g; + } while (g != _lastGrouping); + + _groupings = newGroupings; + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + return Task.FromResult(Count); + } + + IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); + } + + Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) + { + var list = new List>(Count); + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + list.Add(g); + } + while (g != _lastGrouping); + } + + return Task.FromResult(list); + } + + Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) + { + var array = new IAsyncGrouping[Count]; + var index = 0; + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + array[index] = g; + ++index; + } + while (g != _lastGrouping); + } + + return Task.FromResult(array); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 6a4a8e1327..275a205f30 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -215,596 +215,3 @@ private static async Task> ToLookupCore : ILookup, IAsyncIListProvider> - { - private readonly IEqualityComparer _comparer; - private Grouping[] _groupings; - private Grouping _lastGrouping; - - private Lookup(IEqualityComparer comparer) - { - _comparer = comparer ?? EqualityComparer.Default; - _groupings = new Grouping[7]; - } - - public int Count { get; private set; } - - public IEnumerable this[TKey key] - { - get - { - var grouping = GetGrouping(key, create: false); - if (grouping != null) - { - return grouping; - } - -#if NO_ARRAY_EMPTY - return EmptyArray.Value; -#else - return Array.Empty(); -#endif - } - } - - public bool Contains(TKey key) - { - return GetGrouping(key, create: false) != null; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public IEnumerator> GetEnumerator() - { - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - yield return g; - } while (g != _lastGrouping); - } - } - - public IEnumerable ApplyResultSelector(Func, TResult> resultSelector) - { - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - g.Trim(); - - var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); - yield return result; - } while (g != _lastGrouping); - } - } - - internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(elementSelector != null); - - var lookup = new Lookup(comparer); - - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var key = keySelector(enu.Current); - var group = lookup.GetGrouping(key, create: true); - - var element = elementSelector(enu.Current); - group.Add(element); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return lookup; - } - - internal static async Task> CreateAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - - var lookup = new Lookup(comparer); - - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var key = keySelector(enu.Current); - lookup.GetGrouping(key, create: true).Add(enu.Current); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return lookup; - } - - internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - var lookup = new Lookup(comparer); - - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var key = keySelector(enu.Current); - if (key != null) - { - lookup.GetGrouping(key, create: true).Add(enu.Current); - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return lookup; - } - - internal Grouping GetGrouping(TKey key, bool create) - { - var hashCode = InternalGetHashCode(key); - for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) - { - if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) - { - return g; - } - } - - if (create) - { - if (Count == _groupings.Length) - { - Resize(); - } - - var index = hashCode % _groupings.Length; - var g = new Grouping - { - _key = key, - _hashCode = hashCode, - _elements = new TElement[1], - _hashNext = _groupings[index] - }; - _groupings[index] = g; - if (_lastGrouping == null) - { - g._next = g; - } - else - { - g._next = _lastGrouping._next; - _lastGrouping._next = g; - } - - _lastGrouping = g; - Count++; - return g; - } - - return null; - } - - internal int InternalGetHashCode(TKey key) - { - // Handle comparer implementations that throw when passed null - return (key == null) ? 0 : _comparer.GetHashCode(key) & 0x7FFFFFFF; - } - - internal TResult[] ToArray(Func, TResult> resultSelector) - { - var array = new TResult[Count]; - var index = 0; - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - g.Trim(); - array[index] = resultSelector(g._key, g._elements.ToAsyncEnumerable()); - ++index; - } while (g != _lastGrouping); - } - - return array; - } - - internal List ToList(Func, TResult> resultSelector) - { - var list = new List(Count); - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - g.Trim(); - - var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); - list.Add(result); - } while (g != _lastGrouping); - } - - return list; - } - - private void Resize() - { - var newSize = checked((Count * 2) + 1); - var newGroupings = new Grouping[newSize]; - var g = _lastGrouping; - do - { - g = g._next; - var index = g._hashCode % newSize; - g._hashNext = newGroupings[index]; - newGroupings[index] = g; - } while (g != _lastGrouping); - - _groupings = newGroupings; - } - - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - return Task.FromResult(Count); - } - - IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); - } - - Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) - { - var list = new List>(Count); - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - list.Add(g); - } - while (g != _lastGrouping); - } - - return Task.FromResult(list); - } - - Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) - { - var array = new IAsyncGrouping[Count]; - var index = 0; - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - array[index] = g; - ++index; - } - while (g != _lastGrouping); - } - - return Task.FromResult(array); - } - } - - internal class LookupWithTask : ILookup, IAsyncIListProvider> - { - private readonly IEqualityComparer _comparer; - private Grouping[] _groupings; - private Grouping _lastGrouping; - - private LookupWithTask(IEqualityComparer comparer) - { - _comparer = comparer ?? EqualityComparer.Default; - _groupings = new Grouping[7]; - } - - public int Count { get; private set; } - - public IEnumerable this[TKey key] - { - get - { - var grouping = GetGrouping(key, create: false); - if (grouping != null) - { - return grouping; - } - -#if NO_ARRAY_EMPTY - return EmptyArray.Value; -#else - return Array.Empty(); -#endif - } - } - - public bool Contains(TKey key) - { - return GetGrouping(key, create: false) != null; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public IEnumerator> GetEnumerator() - { - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - yield return g; - } while (g != _lastGrouping); - } - } - - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(elementSelector != null); - - var lookup = new LookupWithTask(comparer); - - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var key = await keySelector(enu.Current).ConfigureAwait(false); - var group = lookup.GetGrouping(key, create: true); - - var element = await elementSelector(enu.Current).ConfigureAwait(false); - group.Add(element); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return lookup; - } - - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - - var lookup = new LookupWithTask(comparer); - - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var key = await keySelector(enu.Current).ConfigureAwait(false); - lookup.GetGrouping(key, create: true).Add(enu.Current); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return lookup; - } - - internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - var lookup = new LookupWithTask(comparer); - - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var key = await keySelector(enu.Current).ConfigureAwait(false); - if (key != null) - { - lookup.GetGrouping(key, create: true).Add(enu.Current); - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - - return lookup; - } - - internal Grouping GetGrouping(TKey key, bool create) - { - var hashCode = InternalGetHashCode(key); - for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) - { - if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) - { - return g; - } - } - - if (create) - { - if (Count == _groupings.Length) - { - Resize(); - } - - var index = hashCode % _groupings.Length; - var g = new Grouping - { - _key = key, - _hashCode = hashCode, - _elements = new TElement[1], - _hashNext = _groupings[index] - }; - _groupings[index] = g; - if (_lastGrouping == null) - { - g._next = g; - } - else - { - g._next = _lastGrouping._next; - _lastGrouping._next = g; - } - - _lastGrouping = g; - Count++; - return g; - } - - return null; - } - - internal int InternalGetHashCode(TKey key) - { - // Handle comparer implementations that throw when passed null - return (key == null) ? 0 : _comparer.GetHashCode(key) & 0x7FFFFFFF; - } - - internal async Task ToArray(Func, Task> resultSelector) - { - var array = new TResult[Count]; - var index = 0; - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - g.Trim(); - array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); - ++index; - } while (g != _lastGrouping); - } - - return array; - } - - internal async Task> ToList(Func, Task> resultSelector) - { - var list = new List(Count); - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - g.Trim(); - - var result = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); - list.Add(result); - } while (g != _lastGrouping); - } - - return list; - } - - private void Resize() - { - var newSize = checked((Count * 2) + 1); - var newGroupings = new Grouping[newSize]; - var g = _lastGrouping; - do - { - g = g._next; - var index = g._hashCode % newSize; - g._hashNext = newGroupings[index]; - newGroupings[index] = g; - } while (g != _lastGrouping); - - _groupings = newGroupings; - } - - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - return Task.FromResult(Count); - } - - IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); - } - - Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) - { - var list = new List>(Count); - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - list.Add(g); - } - while (g != _lastGrouping); - } - - return Task.FromResult(list); - } - - Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) - { - var array = new IAsyncGrouping[Count]; - var index = 0; - var g = _lastGrouping; - if (g != null) - { - do - { - g = g._next; - array[index] = g; - ++index; - } - while (g != _lastGrouping); - } - - return Task.FromResult(array); - } - } -} From 4b3dab55a96561b5794cba6255d5925e5d8720d3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:27:26 -0800 Subject: [PATCH 446/862] Reorder some overloads. --- .../System/Linq/Operators/All.cs | 8 +++--- .../System/Linq/Operators/Any.cs | 28 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index dae2e2e18e..7ef963ec32 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -20,24 +20,24 @@ public static Task All(this IAsyncEnumerable source, Fun return AllCore(source, predicate, CancellationToken.None); } - public static Task All(this IAsyncEnumerable source, Func> predicate) + public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AllCore(source, predicate, CancellationToken.None); + return AllCore(source, predicate, cancellationToken); } - public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task All(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AllCore(source, predicate, cancellationToken); + return AllCore(source, predicate, CancellationToken.None); } public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 04f16fd53f..8c14e01e13 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -10,32 +10,30 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Any(this IAsyncEnumerable source, Func predicate) + public static Task Any(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, predicate, CancellationToken.None); + return AnyCore(source, CancellationToken.None); } - public static Task Any(this IAsyncEnumerable source, Func> predicate) + public static Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, predicate, CancellationToken.None); + return AnyCore(source, cancellationToken); } - public static Task Any(this IAsyncEnumerable source) + public static Task Any(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, CancellationToken.None); + return AnyCore(source, predicate, CancellationToken.None); } public static Task Any(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) @@ -48,22 +46,24 @@ public static Task Any(this IAsyncEnumerable source, Fun return AnyCore(source, predicate, cancellationToken); } - public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task Any(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, predicate, cancellationToken); + return AnyCore(source, predicate, CancellationToken.None); } - public static Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, cancellationToken); + return AnyCore(source, predicate, cancellationToken); } private static async Task AnyCore(IAsyncEnumerable source, CancellationToken cancellationToken) From 34fdbf6da7d99b800cf3ce3602d422e5eedef674 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:27:39 -0800 Subject: [PATCH 447/862] Clean up a few operators. --- .../System/Linq/Operators/DefaultIfEmpty.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 23f190fbef..4f29fdcfc5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -12,20 +12,20 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source, TSource defaultValue) + public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return new DefaultIfEmptyAsyncIterator(source, defaultValue); + return new DefaultIfEmptyAsyncIterator(source, default); } - public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source) + public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source, TSource defaultValue) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return DefaultIfEmpty(source, default); + return new DefaultIfEmptyAsyncIterator(source, defaultValue); } private sealed class DefaultIfEmptyAsyncIterator : AsyncIterator, IAsyncIListProvider From c4cf6ed51fd93c9f88c3ce97696106aceef54603 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:33:09 -0800 Subject: [PATCH 448/862] Fixing ElementAtOrDefault behavior. --- .../Linq/Operators/ElementAtOrDefault.cs | 10 ++-- .../Linq/Operators/ElementAtOrDefault.cs | 50 +++++++++---------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index 692b0cd5e6..a59579188d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -17,10 +17,7 @@ public class ElementAtOrDefault : AsyncEnumerableTests public async Task ElementAtOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(Return42, -1)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default, 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(Return42, -1, CancellationToken.None)); } [Fact] @@ -60,6 +57,13 @@ public void ElementAtOrDefault5() [Fact] public void ElementAtOrDefault6() + { + var res = Return42.ElementAtOrDefault(-1); + Assert.Equal(0, res.Result); + } + + [Fact] + public void ElementAtOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAtOrDefault(15); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 407b14b082..08abff8fa5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -14,8 +14,6 @@ public static Task ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefaultCore(IAsyncEnumerable source, int index, CancellationToken cancellationToken) { - if (source is IList list) - { - if (index < list.Count) - { - return list[index]; - } - } - else if (source is IAsyncPartition p) + if (source is IAsyncPartition p) { var first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); @@ -48,25 +37,36 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera return first.Value; } } - else - { - var e = source.GetAsyncEnumerator(cancellationToken); - try + if (index >= 0) + { + if (source is IList list) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + if (index < list.Count) { - if (index == 0) - { - return e.Current; - } - - index--; + return list[index]; } } - finally + else { - await e.DisposeAsync().ConfigureAwait(false); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (index == 0) + { + return e.Current; + } + + index--; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } From db577709c47bcca1a4a261900b06df28ce6c0847 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:33:28 -0800 Subject: [PATCH 449/862] Clean up Distinct. --- .../Source/System.Linq.Async/System/Linq/Operators/Distinct.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 586f2f2fc9..6641b81b73 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -16,7 +16,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnumerable< if (source == null) throw Error.ArgumentNull(nameof(source)); - return source.Distinct(EqualityComparer.Default); + return new DistinctAsyncIterator(source, EqualityComparer.Default); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, IEqualityComparer comparer) From 46668196a3ed1afe6729a3f51ebdd67320139e46 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:38:35 -0800 Subject: [PATCH 450/862] Align ElementAt behavior with synchronous LINQ. --- .../System/Linq/Operators/ElementAt.cs | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index dd44edf105..5736d6efb6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -22,22 +22,13 @@ public static Task ElementAt(this IAsyncEnumerable so { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (index < 0) - throw Error.ArgumentOutOfRange(nameof(index)); return ElementAtCore(source, index, cancellationToken); } private static async Task ElementAtCore(IAsyncEnumerable source, int index, CancellationToken cancellationToken) { - if (source is IList list) - { - if (index < list.Count) - { - return list[index]; - } - } - else if (source is IAsyncPartition p) + if (source is IAsyncPartition p) { var first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); @@ -45,30 +36,34 @@ private static async Task ElementAtCore(IAsyncEnumerable list) + { + return list[index]; + } - try + if (index >= 0) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (index == 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - return e.Current; - } + if (index == 0) + { + return e.Current; + } - index--; + index--; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); } } From 7b84d0a23f43fbbb697bbb0b65b18c223ee7e1dd Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:41:18 -0800 Subject: [PATCH 451/862] Streamline overloads for Except, Intersect, and Union. --- .../System.Linq.Async/System/Linq/Operators/Except.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/Intersect.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/Union.cs | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index ac8f34be84..eb30d64de9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable.Default); + return new ExceptAsyncIterator(first, second, EqualityComparer.Default); } public static IAsyncEnumerable Except(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index bf95bffe2f..9700a03152 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable if (second == null) throw Error.ArgumentNull(nameof(second)); - return first.Intersect(second, EqualityComparer.Default); + return new IntersectAsyncIterator(first, second, EqualityComparer.Default); } public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 92d172ea04..32f3462baa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable.Default); + return UnionCore(first, second, EqualityComparer.Default); } public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) @@ -30,6 +30,11 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable UnionCore(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) + { return first is UnionAsyncIterator union && AreEqualityComparersEqual(comparer, union._comparer) ? union.Union(second) : new UnionAsyncIterator2(first, second, comparer); } From 8b994b06e168fec108b4d77f4ff7b3ad7bc84e6d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 12:48:45 -0800 Subject: [PATCH 452/862] Streamline some GroupBy overloads. --- .../System.Linq.Async/System/Linq/Operators/GroupBy.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 3926edcb87..a6e49c8db2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -64,7 +64,7 @@ public static IAsyncEnumerable> GroupBy.Default); + return new GroupedAsyncEnumerable(source, keySelector, elementSelector, EqualityComparer.Default); } public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) @@ -90,7 +90,7 @@ public static IAsyncEnumerable> GroupBy.Default); + return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, EqualityComparer.Default); } public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) @@ -116,7 +116,7 @@ public static IAsyncEnumerable GroupBy(this IAs if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); + return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, EqualityComparer.Default); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) @@ -142,7 +142,7 @@ public static IAsyncEnumerable GroupBy(this IAs if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return GroupBy(source, keySelector, resultSelector, EqualityComparer.Default); + return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, EqualityComparer.Default); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) From 0966b15aa0e0189fd8a19511fb5bdb4967ebe2dc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 13:20:44 -0800 Subject: [PATCH 453/862] Remove dependency on System.Interactive for async tests. --- ...stem.Interactive.Async.Providers.Tests.csproj | 1 - .../AsyncTests.Bugs.cs | 16 +++++++++++++++- .../System.Interactive.Async.Tests.csproj | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj index d5d26b5a1e..94ad2219d1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj @@ -14,7 +14,6 @@ - diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index c4057907fe..98e2cfadb1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -158,13 +158,27 @@ internal static class MyExt { public static IEnumerable WithDispose(this IEnumerable source, Action a) { - return EnumerableEx.Create(() => + return new Enumerable(() => { var e = source.GetEnumerator(); return new Enumerator(e.MoveNext, () => e.Current, () => { e.Dispose(); a(); }); }); } + private sealed class Enumerable : IEnumerable + { + private readonly Func> _getEnumerator; + + public Enumerable(Func> getEnumerator) + { + _getEnumerator = getEnumerator; + } + + public IEnumerator GetEnumerator() => _getEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } + private sealed class Enumerator : IEnumerator { private readonly Func _moveNext; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index 19d98d9516..b6bd310725 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -14,7 +14,6 @@ - From 1362fd4d81fbdf77254a5e0db628da9f1df8dc58 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 13:22:15 -0800 Subject: [PATCH 454/862] Add minimal solution for Ix.Async. --- Ix.NET/Source/Ix.Async.NET.sln | 93 ++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Ix.NET/Source/Ix.Async.NET.sln diff --git a/Ix.NET/Source/Ix.Async.NET.sln b/Ix.NET/Source/Ix.Async.NET.sln new file mode 100644 index 0000000000..3cf8c2088d --- /dev/null +++ b/Ix.NET/Source/Ix.Async.NET.sln @@ -0,0 +1,93 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B733D97A-F1ED-4FC3-BF8E-9AC47A89DE96}" + ProjectSection(SolutionItems) = preProject + ..\..\.editorconfig = ..\..\.editorconfig + ..\..\azure-pipelines.ix.yml = ..\..\azure-pipelines.ix.yml + CodeCoverage.runsettings = CodeCoverage.runsettings + Directory.build.props = Directory.build.props + Directory.build.targets = Directory.build.targets + global.json = global.json + NuGet.Config = NuGet.Config + version.json = version.json + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async", "System.Interactive.Async\System.Interactive.Async.csproj", "{A9F6D09B-15B9-4CE8-867F-6F3383C5F247}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers", "System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj", "{33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Tests", "System.Interactive.Async.Tests\System.Interactive.Async.Tests.csproj", "{172BD8C4-5C3E-4928-9D3F-746CF336FFEC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async", "System.Linq.Async\System.Linq.Async.csproj", "{9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable", "System.Linq.Async.Queryable\System.Linq.Async.Queryable.csproj", "{513F9ABD-4FB8-4AC1-89DA-C3300399F34C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{80EFE3A1-1414-42EA-949B-1B5370A1B2EA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Tests", "System.Linq.Async.Tests\System.Linq.Async.Tests.csproj", "{2E23D7AD-0B21-4725-87C4-BD43271260A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Linq.Async.Queryable.Tests", "System.Linq.Async.Queryable.Tests\System.Linq.Async.Queryable.Tests.csproj", "{134E9066-6217-4AF0-B408-47D92AB595BD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Providers.Tests", "System.Interactive.Async.Providers.Tests\System.Interactive.Async.Providers.Tests.csproj", "{974056C0-91BD-4EB6-8431-E30A614FD1D4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release|Any CPU.Build.0 = Release|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug|Any CPU.Build.0 = Debug|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release|Any CPU.ActiveCfg = Release|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release|Any CPU.Build.0 = Release|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.Build.0 = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.Build.0 = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.Build.0 = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.Build.0 = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.Build.0 = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C} = {80EFE3A1-1414-42EA-949B-1B5370A1B2EA} + {2E23D7AD-0B21-4725-87C4-BD43271260A1} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} + {134E9066-6217-4AF0-B408-47D92AB595BD} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} + {974056C0-91BD-4EB6-8431-E30A614FD1D4} = {87534290-A7A6-47A4-9A3A-D0D21A9AD1D4} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AF70B0C6-C9D9-43B1-9BE4-08720EC1B7B7} + EndGlobalSection +EndGlobal From 01f79649b68fba351097e76116a389d5b83fbe2c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 13:25:09 -0800 Subject: [PATCH 455/862] Improving GetCountAsync to avoid async machinery. --- .../System/Linq/AsyncEnumerablePartition.cs | 57 +++++++------- .../System/Linq/Operators/Concat.cs | 31 ++++---- .../System/Linq/Operators/GroupBy.cs | 78 +++++++++++++------ .../System/Linq/Operators/Select.cs | 23 +++--- .../System/Threading/Tasks/TaskExt.cs | 1 + 5 files changed, 118 insertions(+), 72 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 9f45ed801e..30b31273e5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -62,40 +62,45 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - if (!HasLimit) + return Core(); + + async Task Core() { - // If HasLimit is false, we contain everything past _minIndexInclusive. - // Therefore, we have to iterate the whole enumerable. - return Math.Max(await _source.Count(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); - } + if (!HasLimit) + { + // If HasLimit is false, we contain everything past _minIndexInclusive. + // Therefore, we have to iterate the whole enumerable. + return Math.Max(await _source.Count(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); + } - var en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); - try - { - // We only want to iterate up to _maxIndexInclusive + 1. - // Past that, we know the enumerable will be able to fit this partition, - // so the count will just be _maxIndexInclusive + 1 - _minIndexInclusive. - - // Note that it is possible for _maxIndexInclusive to be int.MaxValue here, - // so + 1 may result in signed integer overflow. We need to handle this. - // At the same time, however, we are guaranteed that our max count can fit - // in an int because if that is true, then _minIndexInclusive must > 0. - - var count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en, cancellationToken).ConfigureAwait(false); - Debug.Assert(count != (uint)int.MaxValue + 1 || _minIndexInclusive > 0, "Our return value will be incorrect."); - return Math.Max((int)count - _minIndexInclusive, 0); - } - finally - { - await en.DisposeAsync().ConfigureAwait(false); + try + { + // We only want to iterate up to _maxIndexInclusive + 1. + // Past that, we know the enumerable will be able to fit this partition, + // so the count will just be _maxIndexInclusive + 1 - _minIndexInclusive. + + // Note that it is possible for _maxIndexInclusive to be int.MaxValue here, + // so + 1 may result in signed integer overflow. We need to handle this. + // At the same time, however, we are guaranteed that our max count can fit + // in an int because if that is true, then _minIndexInclusive must > 0. + + var count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en, cancellationToken).ConfigureAwait(false); + Debug.Assert(count != (uint)int.MaxValue + 1 || _minIndexInclusive > 0, "Our return value will be incorrect."); + return Math.Max((int)count - _minIndexInclusive, 0); + } + finally + { + await en.DisposeAsync().ConfigureAwait(false); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 784e0377ab..5745980eca 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -100,29 +100,34 @@ public async Task> ToListAsync(CancellationToken cancellationToken return list; } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var count = 0; - for (var i = 0; ; i++) + return Core(); + + async Task Core() { - var source = GetAsyncEnumerable(i); - if (source == null) + var count = 0; + for (var i = 0; ; i++) { - break; - } + var source = GetAsyncEnumerable(i); + if (source == null) + { + break; + } - checked - { - count += await source.Count(cancellationToken).ConfigureAwait(false); + checked + { + count += await source.Count(cancellationToken).ConfigureAwait(false); + } } - } - return count; + return count; + } } public override async ValueTask DisposeAsync() diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index a6e49c8db2..8ca86e2c4f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -295,16 +295,21 @@ public async Task> ToListAsync(CancellationToken cancellationToken return l.ToList(_resultSelector); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return Core(); + + async Task Core() + { + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); - return l.Count; + return l.Count; + } } } @@ -384,16 +389,21 @@ public async Task> ToListAsync(CancellationToken cancellationToken return await l.ToList(_resultSelector).ConfigureAwait(false); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return Core(); - return l.Count; + async Task Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } } } @@ -473,16 +483,21 @@ public async Task>> ToListAsync(Cancellation return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return Core(); - return l.Count; + async Task Core() + { + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } } } @@ -562,16 +577,21 @@ public async Task>> ToListAsync(Cancellation return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return Core(); - return l.Count; + async Task Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } } } @@ -647,16 +667,21 @@ public async Task>> ToListAsync(CancellationT return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return Core(); + + async Task Core() + { + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); - return l.Count; + return l.Count; + } } } @@ -732,16 +757,21 @@ public async Task>> ToListAsync(CancellationT return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return Core(); - return l.Count; + async Task Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index f29b997b16..d69868d80c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -471,26 +471,31 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return -1; + return TaskExt.MinusOne; } - var count = 0; + return Core(); - foreach (var item in _source) + async Task Core() { - await _selector(item).ConfigureAwait(false); + var count = 0; - checked + foreach (var item in _source) { - count++; + await _selector(item).ConfigureAwait(false); + + checked + { + count++; + } } - } - return count; + return count; + } } public override IAsyncEnumerable Select(Func> selector) diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs index e617a8ae12..80d8788f7b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs @@ -9,5 +9,6 @@ internal static class TaskExt public static readonly ValueTask True = new ValueTask(true); public static readonly ValueTask False = new ValueTask(false); public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); + public static readonly Task MinusOne = Task.FromResult(-1); } } From e25eb849f013a6162bd7986720ad33c4c2908d71 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 13:29:27 -0800 Subject: [PATCH 456/862] Reduce TaskExt surface. --- .../System.Interactive.Async/System/Linq/Operators/Repeat.cs | 2 +- Ix.NET/Source/System.Interactive.Async/TaskExt.cs | 2 -- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs | 2 +- .../Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index 6a1a8c6628..dc50ff31e2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -53,7 +53,7 @@ protected override ValueTask MoveNextCore(CancellationToken cancellationTo cancellationToken.ThrowIfCancellationRequested(); current = _element; - return TaskExt.True; + return new ValueTask(true); } } diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index 0f8caa233f..918b9026e9 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -6,8 +6,6 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly ValueTask True = new ValueTask(true); - public static readonly ValueTask False = new ValueTask(false); public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); public static readonly ValueTask Never = new ValueTask(new TaskCompletionSource().Task); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 3f17a47fa4..29fdd61f92 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -40,7 +40,7 @@ public Task ToArrayAsync(CancellationToken cancellationToken) => Task. public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe()); - public ValueTask MoveNextAsync() => TaskExt.False; + public ValueTask MoveNextAsync() => new ValueTask(false); public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => this; diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs index 80d8788f7b..6a23fabf3f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs @@ -6,8 +6,6 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly ValueTask True = new ValueTask(true); - public static readonly ValueTask False = new ValueTask(false); public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); public static readonly Task MinusOne = Task.FromResult(-1); } From 095cea4e2ab1828ad30365613100cd8f580a2c8a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 13:34:02 -0800 Subject: [PATCH 457/862] Improve ThenBy calls. --- .../Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index 65d8b688a0..6bb907bedd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -147,7 +147,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.ThenByDescending(keySelector, Comparer.Default); + return source.CreateOrderedEnumerable(keySelector, Comparer.Default, descending: true); } public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) @@ -157,7 +157,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.ThenByDescending(keySelector, Comparer.Default); + return source.CreateOrderedEnumerable(keySelector, Comparer.Default, descending: true); } public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector, IComparer comparer) From fcb9967b83e36088c51c61490a63dcefd9a08945 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 13:35:57 -0800 Subject: [PATCH 458/862] Add review comment for OrderBy. --- .../System/Linq/Operators/OrderedAsyncEnumerable.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 917ce27e21..3b07c87990 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -35,6 +35,8 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella case AsyncIteratorState.Allocated: _buffer = await _source.ToArray(cancellationToken).ConfigureAwait(false); + // REVIEW: If we add selectors with CancellationToken support, we should feed the token to Sort. + var sorter = GetAsyncEnumerableSorter(next: null); _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); _index = 0; From f42f8a6ccd2ce9b9fc0431c275067d75d42c533e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 13:48:03 -0800 Subject: [PATCH 459/862] Improve ToEnumerable exception behavior. --- .../System/Linq/Operators/ToEnumerable.cs | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs index 876efe1c3a..ce57fb1961 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs @@ -13,29 +13,27 @@ public static IEnumerable ToEnumerable(this IAsyncEnumerable ToEnumerableCore(IAsyncEnumerable source) - { - var e = source.GetAsyncEnumerator(default); + return Core(); - try + IEnumerable Core() { - while (true) - { - if (!e.MoveNextAsync().Result) - break; + var e = source.GetAsyncEnumerator(default); - var c = e.Current; + try + { + while (true) + { + if (!e.MoveNextAsync().GetAwaiter().GetResult()) + break; - yield return c; + yield return e.Current; + } + } + finally + { + // Wait + e.DisposeAsync().GetAwaiter().GetResult(); } - } - finally - { - // Wait - e.DisposeAsync().GetAwaiter().GetResult(); } } } From 9ae1b177c4841207bff7e42ec00c0e64f8a898a1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 14:00:25 -0800 Subject: [PATCH 460/862] Remove unused Throw. --- .../System/Linq/AsyncEnumerable.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 0de4fdac19..714cb07c0a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Threading.Tasks; namespace System.Linq { @@ -16,26 +15,5 @@ public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEn return source.Select(x => x); } - - private static IAsyncEnumerable Throw(Exception exception) - { - if (exception == null) - throw Error.ArgumentNull(nameof(exception)); - -#if NO_TASK_FROMEXCEPTION - var tcs = new TaskCompletionSource(); - tcs.TrySetException(exception); - var moveNextThrows = new ValueTask(tcs.Task); -#else - var moveNextThrows = new ValueTask(Task.FromException(exception)); -#endif - - return CreateEnumerable( - _ => CreateEnumerator( - () => moveNextThrows, - current: null, - dispose: null) - ); - } } } From 63515ad6f955236a230d53d536385d1b290067b3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 14:01:42 -0800 Subject: [PATCH 461/862] No more hiding for AsAsyncEnumerable. --- .../System.Linq.Async/System/Linq/AsyncEnumerable.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 714cb07c0a..074d1b7e3b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -8,12 +8,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); + // NB: Synchronous LINQ to Objects doesn't hide the implementation of the source either. - return source.Select(x => x); - } + public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEnumerable source) => source; } } From e7c1846962a4b082bd6972f7be2ac6027913a587 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 10 Nov 2018 14:03:48 -0800 Subject: [PATCH 462/862] Fixing AsAsyncEnumerable test. --- .../System/Linq/Operators/AsAsyncEnumerable.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs index 6c0203d231..eb02bed50d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/AsAsyncEnumerable.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; using System.Linq; using Xunit; @@ -11,23 +9,13 @@ namespace Tests { public class AsAsyncEnumerable : AsyncEnumerableTests { - [Fact] - public void AsAsyncEnumerable_Null() - { - AssertThrows(() => AsyncEnumerable.AsAsyncEnumerable(default(IAsyncEnumerable))); - } - [Fact] public void AsAsyncEnumerable1() { var xs = Return42; var ys = xs.AsAsyncEnumerable(); - Assert.NotSame(xs, ys); - - var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); + Assert.Same(xs, ys); // NB: Consistent with LINQ to Objects behavior. } } } From bfaaf0b39e2dc8820597e022c6b2b95d30e3c565 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 09:52:41 -0800 Subject: [PATCH 463/862] Avoid using .Result in favor of await (cf. exception behavior). --- .../Source/System.Linq.Async/System/Linq/Operators/Except.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/Intersect.cs | 2 +- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index eb30d64de9..41ff821144 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -99,7 +99,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella await Task.WhenAll(moveNextTask.AsTask(), _fillSetTask).ConfigureAwait(false); _setFilled = true; - moveNext = moveNextTask.Result; + moveNext = await moveNextTask.ConfigureAwait(false); } else { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 9700a03152..9737bebd08 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -99,7 +99,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella var moveNextTask = _firstEnumerator.MoveNextAsync(); await Task.WhenAll(moveNextTask.AsTask(), _fillSetTask).ConfigureAwait(false); _setFilled = true; - moveNext = moveNextTask.Result; + moveNext = await moveNextTask.ConfigureAwait(false); } else { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 49cd5f877c..853aeb9ca9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -99,7 +99,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); - if (ft.Result && st.Result) + if (await ft.ConfigureAwait(false) && await st.ConfigureAwait(false)) { current = _selector(_firstEnumerator.Current, _secondEnumerator.Current); return true; @@ -173,7 +173,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella var st = _secondEnumerator.MoveNextAsync(); await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); - if (ft.Result && st.Result) + if (await ft.ConfigureAwait(false) && await st.ConfigureAwait(false)) { current = await _selector(_firstEnumerator.Current, _secondEnumerator.Current).ConfigureAwait(false); return true; From dd3885abe58cb61e7e8b06e8ebaaf3c122d5a693 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 09:53:22 -0800 Subject: [PATCH 464/862] Reuse cached task for -1. --- .../Source/System.Linq.Async/System/Linq/Operators/Reverse.cs | 2 +- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs | 2 +- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index 9655ec874e..f606c03aa8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -69,7 +69,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT if (!(_source is ICollection) && !(_source is ICollection)) { - return Task.FromResult(-1); + return TaskExt.MinusOne; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index d69868d80c..c081807962 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -238,7 +238,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT { if (onlyIfCheap) { - return Task.FromResult(-1); + return TaskExt.MinusOne; } var count = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 32f3462baa..c67c22346a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -182,7 +182,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke public Task> ToListAsync(CancellationToken cancellationToken) => FillSetAsync(cancellationToken).ContinueWith(set => set.Result.ToList()); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => onlyIfCheap ? Task.FromResult(-1) : FillSetAsync(cancellationToken).ContinueWith(set => set.Result.Count); + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => onlyIfCheap ? TaskExt.MinusOne : FillSetAsync(cancellationToken).ContinueWith(set => set.Result.Count); } /// From d10837ce079e6a8ff518c76fee1c4f3bd8a11603 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 10:28:13 -0800 Subject: [PATCH 465/862] Tame concurrency in Except and Intersect. --- .../System/Linq/AsyncEnumerableHelpers.cs | 21 +++++++++++ .../System/Linq/Operators/Except.cs | 37 ++++--------------- .../System/Linq/Operators/Intersect.cs | 35 ++++-------------- 3 files changed, 35 insertions(+), 58 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 3990701122..170f0a2a9b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -106,6 +106,27 @@ internal static async Task> ToArrayWithLength(IAsyncEnumer return result; } + internal static async Task> ToSet(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + var set = new Set(comparer); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + set.Add(e.Current); + } + + return set; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + internal struct ArrayWithLength { public T[] Array; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 41ff821144..4f55d52aeb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -39,13 +39,9 @@ private sealed class ExceptAsyncIterator : AsyncIterator private readonly IAsyncEnumerable _first; private readonly IAsyncEnumerable _second; - private Task _fillSetTask; - private IAsyncEnumerator _firstEnumerator; private Set _set; - private bool _setFilled; - public ExceptAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { Debug.Assert(first != null); @@ -77,13 +73,16 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { + // NB: Earlier implementations of this operator constructed the set for the second source concurrently + // with the first MoveNextAsync call on the first source. This resulted in an unexpected source of + // concurrency, which isn't a great default behavior because it's very hard to suppress or control + // this behavior. + switch (state) { case AsyncIteratorState.Allocated: + _set = await AsyncEnumerableHelpers.ToSet(_second, _comparer, cancellationToken).ConfigureAwait(false); _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); - _set = new Set(_comparer); - _setFilled = false; - _fillSetTask = FillSetAsync(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -92,19 +91,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella bool moveNext; do { - if (!_setFilled) - { - // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = _firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask.AsTask(), _fillSetTask).ConfigureAwait(false); - - _setFilled = true; - moveNext = await moveNextTask.ConfigureAwait(false); - } - else - { - moveNext = await _firstEnumerator.MoveNextAsync().ConfigureAwait(false); - } + moveNext = await _firstEnumerator.MoveNextAsync().ConfigureAwait(false); if (moveNext) { @@ -123,16 +110,6 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return false; } - - private async Task FillSetAsync(CancellationToken cancellationToken) - { - var array = await _second.ToArray(cancellationToken).ConfigureAwait(false); - - foreach (var t in array) - { - _set.Add(t); - } - } } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 9737bebd08..aabd70415b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -39,13 +39,9 @@ private sealed class IntersectAsyncIterator : AsyncIterator private readonly IAsyncEnumerable _first; private readonly IAsyncEnumerable _second; - private Task _fillSetTask; - private IAsyncEnumerator _firstEnumerator; private Set _set; - private bool _setFilled; - public IntersectAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { Debug.Assert(first != null); @@ -77,13 +73,16 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { + // NB: Earlier implementations of this operator constructed the set for the second source concurrently + // with the first MoveNextAsync call on the first source. This resulted in an unexpected source of + // concurrency, which isn't a great default behavior because it's very hard to suppress or control + // this behavior. + switch (state) { case AsyncIteratorState.Allocated: + _set = await AsyncEnumerableHelpers.ToSet(_second, _comparer, cancellationToken).ConfigureAwait(false); _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); - _set = new Set(_comparer); - _setFilled = false; - _fillSetTask = FillSet(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -93,18 +92,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella bool moveNext; do { - if (!_setFilled) - { - // This is here so we don't need to call Task.WhenAll each time after the set is filled - var moveNextTask = _firstEnumerator.MoveNextAsync(); - await Task.WhenAll(moveNextTask.AsTask(), _fillSetTask).ConfigureAwait(false); - _setFilled = true; - moveNext = await moveNextTask.ConfigureAwait(false); - } - else - { - moveNext = await _firstEnumerator.MoveNextAsync().ConfigureAwait(false); - } + moveNext = await _firstEnumerator.MoveNextAsync().ConfigureAwait(false); if (moveNext) { @@ -123,15 +111,6 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return false; } - - private async Task FillSet(CancellationToken cancellationToken) - { - var array = await _second.ToArray(cancellationToken).ConfigureAwait(false); - for (var i = 0; i < array.Length; i++) - { - _set.Add(array[i]); - } - } } } } From 99df49c46f39ffdaeea12552146922181a0fc597 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 10:32:04 -0800 Subject: [PATCH 466/862] Taming the concurrency in Zip. --- .../System/Linq/Operators/Zip.cs | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 853aeb9ca9..45175a29d3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -79,6 +79,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { + // REVIEW: Earlier versions of this operator performed concurrent MoveNextAsync calls, which isn't a great default and + // results in an unexpected source of concurrency. However, a concurrent Zip may be a worthy addition to the + // API or System.Interactive.Async as a complementary implementation besides the conservative default. + switch (state) { case AsyncIteratorState.Allocated: @@ -89,17 +93,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - - // REVIEW: Do we want concurrent behavior by default? Likely not, so we should introduce ConcurrentZip - // either here or in System.Interactive.Async. - - // We kick these off and join so they can potentially run in parallel - var ft = _firstEnumerator.MoveNextAsync(); - var st = _secondEnumerator.MoveNextAsync(); - - await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); - - if (await ft.ConfigureAwait(false) && await st.ConfigureAwait(false)) + if (await _firstEnumerator.MoveNextAsync().ConfigureAwait(false) && await _secondEnumerator.MoveNextAsync().ConfigureAwait(false)) { current = _selector(_firstEnumerator.Current, _secondEnumerator.Current); return true; @@ -157,6 +151,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { + // REVIEW: Earlier versions of this operator performed concurrent MoveNextAsync calls, which isn't a great default and + // results in an unexpected source of concurrency. However, a concurrent Zip may be a worthy addition to the + // API or System.Interactive.Async as a complementary implementation besides the conservative default. + switch (state) { case AsyncIteratorState.Allocated: @@ -167,13 +165,7 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - - // We kick these off and join so they can potentially run in parallel - var ft = _firstEnumerator.MoveNextAsync(); - var st = _secondEnumerator.MoveNextAsync(); - await Task.WhenAll(ft.AsTask(), st.AsTask()).ConfigureAwait(false); - - if (await ft.ConfigureAwait(false) && await st.ConfigureAwait(false)) + if (await _firstEnumerator.MoveNextAsync().ConfigureAwait(false) && await _secondEnumerator.MoveNextAsync().ConfigureAwait(false)) { current = await _selector(_firstEnumerator.Current, _secondEnumerator.Current).ConfigureAwait(false); return true; From 674b5db3f15c4647aea5833fe4ce70a17104a841 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 10:40:50 -0800 Subject: [PATCH 467/862] Fix dispose order in Zip. --- .../System/Linq/Operators/Zip.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 45175a29d3..989f795936 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -62,18 +62,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_firstEnumerator != null) - { - await _firstEnumerator.DisposeAsync().ConfigureAwait(false); - _firstEnumerator = null; - } - if (_secondEnumerator != null) { await _secondEnumerator.DisposeAsync().ConfigureAwait(false); _secondEnumerator = null; } + if (_firstEnumerator != null) + { + await _firstEnumerator.DisposeAsync().ConfigureAwait(false); + _firstEnumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); } @@ -134,18 +134,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_firstEnumerator != null) - { - await _firstEnumerator.DisposeAsync().ConfigureAwait(false); - _firstEnumerator = null; - } - if (_secondEnumerator != null) { await _secondEnumerator.DisposeAsync().ConfigureAwait(false); _secondEnumerator = null; } + if (_firstEnumerator != null) + { + await _firstEnumerator.DisposeAsync().ConfigureAwait(false); + _firstEnumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); } From 1eb95c90fe1eeca024c17cc61bd871347c9215f8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 12:06:42 -0800 Subject: [PATCH 468/862] Using a null comparer is allowed. --- .../System/Linq/Operators/Distinct.cs | 1 - .../System/Linq/Operators/Contains.cs | 2 - .../System/Linq/Operators/Distinct.cs | 1 - .../System/Linq/Operators/Except.cs | 1 - .../System/Linq/Operators/GroupBy.cs | 4 -- .../System/Linq/Operators/GroupJoin.cs | 1 - .../System/Linq/Operators/Intersect.cs | 1 - .../System/Linq/Operators/Join.cs | 1 - .../System/Linq/Operators/OrderBy.cs | 4 -- .../System/Linq/Operators/SequenceEqual.cs | 2 - .../System/Linq/Operators/ToDictionary.cs | 4 -- .../System/Linq/Operators/ToHashSet.cs | 1 - .../System/Linq/Operators/ToLookup.cs | 4 -- .../System/Linq/Operators/Union.cs | 2 - .../System/Linq/Operators/Contains.cs | 4 -- .../System/Linq/Operators/Distinct.cs | 4 +- .../System/Linq/Operators/Except.cs | 5 +-- .../System/Linq/Operators/GroupBy.cs | 38 ++++--------------- .../System/Linq/Operators/GroupJoin.cs | 8 +--- .../System/Linq/Operators/Intersect.cs | 5 +-- .../System/Linq/Operators/Join.cs | 10 +---- .../System/Linq/Operators/OrderBy.cs | 24 ++---------- .../Linq/Operators/OrderedAsyncEnumerable.cs | 4 +- .../System/Linq/Operators/SequenceEqual.cs | 13 ++++--- .../System/Linq/Operators/ToDictionary.cs | 16 -------- .../System/Linq/Operators/ToHashSet.cs | 8 +--- .../System/Linq/Operators/ToLookup.cs | 34 ++++------------- .../System/Linq/Operators/Union.cs | 4 +- 28 files changed, 38 insertions(+), 168 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index 319f90a210..144d785fa5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -22,7 +22,6 @@ public void Distinct_Null() AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index 51280f9fb8..5f251ed936 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -18,11 +18,9 @@ public async Task Contains_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(Return42, 42, null)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(Return42, 42, null, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index b7769376bc..2d31b792b0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -17,7 +17,6 @@ public void Distinct_Null() { AssertThrows(() => AsyncEnumerable.Distinct(default)); AssertThrows(() => AsyncEnumerable.Distinct(default, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Distinct(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs index b6d4749b72..96cee59158 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs @@ -20,7 +20,6 @@ public void Except_Null() AssertThrows(() => AsyncEnumerable.Except(default, Return42, new Eq())); AssertThrows(() => AsyncEnumerable.Except(Return42, null, new Eq())); - AssertThrows(() => AsyncEnumerable.Except(Return42, Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 1b21c10ed2..0d9a7d4c11 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -20,7 +20,6 @@ public void GroupBy_Null() AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default)); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x)); @@ -29,7 +28,6 @@ public void GroupBy_Null() AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default)); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x)); @@ -38,7 +36,6 @@ public void GroupBy_Null() AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, (x, ys) => x, default)); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x)); @@ -49,7 +46,6 @@ public void GroupBy_Null() AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, (x, ys) => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index a01ba4c037..648eb79d64 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -25,7 +25,6 @@ public void GroupJoin_Null() AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, (x, y) => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs index afe6a150b8..45a8628654 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs @@ -20,7 +20,6 @@ public void Intersect_Null() AssertThrows(() => AsyncEnumerable.Intersect(default, Return42, new Eq())); AssertThrows(() => AsyncEnumerable.Intersect(Return42, default, new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index 01ba0eced2..e4dbd6b0d8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -26,7 +26,6 @@ public void Join_Null() AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, (x, y) => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index 12a41476b8..952d0fbdb7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -20,14 +20,12 @@ public void OrderBy_Null() AssertThrows(() => AsyncEnumerable.OrderBy(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(Return42, x => x, default)); AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x)); AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, x => x, default)); var xs = Return42.OrderBy(x => x); @@ -36,14 +34,12 @@ public void OrderBy_Null() AssertThrows(() => AsyncEnumerable.ThenBy(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, x => x, default)); AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x)); AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x, Comparer.Default)); AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 8b9a6160e0..3951b18038 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -21,14 +21,12 @@ public async Task SequenceEqual_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq())); await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, Return42, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq(), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, Return42, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index fef0d62b99..75536030d9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -21,7 +21,6 @@ public async Task ToDictionary_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0)); @@ -30,14 +29,12 @@ public async Task ToDictionary_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, CancellationToken.None)); @@ -46,7 +43,6 @@ public async Task ToDictionary_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, x => 0, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index 9754076fa2..be3b98d5de 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -20,7 +20,6 @@ public async Task ToHashSet_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(Return42, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index 09bf974bbd..19e3ec8c16 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -22,7 +22,6 @@ public async Task ToLookup_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0)); @@ -31,14 +30,12 @@ public async Task ToLookup_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, x => 0, default(IEqualityComparer))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, CancellationToken.None)); @@ -47,7 +44,6 @@ public async Task ToLookup_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, x => 0, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs index 039c5ecf49..c6a7cd65b3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -15,11 +15,9 @@ public class Union : AsyncEnumerableTests public void Union_Null() { AssertThrows(() => AsyncEnumerable.Union(default, Return42)); - AssertThrows(() => AsyncEnumerable.Union(Return42, default)); AssertThrows(() => AsyncEnumerable.Union(default, Return42, new Eq())); AssertThrows(() => AsyncEnumerable.Union(Return42, default, new Eq())); - AssertThrows(() => AsyncEnumerable.Union(Return42, Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index fd696696c4..5c2bafc2e1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -30,8 +30,6 @@ public static Task Contains(this IAsyncEnumerable source { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ContainsCore(source, value, comparer, CancellationToken.None); } @@ -40,8 +38,6 @@ public static Task Contains(this IAsyncEnumerable source { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ContainsCore(source, value, comparer, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 6641b81b73..eff25f07ba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -16,15 +16,13 @@ public static IAsyncEnumerable Distinct(this IAsyncEnumerable< if (source == null) throw Error.ArgumentNull(nameof(source)); - return new DistinctAsyncIterator(source, EqualityComparer.Default); + return new DistinctAsyncIterator(source, comparer: null); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new DistinctAsyncIterator(source, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 4f55d52aeb..44fd646e35 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable(first, second, EqualityComparer.Default); + return new ExceptAsyncIterator(first, second, comparer: null); } public static IAsyncEnumerable Except(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) @@ -27,8 +27,6 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable(first, second, comparer); } @@ -46,7 +44,6 @@ public ExceptAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable> GroupBy(source, keySelector, EqualityComparer.Default); + return new GroupedAsyncEnumerable(source, keySelector, comparer: null); } public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -27,8 +27,6 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, comparer); } @@ -40,7 +38,7 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, EqualityComparer.Default); + return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer: null); } public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -49,8 +47,6 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, comparer); } @@ -64,7 +60,7 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, EqualityComparer.Default); + return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer: null); } public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) @@ -75,8 +71,6 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, comparer); } @@ -90,7 +84,7 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, EqualityComparer.Default); + return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer: null); } public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) @@ -101,8 +95,6 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, comparer); } @@ -116,7 +108,7 @@ public static IAsyncEnumerable GroupBy(this IAs if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, EqualityComparer.Default); + return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer: null); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) @@ -127,8 +119,6 @@ public static IAsyncEnumerable GroupBy(this IAs throw Error.ArgumentNull(nameof(keySelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); } @@ -142,7 +132,7 @@ public static IAsyncEnumerable GroupBy(this IAs if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, EqualityComparer.Default); + return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) @@ -153,8 +143,6 @@ public static IAsyncEnumerable GroupBy(this IAs throw Error.ArgumentNull(nameof(keySelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); } @@ -170,7 +158,7 @@ public static IAsyncEnumerable GroupBy.Default).Select(g => resultSelector(g.Key, g)); + return source.GroupBy(keySelector, elementSelector, comparer: null).Select(g => resultSelector(g.Key, g)); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) @@ -183,8 +171,6 @@ public static IAsyncEnumerable GroupBy resultSelector(g.Key, g)); } @@ -200,7 +186,7 @@ public static IAsyncEnumerable GroupBy.Default).Select(g => resultSelector(g.Key, g)); + return source.GroupBy(keySelector, elementSelector, comparer: null).Select(g => resultSelector(g.Key, g)); } public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, Task> resultSelector, IEqualityComparer comparer) @@ -213,8 +199,6 @@ public static IAsyncEnumerable GroupBy resultSelector(g.Key, g)); } @@ -234,7 +218,6 @@ public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func source, Fu Debug.Assert(source != null); Debug.Assert(keySelector != null); Debug.Assert(resultSelector != null); - Debug.Assert(comparer != null); _source = source; _keySelector = keySelector; @@ -422,7 +404,6 @@ public GroupedAsyncEnumerable(IAsyncEnumerable source, Func source, Func source, Func source, Func GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector, IEqualityComparer comparer) @@ -38,8 +38,6 @@ public static IAsyncEnumerable GroupJoin throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } @@ -57,7 +55,7 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return outer.GroupJoin(inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector, IEqualityComparer comparer) @@ -72,8 +70,6 @@ public static IAsyncEnumerable GroupJoin throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index aabd70415b..bc20274274 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable if (second == null) throw Error.ArgumentNull(nameof(second)); - return new IntersectAsyncIterator(first, second, EqualityComparer.Default); + return new IntersectAsyncIterator(first, second, comparer: null); } public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) @@ -27,8 +27,6 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable throw Error.ArgumentNull(nameof(first)); if (second == null) throw Error.ArgumentNull(nameof(second)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new IntersectAsyncIterator(first, second, comparer); } @@ -46,7 +44,6 @@ public IntersectAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable< { Debug.Assert(first != null); Debug.Assert(second != null); - Debug.Assert(comparer != null); _first = first; _second = second; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index bc01b53b97..ce4d11039f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -24,7 +24,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector, IEqualityComparer comparer) @@ -39,8 +39,6 @@ public static IAsyncEnumerable Join(this throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } @@ -58,7 +56,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, EqualityComparer.Default); + return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) @@ -73,8 +71,6 @@ public static IAsyncEnumerable Join(this throw Error.ArgumentNull(nameof(innerKeySelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } @@ -97,7 +93,6 @@ public JoinAsyncIterator(IAsyncEnumerable outer, IAsyncEnumerable outer, IAsyncEnumerabl Debug.Assert(outerKeySelector != null); Debug.Assert(innerKeySelector != null); Debug.Assert(resultSelector != null); - Debug.Assert(comparer != null); _outer = outer; _inner = inner; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index 6bb907bedd..6980367d0d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -16,7 +16,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.OrderBy(keySelector, Comparer.Default); + return OrderBy(source, keySelector, comparer: null); } public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) @@ -26,7 +26,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.OrderBy(keySelector, Comparer.Default); + return OrderBy(source, keySelector, comparer: null); } public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) @@ -35,8 +35,6 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); } @@ -46,8 +44,6 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); } @@ -59,7 +55,7 @@ public static IOrderedAsyncEnumerable OrderByDescending( if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.OrderByDescending(keySelector, Comparer.Default); + return source.OrderByDescending(keySelector, comparer: null); } public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) @@ -69,7 +65,7 @@ public static IOrderedAsyncEnumerable OrderByDescending( if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.OrderByDescending(keySelector, Comparer.Default); + return source.OrderByDescending(keySelector, comparer: null); } public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) @@ -78,8 +74,6 @@ public static IOrderedAsyncEnumerable OrderByDescending( throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); } @@ -90,8 +84,6 @@ public static IOrderedAsyncEnumerable OrderByDescending( throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); } @@ -122,8 +114,6 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } @@ -134,8 +124,6 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } @@ -166,8 +154,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } @@ -178,8 +164,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 3b07c87990..a38385dde1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -80,7 +80,6 @@ public OrderedAsyncEnumerable(IAsyncEnumerable source, Func source, Func : AsyncEnumera public AsyncEnumerableSorterBase(IComparer comparer, bool descending, AsyncEnumerableSorter next) { - _comparer = comparer; + _comparer = comparer ?? Comparer.Default; _descending = descending; _next = next; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 4ed72e6195..a60de0aaab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -17,7 +17,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f if (second == null) throw Error.ArgumentNull(nameof(second)); - return SequenceEqualCore(first, second, EqualityComparer.Default, CancellationToken.None); + return SequenceEqualCore(first, second, comparer: null, CancellationToken.None); } public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) @@ -27,7 +27,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f if (second == null) throw Error.ArgumentNull(nameof(second)); - return SequenceEqualCore(first, second, EqualityComparer.Default, cancellationToken); + return SequenceEqualCore(first, second, comparer: null, cancellationToken); } public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) @@ -36,8 +36,6 @@ public static Task SequenceEqual(this IAsyncEnumerable f throw Error.ArgumentNull(nameof(first)); if (second == null) throw Error.ArgumentNull(nameof(second)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return SequenceEqualCore(first, second, comparer, CancellationToken.None); } @@ -48,8 +46,6 @@ public static Task SequenceEqual(this IAsyncEnumerable f throw Error.ArgumentNull(nameof(first)); if (second == null) throw Error.ArgumentNull(nameof(second)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return SequenceEqualCore(first, second, comparer, cancellationToken); } @@ -61,6 +57,11 @@ private static Task SequenceEqualCore(IAsyncEnumerable f return Task.FromResult(false); } + if (comparer == null) + { + comparer = EqualityComparer.Default; + } + return Core(); async Task Core() diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index adb527afe5..ef0637d68c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -56,8 +56,6 @@ public static Task> ToDictionary(this I throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => x, comparer, CancellationToken.None); } @@ -68,8 +66,6 @@ public static Task> ToDictionary(this I throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); } @@ -80,8 +76,6 @@ public static Task> ToDictionary(this I throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None); } @@ -92,8 +86,6 @@ public static Task> ToDictionary(this I throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken); } @@ -154,8 +146,6 @@ public static Task> ToDictionary> ToDictionary> ToDictionary> ToDictionary> ToHashSet(this IAsyncEnumerable.Default, CancellationToken.None); + return ToHashSetCore(source, comparer: null, CancellationToken.None); } public static Task> ToHashSet(this IAsyncEnumerable source, CancellationToken cancellationToken) @@ -23,15 +23,13 @@ public static Task> ToHashSet(this IAsyncEnumerable.Default, cancellationToken); + return ToHashSetCore(source, comparer: null, cancellationToken); } public static Task> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToHashSetCore(source, comparer, CancellationToken.None); } @@ -40,8 +38,6 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => x, EqualityComparer.Default, CancellationToken.None); + return ToLookupCore(source, keySelector, x => x, comparer: null, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) @@ -29,7 +27,7 @@ public static Task> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, x => x, comparer: null, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector) @@ -39,7 +37,7 @@ public static Task> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, CancellationToken.None); + return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer: null, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) @@ -49,7 +47,7 @@ public static Task> ToLookup(this IAsyncEn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer: null, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -58,8 +56,6 @@ public static Task> ToLookup(this IAsyncEn throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, x => x, comparer, CancellationToken.None); } @@ -70,8 +66,6 @@ public static Task> ToLookup(this IAsyncEn throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, x => x, comparer, cancellationToken); } @@ -82,8 +76,6 @@ public static Task> ToLookup(this IAsyncEn throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None); } @@ -94,8 +86,6 @@ public static Task> ToLookup(this IAsyncEn throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken); } @@ -109,7 +99,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); + return ToLookupCore(source, keySelector, elementSelector, comparer: null, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) @@ -121,7 +111,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) @@ -133,7 +123,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); + return ToLookupCore(source, keySelector, elementSelector, comparer: null, CancellationToken.None); } public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) @@ -145,7 +135,7 @@ public static Task> ToLookup(th if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - return ToLookupCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); + return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) @@ -156,8 +146,6 @@ public static Task> ToLookup(th throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } @@ -170,8 +158,6 @@ public static Task> ToLookup(th throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, elementSelector, comparer, cancellationToken); } @@ -184,8 +170,6 @@ public static Task> ToLookup(th throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } @@ -198,8 +182,6 @@ public static Task> ToLookup(th throw Error.ArgumentNull(nameof(keySelector)); if (elementSelector == null) throw Error.ArgumentNull(nameof(elementSelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return ToLookupCore(source, keySelector, elementSelector, comparer, cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index c67c22346a..ecc7c95178 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable.Default); + return UnionCore(first, second, comparer: null); } public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) @@ -27,8 +27,6 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable Date: Mon, 12 Nov 2018 12:21:14 -0800 Subject: [PATCH 469/862] Comparers can be null. --- .../Linq/Operators/DistinctUntilChanged.cs | 2 -- .../System/Linq/Operators/Max.cs | 2 -- .../System/Linq/Operators/MaxBy.cs | 2 -- .../System/Linq/Operators/Min.cs | 2 -- .../System/Linq/Operators/MinBy.cs | 2 -- .../System/Linq/Operators/Distinct.cs | 8 ++---- .../Linq/Operators/DistinctUntilChanged.cs | 17 +++++------- .../System/Linq/Operators/Max.cs | 11 ++++---- .../System/Linq/Operators/MaxBy.cs | 26 ++++++++++--------- .../System/Linq/Operators/Min.cs | 9 ++++--- .../System/Linq/Operators/MinBy.cs | 26 ++++++++++--------- 11 files changed, 47 insertions(+), 60 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs index 0ba87cfbc7..0103fca7c6 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -18,14 +18,12 @@ public void DistinctUntilChanged_Null() AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default)); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func))); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs index abcfd7bbd2..5c5563ea15 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs @@ -17,10 +17,8 @@ public class Max : AsyncEnumerableExTests public async Task Max_Null() { await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(AsyncEnumerable.Empty(), default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index a59aa074da..48dfedf8a4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -21,14 +21,12 @@ public async Task MaxBy_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, x => x, default(IComparer))); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, x => x, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs index 111a9d17f9..50a1157c78 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs @@ -17,10 +17,8 @@ public class Min : AsyncEnumerableExTests public async Task Min_Null() { await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(AsyncEnumerable.Empty(), default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index f4af0f8ddb..af3ef50bb1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -21,14 +21,12 @@ public async Task MinBy_Null() await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, x => x, default(IComparer))); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, x => x, default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index d87ce0a44d..80a783b4cc 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return DistinctCore(source, keySelector, EqualityComparer.Default); + return DistinctCore(source, keySelector, comparer: null); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -27,8 +27,6 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); return DistinctCore(source, keySelector, comparer); } @@ -40,7 +38,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return DistinctCore(source, keySelector, EqualityComparer.Default); + return DistinctCore(source, keySelector, comparer: null); } public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -78,7 +76,6 @@ public DistinctAsyncIterator(IAsyncEnumerable source, Func source, Func DistinctUntilChanged(this IAsyn if (source == null) throw new ArgumentNullException(nameof(source)); - return DistinctUntilChangedCore(source, EqualityComparer.Default); + return DistinctUntilChangedCore(source, comparer: null); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); return DistinctUntilChangedCore(source, comparer); } @@ -36,7 +34,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return DistinctUntilChangedCore(source, keySelector, EqualityComparer.Default); + return DistinctUntilChangedCore(source, keySelector, comparer: null); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -45,8 +43,6 @@ public static IAsyncEnumerable DistinctUntilChanged(this throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); return DistinctUntilChangedCore(source, keySelector, comparer); } @@ -58,7 +54,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return DistinctUntilChangedCore(source, keySelector, EqualityComparer.Default); + return DistinctUntilChangedCore(source, keySelector, comparer: null); } public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -99,11 +95,10 @@ private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator< public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, IEqualityComparer comparer) { - Debug.Assert(comparer != null); Debug.Assert(source != null); _source = source; - _comparer = comparer; + _comparer = comparer ?? EqualityComparer.Default; } public override AsyncIterator Clone() @@ -174,7 +169,7 @@ public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, Func< { _source = source; _keySelector = keySelector; - _comparer = comparer; + _comparer = comparer ?? EqualityComparer.Default; } public override AsyncIterator Clone() @@ -245,7 +240,7 @@ public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable sourc { _source = source; _keySelector = keySelector; - _comparer = comparer; + _comparer = comparer ?? EqualityComparer.Default; } public override AsyncIterator Clone() diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index ad3cfe2250..600eafd5e5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -14,8 +14,6 @@ public static Task Max(this IAsyncEnumerable source, { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); return MaxCore(source, comparer, CancellationToken.None); } @@ -24,14 +22,17 @@ public static Task Max(this IAsyncEnumerable source, { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); - + return MaxCore(source, comparer, cancellationToken); } private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { + if (comparer == null) + { + comparer = Comparer.Default; + } + var e = source.GetAsyncEnumerator(cancellationToken); try diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index 1193abbf6f..fd528994f4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -17,7 +17,7 @@ public static Task> MaxBy(this IAsyncEnumerable.Default, CancellationToken.None); + return MaxByCore(source, keySelector, comparer: null, CancellationToken.None); } public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) @@ -27,7 +27,7 @@ public static Task> MaxBy(this IAsyncEnumerable.Default, cancellationToken); + return MaxByCore(source, keySelector, comparer: null, cancellationToken); } public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) @@ -36,8 +36,6 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable.Default, CancellationToken.None); + return MaxByCore(source, keySelector, comparer: null, CancellationToken.None); } public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) @@ -71,7 +67,7 @@ public static Task> MaxBy(this IAsyncEnumerable.Default, cancellationToken); + return MaxByCore(source, keySelector, comparer: null, cancellationToken); } public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) @@ -80,8 +76,6 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable> MaxByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { + if (comparer == null) + { + comparer = Comparer.Default; + } + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); } private static Task> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { + if (comparer == null) + { + comparer = Comparer.Default; + } + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 4866e48cc8..c712a4a8ac 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -14,8 +14,6 @@ public static Task Min(this IAsyncEnumerable source, { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); return MinCore(source, comparer, CancellationToken.None); } @@ -24,14 +22,17 @@ public static Task Min(this IAsyncEnumerable source, { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); return MinCore(source, comparer, cancellationToken); } private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { + if (comparer == null) + { + comparer = Comparer.Default; + } + var e = source.GetAsyncEnumerator(cancellationToken); try diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 937b8df1fb..c5dfd4a68d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -17,7 +17,7 @@ public static Task> MinBy(this IAsyncEnumerable.Default, CancellationToken.None); + return MinByCore(source, keySelector, comparer: null, CancellationToken.None); } public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) @@ -27,7 +27,7 @@ public static Task> MinBy(this IAsyncEnumerable.Default, cancellationToken); + return MinByCore(source, keySelector, comparer: null, cancellationToken); } public static Task> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) @@ -36,8 +36,6 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable.Default, CancellationToken.None); + return MinByCore(source, keySelector, comparer: null, CancellationToken.None); } public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) @@ -71,7 +67,7 @@ public static Task> MinBy(this IAsyncEnumerable.Default, cancellationToken); + return MinByCore(source, keySelector, comparer: null, cancellationToken); } public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) @@ -80,8 +76,6 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable> MinByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { + if (comparer == null) + { + comparer = Comparer.Default; + } + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); } private static Task> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { + if (comparer == null) + { + comparer = Comparer.Default; + } + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); } From 24e92b041483fed50b24bae587c8b4d18d9d81fb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 12:27:18 -0800 Subject: [PATCH 470/862] Remove UnionWithAsync. --- .../System/Linq/Operators/Distinct.cs | 23 ++++++++++++------- .../System/Linq/Operators/Union.cs | 14 ++++++++++- .../System.Linq.Async/System/Linq/Set.cs | 17 -------------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index eff25f07ba..7a5d18342c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -55,9 +55,20 @@ public async Task> ToListAsync(CancellationToken cancellationToken return s.ToList(); } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return onlyIfCheap ? -1 : (await FillSetAsync(cancellationToken).ConfigureAwait(false)).Count; + if (onlyIfCheap) + { + return TaskExt.MinusOne; + } + + return Core(); + + async Task Core() + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s.Count; + } } public override AsyncIterator Clone() @@ -115,13 +126,9 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return false; } - private async Task> FillSetAsync(CancellationToken cancellationToken) + private Task> FillSetAsync(CancellationToken cancellationToken) { - var s = new Set(_comparer); - - await s.UnionWithAsync(_source, cancellationToken).ConfigureAwait(false); - - return s; + return AsyncEnumerableHelpers.ToSet(_source, _comparer, cancellationToken); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index ecc7c95178..e284f519bd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -172,7 +172,19 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } - await set.UnionWithAsync(enumerable, cancellationToken).ConfigureAwait(false); + var e = enumerable.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + set.Add(e.Current); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index c0551af87e..d8b8912bdb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -145,23 +145,6 @@ private void Resize() _slots = newSlots; } - public async ValueTask UnionWithAsync(IAsyncEnumerable other, CancellationToken cancellationToken) - { - var enu = other.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - Add(enu.Current); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } - } - internal struct Slot { internal int _hashCode; From 536438d7b918f04f00966c7ccd3456825c253cbc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 12:45:45 -0800 Subject: [PATCH 471/862] Some code cosmetics. --- .../System/Linq/Operators/Buffer.cs | 13 ------------- .../System/Linq/Operators/Generate.cs | 8 -------- .../System/Linq/Operators/IgnoreElements.cs | 2 -- .../System/Linq/Operators/StartWith.cs | 2 -- 4 files changed, 25 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index b2b26ac962..c6e2df3d57 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -14,14 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable> Buffer(this IAsyncEnumerable source, int count) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (count <= 0) - { throw new ArgumentOutOfRangeException(nameof(count)); - } return new BufferAsyncIterator(source, count, count); } @@ -29,19 +24,11 @@ public static IAsyncEnumerable> Buffer(this IAsyncEnumer public static IAsyncEnumerable> Buffer(this IAsyncEnumerable source, int count, int skip) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } - if (count <= 0) - { throw new ArgumentOutOfRangeException(nameof(count)); - } - if (skip <= 0) - { throw new ArgumentOutOfRangeException(nameof(skip)); - } return new BufferAsyncIterator(source, count, skip); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index bb1f10f147..74ec0a308c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -14,19 +14,11 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Generate(TState initialState, Func condition, Func iterate, Func resultSelector) { if (condition == null) - { throw new ArgumentNullException(nameof(condition)); - } - if (iterate == null) - { throw new ArgumentNullException(nameof(iterate)); - } - if (resultSelector == null) - { throw new ArgumentNullException(nameof(resultSelector)); - } return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index 3879828290..dbcb04bf7c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -14,9 +14,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable IgnoreElements(this IAsyncEnumerable source) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } return new IgnoreElementsAsyncIterator(source); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs index 8eb452df10..3d34d559c5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs @@ -11,9 +11,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable StartWith(this IAsyncEnumerable source, params TSource[] values) { if (source == null) - { throw new ArgumentNullException(nameof(source)); - } return values.ToAsyncEnumerable().Concat(source); } From 07a9483ed7d4879e17114574bd106f6198ebe7db Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 13:23:09 -0800 Subject: [PATCH 472/862] Share some code and streamline exceptions. --- .../System.Interactive.Async.csproj | 6 ++ .../System/Linq/Operators/Amb.cs | 8 +- .../System/Linq/Operators/Buffer.cs | 10 +-- .../System/Linq/Operators/Catch.cs | 16 ++-- .../System/Linq/Operators/Concat.cs | 6 +- .../System/Linq/Operators/Defer.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 18 ++-- .../Linq/Operators/DistinctUntilChanged.cs | 22 ++--- .../System/Linq/Operators/Do.cs | 52 +++++------ .../System/Linq/Operators/Expand.cs | 8 +- .../System/Linq/Operators/Finally.cs | 8 +- .../System/Linq/Operators/Generate.cs | 6 +- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../System/Linq/Operators/IsEmpty.cs | 4 +- .../System/Linq/Operators/Max.cs | 6 +- .../System/Linq/Operators/MaxBy.cs | 32 +++---- .../System/Linq/Operators/Merge.cs | 6 +- .../System/Linq/Operators/Min.cs | 6 +- .../System/Linq/Operators/MinBy.cs | 36 ++++---- .../Linq/Operators/OnErrorResumeNext.cs | 8 +- .../System/Linq/Operators/Repeat.cs | 6 +- .../System/Linq/Operators/Retry.cs | 6 +- .../System/Linq/Operators/Scan.cs | 16 ++-- .../System/Linq/Operators/SelectMany.cs | 4 +- .../System/Linq/Operators/StartWith.cs | 2 +- .../System/Linq/Operators/Throw.cs | 2 +- .../System/Linq/Operators/Timeout.cs | 4 +- .../System/Linq/Operators/Using.cs | 8 +- .../System/Linq/Set.cs | 86 ------------------- .../System/Linq/Strings.cs | 13 --- 30 files changed, 159 insertions(+), 252 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs delete mode 100644 Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 3e60c50a47..7baabe714d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -7,6 +7,12 @@ Ix;Interactive;Extensions;Enumerable;Asynchronous + + + + + + diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 9ba5dee14e..62b0d6084b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Amb(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); return new AmbAsyncIterator(first, second); } @@ -24,7 +24,7 @@ public static IAsyncEnumerable Amb(this IAsyncEnumerable Amb(params IAsyncEnumerable[] sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return new AmbAsyncIteratorN(sources); } @@ -32,7 +32,7 @@ public static IAsyncEnumerable Amb(params IAsyncEnumerable Amb(this IEnumerable> sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return new AmbAsyncIteratorN(sources.ToArray()); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index c6e2df3d57..565f24661a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable> Buffer(this IAsyncEnumerable source, int count) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (count <= 0) - throw new ArgumentOutOfRangeException(nameof(count)); + throw Error.ArgumentOutOfRange(nameof(count)); return new BufferAsyncIterator(source, count, count); } @@ -24,11 +24,11 @@ public static IAsyncEnumerable> Buffer(this IAsyncEnumer public static IAsyncEnumerable> Buffer(this IAsyncEnumerable source, int count, int skip) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (count <= 0) - throw new ArgumentOutOfRangeException(nameof(count)); + throw Error.ArgumentOutOfRange(nameof(count)); if (skip <= 0) - throw new ArgumentOutOfRangeException(nameof(skip)); + throw Error.ArgumentOutOfRange(nameof(skip)); return new BufferAsyncIterator(source, count, skip); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index e1e5944e50..0d601a8a8a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -16,9 +16,9 @@ public static IAsyncEnumerable Catch(this IAsyncEn where TException : Exception { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (handler == null) - throw new ArgumentNullException(nameof(handler)); + throw Error.ArgumentNull(nameof(handler)); return new CatchAsyncIterator(source, handler); } @@ -27,9 +27,9 @@ public static IAsyncEnumerable Catch(this IAsyncEn where TException : Exception { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (handler == null) - throw new ArgumentNullException(nameof(handler)); + throw Error.ArgumentNull(nameof(handler)); return new CatchAsyncIteratorWithTask(source, handler); } @@ -37,7 +37,7 @@ public static IAsyncEnumerable Catch(this IAsyncEn public static IAsyncEnumerable Catch(this IEnumerable> sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return CatchCore(sources); } @@ -45,7 +45,7 @@ public static IAsyncEnumerable Catch(this IEnumerable Catch(params IAsyncEnumerable[] sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return CatchCore(sources); } @@ -53,9 +53,9 @@ public static IAsyncEnumerable Catch(params IAsyncEnumerable Catch(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); return CatchCore(new[] { first, second }); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index 65c4e972c0..a2498e305a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Concat(this IAsyncEnumerable> sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return new ConcatAsyncEnumerableAsyncIterator(sources); } @@ -22,7 +22,7 @@ public static IAsyncEnumerable Concat(this IAsyncEnumerable Concat(this IEnumerable> sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return ConcatCore(sources); } @@ -30,7 +30,7 @@ public static IAsyncEnumerable Concat(this IEnumerable Concat(params IAsyncEnumerable[] sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return ConcatCore(sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index 8e74254dc0..fe075eda41 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -15,7 +15,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Defer(Func> factory) { if (factory == null) - throw new ArgumentNullException(nameof(factory)); + throw Error.ArgumentNull(nameof(factory)); return CreateEnumerable(ct => factory().GetAsyncEnumerator(ct)); } @@ -23,7 +23,7 @@ public static IAsyncEnumerable Defer(Func Defer(Func>> factory) { if (factory == null) - throw new ArgumentNullException(nameof(factory)); + throw Error.ArgumentNull(nameof(factory)); return new AnonymousAsyncEnumerableWithTask(async ct => (await factory().ConfigureAwait(false)).GetAsyncEnumerator(ct)); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 80a783b4cc..dc7cbf8279 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return DistinctCore(source, keySelector, comparer: null); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return DistinctCore(source, keySelector, comparer); } @@ -34,9 +34,9 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return DistinctCore(source, keySelector, comparer: null); } @@ -44,11 +44,11 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return DistinctCore(source, keySelector, comparer); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 31a43b1ba1..1e1e89a6f7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return DistinctUntilChangedCore(source, comparer: null); } @@ -22,7 +22,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this IAsyn public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return DistinctUntilChangedCore(source, comparer); } @@ -30,9 +30,9 @@ public static IAsyncEnumerable DistinctUntilChanged(this IAsyn public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return DistinctUntilChangedCore(source, keySelector, comparer: null); } @@ -40,9 +40,9 @@ public static IAsyncEnumerable DistinctUntilChanged(this public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return DistinctUntilChangedCore(source, keySelector, comparer); } @@ -50,9 +50,9 @@ public static IAsyncEnumerable DistinctUntilChanged(this public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return DistinctUntilChangedCore(source, keySelector, comparer: null); } @@ -60,11 +60,11 @@ public static IAsyncEnumerable DistinctUntilChanged(this public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); + throw Error.ArgumentNull(nameof(comparer)); return DistinctUntilChangedCore(source, keySelector, comparer); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index 0ff6673cc8..cabdbca194 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); return DoCore(source, onNext: onNext, onError: null, onCompleted: null); } @@ -24,11 +24,11 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext, Action onCompleted) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + throw Error.ArgumentNull(nameof(onCompleted)); return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted); } @@ -36,11 +36,11 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext, Action onError) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); if (onError == null) - throw new ArgumentNullException(nameof(onError)); + throw Error.ArgumentNull(nameof(onError)); return DoCore(source, onNext: onNext, onError: onError, onCompleted: null); } @@ -48,13 +48,13 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext, Action onError, Action onCompleted) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); if (onError == null) - throw new ArgumentNullException(nameof(onError)); + throw Error.ArgumentNull(nameof(onError)); if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + throw Error.ArgumentNull(nameof(onCompleted)); return DoCore(source, onNext, onError, onCompleted); } @@ -62,9 +62,9 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); return DoCore(source, onNext: onNext, onError: null, onCompleted: null); } @@ -72,11 +72,11 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onCompleted) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + throw Error.ArgumentNull(nameof(onCompleted)); return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted); } @@ -84,11 +84,11 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); if (onError == null) - throw new ArgumentNullException(nameof(onError)); + throw Error.ArgumentNull(nameof(onError)); return DoCore(source, onNext: onNext, onError: onError, onCompleted: null); } @@ -96,13 +96,13 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); + throw Error.ArgumentNull(nameof(onNext)); if (onError == null) - throw new ArgumentNullException(nameof(onError)); + throw Error.ArgumentNull(nameof(onError)); if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + throw Error.ArgumentNull(nameof(onCompleted)); return DoCore(source, onNext, onError, onCompleted); } @@ -110,9 +110,9 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, IObserver observer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (observer == null) - throw new ArgumentNullException(nameof(observer)); + throw Error.ArgumentNull(nameof(observer)); return DoCore(source, new Action(observer.OnNext), new Action(observer.OnError), new Action(observer.OnCompleted)); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 342dd640d1..fcc722e4b2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new ExpandAsyncIterator(source, selector); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable Expand(this IAsyncEnumerable source, Func>> selector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (selector == null) - throw new ArgumentNullException(nameof(selector)); + throw Error.ArgumentNull(nameof(selector)); return new ExpandAsyncIteratorWithTask(source, selector); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 354e585b6b..2f61b69ceb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Finally(this IAsyncEnumerable source, Action finallyAction) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (finallyAction == null) - throw new ArgumentNullException(nameof(finallyAction)); + throw Error.ArgumentNull(nameof(finallyAction)); return new FinallyAsyncIterator(source, finallyAction); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable Finally(this IAsyncEnumerable source, Func finallyAction) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (finallyAction == null) - throw new ArgumentNullException(nameof(finallyAction)); + throw Error.ArgumentNull(nameof(finallyAction)); return new FinallyAsyncIteratorWithTask(source, finallyAction); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 74ec0a308c..f325412dd4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -14,11 +14,11 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Generate(TState initialState, Func condition, Func iterate, Func resultSelector) { if (condition == null) - throw new ArgumentNullException(nameof(condition)); + throw Error.ArgumentNull(nameof(condition)); if (iterate == null) - throw new ArgumentNullException(nameof(iterate)); + throw Error.ArgumentNull(nameof(iterate)); if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + throw Error.ArgumentNull(nameof(resultSelector)); return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index dbcb04bf7c..fff721d0cb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable IgnoreElements(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return new IgnoreElementsAsyncIterator(source); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index daa5ca23d4..7788ee89e5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerableEx public static Task IsEmpty(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return IsEmptyCore(source, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task IsEmpty(this IAsyncEnumerable source) public static Task IsEmpty(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return IsEmptyCore(source, cancellationToken); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 600eafd5e5..75bc99f24a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerableEx public static Task Max(this IAsyncEnumerable source, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, comparer, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Max(this IAsyncEnumerable source, public static Task Max(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MaxCore(source, comparer, cancellationToken); } @@ -38,7 +38,7 @@ private static async Task MaxCore(IAsyncEnumerable so try { if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); var max = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index fd528994f4..ece27c46c5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -13,9 +13,9 @@ public static partial class AsyncEnumerableEx public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer: null, CancellationToken.None); } @@ -23,9 +23,9 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer: null, cancellationToken); } @@ -33,9 +33,9 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer, CancellationToken.None); } @@ -43,9 +43,9 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer, cancellationToken); } @@ -53,9 +53,9 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer: null, CancellationToken.None); } @@ -63,9 +63,9 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer: null, cancellationToken); } @@ -73,9 +73,9 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer, CancellationToken.None); } @@ -83,9 +83,9 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MaxByCore(source, keySelector, comparer, cancellationToken); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 0b75a63f07..0c4ed2559e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -14,7 +14,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Merge(params IAsyncEnumerable[] sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return new MergeAsyncIterator(sources); } @@ -22,7 +22,7 @@ public static IAsyncEnumerable Merge(params IAsyncEnumerable Merge(this IEnumerable> sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return sources.ToAsyncEnumerable().SelectMany(source => source); } @@ -30,7 +30,7 @@ public static IAsyncEnumerable Merge(this IEnumerable Merge(this IAsyncEnumerable> sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return sources.SelectMany(source => source); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index c712a4a8ac..a332b57906 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -13,7 +13,7 @@ public static partial class AsyncEnumerableEx public static Task Min(this IAsyncEnumerable source, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, comparer, CancellationToken.None); } @@ -21,7 +21,7 @@ public static Task Min(this IAsyncEnumerable source, public static Task Min(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return MinCore(source, comparer, cancellationToken); } @@ -38,7 +38,7 @@ private static async Task MinCore(IAsyncEnumerable so try { if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); var min = e.Current; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index c5dfd4a68d..b721613e9d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -13,9 +13,9 @@ public static partial class AsyncEnumerableEx public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer: null, CancellationToken.None); } @@ -23,9 +23,9 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer: null, cancellationToken); } @@ -33,9 +33,9 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer, CancellationToken.None); } @@ -43,9 +43,9 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer, cancellationToken); } @@ -53,9 +53,9 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer: null, CancellationToken.None); } @@ -63,9 +63,9 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer: null, cancellationToken); } @@ -73,9 +73,9 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer, CancellationToken.None); } @@ -83,9 +83,9 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + throw Error.ArgumentNull(nameof(keySelector)); return MinByCore(source, keySelector, comparer, cancellationToken); } @@ -119,7 +119,7 @@ private static async Task> ExtremaBy(IAsyncEnumera try { if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); var current = e.Current; var resKey = keySelector(current); @@ -159,7 +159,7 @@ private static async Task> ExtremaBy(IAsyncEnumera try { if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw new InvalidOperationException(Strings.NO_ELEMENTS); + throw Error.NoElements(); var current = e.Current; var resKey = await keySelector(current).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index 2bf820f122..fe7ad3cb70 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable OnErrorResumeNext(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) - throw new ArgumentNullException(nameof(first)); + throw Error.ArgumentNull(nameof(first)); if (second == null) - throw new ArgumentNullException(nameof(second)); + throw Error.ArgumentNull(nameof(second)); return OnErrorResumeNextCore(new[] { first, second }); } @@ -24,7 +24,7 @@ public static IAsyncEnumerable OnErrorResumeNext(this IAsyncEn public static IAsyncEnumerable OnErrorResumeNext(params IAsyncEnumerable[] sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return OnErrorResumeNextCore(sources); } @@ -32,7 +32,7 @@ public static IAsyncEnumerable OnErrorResumeNext(params IAsync public static IAsyncEnumerable OnErrorResumeNext(this IEnumerable> sources) { if (sources == null) - throw new ArgumentNullException(nameof(sources)); + throw Error.ArgumentNull(nameof(sources)); return OnErrorResumeNextCore(sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index dc50ff31e2..21297ecf26 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -19,7 +19,7 @@ public static IAsyncEnumerable Repeat(TResult element) public static IAsyncEnumerable Repeat(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return new RepeatSequenceAsyncIterator(source, -1); } @@ -27,9 +27,9 @@ public static IAsyncEnumerable Repeat(this IAsyncEnumerable Repeat(this IAsyncEnumerable source, int count) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); + throw Error.ArgumentOutOfRange(nameof(count)); return new RepeatSequenceAsyncIterator(source, count); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs index 35c3a5b35e..8ef41c117c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Retry(this IAsyncEnumerable source) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return new[] { source }.Repeat().Catch(); } @@ -19,9 +19,9 @@ public static IAsyncEnumerable Retry(this IAsyncEnumerable Retry(this IAsyncEnumerable source, int retryCount) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (retryCount < 0) - throw new ArgumentOutOfRangeException(nameof(retryCount)); + throw Error.ArgumentOutOfRange(nameof(retryCount)); return new[] { source }.Repeat(retryCount).Catch(); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 079bb86eed..bee2cc5ea2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return new ScanAsyncEnumerable(source, accumulator); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return new ScanAsyncEnumerable(source, seed, accumulator); } @@ -34,9 +34,9 @@ public static IAsyncEnumerable Scan(this IAsy public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func> accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return new ScanAsyncEnumerableWithTask(source, accumulator); } @@ -44,9 +44,9 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); + throw Error.ArgumentNull(nameof(accumulator)); return new ScanAsyncEnumerableWithTask(source, seed, accumulator); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs index 01cb137f6f..be1c3f8076 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/SelectMany.cs @@ -11,9 +11,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, IAsyncEnumerable other) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); if (other == null) - throw new ArgumentNullException(nameof(other)); + throw Error.ArgumentNull(nameof(other)); return source.SelectMany(_ => other); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs index 3d34d559c5..9b7786b4a2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs @@ -11,7 +11,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable StartWith(this IAsyncEnumerable source, params TSource[] values) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); return values.ToAsyncEnumerable().Concat(source); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index dfbdb4a5f1..739a440054 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -12,7 +12,7 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Throw(Exception exception) { if (exception == null) - throw new ArgumentNullException(nameof(exception)); + throw Error.ArgumentNull(nameof(exception)); #if NO_TASK_FROMEXCEPTION var tcs = new TaskCompletionSource(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index 8d108db4c3..363213711d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -14,11 +14,11 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Timeout(this IAsyncEnumerable source, TimeSpan timeout) { if (source == null) - throw new ArgumentNullException(nameof(source)); + throw Error.ArgumentNull(nameof(source)); var num = (long)timeout.TotalMilliseconds; if (num < -1L || num > int.MaxValue) - throw new ArgumentOutOfRangeException(nameof(timeout)); + throw Error.ArgumentOutOfRange(nameof(timeout)); return new TimeoutAsyncIterator(source, timeout); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 529ba05bed..a42ee5a64b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -14,9 +14,9 @@ public static partial class AsyncEnumerableEx public static IAsyncEnumerable Using(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable { if (resourceFactory == null) - throw new ArgumentNullException(nameof(resourceFactory)); + throw Error.ArgumentNull(nameof(resourceFactory)); if (enumerableFactory == null) - throw new ArgumentNullException(nameof(enumerableFactory)); + throw Error.ArgumentNull(nameof(enumerableFactory)); return new UsingAsyncIterator(resourceFactory, enumerableFactory); } @@ -24,9 +24,9 @@ public static IAsyncEnumerable Using(Func Using(Func> resourceFactory, Func>> enumerableFactory) where TResource : IDisposable { if (resourceFactory == null) - throw new ArgumentNullException(nameof(resourceFactory)); + throw Error.ArgumentNull(nameof(resourceFactory)); if (enumerableFactory == null) - throw new ArgumentNullException(nameof(enumerableFactory)); + throw Error.ArgumentNull(nameof(enumerableFactory)); return new UsingAsyncIteratorWithTask(resourceFactory, enumerableFactory); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs deleted file mode 100644 index 16c0163ebc..0000000000 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Set.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; - -// from https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/System.Linq/src/System/Linq/Set.cs -namespace System.Linq -{ - [ExcludeFromCodeCoverage] - internal sealed class Set - { - private readonly IEqualityComparer _comparer; - private int[] _buckets; - - private Slot[] _slots; - - public Set(IEqualityComparer comparer) - { - _comparer = comparer ?? EqualityComparer.Default; - _buckets = new int[7]; - _slots = new Slot[7]; - } - - internal int Count { get; private set; } - - // If value is not in set, add it and return true; otherwise return false - public bool Add(TElement value) - { - var hashCode = InternalGetHashCode(value); - for (var i = _buckets[hashCode%_buckets.Length] - 1; i >= 0; i = _slots[i]._next) - { - if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) - { - return false; - } - } - - if (Count == _slots.Length) - { - Resize(); - } - - var index = Count; - Count++; - var bucket = hashCode%_buckets.Length; - _slots[index]._hashCode = hashCode; - _slots[index]._value = value; - _slots[index]._next = _buckets[bucket] - 1; - _buckets[bucket] = index + 1; - return true; - } - - internal int InternalGetHashCode(TElement value) - { - // Handle comparer implementations that throw when passed null - return (value == null) ? 0 : _comparer.GetHashCode(value) & 0x7FFFFFFF; - } - - private void Resize() - { - var newSize = checked((Count*2) + 1); - var newBuckets = new int[newSize]; - var newSlots = new Slot[newSize]; - Array.Copy(_slots, 0, newSlots, 0, Count); - for (var i = 0; i < Count; i++) - { - var bucket = newSlots[i]._hashCode%newSize; - newSlots[i]._next = newBuckets[bucket] - 1; - newBuckets[bucket] = i + 1; - } - - _buckets = newBuckets; - _slots = newSlots; - } - - internal struct Slot - { - internal int _hashCode; - internal int _next; - internal TElement _value; - } - } -} diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs deleted file mode 100644 index 755114023d..0000000000 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Strings.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -namespace System.Linq -{ - internal static class Strings - { - public static string NO_ELEMENTS = "Source sequence doesn't contain any elements."; - public static string MORE_THAN_ONE_ELEMENT = "Source sequence contains more than one element."; - public static string NOT_SUPPORTED = "Specified method is not supported."; - } -} From 1c01866f8d330aab1bf5e065e16a73dbd06ff92e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 13:45:47 -0800 Subject: [PATCH 473/862] Converge copies of AsyncIterator. --- .../Source/System.Interactive.Async/AsyncIterator.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index 2c0e7b8dd8..a6ada80884 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -16,25 +16,25 @@ internal abstract class AsyncIterator : IAsyncEnumerable, IAsy internal TSource current; internal AsyncIteratorState state = AsyncIteratorState.New; - internal CancellationToken token; + internal CancellationToken cancellationToken; protected AsyncIterator() { _threadId = Environment.CurrentManagedThreadId; } - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); enumerator.state = AsyncIteratorState.Allocated; - enumerator.token = token; + enumerator.cancellationToken = cancellationToken; try { - enumerator.OnGetEnumerator(token); + enumerator.OnGetEnumerator(cancellationToken); } catch { @@ -77,7 +77,7 @@ public async ValueTask MoveNextAsync() try { - var result = await MoveNextCore(token).ConfigureAwait(false); + var result = await MoveNextCore(cancellationToken).ConfigureAwait(false); _currentIsInvalid = !result; // if move next is false, invalid otherwise valid From c2a27a8604bad69f6403fb97e7eb32c5b50291aa Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 13:45:58 -0800 Subject: [PATCH 474/862] Refactor AsyncIterator to allow for reuse. --- .../System/Linq/AsyncIterator.Opt.cs | 33 +++++++++++++++++++ .../System/Linq/AsyncIterator.cs | 22 +------------ 2 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs new file mode 100644 index 0000000000..400d93971d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + partial class AsyncIterator + { + public virtual IAsyncEnumerable Select(Func selector) + { + return new AsyncEnumerable.SelectEnumerableAsyncIterator(this, selector); + } + + public virtual IAsyncEnumerable Select(Func> selector) + { + return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask(this, selector); + } + + public virtual IAsyncEnumerable Where(Func predicate) + { + return new AsyncEnumerable.WhereEnumerableAsyncIterator(this, predicate); + } + + public virtual IAsyncEnumerable Where(Func> predicate) + { + return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index df06c8c7e2..ac4cd70068 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -8,7 +8,7 @@ namespace System.Linq { - internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator + internal abstract partial class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator { private readonly int _threadId; @@ -93,26 +93,6 @@ public async ValueTask MoveNextAsync() public abstract AsyncIterator Clone(); - public virtual IAsyncEnumerable Select(Func selector) - { - return new AsyncEnumerable.SelectEnumerableAsyncIterator(this, selector); - } - - public virtual IAsyncEnumerable Select(Func> selector) - { - return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask(this, selector); - } - - public virtual IAsyncEnumerable Where(Func predicate) - { - return new AsyncEnumerable.WhereEnumerableAsyncIterator(this, predicate); - } - - public virtual IAsyncEnumerable Where(Func> predicate) - { - return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); - } - protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); protected virtual void OnGetEnumerator(CancellationToken cancellationToken) From 2fc54b393b3788125f41e9c09b9662e0e943161e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 13:47:52 -0800 Subject: [PATCH 475/862] Remove OnGetEnumerator. --- .../System.Linq.Async/System/Linq/AsyncIterator.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index ac4cd70068..9d90cd9db6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -32,16 +32,6 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati enumerator.state = AsyncIteratorState.Allocated; enumerator.cancellationToken = cancellationToken; - try - { - enumerator.OnGetEnumerator(cancellationToken); - } - catch - { - enumerator.DisposeAsync(); // REVIEW: fire-and-forget? - throw; - } - return enumerator; } @@ -94,10 +84,6 @@ public async ValueTask MoveNextAsync() public abstract AsyncIterator Clone(); protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); - - protected virtual void OnGetEnumerator(CancellationToken cancellationToken) - { - } } internal enum AsyncIteratorState From f7a056b9c05fe72ec272c8833947c4434df30df9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:20:53 -0800 Subject: [PATCH 476/862] Making Using behavior consistent. --- .../System/Linq/Operators/Using.cs | 37 +++++++++++++++---- .../System.Interactive.Async/AsyncIterator.cs | 14 ------- .../System/Linq/Operators/Using.cs | 17 +++------ 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index 1052310c53..17d90712b5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -35,9 +35,12 @@ public void Using1() ); Assert.Equal(0, i); + Assert.Equal(0, d); var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); + + Assert.Equal(0, i); + Assert.Equal(0, d); } [Fact] @@ -56,16 +59,20 @@ public async Task Using2() ); Assert.Equal(0, i); + Assert.Equal(0, d); var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); + Assert.Equal(0, i); + Assert.Equal(0, d); await e.DisposeAsync(); - Assert.Equal(1, d); + + Assert.Equal(0, i); + Assert.Equal(0, d); } [Fact] - public void Using3() + public async Task Using3() { var ex = new Exception("Bang!"); var i = 0; @@ -81,10 +88,17 @@ public void Using3() ); Assert.Equal(0, i); + Assert.Equal(0, d); + + var e = xs.GetAsyncEnumerator(); + + Assert.Equal(0, i); + Assert.Equal(0, d); - AssertThrows(() => xs.GetAsyncEnumerator(), ex_ => ex_ == ex); + await e.DisposeAsync(); - Assert.Equal(1, d); + Assert.Equal(0, i); + Assert.Equal(0, d); } [Fact] @@ -105,9 +119,13 @@ public void Using4() Assert.Equal(0, i); var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); + + Assert.Equal(0, i); HasNext(e, 42); + + Assert.Equal(1, i); + NoNext(e); Assert.True(disposed.Task.Result); @@ -132,10 +150,13 @@ public void Using5() Assert.Equal(0, i); var e = xs.GetAsyncEnumerator(); - Assert.Equal(1, i); + + Assert.Equal(0, i); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + Assert.Equal(1, i); + Assert.True(disposed.Task.Result); } diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs index a6ada80884..56aa0ee8a4 100644 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs @@ -32,16 +32,6 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati enumerator.state = AsyncIteratorState.Allocated; enumerator.cancellationToken = cancellationToken; - try - { - enumerator.OnGetEnumerator(cancellationToken); - } - catch - { - enumerator.DisposeAsync(); // REVIEW: fire-and-forget? - throw; - } - return enumerator; } @@ -94,10 +84,6 @@ public async ValueTask MoveNextAsync() public abstract AsyncIterator Clone(); protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); - - protected virtual void OnGetEnumerator(CancellationToken cancellationToken) - { - } } internal enum AsyncIteratorState diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index a42ee5a64b..5beceba4c3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -73,10 +73,15 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) { + // NB: Earlier behavior of this operator was more eager, causing the resource factory to be called upon calling + // GetAsyncEnumerator. This is inconsistent with asynchronous "using" and with a C# 8.0 async iterator with + // a using statement inside, so this logic got moved to MoveNextAsync instead. + switch (state) { case AsyncIteratorState.Allocated: - _enumerator = _enumerable.GetAsyncEnumerator(cancellationToken); + _resource = _resourceFactory(); + _enumerator = _enumerableFactory(_resource).GetAsyncEnumerator(cancellationToken); state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -93,16 +98,6 @@ protected override async ValueTask MoveNextCore(CancellationToken cancella return false; } - - protected override void OnGetEnumerator(CancellationToken cancellationToken) - { - // REVIEW: Wire cancellation to the functions. - - _resource = _resourceFactory(); - _enumerable = _enumerableFactory(_resource); - - base.OnGetEnumerator(cancellationToken); - } } private sealed class UsingAsyncIteratorWithTask : AsyncIterator where TResource : IDisposable From 2cd427d29e817270ebb4f241727b9344d46df6be Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:22:19 -0800 Subject: [PATCH 477/862] Remove copy of AsyncIterator. --- .../System.Interactive.Async/AsyncIterator.cs | 96 ------------------- .../System.Interactive.Async.csproj | 1 + 2 files changed, 1 insertion(+), 96 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs diff --git a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs b/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs deleted file mode 100644 index 56aa0ee8a4..0000000000 --- a/Ix.NET/Source/System.Interactive.Async/AsyncIterator.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - internal abstract class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator - { - private readonly int _threadId; - - private bool _currentIsInvalid = true; - - internal TSource current; - internal AsyncIteratorState state = AsyncIteratorState.New; - internal CancellationToken cancellationToken; - - protected AsyncIterator() - { - _threadId = Environment.CurrentManagedThreadId; - } - - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - { - var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId - ? this - : Clone(); - - enumerator.state = AsyncIteratorState.Allocated; - enumerator.cancellationToken = cancellationToken; - - return enumerator; - } - - public virtual ValueTask DisposeAsync() - { - current = default; - state = AsyncIteratorState.Disposed; - - return TaskExt.CompletedTask; - } - - public TSource Current - { - get - { - if (_currentIsInvalid) - throw new InvalidOperationException("Enumerator is in an invalid state"); - - return current; - } - } - - public async ValueTask MoveNextAsync() - { - // Note: MoveNext *must* be implemented as an async method to ensure - // that any exceptions thrown from the MoveNextCore call are handled - // by the try/catch, whether they're sync or async - - if (state == AsyncIteratorState.Disposed) - { - return false; - } - - try - { - var result = await MoveNextCore(cancellationToken).ConfigureAwait(false); - - _currentIsInvalid = !result; // if move next is false, invalid otherwise valid - - return result; - } - catch - { - _currentIsInvalid = true; - await DisposeAsync().ConfigureAwait(false); - throw; - } - } - - public abstract AsyncIterator Clone(); - - protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); - } - - internal enum AsyncIteratorState - { - New = 0, - Allocated = 1, - Iterating = 2, - Disposed = -1, - } -} diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 7baabe714d..190f22600c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -9,6 +9,7 @@ + From 61d300dd989f3724b706bea7088297997ae65184 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:43:20 -0800 Subject: [PATCH 478/862] Current has undefined behavior when MoveNextAsync returns false or throws. --- .../System/Linq/Operators/IgnoreElements.cs | 6 ------ .../System/Linq/Operators/Never.cs | 1 - .../System/Linq/Operators/Throw.cs | 1 - .../System/Linq/AsyncIterator.cs | 20 ++----------------- 4 files changed, 2 insertions(+), 26 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs index 6a3ea2ffea..8615420452 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -25,8 +25,6 @@ public void IgnoreElements1() var e = xs.GetAsyncEnumerator(); NoNext(e); - - AssertThrows(() => { var ignored = e.Current; }); } [Fact] @@ -36,8 +34,6 @@ public void IgnoreElements2() var e = xs.GetAsyncEnumerator(); NoNext(e); - - AssertThrows(() => { var ignored = e.Current; }); } [Fact] @@ -47,8 +43,6 @@ public void IgnoreElements3() var e = xs.GetAsyncEnumerator(); NoNext(e); - - AssertThrows(() => { var ignored = e.Current; }); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs index 0ac26f3cf4..b560621083 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs @@ -18,7 +18,6 @@ public async Task Never1() var e = xs.GetAsyncEnumerator(); Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check - AssertThrows(() => Nop(e.Current)); await e.DisposeAsync(); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index 3d63a4c48b..28e6df470b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -24,7 +24,6 @@ public void Throw1() var e = xs.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - AssertThrows(() => Nop(e.Current)); } private void Nop(object o) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 9d90cd9db6..bc40ae1f95 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -12,8 +12,6 @@ internal abstract partial class AsyncIterator : IAsyncEnumerable current; public async ValueTask MoveNextAsync() { @@ -67,15 +56,10 @@ public async ValueTask MoveNextAsync() try { - var result = await MoveNextCore(cancellationToken).ConfigureAwait(false); - - _currentIsInvalid = !result; // if move next is false, invalid otherwise valid - - return result; + return await MoveNextCore(cancellationToken).ConfigureAwait(false); } catch { - _currentIsInvalid = true; await DisposeAsync().ConfigureAwait(false); throw; } From 3804a0b72630ee7bcfc73dc2074fbc6e539eb14b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:43:30 -0800 Subject: [PATCH 479/862] Cosmetics. --- .../System/Linq/Operators/Never.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs index b560621083..daba9976e0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Linq; using System.Threading.Tasks; using Xunit; From 53859f1eede29ec8f4c6e9deaa471f2c68988165 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:43:40 -0800 Subject: [PATCH 480/862] Remove dead code. --- .../System/Linq/Operators/Never.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs index daba9976e0..ec5b14516c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs @@ -19,9 +19,5 @@ public async Task Never1() Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check await e.DisposeAsync(); } - - private void Nop(object o) - { - } } } From 9a5b5cf136f5d55728af101e928fad2c5bab6570 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:46:15 -0800 Subject: [PATCH 481/862] Remove unused field. --- .../System.Interactive.Async/System/Linq/Operators/Using.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 5beceba4c3..435f2b4e1c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -36,7 +36,6 @@ private sealed class UsingAsyncIterator : AsyncIterator> _enumerableFactory; private readonly Func _resourceFactory; - private IAsyncEnumerable _enumerable; private IAsyncEnumerator _enumerator; private TResource _resource; From d57c0e31494a21625ffb342dc3006539f475a3ab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:46:40 -0800 Subject: [PATCH 482/862] Fields can be made protected. --- .../Source/System.Linq.Async/System/Linq/AsyncIterator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index bc40ae1f95..266aa9dca4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -12,9 +12,9 @@ internal abstract partial class AsyncIterator : IAsyncEnumerable Date: Mon, 12 Nov 2018 14:48:28 -0800 Subject: [PATCH 483/862] Use cancellation token from field. --- .../System/Linq/Operators/Amb.cs | 4 ++-- .../System/Linq/Operators/Buffer.cs | 2 +- .../System/Linq/Operators/Catch.cs | 6 +++--- .../System/Linq/Operators/Concat.cs | 4 ++-- .../System/Linq/Operators/Distinct.cs | 4 ++-- .../Linq/Operators/DistinctUntilChanged.cs | 6 +++--- .../System/Linq/Operators/Do.cs | 4 ++-- .../System/Linq/Operators/Expand.cs | 4 ++-- .../System/Linq/Operators/Finally.cs | 4 ++-- .../System/Linq/Operators/Generate.cs | 2 +- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../System/Linq/Operators/Merge.cs | 2 +- .../System/Linq/Operators/OnErrorResumeNext.cs | 2 +- .../System/Linq/Operators/Repeat.cs | 4 ++-- .../System/Linq/Operators/Scan.cs | 8 ++++---- .../System/Linq/Operators/Timeout.cs | 2 +- .../System/Linq/Operators/Using.cs | 4 ++-- .../System/Linq/AsyncEnumerablePartition.cs | 2 +- .../System/Linq/AsyncEnumerator.cs | 2 +- .../System/Linq/AsyncIterator.cs | 4 ++-- .../System/Linq/AsyncListPartition.cs | 2 +- .../System/Linq/Operators/AppendPrepend.cs | 4 ++-- .../System/Linq/Operators/Cast.cs | 2 +- .../System/Linq/Operators/Concat.cs | 2 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 2 +- .../System/Linq/Operators/Distinct.cs | 2 +- .../System/Linq/Operators/Except.cs | 2 +- .../System/Linq/Operators/GroupBy.cs | 12 ++++++------ .../System/Linq/Operators/Intersect.cs | 2 +- .../System/Linq/Operators/Join.cs | 4 ++-- .../System/Linq/Operators/OfType.cs | 2 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 2 +- .../System/Linq/Operators/Range.cs | 2 +- .../System/Linq/Operators/Repeat.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/Select.cs | 12 ++++++------ .../System/Linq/Operators/SelectMany.cs | 16 ++++++++-------- .../System/Linq/Operators/SkipLast.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 8 ++++---- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 8 ++++---- .../System/Linq/Operators/ToAsyncEnumerable.cs | 6 +++--- .../System/Linq/Operators/Union.cs | 2 +- .../System/Linq/Operators/Where.cs | 10 +++++----- .../System/Linq/Operators/Zip.cs | 4 ++-- 45 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 62b0d6084b..4ae0d86da6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -69,7 +69,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -164,7 +164,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 565f24661a..f1f0700dc5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -71,7 +71,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 0d601a8a8a..0282814b7c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -98,7 +98,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -191,7 +191,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -291,7 +291,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index a2498e305a..ddad69506e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -81,7 +81,7 @@ public override async ValueTask DisposeAsync() private const int State_OuterNext = 1; private const int State_While = 4; - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -170,7 +170,7 @@ public override async ValueTask DisposeAsync() private const int State_OuterNext = 1; private const int State_While = 4; - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index dc7cbf8279..62685c181c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -142,7 +142,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -287,7 +287,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 1e1e89a6f7..6dac659d6f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -118,7 +118,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -189,7 +189,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -260,7 +260,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index cabdbca194..9e2d21ed4c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -163,7 +163,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -239,7 +239,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index fcc722e4b2..37635cba96 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -67,7 +67,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -157,7 +157,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 2f61b69ceb..985248216e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -65,7 +65,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -123,7 +123,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index f325412dd4..3962da5ea6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -58,7 +58,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index fff721d0cb..fa12f5c4e3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -47,7 +47,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 0c4ed2559e..a035f87db8 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -76,7 +76,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index fe7ad3cb70..1033ea08a4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -78,7 +78,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index 21297ecf26..60be6f57ce 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -48,7 +48,7 @@ public override AsyncIterator Clone() return new RepeatElementAsyncIterator(_element); } - protected override ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override ValueTask MoveNextCore() { cancellationToken.ThrowIfCancellationRequested(); @@ -92,7 +92,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index bee2cc5ea2..c9d9524923 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -87,7 +87,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -161,7 +161,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -225,7 +225,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -299,7 +299,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index 363213711d..2a65614852 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -54,7 +54,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 435f2b4e1c..b7cf5fa97f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -70,7 +70,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { // NB: Earlier behavior of this operator was more eager, causing the resource factory to be called upon calling // GetAsyncEnumerator. This is inconsistent with asynchronous "using" and with a C# 8.0 async iterator with @@ -139,7 +139,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 30b31273e5..2fb456d9fd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -107,7 +107,7 @@ async Task Core() private bool _hasSkipped; private int _taken; - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 95eb65ec3a..e42f18e503 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -139,7 +139,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 266aa9dca4..20df466766 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -56,7 +56,7 @@ public async ValueTask MoveNextAsync() try { - return await MoveNextCore(cancellationToken).ConfigureAwait(false); + return await MoveNextCore().ConfigureAwait(false); } catch { @@ -67,7 +67,7 @@ public async ValueTask MoveNextAsync() public abstract AsyncIterator Clone(); - protected abstract ValueTask MoveNextCore(CancellationToken cancellationToken); + protected abstract ValueTask MoveNextCore(); } internal enum AsyncIteratorState diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 38ca225068..131d5bee70 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -38,7 +38,7 @@ public override AsyncIterator Clone() return new AsyncListPartition(_source, _minIndexInclusive, _maxIndexInclusive); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { if ((uint)_index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && _index < _source.Count - _minIndexInclusive) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 13c0c57612..51d7390b98 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -110,7 +110,7 @@ public override AsyncIterator Clone() return new AppendPrepend1AsyncIterator(_source, _item, _appending); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -313,7 +313,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index 78de8dd5ac..5753376d29 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -53,7 +53,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 5745980eca..049be854d6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -141,7 +141,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { if (state == AsyncIteratorState.Allocated) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 4f29fdcfc5..6bfeef84de 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -59,7 +59,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 7a5d18342c..7e8d4e5a99 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -88,7 +88,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 44fd646e35..f5d4e2977c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -68,7 +68,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { // NB: Earlier implementations of this operator constructed the set for the second source concurrently // with the first MoveNextAsync call on the first source. This resulted in an unexpected source of diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index a6c530ea7b..7dc28260ad 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -242,7 +242,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -335,7 +335,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -428,7 +428,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -521,7 +521,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -610,7 +610,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -699,7 +699,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index bc20274274..3a5f4fa3cc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -68,7 +68,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { // NB: Earlier implementations of this operator constructed the set for the second source concurrently // with the first MoveNextAsync call on the first source. This resulted in an unexpected source of diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index ce4d11039f..84f486d4de 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -131,7 +131,7 @@ public override async ValueTask DisposeAsync() private const int State_For = 3; private const int State_While = 4; - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -258,7 +258,7 @@ public override async ValueTask DisposeAsync() private const int State_For = 3; private const int State_While = 4; - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index b9fef72345..bdfe3c4a6b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -47,7 +47,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index a38385dde1..9adf5373cc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -28,7 +28,7 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere return new OrderedAsyncEnumerableWithTask(_source, keySelector, comparer, descending, this); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 84645abbd9..6b31293446 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -107,7 +107,7 @@ public Task> TryGetElementAsync(int index, CancellationToken cancella public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(_end - 1)); - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index b8166a1a9c..ca7d2a7216 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -58,7 +58,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index f606c03aa8..e3ed81c429 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -87,7 +87,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index c081807962..7ee6fd7a00 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -118,7 +118,7 @@ public override IAsyncEnumerable Select(Func(_source, CombineSelectors(_selector, selector)); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -174,7 +174,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -289,7 +289,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -350,7 +350,7 @@ public override IAsyncEnumerable Select(Func(_source, CombineSelectors(_selector, selector)); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -406,7 +406,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -531,7 +531,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken return res; } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index dcac5fd1a7..8129fd1256 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -142,7 +142,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -233,7 +233,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -330,7 +330,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -428,7 +428,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -527,7 +527,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -633,7 +633,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -733,7 +733,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -831,7 +831,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 0209339c2b..945da72e0c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -66,7 +66,7 @@ public override async ValueTask DisposeAsync() } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 4d8c2b1bbd..6bbfbb0254 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -84,7 +84,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -161,7 +161,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -243,7 +243,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -320,7 +320,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index e1db4f4579..2b2b7b5e7b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -59,7 +59,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index dab9997c33..aae981ac42 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -83,7 +83,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -148,7 +148,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -217,7 +217,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -282,7 +282,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 1cf241d3e7..a512f87493 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -152,7 +152,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -221,7 +221,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -325,7 +325,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index e284f519bd..fd20d1f7f0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -110,7 +110,7 @@ private async Task GetNextAsync() return false; } - protected sealed override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected sealed override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index e268b23e53..98d05e9af7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -114,7 +114,7 @@ public override IAsyncEnumerable Where(Func predicate) return new WhereEnumerableAsyncIterator(_source, CombinePredicates(_predicate, predicate)); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -175,7 +175,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -244,7 +244,7 @@ public override IAsyncEnumerable Where(Func> predic return new WhereEnumerableAsyncIteratorWithTask(_source, CombinePredicates(_predicate, predicate)); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -305,7 +305,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { @@ -378,7 +378,7 @@ public override IAsyncEnumerable Select(Func(_source, _predicate, CombineSelectors(_selector, selector)); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { switch (state) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 989f795936..2fb45e6979 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -77,7 +77,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { // REVIEW: Earlier versions of this operator performed concurrent MoveNextAsync calls, which isn't a great default and // results in an unexpected source of concurrency. However, a concurrent Zip may be a worthy addition to the @@ -149,7 +149,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - protected override async ValueTask MoveNextCore(CancellationToken cancellationToken) + protected override async ValueTask MoveNextCore() { // REVIEW: Earlier versions of this operator performed concurrent MoveNextAsync calls, which isn't a great default and // results in an unexpected source of concurrency. However, a concurrent Zip may be a worthy addition to the From 906f9c55778e612229336348d1a8eb06a175ae52 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:49:53 -0800 Subject: [PATCH 484/862] Fix field names. --- .../System/Linq/Operators/Amb.cs | 22 ++--- .../System/Linq/Operators/Buffer.cs | 10 +-- .../System/Linq/Operators/Catch.cs | 32 ++++---- .../System/Linq/Operators/Concat.cs | 18 ++--- .../System/Linq/Operators/Distinct.cs | 20 ++--- .../Linq/Operators/DistinctUntilChanged.cs | 24 +++--- .../System/Linq/Operators/Do.cs | 20 ++--- .../System/Linq/Operators/Expand.cs | 16 ++-- .../System/Linq/Operators/Finally.cs | 16 ++-- .../System/Linq/Operators/Generate.cs | 6 +- .../System/Linq/Operators/IgnoreElements.cs | 6 +- .../System/Linq/Operators/Merge.cs | 8 +- .../Linq/Operators/OnErrorResumeNext.cs | 8 +- .../System/Linq/Operators/Repeat.cs | 12 +-- .../System/Linq/Operators/Scan.cs | 32 ++++---- .../System/Linq/Operators/Timeout.cs | 8 +- .../System/Linq/Operators/Using.cs | 16 ++-- .../System/Linq/AsyncEnumerablePartition.cs | 8 +- .../System/Linq/AsyncEnumerator.cs | 6 +- .../System/Linq/AsyncIterator.cs | 20 ++--- .../System/Linq/AsyncListPartition.cs | 2 +- .../System/Linq/Operators/AppendPrepend.cs | 22 ++--- .../System/Linq/Operators/Cast.cs | 8 +- .../System/Linq/Operators/Concat.cs | 12 +-- .../System/Linq/Operators/DefaultIfEmpty.cs | 14 ++-- .../System/Linq/Operators/Distinct.cs | 10 +-- .../System/Linq/Operators/Except.cs | 10 +-- .../System/Linq/Operators/GroupBy.cs | 50 ++++++------ .../System/Linq/Operators/Intersect.cs | 10 +-- .../System/Linq/Operators/Join.cs | 20 ++--- .../System/Linq/Operators/OfType.cs | 8 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 8 +- .../System/Linq/Operators/Range.cs | 10 +-- .../System/Linq/Operators/Repeat.cs | 6 +- .../System/Linq/Operators/Reverse.cs | 8 +- .../System/Linq/Operators/Select.cs | 44 +++++----- .../System/Linq/Operators/SelectMany.cs | 80 +++++++++---------- .../System/Linq/Operators/SkipLast.cs | 8 +- .../System/Linq/Operators/SkipWhile.cs | 40 +++++----- .../System/Linq/Operators/TakeLast.cs | 8 +- .../System/Linq/Operators/TakeWhile.cs | 32 ++++---- .../Linq/Operators/ToAsyncEnumerable.cs | 18 ++--- .../System/Linq/Operators/Union.cs | 12 +-- .../System/Linq/Operators/Where.cs | 40 +++++----- .../System/Linq/Operators/Zip.cs | 20 ++--- 45 files changed, 404 insertions(+), 404 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 4ae0d86da6..690175b87e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -71,11 +71,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - var firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); - var secondEnumerator = _second.GetAsyncEnumerator(cancellationToken); + var firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); + var secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); var firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); var secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); @@ -110,11 +110,11 @@ protected override async ValueTask MoveNextCore() }); } - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; if (await winner.ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -123,7 +123,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -166,7 +166,7 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: var n = _sources.Length; @@ -176,7 +176,7 @@ protected override async ValueTask MoveNextCore() for (var i = 0; i < n; i++) { - var enumerator = _sources[i].GetAsyncEnumerator(cancellationToken); + var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); enumerators[i] = enumerator; moveNexts[i] = enumerator.MoveNextAsync(); @@ -208,11 +208,11 @@ protected override async ValueTask MoveNextCore() } } - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; if (await winner.ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -221,7 +221,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index f1f0700dc5..892781b818 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -73,15 +73,15 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _buffers = new Queue>(); _index = 0; _stopped = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -104,7 +104,7 @@ protected override async ValueTask MoveNextCore() if (_buffers.Count > 0 && _buffers.Peek().Count == _count) { - current = _buffers.Dequeue(); + _current = _buffers.Dequeue(); return true; } @@ -120,7 +120,7 @@ protected override async ValueTask MoveNextCore() if (_buffers.Count > 0) { - current = _buffers.Dequeue(); + _current = _buffers.Dequeue(); return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 0282814b7c..62fe08cb59 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -100,13 +100,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _isDone = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -118,7 +118,7 @@ protected override async ValueTask MoveNextCore() { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } } @@ -128,7 +128,7 @@ protected override async ValueTask MoveNextCore() // invoking the handler, but we use this order to preserve // current behavior var inner = _handler(ex); - var err = inner.GetAsyncEnumerator(cancellationToken); + var err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { @@ -143,7 +143,7 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -193,13 +193,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _isDone = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -211,7 +211,7 @@ protected override async ValueTask MoveNextCore() { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } } @@ -221,7 +221,7 @@ protected override async ValueTask MoveNextCore() // invoking the handler, but we use this order to preserve // current behavior var inner = await _handler(ex).ConfigureAwait(false); - var err = inner.GetAsyncEnumerator(cancellationToken); + var err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { @@ -236,7 +236,7 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -293,12 +293,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _sourcesEnumerator = _sources.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -314,14 +314,14 @@ protected override async ValueTask MoveNextCore() } _error = null; - _enumerator = _sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _enumerator = _sourcesEnumerator.Current.GetAsyncEnumerator(_cancellationToken); } try { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index ddad69506e..b5d9fc626a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -83,12 +83,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _outerEnumerator = _source.GetEnumerator(); _mode = State_OuterNext; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -103,7 +103,7 @@ protected override async ValueTask MoveNextCore() await _currentEnumerator.DisposeAsync().ConfigureAwait(false); } - _currentEnumerator = _outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _currentEnumerator = _outerEnumerator.Current.GetAsyncEnumerator(_cancellationToken); _mode = State_While; goto case State_While; @@ -113,7 +113,7 @@ protected override async ValueTask MoveNextCore() case State_While: if (await _currentEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _currentEnumerator.Current; + _current = _currentEnumerator.Current; return true; } @@ -172,12 +172,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _outerEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _outerEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _mode = State_OuterNext; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -192,7 +192,7 @@ protected override async ValueTask MoveNextCore() await _currentEnumerator.DisposeAsync().ConfigureAwait(false); } - _currentEnumerator = _outerEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _currentEnumerator = _outerEnumerator.Current.GetAsyncEnumerator(_cancellationToken); _mode = State_While; goto case State_While; @@ -202,7 +202,7 @@ protected override async ValueTask MoveNextCore() case State_While: if (await _currentEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _currentEnumerator.Current; + _current = _currentEnumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 62685c181c..b5c1dee8b2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -144,10 +144,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); if (!await _enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -158,9 +158,9 @@ protected override async ValueTask MoveNextCore() var element = _enumerator.Current; _set = new Set(_comparer); _set.Add(_keySelector(element)); - current = element; + _current = element; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: @@ -169,7 +169,7 @@ protected override async ValueTask MoveNextCore() element = _enumerator.Current; if (_set.Add(_keySelector(element))) { - current = element; + _current = element; return true; } } @@ -289,10 +289,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); if (!await _enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -303,9 +303,9 @@ protected override async ValueTask MoveNextCore() var element = _enumerator.Current; _set = new Set(_comparer); _set.Add(await _keySelector(element).ConfigureAwait(false)); - current = element; + _current = element; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: @@ -314,7 +314,7 @@ protected override async ValueTask MoveNextCore() element = _enumerator.Current; if (_set.Add(await _keySelector(element).ConfigureAwait(false))) { - current = element; + _current = element; return true; } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 6dac659d6f..fbe357e88b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -120,11 +120,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -142,7 +142,7 @@ protected override async ValueTask MoveNextCore() { _hasCurrentValue = true; _currentValue = item; - current = item; + _current = item; return true; } } @@ -191,11 +191,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -213,7 +213,7 @@ protected override async ValueTask MoveNextCore() { _hasCurrentKey = true; _currentKeyValue = key; - current = item; + _current = item; return true; } } @@ -262,11 +262,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -284,7 +284,7 @@ protected override async ValueTask MoveNextCore() { _hasCurrentKey = true; _currentKeyValue = key; - current = item; + _current = item; return true; } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index 9e2d21ed4c..987e0d0314 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -165,11 +165,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -177,8 +177,8 @@ protected override async ValueTask MoveNextCore() { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; - _onNext(current); + _current = _enumerator.Current; + _onNext(_current); return true; } @@ -241,11 +241,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -253,8 +253,8 @@ protected override async ValueTask MoveNextCore() { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; - await _onNext(current).ConfigureAwait(false); + _current = _enumerator.Current; + await _onNext(_current).ConfigureAwait(false); return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 37635cba96..7fc494443f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -69,13 +69,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _queue = new Queue>(); _queue.Enqueue(_source); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -92,7 +92,7 @@ protected override async ValueTask MoveNextCore() await _enumerator.DisposeAsync().ConfigureAwait(false); } - _enumerator = src.GetAsyncEnumerator(cancellationToken); + _enumerator = src.GetAsyncEnumerator(_cancellationToken); continue; // loop } @@ -105,7 +105,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; var next = _selector(item); _queue.Enqueue(next); - current = item; + _current = item; return true; } @@ -159,13 +159,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _queue = new Queue>(); _queue.Enqueue(_source); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -182,7 +182,7 @@ protected override async ValueTask MoveNextCore() await _enumerator.DisposeAsync().ConfigureAwait(false); } - _enumerator = src.GetAsyncEnumerator(cancellationToken); + _enumerator = src.GetAsyncEnumerator(_cancellationToken); continue; // loop } @@ -195,7 +195,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; var next = await _selector(item).ConfigureAwait(false); _queue.Enqueue(next); - current = item; + _current = item; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 985248216e..4d9f70c4c0 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -67,17 +67,17 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -125,17 +125,17 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 3962da5ea6..4c16e90252 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -60,13 +60,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _started = false; _currentState = _initialState; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -79,7 +79,7 @@ protected override async ValueTask MoveNextCore() if (_condition(_currentState)) { - current = _resultSelector(_currentState); + _current = _resultSelector(_currentState); return true; } break; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index fa12f5c4e3..9c5cb77c6b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -49,11 +49,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index a035f87db8..61bb76ea20 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -78,7 +78,7 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: var n = _sources.Length; @@ -89,12 +89,12 @@ protected override async ValueTask MoveNextCore() for (var i = 0; i < n; i++) { - var enumerator = _sources[i].GetAsyncEnumerator(cancellationToken); + var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); _enumerators[i] = enumerator; _moveNexts[i] = enumerator.MoveNextAsync(); } - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -118,7 +118,7 @@ protected override async ValueTask MoveNextCore() else { var enumerator = _enumerators[index]; - current = enumerator.Current; + _current = enumerator.Current; _moveNexts[index] = enumerator.MoveNextAsync(); return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index 1033ea08a4..ec998483d7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -80,12 +80,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _sourcesEnumerator = _sources.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -98,14 +98,14 @@ protected override async ValueTask MoveNextCore() break; // while -- done, nothing else to do } - _enumerator = _sourcesEnumerator.Current.GetAsyncEnumerator(cancellationToken); + _enumerator = _sourcesEnumerator.Current.GetAsyncEnumerator(_cancellationToken); } try { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index 60be6f57ce..4509c934a9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -50,9 +50,9 @@ public override AsyncIterator Clone() protected override ValueTask MoveNextCore() { - cancellationToken.ThrowIfCancellationRequested(); + _cancellationToken.ThrowIfCancellationRequested(); - current = _element; + _current = _element; return new ValueTask(true); } } @@ -94,7 +94,7 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: @@ -107,15 +107,15 @@ protected override async ValueTask MoveNextCore() if (!_isInfinite && _currentCount-- == 0) break; - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index c9d9524923..de9626dc77 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -89,14 +89,14 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _hasSeed = false; _accumulated = default; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -112,7 +112,7 @@ protected override async ValueTask MoveNextCore() } _accumulated = _accumulator(_accumulated, item); - current = _accumulated; + _current = _accumulated; return true; } @@ -163,13 +163,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _accumulated = _seed; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -177,7 +177,7 @@ protected override async ValueTask MoveNextCore() { var item = _enumerator.Current; _accumulated = _accumulator(_accumulated, item); - current = _accumulated; + _current = _accumulated; return true; } @@ -227,14 +227,14 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _hasSeed = false; _accumulated = default; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -250,7 +250,7 @@ protected override async ValueTask MoveNextCore() } _accumulated = await _accumulator(_accumulated, item).ConfigureAwait(false); - current = _accumulated; + _current = _accumulated; return true; } @@ -301,13 +301,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _accumulated = _seed; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -315,7 +315,7 @@ protected override async ValueTask MoveNextCore() { var item = _enumerator.Current; _accumulated = await _accumulator(_accumulated, item).ConfigureAwait(false); - current = _accumulated; + _current = _accumulated; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index 2a65614852..474ec0077c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -56,12 +56,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -86,7 +86,7 @@ protected override async ValueTask MoveNextCore() if (await moveNext.ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index b7cf5fa97f..0347733dd7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -76,18 +76,18 @@ protected override async ValueTask MoveNextCore() // GetAsyncEnumerator. This is inconsistent with asynchronous "using" and with a C# 8.0 async iterator with // a using statement inside, so this logic got moved to MoveNextAsync instead. - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _resource = _resourceFactory(); - _enumerator = _enumerableFactory(_resource).GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _enumerableFactory(_resource).GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -141,20 +141,20 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _resource = await _resourceFactory().ConfigureAwait(false); _enumerable = await _enumerableFactory(_resource).ConfigureAwait(false); - _enumerator = _enumerable.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _enumerable.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 2fb456d9fd..cdeff0f874 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -109,14 +109,14 @@ async Task Core() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _hasSkipped = false; _taken = 0; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -141,7 +141,7 @@ protected override async ValueTask MoveNextCore() _taken++; } - current = _enumerator.Current; + _current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index e42f18e503..2aa0610ec5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -141,16 +141,16 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _moveNext().ConfigureAwait(false)) { - current = _currentFunc(); + _current = _currentFunc(); return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 20df466766..68c83877ac 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -12,9 +12,9 @@ internal abstract partial class AsyncIterator : IAsyncEnumerable GetAsyncEnumerator(CancellationToken cancellationToken) { - var enumerator = state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId + var enumerator = _state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); - enumerator.state = AsyncIteratorState.Allocated; - enumerator.cancellationToken = cancellationToken; + enumerator._state = AsyncIteratorState.Allocated; + enumerator._cancellationToken = cancellationToken; return enumerator; } public virtual ValueTask DisposeAsync() { - current = default; - state = AsyncIteratorState.Disposed; + _current = default; + _state = AsyncIteratorState.Disposed; return TaskExt.CompletedTask; } - public TSource Current => current; + public TSource Current => _current; public async ValueTask MoveNextAsync() { @@ -49,7 +49,7 @@ public async ValueTask MoveNextAsync() // that any exceptions thrown from the MoveNextCore call are handled // by the try/catch, whether they're sync or async - if (state == AsyncIteratorState.Disposed) + if (_state == AsyncIteratorState.Disposed) { return false; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 131d5bee70..8a0525f7c4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -42,7 +42,7 @@ protected override async ValueTask MoveNextCore() { if ((uint)_index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && _index < _source.Count - _minIndexInclusive) { - current = _source[_minIndexInclusive + _index]; + _current = _source[_minIndexInclusive + _index]; ++_index; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 51d7390b98..9bd581c51a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -62,7 +62,7 @@ protected async Task LoadFromEnumeratorAsync() { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -112,14 +112,14 @@ public override AsyncIterator Clone() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _hasEnumerator = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; if (!_appending) { - current = _item; + _current = _item; return true; } @@ -128,7 +128,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (!_hasEnumerator) { - GetSourceEnumerator(cancellationToken); + GetSourceEnumerator(_cancellationToken); _hasEnumerator = true; } @@ -141,7 +141,7 @@ protected override async ValueTask MoveNextCore() if (_appending) { - current = _item; + _current = _item; return true; } } @@ -315,11 +315,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _mode = 1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -333,12 +333,12 @@ protected override async ValueTask MoveNextCore() case 2: if (_node != null) { - current = _node.Item; + _current = _node.Item; _node = _node.Linked; return true; } - GetSourceEnumerator(cancellationToken); + GetSourceEnumerator(_cancellationToken); _mode = 3; goto case 3; @@ -361,7 +361,7 @@ protected override async ValueTask MoveNextCore() case 4: if (_appendedEnumerator.MoveNext()) { - current = _appendedEnumerator.Current; + _current = _appendedEnumerator.Current; return true; } break; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index 5753376d29..8633aa39f5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -55,17 +55,17 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = (TResult)_enumerator.Current; + _current = (TResult)_enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 049be854d6..2a6c5458ce 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -143,20 +143,20 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - if (state == AsyncIteratorState.Allocated) + if (_state == AsyncIteratorState.Allocated) { - _enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = GetAsyncEnumerable(0).GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; _counter = 2; } - if (state == AsyncIteratorState.Iterating) + if (_state == AsyncIteratorState.Iterating) { while (true) { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } // note, this is simply to match the logic of @@ -165,7 +165,7 @@ protected override async ValueTask MoveNextCore() if (next != null) { await _enumerator.DisposeAsync().ConfigureAwait(false); - _enumerator = next.GetAsyncEnumerator(cancellationToken); + _enumerator = next.GetAsyncEnumerator(_cancellationToken); continue; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 6bfeef84de..e11ec3067b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -61,29 +61,29 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; - state = AsyncIteratorState.Iterating; + _current = _enumerator.Current; + _state = AsyncIteratorState.Iterating; } else { - current = _defaultValue; + _current = _defaultValue; await _enumerator.DisposeAsync().ConfigureAwait(false); _enumerator = null; - state = AsyncIteratorState.Disposed; + _state = AsyncIteratorState.Disposed; } return true; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } break; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 7e8d4e5a99..e6e20aeeb3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -90,10 +90,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); if (!await _enumerator.MoveNextAsync().ConfigureAwait(false)) { await DisposeAsync().ConfigureAwait(false); @@ -103,9 +103,9 @@ protected override async ValueTask MoveNextCore() var element = _enumerator.Current; _set = new Set(_comparer); _set.Add(element); - current = element; + _current = element; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: @@ -114,7 +114,7 @@ protected override async ValueTask MoveNextCore() element = _enumerator.Current; if (_set.Add(element)) { - current = element; + _current = element; return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index f5d4e2977c..3c073eb79e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -75,13 +75,13 @@ protected override async ValueTask MoveNextCore() // concurrency, which isn't a great default behavior because it's very hard to suppress or control // this behavior. - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _set = await AsyncEnumerableHelpers.ToSet(_second, _comparer, cancellationToken).ConfigureAwait(false); - _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); + _set = await AsyncEnumerableHelpers.ToSet(_second, _comparer, _cancellationToken).ConfigureAwait(false); + _firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -95,7 +95,7 @@ protected override async ValueTask MoveNextCore() var item = _firstEnumerator.Current; if (_set.Add(item)) { - current = item; + _current = item; return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 7dc28260ad..57d454a754 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -244,18 +244,18 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); _enumerator = _lookup.ApplyResultSelector(_resultSelector).GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -337,18 +337,18 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); + _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -430,18 +430,18 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)_enumerator.Current; + _current = (IAsyncGrouping)_enumerator.Current; return true; } @@ -523,18 +523,18 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)_enumerator.Current; + _current = (IAsyncGrouping)_enumerator.Current; return true; } @@ -612,18 +612,18 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)_enumerator.Current; + _current = (IAsyncGrouping)_enumerator.Current; return true; } @@ -701,18 +701,18 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); _enumerator = _lookup.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = (IAsyncGrouping)_enumerator.Current; + _current = (IAsyncGrouping)_enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 3a5f4fa3cc..973e3f06ac 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -75,13 +75,13 @@ protected override async ValueTask MoveNextCore() // concurrency, which isn't a great default behavior because it's very hard to suppress or control // this behavior. - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _set = await AsyncEnumerableHelpers.ToSet(_second, _comparer, cancellationToken).ConfigureAwait(false); - _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); + _set = await AsyncEnumerableHelpers.ToSet(_second, _comparer, _cancellationToken).ConfigureAwait(false); + _firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -96,7 +96,7 @@ protected override async ValueTask MoveNextCore() var item = _firstEnumerator.Current; if (_set.Remove(item)) { - current = item; + _current = item; return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 84f486d4de..ff389e820e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -133,12 +133,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _outerEnumerator = _outer.GetAsyncEnumerator(cancellationToken); + _outerEnumerator = _outer.GetAsyncEnumerator(_cancellationToken); _mode = State_If; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -147,7 +147,7 @@ protected override async ValueTask MoveNextCore() case State_If: if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { - _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); if (_lookup.Count != 0) { @@ -175,7 +175,7 @@ protected override async ValueTask MoveNextCore() goto case State_While; case State_For: - current = _resultSelector(_item, _elements[_index]); + _current = _resultSelector(_item, _elements[_index]); _index++; if (_index == _count) { @@ -260,12 +260,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _outerEnumerator = _outer.GetAsyncEnumerator(cancellationToken); + _outerEnumerator = _outer.GetAsyncEnumerator(_cancellationToken); _mode = State_If; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -274,7 +274,7 @@ protected override async ValueTask MoveNextCore() case State_If: if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false)) { - _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, cancellationToken).ConfigureAwait(false); + _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); if (_lookup.Count != 0) { @@ -302,7 +302,7 @@ protected override async ValueTask MoveNextCore() goto case State_While; case State_For: - current = await _resultSelector(_item, _elements[_index]).ConfigureAwait(false); + _current = await _resultSelector(_item, _elements[_index]).ConfigureAwait(false); _index++; if (_index == _count) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index bdfe3c4a6b..752a15b903 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -49,11 +49,11 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -62,7 +62,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; if (item is TResult res) { - current = res; + _current = res; return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 9adf5373cc..562fb46949 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -30,10 +30,10 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _buffer = await _source.ToArray(cancellationToken).ConfigureAwait(false); + _buffer = await _source.ToArray(_cancellationToken).ConfigureAwait(false); // REVIEW: If we add selectors with CancellationToken support, we should feed the token to Sort. @@ -41,13 +41,13 @@ protected override async ValueTask MoveNextCore() _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); _index = 0; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_index < _buffer.Length) { - current = _buffer[_indexes[_index++]]; + _current = _buffer[_indexes[_index++]]; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 6b31293446..ff612e8688 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -109,18 +109,18 @@ public Task> TryGetElementAsync(int index, CancellationToken cancella protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - current = _start; + _current = _start; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; return true; case AsyncIteratorState.Iterating: - current++; + _current++; - if (current != _end) + if (_current != _end) { return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index ca7d2a7216..61aa982744 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -60,17 +60,17 @@ public Task> ToListAsync(CancellationToken cancellationToken) protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _remaining = _count; if (_remaining > 0) { - current = _element; + _current = _element; } - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index e3ed81c429..31adbe7b65 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -89,19 +89,19 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _items = await _source.ToArray(cancellationToken).ConfigureAwait(false); + _items = await _source.ToArray(_cancellationToken).ConfigureAwait(false); _index = _items.Length - 1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_index != -1) { - current = _items[_index]; + _current = _items[_index]; --_index; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 7ee6fd7a00..d906b45800 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -120,17 +120,17 @@ public override IAsyncEnumerable Select(Func MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _selector(_enumerator.Current); + _current = _selector(_enumerator.Current); return true; } @@ -176,12 +176,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -191,7 +191,7 @@ protected override async ValueTask MoveNextCore() { _index++; } - current = _selector(_enumerator.Current, _index); + _current = _selector(_enumerator.Current, _index); return true; } @@ -291,17 +291,17 @@ public Task> ToListAsync(CancellationToken cancellationToken) protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _enumerator = _source.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = _selector(_enumerator.Current); + _current = _selector(_enumerator.Current); return true; } @@ -352,17 +352,17 @@ public override IAsyncEnumerable Select(Func MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = await _selector(_enumerator.Current).ConfigureAwait(false); + _current = await _selector(_enumerator.Current).ConfigureAwait(false); return true; } @@ -408,12 +408,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -423,7 +423,7 @@ protected override async ValueTask MoveNextCore() { _index++; } - current = await _selector(_enumerator.Current, _index).ConfigureAwait(false); + _current = await _selector(_enumerator.Current, _index).ConfigureAwait(false); return true; } @@ -533,17 +533,17 @@ public async Task> ToListAsync(CancellationToken cancellationToken protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _enumerator = _source.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = await _selector(_enumerator.Current).ConfigureAwait(false); + _current = await _selector(_enumerator.Current).ConfigureAwait(false); return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 8129fd1256..cf371d1f7e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -144,12 +144,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -164,7 +164,7 @@ protected override async ValueTask MoveNextCore() } var inner = _selector(_sourceEnumerator.Current); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -174,7 +174,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _resultEnumerator.Current; + _current = _resultEnumerator.Current; return true; } @@ -235,12 +235,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -255,7 +255,7 @@ protected override async ValueTask MoveNextCore() } var inner = await _selector(_sourceEnumerator.Current).ConfigureAwait(false); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -265,7 +265,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _resultEnumerator.Current; + _current = _resultEnumerator.Current; return true; } @@ -332,12 +332,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -353,7 +353,7 @@ protected override async ValueTask MoveNextCore() _currentSource = _sourceEnumerator.Current; var inner = _collectionSelector(_currentSource); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -363,7 +363,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _resultSelector(_currentSource, _resultEnumerator.Current); + _current = _resultSelector(_currentSource, _resultEnumerator.Current); return true; } @@ -430,12 +430,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -451,7 +451,7 @@ protected override async ValueTask MoveNextCore() _currentSource = _sourceEnumerator.Current; var inner = await _collectionSelector(_currentSource).ConfigureAwait(false); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -461,7 +461,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false); + _current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false); return true; } @@ -529,13 +529,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -557,7 +557,7 @@ protected override async ValueTask MoveNextCore() } var inner = _collectionSelector(_currentSource, _index); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -567,7 +567,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _resultSelector(_currentSource, _resultEnumerator.Current); + _current = _resultSelector(_currentSource, _resultEnumerator.Current); return true; } @@ -635,13 +635,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -663,7 +663,7 @@ protected override async ValueTask MoveNextCore() } var inner = await _collectionSelector(_currentSource, _index).ConfigureAwait(false); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -673,7 +673,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false); + _current = await _resultSelector(_currentSource, _resultEnumerator.Current).ConfigureAwait(false); return true; } @@ -735,13 +735,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -761,7 +761,7 @@ protected override async ValueTask MoveNextCore() } var inner = _selector(_sourceEnumerator.Current, _index); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -771,7 +771,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _resultEnumerator.Current; + _current = _resultEnumerator.Current; return true; } @@ -833,13 +833,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _sourceEnumerator = _source.GetAsyncEnumerator(cancellationToken); + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; _mode = State_Source; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -859,7 +859,7 @@ protected override async ValueTask MoveNextCore() } var inner = await _selector(_sourceEnumerator.Current, _index).ConfigureAwait(false); - _resultEnumerator = inner.GetAsyncEnumerator(cancellationToken); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; goto case State_Result; @@ -869,7 +869,7 @@ protected override async ValueTask MoveNextCore() case State_Result: if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _resultEnumerator.Current; + _current = _resultEnumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 945da72e0c..57cd7bbb66 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -68,13 +68,13 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _queue = new Queue(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -86,7 +86,7 @@ protected override async ValueTask MoveNextCore() if (_queue.Count > _count) { - current = _queue.Dequeue(); + _current = _queue.Dequeue(); return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 6bbfbb0254..7047a81e27 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -86,10 +86,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) @@ -98,7 +98,7 @@ protected override async ValueTask MoveNextCore() if (!_predicate(element)) { _doMoveNext = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } } @@ -108,13 +108,13 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } if (!_doMoveNext) { - current = _enumerator.Current; + _current = _enumerator.Current; _doMoveNext = true; return true; } @@ -163,10 +163,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; // skip elements as requested @@ -181,7 +181,7 @@ protected override async ValueTask MoveNextCore() if (!_predicate(element, _index)) { _doMoveNext = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } } @@ -191,13 +191,13 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } if (!_doMoveNext) { - current = _enumerator.Current; + _current = _enumerator.Current; _doMoveNext = true; return true; } @@ -245,10 +245,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) @@ -257,7 +257,7 @@ protected override async ValueTask MoveNextCore() if (!await _predicate(element).ConfigureAwait(false)) { _doMoveNext = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } } @@ -267,13 +267,13 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } if (!_doMoveNext) { - current = _enumerator.Current; + _current = _enumerator.Current; _doMoveNext = true; return true; } @@ -322,10 +322,10 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; // skip elements as requested @@ -340,7 +340,7 @@ protected override async ValueTask MoveNextCore() if (!await _predicate(element, _index).ConfigureAwait(false)) { _doMoveNext = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; } } @@ -350,13 +350,13 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } if (!_doMoveNext) { - current = _enumerator.Current; + _current = _enumerator.Current; _doMoveNext = true; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 2b2b7b5e7b..46bfe65f0c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -61,14 +61,14 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _queue = new Queue(); _isDone = false; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -102,7 +102,7 @@ protected override async ValueTask MoveNextCore() if (_queue.Count > 0) { - current = _queue.Dequeue(); + _current = _queue.Dequeue(); return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index aae981ac42..3338bcc91b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -85,12 +85,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -103,7 +103,7 @@ protected override async ValueTask MoveNextCore() break; } - current = item; + _current = item; return true; } @@ -150,12 +150,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -173,7 +173,7 @@ protected override async ValueTask MoveNextCore() break; } - current = item; + _current = item; return true; } @@ -219,12 +219,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -237,7 +237,7 @@ protected override async ValueTask MoveNextCore() break; } - current = item; + _current = item; return true; } @@ -284,12 +284,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -307,7 +307,7 @@ protected override async ValueTask MoveNextCore() break; } - current = item; + _current = item; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index a512f87493..3a31ae25b5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -154,17 +154,17 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _enumerator = _source.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -223,17 +223,17 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _enumerator = _source.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } @@ -327,17 +327,17 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _enumerator = _source.GetEnumerator(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (_enumerator.MoveNext()) { - current = _enumerator.Current; + _current = _enumerator.Current; return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index fd20d1f7f0..983180d8ce 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -88,7 +88,7 @@ private void StoreFirst() var set = new Set(_comparer); var element = _enumerator.Current; set.Add(element); - current = element; + _current = element; _set = set; } @@ -102,7 +102,7 @@ private async Task GetNextAsync() var element = _enumerator.Current; if (set.Add(element)) { - current = element; + _current = element; return true; } } @@ -112,7 +112,7 @@ private async Task GetNextAsync() protected sealed override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: _index = 0; @@ -121,14 +121,14 @@ protected sealed override async ValueTask MoveNextCore() { ++_index; - var enumerator = enumerable.GetAsyncEnumerator(cancellationToken); + var enumerator = enumerable.GetAsyncEnumerator(_cancellationToken); if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { await SetEnumeratorAsync(enumerator).ConfigureAwait(false); StoreFirst(); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; return true; } } @@ -149,7 +149,7 @@ protected sealed override async ValueTask MoveNextCore() break; } - await SetEnumeratorAsync(enumerable.GetAsyncEnumerator(cancellationToken)).ConfigureAwait(false); + await SetEnumeratorAsync(enumerable.GetAsyncEnumerator(_cancellationToken)).ConfigureAwait(false); ++_index; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 98d05e9af7..65994668de 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -116,11 +116,11 @@ public override IAsyncEnumerable Where(Func predicate) protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -129,7 +129,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; if (_predicate(item)) { - current = item; + _current = item; return true; } } @@ -177,12 +177,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -195,7 +195,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; if (_predicate(item, _index)) { - current = item; + _current = item; return true; } } @@ -246,11 +246,11 @@ public override IAsyncEnumerable Where(Func> predic protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -259,7 +259,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; if (await _predicate(item).ConfigureAwait(false)) { - current = item; + _current = item; return true; } } @@ -307,12 +307,12 @@ public override async ValueTask DisposeAsync() protected override async ValueTask MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); _index = -1; - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -325,7 +325,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; if (await _predicate(item, _index).ConfigureAwait(false)) { - current = item; + _current = item; return true; } } @@ -380,11 +380,11 @@ public override IAsyncEnumerable Select(Func MoveNextCore() { - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _enumerator = _source.GetAsyncEnumerator(cancellationToken); - state = AsyncIteratorState.Iterating; + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: @@ -393,7 +393,7 @@ protected override async ValueTask MoveNextCore() var item = _enumerator.Current; if (_predicate(item)) { - current = _selector(item); + _current = _selector(item); return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 2fb45e6979..1b52e171fb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -83,19 +83,19 @@ protected override async ValueTask MoveNextCore() // results in an unexpected source of concurrency. However, a concurrent Zip may be a worthy addition to the // API or System.Interactive.Async as a complementary implementation besides the conservative default. - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); - _secondEnumerator = _second.GetAsyncEnumerator(cancellationToken); + _firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); + _secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _firstEnumerator.MoveNextAsync().ConfigureAwait(false) && await _secondEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = _selector(_firstEnumerator.Current, _secondEnumerator.Current); + _current = _selector(_firstEnumerator.Current, _secondEnumerator.Current); return true; } @@ -155,19 +155,19 @@ protected override async ValueTask MoveNextCore() // results in an unexpected source of concurrency. However, a concurrent Zip may be a worthy addition to the // API or System.Interactive.Async as a complementary implementation besides the conservative default. - switch (state) + switch (_state) { case AsyncIteratorState.Allocated: - _firstEnumerator = _first.GetAsyncEnumerator(cancellationToken); - _secondEnumerator = _second.GetAsyncEnumerator(cancellationToken); + _firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); + _secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); - state = AsyncIteratorState.Iterating; + _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: if (await _firstEnumerator.MoveNextAsync().ConfigureAwait(false) && await _secondEnumerator.MoveNextAsync().ConfigureAwait(false)) { - current = await _selector(_firstEnumerator.Current, _secondEnumerator.Current).ConfigureAwait(false); + _current = await _selector(_firstEnumerator.Current, _secondEnumerator.Current).ConfigureAwait(false); return true; } From 8fea84666db68db6cd972328d700f792f71cb8da Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 14:55:53 -0800 Subject: [PATCH 485/862] Default value of ValueTask is good enough to report completion. --- .../System.Interactive.Async/System/Linq/Operators/Defer.cs | 2 +- Ix.NET/Source/System.Interactive.Async/TaskExt.cs | 1 - Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/Empty.cs | 2 +- .../System/Linq/Operators/ToAsyncEnumerable.cs | 4 ++-- .../System.Linq.Async/System/Threading/Tasks/TaskExt.cs | 1 - 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index fe075eda41..a01e982f15 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -111,7 +111,7 @@ private sealed class DisposedEnumerator : IAsyncEnumerator public T Current => throw new ObjectDisposedException("this"); - public ValueTask DisposeAsync() => TaskExt.CompletedTask; + public ValueTask DisposeAsync() => default; public ValueTask MoveNextAsync() => throw new ObjectDisposedException("this"); } diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index 918b9026e9..521f0a63ca 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -6,7 +6,6 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); public static readonly ValueTask Never = new ValueTask(new TaskCompletionSource().Task); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 68c83877ac..7f80d75cc7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -38,7 +38,7 @@ public virtual ValueTask DisposeAsync() _current = default; _state = AsyncIteratorState.Disposed; - return TaskExt.CompletedTask; + return default; } public TSource Current => _current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 29fdd61f92..ee045b3d66 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -44,7 +44,7 @@ public Task ToArrayAsync(CancellationToken cancellationToken) => Task. public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => this; - public ValueTask DisposeAsync() => TaskExt.CompletedTask; + public ValueTask DisposeAsync() => default; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 3a31ae25b5..15a1b45d4e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -49,7 +49,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task value, - () => TaskExt.CompletedTask); + () => default); }); } @@ -118,7 +118,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva ctr.Dispose(); subscription.Dispose(); // Should we cancel in-flight operations somehow? - return TaskExt.CompletedTask; + return default; }); }); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs index 6a23fabf3f..bd2d093e90 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs @@ -6,7 +6,6 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); public static readonly Task MinusOne = Task.FromResult(-1); } } From 4802dc8f35d392826c3f3f2a976d04bcacdca2b4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:03:39 -0800 Subject: [PATCH 486/862] Minor modernization. --- .../System/Linq/Operators/Select.cs | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index d906b45800..4aa6b9af44 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -18,14 +18,12 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); - if (source is AsyncIterator iterator) + switch (source) { - return iterator.Select(selector); - } - - if (source is IList ilist) - { - return new SelectIListIterator(ilist, selector); + case AsyncIterator iterator: + return iterator.Select(selector); + case IList list: + return new SelectIListIterator(list, selector); } return new SelectEnumerableAsyncIterator(source, selector); @@ -48,14 +46,12 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); - if (source is AsyncIterator iterator) - { - return iterator.Select(selector); - } - - if (source is IList ilist) + switch (source) { - return new SelectIListIteratorWithTask(ilist, selector); + case AsyncIterator iterator: + return iterator.Select(selector); + case IList list: + return new SelectIListIteratorWithTask(list, selector); } return new SelectEnumerableAsyncIteratorWithTask(source, selector); From 516926652ad6deaf77037e058343c8ec5e646a58 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:07:45 -0800 Subject: [PATCH 487/862] Access Current prior to checked arithmetic. --- .../System.Linq.Async/System/Linq/Operators/Select.cs | 10 ++++++++-- .../System/Linq/Operators/SkipWhile.cs | 6 ++++-- .../System/Linq/Operators/TakeWhile.cs | 2 ++ .../System.Linq.Async/System/Linq/Operators/Where.cs | 8 ++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 4aa6b9af44..2935957cb5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -183,11 +183,14 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { + var item = _enumerator.Current; + checked { _index++; } - _current = _selector(_enumerator.Current, _index); + + _current = _selector(item, _index); return true; } @@ -415,11 +418,14 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { + var item = _enumerator.Current; + checked { _index++; } - _current = await _selector(_enumerator.Current, _index).ConfigureAwait(false); + + _current = await _selector(item, _index).ConfigureAwait(false); return true; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 7047a81e27..fb1a99377e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -172,12 +172,13 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { + var element = _enumerator.Current; + checked { _index++; } - var element = _enumerator.Current; if (!_predicate(element, _index)) { _doMoveNext = false; @@ -331,12 +332,13 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { + var element = _enumerator.Current; + checked { _index++; } - var element = _enumerator.Current; if (!await _predicate(element, _index).ConfigureAwait(false)) { _doMoveNext = false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 3338bcc91b..15f8ca093b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -163,6 +163,7 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = _enumerator.Current; + checked { _index++; @@ -297,6 +298,7 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { var item = _enumerator.Current; + checked { _index++; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 65994668de..e8786f6431 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -188,11 +188,13 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { + var item = _enumerator.Current; + checked { _index++; } - var item = _enumerator.Current; + if (_predicate(item, _index)) { _current = item; @@ -318,11 +320,13 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { + var item = _enumerator.Current; + checked { _index++; } - var item = _enumerator.Current; + if (await _predicate(item, _index).ConfigureAwait(false)) { _current = item; From 0af62a18c3bc7a9e75151c348af1b0e227b8e8d5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:14:40 -0800 Subject: [PATCH 488/862] Fix dispose order in SelectMany. --- .../System/Linq/Operators/SelectMany.cs | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index cf371d1f7e..6bc693e522 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -127,18 +127,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); } @@ -218,18 +218,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); } @@ -313,18 +313,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); @@ -411,18 +411,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); @@ -510,18 +510,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); @@ -616,18 +616,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + _currentSource = default; await base.DisposeAsync().ConfigureAwait(false); @@ -718,18 +718,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); } @@ -816,18 +816,18 @@ public override AsyncIterator Clone() public override async ValueTask DisposeAsync() { - if (_sourceEnumerator != null) - { - await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); - _sourceEnumerator = null; - } - if (_resultEnumerator != null) { await _resultEnumerator.DisposeAsync().ConfigureAwait(false); _resultEnumerator = null; } + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + await base.DisposeAsync().ConfigureAwait(false); } From a7c9d8cb8040a27deb1fbf21e931a2a00811a015 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:28:39 -0800 Subject: [PATCH 489/862] Conditional compilation of ForEachAsync support. --- .../System/Linq/Operators/ForEachAsync.cs | 3 ++- .../System/Linq/Operators/TakeLast.cs | 8 -------- .../System.Linq.Async/System/Linq/Operators/ForEach.cs | 7 +++++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 30791dcae4..fd0897edd4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +#if !HAS_AWAIT_FOREACH using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -84,3 +84,4 @@ public void ForEachAsync6() } } } +#endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs index f81271bd87..d06dcfd7b8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs @@ -62,14 +62,6 @@ public async Task TakeLast3() [Fact] public void TakeLast_BugFix_TakeLast_Zero_TakesForever() { - var isSet = false; - new int[] { 1, 2, 3, 4 }.ToAsyncEnumerable() - .TakeLast(0) - .ForEachAsync(_ => { isSet = true; }) - .Wait(WaitTimeoutMs); - - Assert.False(isSet); - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(0); var e = xs.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 0c6beac147..4002d43892 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +#if !HAS_AWAIT_FOREACH using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -10,6 +11,11 @@ namespace System.Linq { public static partial class AsyncEnumerable { + // REVIEW: Once we have C# 8.0 language support, we may want to do away with these methods. An open question is how to + // provide support for cancellation, which could be offered through WithCancellation on the source. If we still + // want to keep these methods, they may be a candidate for System.Interactive.Async if we consider them to be + // non-standard (i.e. IEnumerable doesn't have a ForEach extension method either). + public static Task ForEachAsync(this IAsyncEnumerable source, Action action) { if (source == null) @@ -183,3 +189,4 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so } } } +#endif From 65e40bed85997b2be04c0438f552c961f8f460d7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:38:12 -0800 Subject: [PATCH 490/862] Improve code-gen stability for queryable API surface. --- .../System.Interactive.Async.Providers.csproj | 4 + .../System/Linq/AsyncQueryableEx.Generated.cs | 168 +- .../System/Linq/AsyncQueryableEx.Generated.tt | 2 +- .../System.Linq.Async.Queryable.csproj | 4 + .../System/Linq/AsyncQueryable.Generated.cs | 1672 ++++++++--------- .../System/Linq/AsyncQueryable.Generated.tt | 2 +- 6 files changed, 930 insertions(+), 922 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index a305d2f244..77ce7508d5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -25,4 +25,8 @@ + + + + diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index e1f22ad846..5700ad04dd 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -104,7 +104,7 @@ public static IAsyncQueryable Concat(this IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -112,13 +112,13 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -126,13 +126,13 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -142,13 +142,13 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -158,7 +158,7 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -190,7 +190,7 @@ public static IAsyncQueryable DistinctUntilChanged(this IAsync #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -198,13 +198,13 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -212,13 +212,13 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -228,13 +228,13 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -244,26 +244,12 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (observer == null) - throw new ArgumentNullException(nameof(observer)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); -#endif - } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) @@ -292,23 +278,21 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) + public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (onNext == null) - throw new ArgumentNullException(nameof(onNext)); - if (onCompleted == null) - throw new ArgumentNullException(nameof(onCompleted)); + if (observer == null) + throw new ArgumentNullException(nameof(observer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); #endif } - public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -318,9 +302,9 @@ public static IAsyncQueryable Do(this IAsyncQueryable throw new ArgumentNullException(nameof(onCompleted)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); #endif } @@ -356,6 +340,22 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); +#endif + } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Action onCompleted) { if (source == null) @@ -512,7 +512,7 @@ public static Task Max(this IAsyncQueryable source, I #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -520,13 +520,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -534,13 +534,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -548,43 +548,43 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -594,13 +594,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -610,13 +610,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -626,7 +626,7 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -672,7 +672,7 @@ public static Task Min(this IAsyncQueryable source, I #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -680,13 +680,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -694,13 +694,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -708,43 +708,43 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -754,13 +754,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -770,13 +770,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -786,7 +786,7 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -854,7 +854,7 @@ public static IAsyncQueryable Retry(this IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -862,13 +862,13 @@ public static IAsyncQueryable Scan(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); #endif } - public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -876,7 +876,7 @@ public static IAsyncQueryable Scan(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); #endif diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt index efc034b348..1023430931 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -130,7 +130,7 @@ foreach (var m in typeof(AsyncEnumerableEx).GetMethods() .OrderBy(m => m.Name) .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) .ThenBy(m => m.GetParameters().Length) - .ThenBy(m => string.Join(", ", m.GetParameters().Select(p => p.Name)))) + .ThenBy(m => string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i) + " " + p.Name)))) { var genArgs = m.GetGenericArguments(); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index c174c290c1..69dc5f50b2 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -23,4 +23,8 @@ + + + + diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 858dc489b7..342bb03a53 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -12,7 +12,7 @@ namespace System.Linq { public static partial class AsyncQueryable { - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) + public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -20,13 +20,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator) + public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -34,13 +34,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -48,13 +48,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -62,7 +62,7 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -336,15 +336,15 @@ public static IAsyncQueryable Append(this IAsyncQueryable Average(this IAsyncQueryable source) + public static Task Average(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -360,27 +360,27 @@ public static Task Average(this IAsyncQueryable source) #endif } - public static Task Average(this IAsyncQueryable source) + public static Task Average(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task Average(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -396,27 +396,27 @@ public static Task Average(this IAsyncQueryable source) #endif } - public static Task Average(this IAsyncQueryable source) + public static Task Average(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task Average(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -432,51 +432,39 @@ public static Task Average(this IAsyncQueryable source) #endif } - public static Task Average(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task Average(this IAsyncQueryable source) + public static Task Average(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -492,27 +480,27 @@ public static Task Average(this IAsyncQueryable source, Cancel #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -528,27 +516,27 @@ public static Task Average(this IAsyncQueryable source, Cancel #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -564,6 +552,18 @@ public static Task Average(this IAsyncQueryable source, Cancellatio #endif } + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) @@ -576,7 +576,7 @@ public static Task Average(this IAsyncQueryable source, Cancellati #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -584,13 +584,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -598,13 +598,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -612,13 +612,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -626,13 +626,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -640,13 +640,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -654,9 +654,9 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -674,7 +674,7 @@ public static Task Average(this IAsyncQueryable sourc #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -682,9 +682,9 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -702,7 +702,7 @@ public static Task Average(this IAsyncQueryable sourc #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -710,13 +710,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -724,13 +724,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -738,13 +738,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -752,13 +752,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -766,13 +766,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -780,13 +780,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -794,13 +794,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -808,9 +808,9 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -828,7 +828,7 @@ public static Task Average(this IAsyncQueryable source #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -836,9 +836,9 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -856,7 +856,7 @@ public static Task Average(this IAsyncQueryable source #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -864,13 +864,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -878,13 +878,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -892,13 +892,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -906,13 +906,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -920,13 +920,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -934,9 +934,9 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -954,7 +954,7 @@ public static Task Average(this IAsyncQueryable sourc #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -962,9 +962,9 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -982,7 +982,7 @@ public static Task Average(this IAsyncQueryable sourc #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -990,13 +990,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1004,13 +1004,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1018,13 +1018,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1032,13 +1032,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1046,13 +1046,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1060,13 +1060,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1074,13 +1074,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1088,9 +1088,9 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -1108,7 +1108,7 @@ public static Task Average(this IAsyncQueryable source #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1116,9 +1116,9 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -1582,7 +1582,7 @@ public static Task FirstOrDefault(this IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1590,13 +1590,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1604,13 +1604,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1620,13 +1620,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1636,29 +1636,29 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1668,7 +1668,7 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif @@ -1690,41 +1690,41 @@ public static IAsyncQueryable GroupBy(this IAsy #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1736,7 +1736,7 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -1760,25 +1760,25 @@ public static IAsyncQueryable GroupBy(this IAsy #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); if (comparer == null) throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1790,13 +1790,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1808,13 +1808,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1828,13 +1828,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1848,13 +1848,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1868,13 +1868,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1888,13 +1888,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1910,13 +1910,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1932,7 +1932,7 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -1968,7 +1968,7 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1982,13 +1982,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -2002,13 +2002,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -2024,13 +2024,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -2046,7 +2046,7 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -2292,39 +2292,39 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -2340,111 +2340,111 @@ public static Task Max(this IAsyncQueryable source) #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task Max(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -2460,75 +2460,75 @@ public static Task Max(this IAsyncQueryable source, Cancellation #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -2570,7 +2570,7 @@ public static Task Max(this IAsyncQueryable source, C #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2578,13 +2578,13 @@ public static Task Max(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2592,13 +2592,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2606,13 +2606,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2620,13 +2620,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2634,13 +2634,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2648,13 +2648,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2662,13 +2662,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2676,13 +2676,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2690,13 +2690,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2704,9 +2704,9 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -2724,7 +2724,7 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2732,13 +2732,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2746,13 +2746,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2760,13 +2760,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2774,13 +2774,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2788,13 +2788,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2802,13 +2802,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2816,13 +2816,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2830,9 +2830,9 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -2850,7 +2850,7 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2858,13 +2858,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2872,13 +2872,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2886,13 +2886,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2900,13 +2900,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2914,13 +2914,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2928,13 +2928,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2942,13 +2942,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2956,13 +2956,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2970,13 +2970,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2984,9 +2984,9 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3004,7 +3004,7 @@ public static Task Max(this IAsyncQueryable source, E #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3012,13 +3012,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3026,13 +3026,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3040,13 +3040,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3054,13 +3054,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3068,13 +3068,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3082,13 +3082,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3096,13 +3096,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3110,13 +3110,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3124,13 +3124,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3138,13 +3138,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3152,13 +3152,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3166,7 +3166,7 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -3184,63 +3184,63 @@ public static Task Max(this IAsyncQueryable #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -3256,39 +3256,39 @@ public static Task Min(this IAsyncQueryable source) #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task Min(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -3304,63 +3304,63 @@ public static Task Min(this IAsyncQueryable source) #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3376,39 +3376,39 @@ public static Task Min(this IAsyncQueryable source, Cancellati #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3450,7 +3450,7 @@ public static Task Min(this IAsyncQueryable source, C #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3458,13 +3458,13 @@ public static Task Min(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3472,13 +3472,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3486,13 +3486,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3500,13 +3500,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3514,13 +3514,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3528,13 +3528,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3542,13 +3542,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3556,13 +3556,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3570,13 +3570,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3584,9 +3584,9 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -3604,7 +3604,7 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3612,13 +3612,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3626,13 +3626,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3640,13 +3640,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3654,13 +3654,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3668,13 +3668,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3682,13 +3682,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3696,13 +3696,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3710,9 +3710,9 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -3730,7 +3730,7 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3738,13 +3738,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3752,13 +3752,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3766,13 +3766,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3780,13 +3780,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3794,13 +3794,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3808,13 +3808,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3822,13 +3822,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3836,13 +3836,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3850,13 +3850,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3864,9 +3864,9 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -3884,7 +3884,7 @@ public static Task Min(this IAsyncQueryable source, E #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3892,13 +3892,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3906,13 +3906,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3920,13 +3920,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3934,13 +3934,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3948,13 +3948,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3962,13 +3962,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3976,13 +3976,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3990,9 +3990,9 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -4052,19 +4052,19 @@ public static Task Min(this IAsyncQueryable #endif } - public static IAsyncQueryable OfType(this IAsyncQueryable source) + public static IAsyncQueryable OfType(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TType)), source.Expression)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4072,13 +4072,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4086,13 +4086,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4102,13 +4102,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4118,13 +4118,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4132,13 +4132,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4146,13 +4146,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4162,13 +4162,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4178,7 +4178,7 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif @@ -4208,7 +4208,7 @@ public static IAsyncQueryable Reverse(this IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4216,7 +4216,7 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif @@ -4250,7 +4250,7 @@ public static IAsyncQueryable Select(this IAsyncQuery #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4258,7 +4258,7 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif @@ -4278,7 +4278,7 @@ public static IAsyncQueryable SelectMany(this IAsyncQ #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4286,13 +4286,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4300,13 +4300,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4314,7 +4314,7 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif @@ -4336,7 +4336,7 @@ public static IAsyncQueryable SelectMany #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4346,13 +4346,13 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4362,13 +4362,13 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4378,7 +4378,7 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif @@ -4496,7 +4496,7 @@ public static Task Single(this IAsyncQueryable source #endif } - public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4504,13 +4504,13 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4518,7 +4518,7 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4656,7 +4656,7 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4664,13 +4664,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4678,69 +4678,69 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } @@ -4756,111 +4756,111 @@ public static Task Sum(this IAsyncQueryable source) #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task Sum(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -4876,55 +4876,55 @@ public static Task Sum(this IAsyncQueryable source, CancellationTo #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4932,13 +4932,13 @@ public static Task Sum(this IAsyncQueryable source, Cancellati throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4946,9 +4946,9 @@ public static Task Sum(this IAsyncQueryable source, Cancellati throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -4966,7 +4966,7 @@ public static Task Sum(this IAsyncQueryable source, Cancellati #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4974,13 +4974,13 @@ public static Task Sum(this IAsyncQueryable source, Cancellati throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4988,13 +4988,13 @@ public static Task Sum(this IAsyncQueryable source, Cancellati throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5002,13 +5002,13 @@ public static Task Sum(this IAsyncQueryable source, Cancellati throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5016,13 +5016,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5030,13 +5030,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5044,13 +5044,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5058,13 +5058,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5072,13 +5072,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5086,13 +5086,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5100,9 +5100,9 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } @@ -5120,7 +5120,7 @@ public static Task Sum(this IAsyncQueryable source, Ex #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5128,13 +5128,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5142,13 +5142,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5156,13 +5156,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5170,13 +5170,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5184,13 +5184,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5198,13 +5198,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5212,13 +5212,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5226,13 +5226,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5240,13 +5240,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5254,13 +5254,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5268,13 +5268,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5282,13 +5282,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5296,9 +5296,9 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -5316,7 +5316,7 @@ public static Task Sum(this IAsyncQueryable source, Expre #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5324,9 +5324,9 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -5344,7 +5344,7 @@ public static Task Sum(this IAsyncQueryable source, Expr #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5352,13 +5352,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5366,13 +5366,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5380,13 +5380,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5394,13 +5394,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5408,13 +5408,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5422,13 +5422,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5436,13 +5436,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5450,13 +5450,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5464,13 +5464,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5478,9 +5478,9 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -5536,7 +5536,7 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5544,13 +5544,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5558,13 +5558,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5572,13 +5572,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5586,13 +5586,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5602,13 +5602,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5618,13 +5618,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5632,13 +5632,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5646,13 +5646,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5662,13 +5662,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5678,7 +5678,7 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif @@ -5708,7 +5708,7 @@ public static Task ToArray(this IAsyncQueryable sou #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5716,13 +5716,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5730,13 +5730,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5744,43 +5744,43 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5790,13 +5790,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5806,13 +5806,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5822,13 +5822,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5838,13 +5838,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5854,13 +5854,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5870,13 +5870,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5884,15 +5884,17 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5900,17 +5902,15 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5922,13 +5922,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5940,13 +5940,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5958,7 +5958,7 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -6040,7 +6040,7 @@ public static Task> ToList(this IAsyncQueryable #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6048,13 +6048,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6062,13 +6062,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6076,43 +6076,43 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6122,13 +6122,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6138,13 +6138,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6154,13 +6154,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6170,13 +6170,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6186,13 +6186,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6202,13 +6202,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6216,15 +6216,17 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6232,17 +6234,15 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6254,13 +6254,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6272,13 +6272,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6290,7 +6290,7 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -6354,7 +6354,7 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6362,13 +6362,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6376,13 +6376,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -6392,13 +6392,13 @@ public static IAsyncQueryable Zip(this IAsync throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); #else return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); #endif } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -6408,7 +6408,7 @@ public static IAsyncQueryable Zip(this IAsync throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); #else return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); #endif diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index 75c9df2656..f3bd03219e 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -129,7 +129,7 @@ foreach (var m in typeof(AsyncEnumerable).GetMethods() .OrderBy(m => m.Name) .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) .ThenBy(m => m.GetParameters().Length) - .ThenBy(m => string.Join(", ", m.GetParameters().Select(p => p.Name)))) + .ThenBy(m => string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i) + " " + p.Name)))) { var genArgs = m.GetGenericArguments(); From e960ee05605d27a2a2ec89e827e4f3e78cae61c5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:40:44 -0800 Subject: [PATCH 491/862] Minor code modernization. --- .../System/Linq/AsyncEnumerableQuery.cs | 40 +++---------------- .../System/Linq/AsyncEnumerableRewriter.cs | 1 - 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs index c22f813221..c3d4317c49 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs @@ -56,57 +56,27 @@ public AsyncEnumerableQuery(IAsyncEnumerable enumerable) /// /// Gets the type of the elements in the sequence. /// - Type IAsyncQueryable.ElementType - { - get - { - return typeof(T); - } - } + Type IAsyncQueryable.ElementType => typeof(T); /// /// Gets the expression representing the sequence. /// - Expression IAsyncQueryable.Expression - { - get - { - return _expression; - } - } + Expression IAsyncQueryable.Expression => _expression; /// /// Gets the query provider used to execute the sequence. /// - IAsyncQueryProvider IAsyncQueryable.Provider - { - get - { - return this; - } - } + IAsyncQueryProvider IAsyncQueryable.Provider => this; /// /// Gets the enumerable sequence obtained from evaluating the expression tree. /// - internal override object Enumerable - { - get - { - return _enumerable; - } - } + internal override object Enumerable => _enumerable; /// /// Gets the expression tree representing the asynchronous enumerable sequence. /// - internal override Expression Expression - { - get - { - return _expression; - } - } + internal override Expression Expression => _expression; /// /// Creates a new asynchronous enumerable sequence represented by an expression tree. diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs index cf8aa61b36..a1758a9884 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs @@ -19,7 +19,6 @@ internal class AsyncEnumerableRewriter : ExpressionVisitor protected override Expression VisitConstant(ConstantExpression node) { - // // Not an expression representation obtained from the async enumerable query provider, // so just a plain constant that can be returned as-is. From 7bf9840a85fe1af70c3496b94bf510d97bcd9dfe Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:46:51 -0800 Subject: [PATCH 492/862] Cleaning up some test code. --- .../System/Linq/Operators/MaxBy.cs | 6 +++--- .../System/Linq/Operators/MinBy.cs | 6 +++--- .../System/Linq/Operators/Aggregate.cs | 14 +++++++------- .../System/Linq/Operators/All.cs | 4 ++-- .../System/Linq/Operators/Any.cs | 4 ++-- .../System/Linq/Operators/Count.cs | 2 +- .../System/Linq/Operators/ElementAt.cs | 2 +- .../System/Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/First.cs | 4 ++-- .../System/Linq/Operators/FirstOrDefault.cs | 4 ++-- .../System/Linq/Operators/ForEachAsync.cs | 8 ++++---- .../System/Linq/Operators/GroupBy.cs | 4 ++-- .../System/Linq/Operators/Last.cs | 4 ++-- .../System/Linq/Operators/LastOrDefault.cs | 4 ++-- .../System/Linq/Operators/LongCount.cs | 2 +- .../System/Linq/Operators/SequenceEqual.cs | 8 ++++---- .../System/Linq/Operators/Single.cs | 4 ++-- .../System/Linq/Operators/SingleOrDefault.cs | 4 ++-- .../System/Linq/Operators/ToArray.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- 20 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index 48dfedf8a4..5140860cb3 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -52,7 +52,7 @@ public void MaxBy3() var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 3) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -61,7 +61,7 @@ public void MaxBy4() var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 4) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -70,7 +70,7 @@ public void MaxBy5() var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MaxBy(x => x, Comparer.Default); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index af3ef50bb1..03f617b345 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -52,7 +52,7 @@ public void MinBy3() var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 3) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -61,7 +61,7 @@ public void MinBy4() var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 4) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -70,7 +70,7 @@ public void MinBy5() var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MinBy(x => x, Comparer.Default); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 6357b08107..6c7c98b6b9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -59,7 +59,7 @@ public void Aggregate3() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate((x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -68,7 +68,7 @@ public void Aggregate4() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -93,7 +93,7 @@ public void Aggregate7() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -102,7 +102,7 @@ public void Aggregate8() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -127,7 +127,7 @@ public void Aggregate11() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -136,7 +136,7 @@ public void Aggregate12() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => { throw ex; }, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -145,7 +145,7 @@ public void Aggregate13() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y, x => { throw ex; }); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 11490dca18..562e706d83 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -42,7 +42,7 @@ public void All3() { var ex = new Exception("Bang!"); var res = Throw(ex).All(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -50,7 +50,7 @@ public void All4() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 019aafcdee..70250c4499 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -44,7 +44,7 @@ public void Any3() { var ex = new Exception("Bang!"); var res = Throw(ex).Any(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -52,7 +52,7 @@ public void Any4() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 8b294c77cb..3195ce1e1b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -46,7 +46,7 @@ public void Count3() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index ce122152c1..a3e5bdab16 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -63,7 +63,7 @@ public void ElementAt6() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAt(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index a59579188d..b470f96cd6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -67,7 +67,7 @@ public void ElementAtOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAtOrDefault(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 8bd21cfe8d..826f7b4c74 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -65,7 +65,7 @@ public void First6() { var ex = new Exception("Bang!"); var res = Throw(ex).First(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void First7() { var ex = new Exception("Bang!"); var res = Throw(ex).First(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index a587888afe..5230d150bb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -65,7 +65,7 @@ public void FirstOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void FirstOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index fd0897edd4..28f88e43c0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -53,7 +53,7 @@ public void ForEachAsync3() var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -62,7 +62,7 @@ public void ForEachAsync4() var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -71,7 +71,7 @@ public void ForEachAsync5() var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -80,7 +80,7 @@ public void ForEachAsync6() var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 0d9a7d4c11..2454b69483 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -264,8 +264,8 @@ public void GroupBy8() //HasNext(g2e, 2); - //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); - //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 0c857fc9b9..21f63bf80b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -65,7 +65,7 @@ public void Last6() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void Last7() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 14b04b834e..0ff5ec779c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -65,7 +65,7 @@ public void LastOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void LastOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 1dbde20dad..1336c37bbc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -46,7 +46,7 @@ public void LongCount3() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 3951b18038..17944f0cd3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -80,7 +80,7 @@ public void SequenceEqual6() var ys = Throw(ex); var res = xs.SequenceEqual(ys); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -91,7 +91,7 @@ public void SequenceEqual7() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -145,7 +145,7 @@ public void SequenceEqual13() var ys = Throw(ex); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -156,7 +156,7 @@ public void SequenceEqual14() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index e9e0a117f7..73273330f9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -65,7 +65,7 @@ public void Single6() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void Single7() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 877fa5a6f0..0f18268429 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -65,7 +65,7 @@ public void SingleOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void SingleOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 11336bdce2..a947b51a43 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -41,7 +41,7 @@ public void ToArray3() { var ex = new Exception("Bang!"); var res = Throw(ex).ToArray(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index ff3401ae88..86cd4ad5c6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -41,7 +41,7 @@ public void ToList3() { var ex = new Exception("Bang!"); var res = Throw(ex).ToList(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } From 4ddfa1f26e51ff7907895b88316b251049dd3712 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 15:51:38 -0800 Subject: [PATCH 493/862] Simplify some code. --- .../System/Linq/Operators/Aggregate.cs | 27 +++++++++---------- .../System/Linq/Operators/All.cs | 9 +++---- .../System/Linq/Operators/Any.cs | 9 +++---- .../System/Linq/Operators/Concat.cs | 4 +-- .../System/Linq/Operators/Contains.cs | 8 +++--- .../System/Linq/Operators/Count.cs | 6 ++--- .../System/Linq/Operators/CreateEnumerator.cs | 4 +-- .../System/Linq/Operators/DefaultIfEmpty.cs | 2 +- .../System/Linq/Operators/Distinct.cs | 2 +- .../System/Linq/Operators/ElementAt.cs | 6 ++--- .../Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/Except.cs | 8 +++--- .../System/Linq/Operators/First.cs | 8 +++--- .../System/Linq/Operators/FirstOrDefault.cs | 8 +++--- .../System/Linq/Operators/ForEachAsync.cs | 16 +++++------ .../System/Linq/Operators/GroupBy.cs | 22 +++++++-------- .../System/Linq/Operators/GroupJoin.cs | 8 +++--- .../System/Linq/Operators/Intersect.cs | 8 +++--- .../System/Linq/Operators/Join.cs | 8 +++--- .../System/Linq/Operators/Last.cs | 8 +++--- .../System/Linq/Operators/LastOrDefault.cs | 8 +++--- .../System/Linq/Operators/LongCount.cs | 6 ++--- .../System/Linq/Operators/OrderBy.cs | 24 ++++++++--------- .../System/Linq/Operators/Select.cs | 4 +-- .../System/Linq/Operators/SelectMany.cs | 22 +++++++-------- .../System/Linq/Operators/SequenceEqual.cs | 24 ++++++++--------- .../System/Linq/Operators/Single.cs | 8 +++--- .../System/Linq/Operators/SingleOrDefault.cs | 8 +++--- .../System/Linq/Operators/SkipWhile.cs | 4 +-- .../System/Linq/Operators/TakeWhile.cs | 4 +-- .../System/Linq/Operators/ToArray.cs | 2 +- .../Linq/Operators/ToAsyncEnumerable.cs | 6 ++--- .../System/Linq/Operators/ToDictionary.cs | 12 ++++----- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/ToLookup.cs | 12 ++++----- .../System/Linq/Operators/Union.cs | 6 ++--- .../System/Linq/Operators/Where.cs | 4 +-- .../System/Linq/Operators/Zip.cs | 2 +- 39 files changed, 165 insertions(+), 168 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 6c7c98b6b9..f0e43879e2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -17,23 +16,23 @@ public class Aggregate : AsyncEnumerableTests public async Task Aggregate_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default, CancellationToken.None)); } @@ -59,7 +58,7 @@ public void Aggregate3() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate((x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -68,7 +67,7 @@ public void Aggregate4() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -93,7 +92,7 @@ public void Aggregate7() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -102,7 +101,7 @@ public void Aggregate8() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -127,7 +126,7 @@ public void Aggregate11() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -136,7 +135,7 @@ public void Aggregate12() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => { throw ex; }, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -145,7 +144,7 @@ public void Aggregate13() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y, x => { throw ex; }); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 562e706d83..f6f17f2213 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -17,10 +16,10 @@ public class All : AsyncEnumerableTests public async Task All_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.All(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.All(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -42,7 +41,7 @@ public void All3() { var ex = new Exception("Bang!"); var res = Throw(ex).All(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -50,7 +49,7 @@ public void All4() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 70250c4499..6f8145a228 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -18,11 +17,11 @@ public async Task Any_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -44,7 +43,7 @@ public void Any3() { var ex = new Exception("Bang!"); var res = Throw(ex).Any(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -52,7 +51,7 @@ public void Any4() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 49e76ce4b7..51386f9143 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -15,8 +15,8 @@ public class Concat : AsyncEnumerableTests [Fact] public void Concat_Null() { - AssertThrows(() => AsyncEnumerable.Concat(default, Return42)); - AssertThrows(() => AsyncEnumerable.Concat(Return42, default)); + AssertThrows(() => AsyncEnumerable.Concat(default, Return42)); + AssertThrows(() => AsyncEnumerable.Concat(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index 5f251ed936..30a89c088b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -16,11 +16,11 @@ public class Contains : AsyncEnumerableTests [Fact] public async Task Contains_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 3195ce1e1b..d9a1127cf6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -18,11 +18,11 @@ public async Task Count_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -46,7 +46,7 @@ public void Count3() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index 4161a29a13..26c30273f3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -15,13 +15,13 @@ public class CreateEnumerator : AsyncEnumerableTests [Fact] public void CreateEnumerator_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => TaskExt.CompletedTask)); + AssertThrows(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => TaskExt.CompletedTask)); } [Fact] public void CreateEnumerator_Throws() { - var iter = AsyncEnumerable.CreateEnumerator(() => TaskExt.True, () => 3, () => TaskExt.CompletedTask); + var iter = AsyncEnumerable.CreateEnumerator(() => TaskExt.True, () => 3, () => TaskExt.CompletedTask); var enu = (IAsyncEnumerable)iter; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index 1dba99e51e..d2fee5a9d5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -16,7 +16,7 @@ public class DefaultIfEmpty : AsyncEnumerableTests public void DefaultIfEmpty_Null() { AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default)); - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default, 42)); + AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default, 42)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index 2d31b792b0..9728d7b5ae 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -16,7 +16,7 @@ public class Distinct : AsyncEnumerableTests public void Distinct_Null() { AssertThrows(() => AsyncEnumerable.Distinct(default)); - AssertThrows(() => AsyncEnumerable.Distinct(default, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Distinct(default, EqualityComparer.Default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index a3e5bdab16..d4464f5ab6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -17,10 +17,10 @@ public class ElementAt : AsyncEnumerableTests public async Task ElementAt_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1)); await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default, 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1, CancellationToken.None)); } [Fact] @@ -63,7 +63,7 @@ public void ElementAt6() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAt(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index b470f96cd6..cf07f5573c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -67,7 +67,7 @@ public void ElementAtOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAtOrDefault(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs index 96cee59158..b9a09739c1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs @@ -15,11 +15,11 @@ public class Except : AsyncEnumerableTests [Fact] public void Except_Null() { - AssertThrows(() => AsyncEnumerable.Except(default, Return42)); - AssertThrows(() => AsyncEnumerable.Except(Return42, default)); + AssertThrows(() => AsyncEnumerable.Except(default, Return42)); + AssertThrows(() => AsyncEnumerable.Except(Return42, default)); - AssertThrows(() => AsyncEnumerable.Except(default, Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Except(Return42, null, new Eq())); + AssertThrows(() => AsyncEnumerable.Except(default, Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Except(Return42, null, new Eq())); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 826f7b4c74..b1adb66c69 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -18,11 +18,11 @@ public async Task First_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.First(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -65,7 +65,7 @@ public void First6() { var ex = new Exception("Bang!"); var res = Throw(ex).First(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void First7() { var ex = new Exception("Bang!"); var res = Throw(ex).First(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 5230d150bb..208d89159e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -18,11 +18,11 @@ public async Task FirstOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -65,7 +65,7 @@ public void FirstOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void FirstOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 28f88e43c0..b41c04de95 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -17,14 +17,14 @@ public class ForEachAsync : AsyncEnumerableTests public async Task ForEachAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, x => { })); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (x, i) => { })); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, x => { }, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (x, i) => { }, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action), CancellationToken.None)); } [Fact] @@ -53,7 +53,7 @@ public void ForEachAsync3() var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -62,7 +62,7 @@ public void ForEachAsync4() var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -71,7 +71,7 @@ public void ForEachAsync5() var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -80,7 +80,7 @@ public void ForEachAsync6() var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 2454b69483..81e2579912 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -16,26 +16,26 @@ public class GroupBy : AsyncEnumerableTests public void GroupBy_Null() { AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func))); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>))); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>))); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>), EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>), EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x)); @@ -43,7 +43,7 @@ public void GroupBy_Null() AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default)); AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default, EqualityComparer.Default)); } @@ -234,7 +234,7 @@ public void GroupBy7() { var ex = new Exception("Bang!"); var xs = Return42; - var ys = xs.GroupBy(new Func(x => { throw ex; })); + var ys = xs.GroupBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); @@ -245,7 +245,7 @@ public void GroupBy8() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var ys = xs.GroupBy(x => { if (x == 3) throw ex; return x; }); + var ys = xs.GroupBy(x => { if (x == 3) throw ex; return x; }); var e = ys.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index 648eb79d64..4eeed85b3d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -16,14 +16,14 @@ public void GroupJoin_Null() { AssertThrows(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x)); AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x)); AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default)); AssertThrows(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs index 45a8628654..60c4e0eb5a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs @@ -15,11 +15,11 @@ public class Intersect : AsyncEnumerableTests [Fact] public void Intersect_Null() { - AssertThrows(() => AsyncEnumerable.Intersect(default, Return42)); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, default)); + AssertThrows(() => AsyncEnumerable.Intersect(default, Return42)); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, default)); - AssertThrows(() => AsyncEnumerable.Intersect(default, Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, default, new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(default, Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Intersect(Return42, default, new Eq())); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index e4dbd6b0d8..523357e309 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -17,14 +17,14 @@ public void Join_Null() { AssertThrows(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x)); AssertThrows(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x)); AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default)); AssertThrows(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); + AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 21f63bf80b..6b19e968d1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -18,11 +18,11 @@ public async Task Last_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -65,7 +65,7 @@ public void Last6() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void Last7() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 0ff5ec779c..319fead808 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -18,11 +18,11 @@ public async Task LastOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -65,7 +65,7 @@ public void LastOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void LastOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 1336c37bbc..be1ede264a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -18,11 +18,11 @@ public async Task LongCount_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -46,7 +46,7 @@ public void LongCount3() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index 952d0fbdb7..f6d9c83fed 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -16,30 +16,30 @@ public class OrderBy : AsyncEnumerableTests public void OrderBy_Null() { AssertThrows(() => AsyncEnumerable.OrderBy(default, x => x)); - AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.OrderBy(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); var xs = Return42.OrderBy(x => x); AssertThrows(() => AsyncEnumerable.ThenBy(default, x => x)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); AssertThrows(() => AsyncEnumerable.ThenBy(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); + AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); } [Fact] @@ -59,7 +59,7 @@ public void OrderBy2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(new Func(x => { throw ex; })); + var ys = xs.OrderBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); @@ -79,7 +79,7 @@ public void ThenBy2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); + var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); @@ -102,7 +102,7 @@ public void OrderByDescending2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderByDescending(new Func(x => { throw ex; })); + var ys = xs.OrderByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); @@ -122,7 +122,7 @@ public void ThenByDescending2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); - var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); + var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index 2528839843..af89ce83aa 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -17,8 +17,8 @@ public void Select_Null() { AssertThrows(() => AsyncEnumerable.Select(default, x => x)); AssertThrows(() => AsyncEnumerable.Select(default, (x, i) => x)); - AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index aea42b7c9c..5652c9cfb6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -15,17 +15,17 @@ public class SelectMany : AsyncEnumerableTests [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); - - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, x => default, default(Func))); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, (x, i) => default, default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); + + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, x => default, default(Func))); + AssertThrows(() => AsyncEnumerable.SelectMany(Return42, (x, i) => default, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 17944f0cd3..14f30fb16d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -16,17 +16,17 @@ public class SequenceEqual : AsyncEnumerableTests [Fact] public async Task SequenceEqual_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq(), CancellationToken.None)); } [Fact] @@ -80,7 +80,7 @@ public void SequenceEqual6() var ys = Throw(ex); var res = xs.SequenceEqual(ys); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -91,7 +91,7 @@ public void SequenceEqual7() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -145,7 +145,7 @@ public void SequenceEqual13() var ys = Throw(ex); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -156,7 +156,7 @@ public void SequenceEqual14() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 73273330f9..944269b1da 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -18,11 +18,11 @@ public async Task Single_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -65,7 +65,7 @@ public void Single6() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void Single7() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 0f18268429..d69bbfda6b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -18,11 +18,11 @@ public async Task SingleOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func), CancellationToken.None)); } [Fact] @@ -65,7 +65,7 @@ public void SingleOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] @@ -73,7 +73,7 @@ public void SingleOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index 904ee2716f..186aed0bba 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -17,8 +17,8 @@ public void SkipWhile_Null() { AssertThrows(() => AsyncEnumerable.SkipWhile(default, x => true)); AssertThrows(() => AsyncEnumerable.SkipWhile(default, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index 1b1a7f0f06..44640f2e39 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -17,8 +17,8 @@ public void TakeWhile_Null() { AssertThrows(() => AsyncEnumerable.TakeWhile(default, x => true)); AssertThrows(() => AsyncEnumerable.TakeWhile(default, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index a947b51a43..170d3c4a2f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -41,7 +41,7 @@ public void ToArray3() { var ex = new Exception("Bang!"); var res = Throw(ex).ToArray(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index 621c222313..efd9d6bd14 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -15,9 +15,9 @@ public class ToAsyncEnumerable : AsyncEnumerableTests [Fact] public void ToAsyncEnumerable_Null() { - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IEnumerable))); - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); + AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IEnumerable))); + AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); + AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index 75536030d9..8f86667ad8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -17,31 +17,31 @@ public class ToDictionary : AsyncEnumerableTests public async Task ToDictionary_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index be3b98d5de..775c38d46c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -19,7 +19,7 @@ public async Task ToHashSet_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, EqualityComparer.Default, CancellationToken.None)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index 86cd4ad5c6..ad2c72c6fb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -41,7 +41,7 @@ public void ToList3() { var ex = new Exception("Bang!"); var res = Throw(ex).ToList(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index 19e3ec8c16..ec8ae2bd33 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -18,31 +18,31 @@ public class ToLookup : AsyncEnumerableTests public async Task ToLookup_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs index c6a7cd65b3..a405f7b068 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -14,10 +14,10 @@ public class Union : AsyncEnumerableTests [Fact] public void Union_Null() { - AssertThrows(() => AsyncEnumerable.Union(default, Return42)); + AssertThrows(() => AsyncEnumerable.Union(default, Return42)); - AssertThrows(() => AsyncEnumerable.Union(default, Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Union(Return42, default, new Eq())); + AssertThrows(() => AsyncEnumerable.Union(default, Return42, new Eq())); + AssertThrows(() => AsyncEnumerable.Union(Return42, default, new Eq())); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index 46ee636431..79d366f872 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -17,8 +17,8 @@ public void Where_Null() { AssertThrows(() => AsyncEnumerable.Where(default, x => true)); AssertThrows(() => AsyncEnumerable.Where(default, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index 1c3c32f5c8..adefa66cba 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -17,7 +17,7 @@ public void Zip_Null() { AssertThrows(() => AsyncEnumerable.Zip(default, Return42, (x, y) => x + y)); AssertThrows(() => AsyncEnumerable.Zip(Return42, default, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(Return42, Return42, default(Func))); + AssertThrows(() => AsyncEnumerable.Zip(Return42, Return42, default(Func))); } [Fact] From dc6ba35066198f2977d4cc62605cfe7915de9d4b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 16:04:29 -0800 Subject: [PATCH 494/862] Fix warning on accessibility modifiers. --- .../Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs index 400d93971d..9754db0ce4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs @@ -3,12 +3,11 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; namespace System.Linq { - partial class AsyncIterator + internal partial class AsyncIterator { public virtual IAsyncEnumerable Select(Func selector) { From a347d6054759dcc67927a90bd7847151b9fa3415 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 16:17:50 -0800 Subject: [PATCH 495/862] Converting a bunch of test code to async. --- .../System/Linq/AsyncEnumerableTests.cs | 8 +- .../System/Linq/Operators/Append.cs | 30 +- .../System/Linq/Operators/Cast.cs | 15 +- .../System/Linq/Operators/Concat.cs | 54 ++-- .../System/Linq/Operators/CreateEnumerable.cs | 2 +- .../System/Linq/Operators/CreateEnumerator.cs | 4 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 52 ++-- .../System/Linq/Operators/Distinct.cs | 36 +-- .../System/Linq/Operators/Empty.cs | 15 +- .../System/Linq/Operators/Except.cs | 20 +- .../System/Linq/Operators/GroupBy.cs | 282 +++++++++--------- .../System/Linq/Operators/GroupJoin.cs | 47 +-- .../System/Linq/Operators/Intersect.cs | 24 +- .../System/Linq/Operators/Join.cs | 90 +++--- .../System/Linq/Operators/OfType.cs | 11 +- .../System/Linq/Operators/OrderBy.cs | 44 +-- .../System/Linq/Operators/Prepend.cs | 30 +- .../System/Linq/Operators/Range.cs | 21 +- .../System/Linq/Operators/Repeat.cs | 20 +- .../System/Linq/Operators/Reverse.cs | 22 +- .../System/Linq/Operators/Select.cs | 38 +-- .../System/Linq/Operators/SelectMany.cs | 136 ++++----- .../System/Linq/Operators/Skip.cs | 28 +- .../System/Linq/Operators/SkipLast.cs | 26 +- .../System/Linq/Operators/SkipWhile.cs | 70 ++--- .../System/Linq/Operators/Take.cs | 30 +- .../System/Linq/Operators/TakeLast.cs | 30 +- .../System/Linq/Operators/TakeWhile.cs | 64 ++-- .../System/Linq/Operators/Throw.cs | 2 +- .../Linq/Operators/ToAsyncEnumerable.cs | 40 +-- .../System/Linq/Operators/ToEnumerable.cs | 2 +- .../System/Linq/Operators/ToObservable.cs | 2 +- .../System/Linq/Operators/Union.cs | 53 ++-- .../System/Linq/Operators/Where.cs | 60 ++-- .../System/Linq/Operators/Zip.cs | 36 +-- .../System/Linq/Optimizations.cs | 62 ++-- 36 files changed, 751 insertions(+), 755 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 7d6185a3ee..77c67142b6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -46,14 +46,14 @@ public void AssertThrows(Action a, Func assert) } } - public void NoNext(IAsyncEnumerator e) + public async Task NoNextAsync(IAsyncEnumerator e) { - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } - public void HasNext(IAsyncEnumerator e, T value) + public async Task HasNextAsync(IAsyncEnumerator e, T value) { - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.Equal(value, e.Current); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs index beb97e7b3b..633f671ef7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs @@ -15,11 +15,11 @@ public class Append : AsyncEnumerableTests [Fact] public void Append_Null() { - AssertThrows(() => AsyncEnumerable.Append(default, 42)); + Assert.Throws(() => AsyncEnumerable.Append(default, 42)); } [Fact] - public void Append1() + public async Task Append1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -27,11 +27,11 @@ public void Append1() var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] @@ -108,7 +108,7 @@ public async Task Append7() [Fact] - public void AppendN1() + public async Task AppendN1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -118,13 +118,13 @@ public void AppendN1() var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs index 79fba3b75a..1ce2622fb0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -14,21 +15,21 @@ public class Cast : AsyncEnumerableTests [Fact] public void Cast_Null() { - AssertThrows(() => AsyncEnumerable.Cast(default)); + Assert.Throws(() => AsyncEnumerable.Cast(default)); } [Fact] - public void Cast1() + public async Task Cast1() { var xs = new object[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Cast(); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 51386f9143..36f9f43a07 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -15,35 +15,35 @@ public class Concat : AsyncEnumerableTests [Fact] public void Concat_Null() { - AssertThrows(() => AsyncEnumerable.Concat(default, Return42)); - AssertThrows(() => AsyncEnumerable.Concat(Return42, default)); + Assert.Throws(() => AsyncEnumerable.Concat(default, Return42)); + Assert.Throws(() => AsyncEnumerable.Concat(Return42, default)); } [Fact] - public void Concat1() + public async Task Concat1Async() { var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void Concat2() + public async Task Concat2Async() { var ex = new Exception("Bang"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } @@ -58,7 +58,7 @@ public void Concat3() } [Fact] - public void Concat7() + public async Task Concat7Async() { var ws = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var xs = new[] { 4, 5 }.ToAsyncEnumerable(); @@ -68,18 +68,18 @@ public void Concat7() var res = ws.Concat(xs).Concat(ys).Concat(zs); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 8); - HasNext(e, 9); - HasNext(e, 10); - HasNext(e, 11); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await HasNextAsync(e, 7); + await HasNextAsync(e, 8); + await HasNextAsync(e, 9); + await HasNextAsync(e, 10); + await HasNextAsync(e, 11); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs index 486bd7c0d4..07c472b1c9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs @@ -13,7 +13,7 @@ public class CreateEnumerable : AsyncEnumerableTests [Fact] public void CreateEnumerable_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerable(default)); + Assert.Throws(() => AsyncEnumerable.CreateEnumerable(default)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index 26c30273f3..f291e57f35 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -15,7 +15,7 @@ public class CreateEnumerator : AsyncEnumerableTests [Fact] public void CreateEnumerator_Null() { - AssertThrows(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => TaskExt.CompletedTask)); + Assert.Throws(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => TaskExt.CompletedTask)); } [Fact] @@ -25,7 +25,7 @@ public void CreateEnumerator_Throws() var enu = (IAsyncEnumerable)iter; - AssertThrows(() => enu.GetAsyncEnumerator()); + Assert.Throws(() => enu.GetAsyncEnumerator()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index d2fee5a9d5..ad28c44a4f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -15,74 +15,74 @@ public class DefaultIfEmpty : AsyncEnumerableTests [Fact] public void DefaultIfEmpty_Null() { - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default)); - AssertThrows(() => AsyncEnumerable.DefaultIfEmpty(default, 42)); + Assert.Throws(() => AsyncEnumerable.DefaultIfEmpty(default)); + Assert.Throws(() => AsyncEnumerable.DefaultIfEmpty(default, 42)); } [Fact] - public void DefaultIfEmpty1() + public async Task DefaultIfEmpty1() { var xs = AsyncEnumerable.Empty().DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - NoNext(e); + await HasNextAsync(e, 0); + await NoNextAsync(e); } [Fact] - public void DefaultIfEmpty2() + public async Task DefaultIfEmpty2() { var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); + await HasNextAsync(e, 42); + await NoNextAsync(e); } [Fact] - public void DefaultIfEmpty3() + public async Task DefaultIfEmpty3() { var xs = Return42.DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); + await HasNextAsync(e, 42); + await NoNextAsync(e); } [Fact] - public void DefaultIfEmpty4() + public async Task DefaultIfEmpty4() { var xs = Return42.DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); + await HasNextAsync(e, 42); + await NoNextAsync(e); } [Fact] - public void DefaultIfEmpty5() + public async Task DefaultIfEmpty5() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void DefaultIfEmpty6() + public async Task DefaultIfEmpty6() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index 9728d7b5ae..481b667294 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -15,36 +15,36 @@ public class Distinct : AsyncEnumerableTests [Fact] public void Distinct_Null() { - AssertThrows(() => AsyncEnumerable.Distinct(default)); - AssertThrows(() => AsyncEnumerable.Distinct(default, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.Distinct(default)); + Assert.Throws(() => AsyncEnumerable.Distinct(default, EqualityComparer.Default)); } [Fact] - public void Distinct1() + public async Task Distinct1() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 5); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void Distinct2() + public async Task Distinct2() { var xs = new[] { 1, -2, -1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(new Eq()); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, -2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, -2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 5); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] @@ -82,13 +82,13 @@ public async Task Distinct10() } [Fact] - public void Distinct12() + public async Task Distinct12() { var xs = AsyncEnumerable.Empty().Distinct(); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } private sealed class Eq : IEqualityComparer diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs index 17c40213b1..405466ab46 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Empty.cs @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -11,19 +11,10 @@ namespace Tests public class Empty : AsyncEnumerableTests { [Fact] - public void Empty1() + public async Task Empty1() { var xs = AsyncEnumerable.Empty(); - NoNext(xs.GetAsyncEnumerator()); - } - - [Fact] - public void Empty2() - { - var xs = AsyncEnumerable.Empty(); - - var e = xs.GetAsyncEnumerator(); - Assert.False(e.MoveNextAsync().Result); + await NoNextAsync(xs.GetAsyncEnumerator()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs index b9a09739c1..ac18c3bc96 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Except.cs @@ -15,35 +15,35 @@ public class Except : AsyncEnumerableTests [Fact] public void Except_Null() { - AssertThrows(() => AsyncEnumerable.Except(default, Return42)); - AssertThrows(() => AsyncEnumerable.Except(Return42, default)); + Assert.Throws(() => AsyncEnumerable.Except(default, Return42)); + Assert.Throws(() => AsyncEnumerable.Except(Return42, default)); - AssertThrows(() => AsyncEnumerable.Except(default, Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Except(Return42, null, new Eq())); + Assert.Throws(() => AsyncEnumerable.Except(default, Return42, new Eq())); + Assert.Throws(() => AsyncEnumerable.Except(Return42, null, new Eq())); } [Fact] - public void Except1() + public async Task Except1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); var res = xs.Except(ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void Except2() + public async Task Except2() { var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); var res = xs.Except(ys, new Eq()); var e = res.GetAsyncEnumerator(); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 81e2579912..6b30b2a5a3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -15,41 +15,41 @@ public class GroupBy : AsyncEnumerableTests [Fact] public void GroupBy_Null() { - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func))); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, x => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default, x => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func))); - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, x => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default, x => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>))); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>))); - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, (x, ys) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default, (x, ys) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, default(Func, int>), EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default)); - AssertThrows(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, x => x, (x, ys) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default, x => x, (x, ys) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, default, (x, ys) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, x => x, x => x, default, EqualityComparer.Default)); } [Fact] - public void GroupBy1() + public async Task GroupBy1() { var xs = new[] { new { Name = "Bart", Age = 27 }, @@ -70,35 +70,35 @@ public void GroupBy1() Assert.True(e.MoveNextAsync().Result); Assert.Equal(2, e.Current.Key); var g1 = e.Current.GetAsyncEnumerator(); - HasNext(g1, xs[0]); - HasNext(g1, xs[2]); - HasNext(g1, xs[4]); - HasNext(g1, xs[5]); - NoNext(g1); + await HasNextAsync(g1, xs[0]); + await HasNextAsync(g1, xs[2]); + await HasNextAsync(g1, xs[4]); + await HasNextAsync(g1, xs[5]); + await NoNextAsync(g1); Assert.True(e.MoveNextAsync().Result); Assert.Equal(6, e.Current.Key); var g2 = e.Current.GetAsyncEnumerator(); - HasNext(g2, xs[1]); - NoNext(g2); + await HasNextAsync(g2, xs[1]); + await NoNextAsync(g2); Assert.True(e.MoveNextAsync().Result); Assert.Equal(1, e.Current.Key); var g3 = e.Current.GetAsyncEnumerator(); - HasNext(g3, xs[3]); - NoNext(g3); + await HasNextAsync(g3, xs[3]); + await NoNextAsync(g3); Assert.True(e.MoveNextAsync().Result); Assert.Equal(4, e.Current.Key); var g4 = e.Current.GetAsyncEnumerator(); - HasNext(g4, xs[6]); - NoNext(g4); + await HasNextAsync(g4, xs[6]); + await NoNextAsync(g4); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void GroupBy2() + public async Task GroupBy2() { var xs = new[] { new { Name = "Bart", Age = 27 }, @@ -132,36 +132,36 @@ public void GroupBy2() var g4 = e.Current; Assert.Equal(4, g4.Key); - NoNext(e); + await NoNextAsync(e); var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, xs[0]); - HasNext(g1e, xs[2]); - HasNext(g1e, xs[4]); - HasNext(g1e, xs[5]); - NoNext(g1e); + await HasNextAsync(g1e, xs[0]); + await HasNextAsync(g1e, xs[2]); + await HasNextAsync(g1e, xs[4]); + await HasNextAsync(g1e, xs[5]); + await NoNextAsync(g1e); var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, xs[1]); - NoNext(g2e); + await HasNextAsync(g2e, xs[1]); + await NoNextAsync(g2e); var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, xs[3]); - NoNext(g3e); + await HasNextAsync(g3e, xs[3]); + await NoNextAsync(g3e); var g4e = g4.GetAsyncEnumerator(); - HasNext(g4e, xs[6]); - NoNext(g4e); + await HasNextAsync(g4e, xs[6]); + await NoNextAsync(g4e); } [Fact] - public void GroupBy3() + public async Task GroupBy3() { var xs = AsyncEnumerable.Empty(); var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] @@ -189,13 +189,13 @@ public void GroupBy5() //var g1 = e.Current; //Assert.Equal(g1.Key, 42); //var g1e = g1.GetEnumerator(); - //HasNext(g1e, 42); + //await HasNextAsync(g1e, 42); //Assert.True(e.MoveNext().Result); //var g2 = e.Current; //Assert.Equal(g2.Key, 43); //var g2e = g2.GetEnumerator(); - //HasNext(g2e, 43); + //await HasNextAsync(g2e, 43); //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); @@ -216,7 +216,7 @@ public void GroupBy6() //var g1 = e.Current; //Assert.Equal(g1.Key, 42); //var g1e = g1.GetEnumerator(); - //HasNext(g1e, 42); + //await HasNextAsync(g1e, 42); //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); @@ -255,13 +255,13 @@ public void GroupBy8() //var g1 = e.Current; //Assert.Equal(g1.Key, 1); //var g1e = g1.GetEnumerator(); - //HasNext(g1e, 1); + //await HasNextAsync(g1e, 1); //Assert.True(e.MoveNext().Result); //var g2 = e.Current; //Assert.Equal(g2.Key, 2); //var g2e = g2.GetEnumerator(); - //HasNext(g2e, 2); + //await HasNextAsync(g2e, 2); //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); @@ -269,7 +269,7 @@ public void GroupBy8() } [Fact] - public void GroupBy9() + public async Task GroupBy9() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); @@ -280,61 +280,61 @@ public void GroupBy9() var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); + await HasNextAsync(g1e, 'a'); + await HasNextAsync(g1e, 'd'); + await HasNextAsync(g1e, 'g'); + await HasNextAsync(g1e, 'j'); + await NoNextAsync(g1e); Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 'b'); - HasNext(g2e, 'e'); - HasNext(g2e, 'h'); - NoNext(g2e); + await HasNextAsync(g2e, 'b'); + await HasNextAsync(g2e, 'e'); + await HasNextAsync(g2e, 'h'); + await NoNextAsync(g2e); Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 'c'); - HasNext(g3e, 'f'); - HasNext(g3e, 'i'); - NoNext(g3e); + await HasNextAsync(g3e, 'c'); + await HasNextAsync(g3e, 'f'); + await HasNextAsync(g3e, 'i'); + await NoNextAsync(g3e); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void GroupBy10() + public async Task GroupBy10() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - adgj"); - HasNext(e, "1 - beh"); - HasNext(e, "2 - cfi"); - NoNext(e); + await HasNextAsync(e, "0 - adgj"); + await HasNextAsync(e, "1 - beh"); + await HasNextAsync(e, "2 - cfi"); + await NoNextAsync(e); } [Fact] - public void GroupBy11() + public async Task GroupBy11() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - 0369"); - HasNext(e, "1 - 147"); - HasNext(e, "2 - 258"); - NoNext(e); + await HasNextAsync(e, "0 - 0369"); + await HasNextAsync(e, "1 - 147"); + await HasNextAsync(e, "2 - 258"); + await NoNextAsync(e); } [Fact] - public void GroupBy12() + public async Task GroupBy12() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, new EqMod(3)); @@ -345,35 +345,35 @@ public void GroupBy12() var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 0); - HasNext(g1e, 3); - HasNext(g1e, 6); - HasNext(g1e, 9); - NoNext(g1e); + await HasNextAsync(g1e, 0); + await HasNextAsync(g1e, 3); + await HasNextAsync(g1e, 6); + await HasNextAsync(g1e, 9); + await NoNextAsync(g1e); Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 1); - HasNext(g2e, 4); - HasNext(g2e, 7); - NoNext(g2e); + await HasNextAsync(g2e, 1); + await HasNextAsync(g2e, 4); + await HasNextAsync(g2e, 7); + await NoNextAsync(g2e); Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 2); - HasNext(g3e, 5); - HasNext(g3e, 8); - NoNext(g3e); + await HasNextAsync(g3e, 2); + await HasNextAsync(g3e, 5); + await HasNextAsync(g3e, 8); + await NoNextAsync(g3e); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void GroupBy13() + public async Task GroupBy13() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), new EqMod(3)); @@ -384,57 +384,57 @@ public void GroupBy13() var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); + await HasNextAsync(g1e, 'a'); + await HasNextAsync(g1e, 'd'); + await HasNextAsync(g1e, 'g'); + await HasNextAsync(g1e, 'j'); + await NoNextAsync(g1e); Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 'b'); - HasNext(g2e, 'e'); - HasNext(g2e, 'h'); - NoNext(g2e); + await HasNextAsync(g2e, 'b'); + await HasNextAsync(g2e, 'e'); + await HasNextAsync(g2e, 'h'); + await NoNextAsync(g2e); Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 'c'); - HasNext(g3e, 'f'); - HasNext(g3e, 'i'); - NoNext(g3e); + await HasNextAsync(g3e, 'c'); + await HasNextAsync(g3e, 'f'); + await HasNextAsync(g3e, 'i'); + await NoNextAsync(g3e); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void GroupBy14() + public async Task GroupBy14() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - adgj"); - HasNext(e, "1 - beh"); - HasNext(e, "2 - cfi"); - NoNext(e); + await HasNextAsync(e, "0 - adgj"); + await HasNextAsync(e, "1 - beh"); + await HasNextAsync(e, "2 - cfi"); + await NoNextAsync(e); } [Fact] - public void GroupBy15() + public async Task GroupBy15() { var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); var e = ys.GetAsyncEnumerator(); - HasNext(e, "0 - 0369"); - HasNext(e, "1 - 147"); - HasNext(e, "2 - 258"); - NoNext(e); + await HasNextAsync(e, "0 - 0369"); + await HasNextAsync(e, "1 - 147"); + await HasNextAsync(e, "2 - 258"); + await NoNextAsync(e); } [Fact] @@ -449,34 +449,34 @@ public async Task GroupBy16() var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); + await HasNextAsync(g1e, 'a'); + await HasNextAsync(g1e, 'd'); + await HasNextAsync(g1e, 'g'); + await HasNextAsync(g1e, 'j'); + await NoNextAsync(g1e); await g1e.DisposeAsync(); Assert.True(e.MoveNextAsync().Result); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); - HasNext(g2e, 'b'); - HasNext(g2e, 'e'); - HasNext(g2e, 'h'); - NoNext(g2e); + await HasNextAsync(g2e, 'b'); + await HasNextAsync(g2e, 'e'); + await HasNextAsync(g2e, 'h'); + await NoNextAsync(g2e); await g2e.DisposeAsync(); Assert.True(e.MoveNextAsync().Result); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); - HasNext(g3e, 'c'); - HasNext(g3e, 'f'); - HasNext(g3e, 'i'); - NoNext(g3e); + await HasNextAsync(g3e, 'c'); + await HasNextAsync(g3e, 'f'); + await HasNextAsync(g3e, 'i'); + await NoNextAsync(g3e); await g3e.DisposeAsync(); - NoNext(e); + await NoNextAsync(e); await e.DisposeAsync(); } @@ -505,14 +505,14 @@ public async Task GroupBy18() var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); - HasNext(g1e, 'a'); + await HasNextAsync(g1e, 'a'); await e.DisposeAsync(); - HasNext(g1e, 'd'); - HasNext(g1e, 'g'); - HasNext(g1e, 'j'); - NoNext(g1e); + await HasNextAsync(g1e, 'd'); + await HasNextAsync(g1e, 'g'); + await HasNextAsync(g1e, 'j'); + await NoNextAsync(g1e); await g1e.DisposeAsync(); Assert.False(e.MoveNextAsync().Result); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index 4eeed85b3d..42ee01a9e6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -14,21 +15,21 @@ public class GroupJoin : AsyncEnumerableTests [Fact] public void GroupJoin_Null() { - AssertThrows(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default)); - - AssertThrows(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default)); + + Assert.Throws(() => AsyncEnumerable.GroupJoin(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupJoin(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); } [Fact] - public void GroupJoin1() + public async Task GroupJoin1() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 4, 7, 6, 2, 3, 4, 8, 9 }.ToAsyncEnumerable(); @@ -36,14 +37,14 @@ public void GroupJoin1() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - HasNext(e, "0 - 639"); - HasNext(e, "1 - 474"); - HasNext(e, "2 - 28"); - NoNext(e); + await HasNextAsync(e, "0 - 639"); + await HasNextAsync(e, "1 - 474"); + await HasNextAsync(e, "2 - 28"); + await NoNextAsync(e); } [Fact] - public void GroupJoin2() + public async Task GroupJoin2() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); @@ -51,10 +52,10 @@ public void GroupJoin2() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - HasNext(e, "0 - 36"); - HasNext(e, "1 - 4"); - HasNext(e, "2 - "); - NoNext(e); + await HasNextAsync(e, "0 - 36"); + await HasNextAsync(e, "1 - 4"); + await HasNextAsync(e, "2 - "); + await NoNextAsync(e); } [Fact] @@ -110,7 +111,7 @@ public void GroupJoin6() } [Fact] - public void GroupJoin7() + public async Task GroupJoin7() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -124,7 +125,7 @@ public void GroupJoin7() }); var e = res.GetAsyncEnumerator(); - HasNext(e, "0 - 36"); + await HasNextAsync(e, "0 - 36"); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs index 60c4e0eb5a..33ecf8016d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Intersect.cs @@ -15,37 +15,37 @@ public class Intersect : AsyncEnumerableTests [Fact] public void Intersect_Null() { - AssertThrows(() => AsyncEnumerable.Intersect(default, Return42)); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, default)); + Assert.Throws(() => AsyncEnumerable.Intersect(default, Return42)); + Assert.Throws(() => AsyncEnumerable.Intersect(Return42, default)); - AssertThrows(() => AsyncEnumerable.Intersect(default, Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Intersect(Return42, default, new Eq())); + Assert.Throws(() => AsyncEnumerable.Intersect(default, Return42, new Eq())); + Assert.Throws(() => AsyncEnumerable.Intersect(Return42, default, new Eq())); } [Fact] - public void Intersect1() + public async Task Intersect1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); var res = xs.Intersect(ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 3); + await NoNextAsync(e); } [Fact] - public void Intersect2() + public async Task Intersect2() { var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); var res = xs.Intersect(ys, new Eq()); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, -3); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, -3); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index 523357e309..4d8e12af7a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -15,21 +15,21 @@ public class Join : AsyncEnumerableTests [Fact] public void Join_Null() { - AssertThrows(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default)); - - AssertThrows(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default)); + + Assert.Throws(() => AsyncEnumerable.Join(default, Return42, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, default, x => x, x => x, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, Return42, default, x => x, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, Return42, x => x, default, (x, y) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.Join(Return42, Return42, x => x, x => x, default, EqualityComparer.Default)); } [Fact] - public void Join1() + public async Task Join1() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); @@ -37,14 +37,14 @@ public void Join1() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - HasNext(e, 0 + 3); - HasNext(e, 0 + 6); - HasNext(e, 1 + 4); - NoNext(e); + await HasNextAsync(e, 0 + 3); + await HasNextAsync(e, 0 + 6); + await HasNextAsync(e, 1 + 4); + await NoNextAsync(e); } [Fact] - public void Join2() + public async Task Join2() { var xs = new[] { 3, 6, 4 }.ToAsyncEnumerable(); var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -52,14 +52,14 @@ public void Join2() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - HasNext(e, 3 + 0); - HasNext(e, 6 + 0); - HasNext(e, 4 + 1); - NoNext(e); + await HasNextAsync(e, 3 + 0); + await HasNextAsync(e, 6 + 0); + await HasNextAsync(e, 4 + 1); + await NoNextAsync(e); } [Fact] - public void Join3() + public async Task Join3() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 6 }.ToAsyncEnumerable(); @@ -67,13 +67,13 @@ public void Join3() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - HasNext(e, 0 + 3); - HasNext(e, 0 + 6); - NoNext(e); + await HasNextAsync(e, 0 + 3); + await HasNextAsync(e, 0 + 6); + await NoNextAsync(e); } [Fact] - public void Join4() + public async Task Join4() { var xs = new[] { 3, 6 }.ToAsyncEnumerable(); var ys = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -81,9 +81,9 @@ public void Join4() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - HasNext(e, 3 + 0); - HasNext(e, 6 + 0); - NoNext(e); + await HasNextAsync(e, 3 + 0); + await HasNextAsync(e, 6 + 0); + await NoNextAsync(e); } [Fact] @@ -163,7 +163,7 @@ public async Task Join10() } [Fact] - public void Join11() + public async Task Join11() { var customers = new List { @@ -187,17 +187,17 @@ public void Join11() (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); var e = asyncResult.GetAsyncEnumerator(); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); - NoNext(e); + await HasNextAsync(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); + await NoNextAsync(e); } [Fact] - public void Join12() + public async Task Join12() { var customers = new List { @@ -220,13 +220,13 @@ public void Join12() (c, o) => new CustomerOrder { CustomerId = c.CustomerId, OrderId = o.OrderId }); var e = asyncResult.GetAsyncEnumerator(); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); - HasNext(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); - HasNext(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); - NoNext(e); + await HasNextAsync(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 1 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 2 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "ALFKI", OrderId = 3 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 4 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 5 }); + await HasNextAsync(e, new CustomerOrder { CustomerId = "FISSA", OrderId = 6 }); + await NoNextAsync(e); } public class Customer diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs index 9986a61c08..8bbea8ee0c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -14,19 +15,19 @@ public class OfType : AsyncEnumerableTests [Fact] public void OfType_Null() { - AssertThrows(() => AsyncEnumerable.OfType(default)); + Assert.Throws(() => AsyncEnumerable.OfType(default)); } [Fact] - public void OfType1() + public async Task OfType1Async() { var xs = new object[] { 1, 1.2, true, 4, "" }.ToAsyncEnumerable(); var ys = xs.OfType(); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 4); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index f6d9c83fed..b23b31b64c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -15,43 +15,43 @@ public class OrderBy : AsyncEnumerableTests [Fact] public void OrderBy_Null() { - AssertThrows(() => AsyncEnumerable.OrderBy(default, x => x)); - AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.OrderBy(default, x => x)); + Assert.Throws(() => AsyncEnumerable.OrderBy(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.OrderBy(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.OrderBy(default, x => x, Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.OrderByDescending(default, x => x)); + Assert.Throws(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.OrderByDescending(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.OrderByDescending(default, x => x, Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); var xs = Return42.OrderBy(x => x); - AssertThrows(() => AsyncEnumerable.ThenBy(default, x => x)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func))); + Assert.Throws(() => AsyncEnumerable.ThenBy(default, x => x)); + Assert.Throws(() => AsyncEnumerable.ThenBy(xs, default(Func))); - AssertThrows(() => AsyncEnumerable.ThenBy(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.ThenBy(default, x => x, Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); + Assert.Throws(() => AsyncEnumerable.ThenByDescending(default, x => x)); + Assert.Throws(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); - AssertThrows(() => AsyncEnumerable.ThenByDescending(default, x => x, Comparer.Default)); - AssertThrows(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.ThenByDescending(default, x => x, Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); } [Fact] - public void OrderBy1() + public async Task OrderBy1() { var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(x => x); var e = ys.GetAsyncEnumerator(); for (var i = 0; i < 10; i++) - HasNext(e, i); - NoNext(e); + await HasNextAsync(e, i); + await NoNextAsync(e); } [Fact] @@ -86,15 +86,15 @@ public void ThenBy2() } [Fact] - public void OrderByDescending1() + public async Task OrderByDescending1() { var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderByDescending(x => x); var e = ys.GetAsyncEnumerator(); for (var i = 9; i >= 0; i--) - HasNext(e, i); - NoNext(e); + await HasNextAsync(e, i); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs index 312e1e7ae8..110c0b9119 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs @@ -15,11 +15,11 @@ public class Prepend : AsyncEnumerableTests [Fact] public void Prepend_Null() { - AssertThrows(() => AsyncEnumerable.Prepend(default, 42)); + Assert.Throws(() => AsyncEnumerable.Prepend(default, 42)); } [Fact] - public void Prepend1() + public async Task Prepend1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -27,11 +27,11 @@ public void Prepend1() var e = res.GetAsyncEnumerator(); - HasNext(e, 4); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 4); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); } [Fact] @@ -115,7 +115,7 @@ public async Task Prepend8() } [Fact] - public void PrependN1() + public async Task PrependN1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -125,13 +125,13 @@ public void PrependN1() var e = res.GetAsyncEnumerator(); - HasNext(e, 6); - HasNext(e, 5); - HasNext(e, 4); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 6); + await HasNextAsync(e, 5); + await HasNextAsync(e, 4); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs index 832f8b6f55..31c002e8ca 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Range.cs @@ -4,6 +4,7 @@ using System; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -13,30 +14,30 @@ public class Range : AsyncEnumerableTests [Fact] public void Range_Null() { - AssertThrows(() => AsyncEnumerable.Range(0, -1)); + Assert.Throws(() => AsyncEnumerable.Range(0, -1)); } [Fact] - public void Range1() + public async Task Range1Async() { var xs = AsyncEnumerable.Range(2, 5); var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void Range2() + public async Task Range2Async() { var xs = AsyncEnumerable.Range(2, 0); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs index ad72413daf..a7222ad249 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Repeat.cs @@ -14,30 +14,30 @@ public class Repeat : AsyncEnumerableTests [Fact] public void Repeat_Null() { - AssertThrows(() => AsyncEnumerable.Repeat(0, -1)); + Assert.Throws(() => AsyncEnumerable.Repeat(0, -1)); } [Fact] - public void Repeat1() + public async Task Repeat1Async() { var xs = AsyncEnumerable.Repeat(2, 5); var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void Repeat2() + public async Task Repeat2Async() { var xs = AsyncEnumerable.Repeat(2, 0); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index c90eb90487..e6851f1a1f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -15,41 +15,41 @@ public class Reverse : AsyncEnumerableTests [Fact] public void Reverse_Null() { - AssertThrows(() => AsyncEnumerable.Reverse(default)); + Assert.Throws(() => AsyncEnumerable.Reverse(default)); } [Fact] - public void Reverse1() + public async Task Reverse1Async() { var xs = AsyncEnumerable.Empty(); var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void Reverse2() + public async Task Reverse2Async() { var xs = Return42; var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); - HasNext(e, 42); - NoNext(e); + await HasNextAsync(e, 42); + await NoNextAsync(e); } [Fact] - public void Reverse3() + public async Task Reverse3Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 2); - HasNext(e, 1); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 2); + await HasNextAsync(e, 1); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index af89ce83aa..2201b2a319 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -15,36 +15,36 @@ public class Select : AsyncEnumerableTests [Fact] public void Select_Null() { - AssertThrows(() => AsyncEnumerable.Select(default, x => x)); - AssertThrows(() => AsyncEnumerable.Select(default, (x, i) => x)); - AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.Select(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.Select(default, x => x)); + Assert.Throws(() => AsyncEnumerable.Select(default, (x, i) => x)); + Assert.Throws(() => AsyncEnumerable.Select(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.Select(Return42, default(Func))); } [Fact] - public void Select1() + public async Task Select1() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(x => (char)('a' + x)); var e = ys.GetAsyncEnumerator(); - HasNext(e, 'a'); - HasNext(e, 'b'); - HasNext(e, 'c'); - NoNext(e); + await HasNextAsync(e, 'a'); + await HasNextAsync(e, 'b'); + await HasNextAsync(e, 'c'); + await NoNextAsync(e); } [Fact] - public void Select2() + public async Task Select2() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); var ys = xs.Select((x, i) => (char)('a' + i)); var e = ys.GetAsyncEnumerator(); - HasNext(e, 'a'); - HasNext(e, 'b'); - HasNext(e, 'c'); - NoNext(e); + await HasNextAsync(e, 'a'); + await HasNextAsync(e, 'b'); + await HasNextAsync(e, 'c'); + await NoNextAsync(e); } [Fact] @@ -68,16 +68,16 @@ public void Select4() } [Fact] - public void Select5() + public async Task Select5() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x)); var e = ys.GetAsyncEnumerator(); - HasNext(e, 'd'); - HasNext(e, 'e'); - HasNext(e, 'f'); - NoNext(e); + await HasNextAsync(e, 'd'); + await HasNextAsync(e, 'e'); + await HasNextAsync(e, 'f'); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index 5652c9cfb6..ef039623e3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -15,37 +15,37 @@ public class SelectMany : AsyncEnumerableTests [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); - - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, x => default, default(Func))); - AssertThrows(() => AsyncEnumerable.SelectMany(Return42, (x, i) => default, default(Func))); + Assert.Throws(() => AsyncEnumerable.SelectMany(default, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SelectMany(default, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SelectMany(Return42, default(Func>))); + + Assert.Throws(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.SelectMany(default, default(Func>), (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.SelectMany(Return42, default(Func>), (x, y) => x)); + Assert.Throws(() => AsyncEnumerable.SelectMany(Return42, x => default, default(Func))); + Assert.Throws(() => AsyncEnumerable.SelectMany(Return42, (x, i) => default, default(Func))); } [Fact] - public void SelectMany1() + public async Task SelectMany1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); - HasNext(e, 0); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 0); + await HasNextAsync(e, 0); + await HasNextAsync(e, 1); + await HasNextAsync(e, 0); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void SelectMany2() + public async Task SelectMany2Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -58,9 +58,9 @@ public void SelectMany2() }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); + await HasNextAsync(e, 0); + await HasNextAsync(e, 0); + await HasNextAsync(e, 1); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } @@ -76,7 +76,7 @@ public void SelectMany3() } [Fact] - public void SelectMany4() + public async Task SelectMany4Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -89,30 +89,30 @@ public void SelectMany4() }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); + await HasNextAsync(e, 0); + await HasNextAsync(e, 0); + await HasNextAsync(e, 1); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] - public void SelectMany5() + public async Task SelectMany5Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 5, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 7); - HasNext(e, 8); - HasNext(e, 9); - NoNext(e); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await HasNextAsync(e, 7); + await HasNextAsync(e, 7); + await HasNextAsync(e, 8); + await HasNextAsync(e, 9); + await NoNextAsync(e); } [Fact] - public void SelectMany6() + public async Task SelectMany6Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -125,9 +125,9 @@ public void SelectMany6() }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); + await HasNextAsync(e, 0); + await HasNextAsync(e, 0); + await HasNextAsync(e, 1); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } @@ -143,7 +143,7 @@ public void SelectMany7() } [Fact] - public void SelectMany8() + public async Task SelectMany8Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -156,46 +156,46 @@ public void SelectMany8() }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 0); - HasNext(e, 1); + await HasNextAsync(e, 0); + await HasNextAsync(e, 0); + await HasNextAsync(e, 1); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] - public void SelectMany9() + public async Task SelectMany9Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany(x => Enumerable.Range(3, x).ToAsyncEnumerable(), (x, y) => x * y); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 6); - HasNext(e, 8); - HasNext(e, 9); - HasNext(e, 12); - HasNext(e, 15); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 6); + await HasNextAsync(e, 8); + await HasNextAsync(e, 9); + await HasNextAsync(e, 12); + await HasNextAsync(e, 15); + await NoNextAsync(e); } [Fact] - public void SelectMany10() + public async Task SelectMany10Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.SelectMany((x, i) => Enumerable.Range(i + 3, x).ToAsyncEnumerable(), (x, y) => x * y); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 8); - HasNext(e, 10); - HasNext(e, 15); - HasNext(e, 18); - HasNext(e, 21); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 8); + await HasNextAsync(e, 10); + await HasNextAsync(e, 15); + await HasNextAsync(e, 18); + await HasNextAsync(e, 21); + await NoNextAsync(e); } [Fact] - public void SelectMany11() + public async Task SelectMany11Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -207,15 +207,15 @@ public void SelectMany11() }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 6); - HasNext(e, 8); - HasNext(e, 9); + await HasNextAsync(e, 3); + await HasNextAsync(e, 6); + await HasNextAsync(e, 8); + await HasNextAsync(e, 9); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] - public void SelectMany12() + public async Task SelectMany12Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -227,9 +227,9 @@ public void SelectMany12() }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 8); - HasNext(e, 10); + await HasNextAsync(e, 3); + await HasNextAsync(e, 8); + await HasNextAsync(e, 10); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index f8f84a7560..c36d8609b9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -15,7 +15,7 @@ public class Skip : AsyncEnumerableTests [Fact] public void Skip_Null() { - AssertThrows(() => AsyncEnumerable.Skip(default, 5)); + Assert.Throws(() => AsyncEnumerable.Skip(default, 5)); } //[Fact] @@ -25,43 +25,43 @@ public void Skip_Null() // var ys = xs.Skip(-2); // var e = ys.GetEnumerator(); - // NoNext(e); + // await NoNextAsync(e); //} [Fact] - public void Skip1() + public async Task Skip1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Skip(2); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void Skip2() + public async Task Skip2() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Skip(10); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void Skip3() + public async Task Skip3() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Skip(0); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs index c204b8e700..44ef76664e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs @@ -15,27 +15,27 @@ public class SkipLast : AsyncEnumerableTests [Fact] public void SkipLast_Null() { - AssertThrows(() => AsyncEnumerable.SkipLast(default(IAsyncEnumerable), 5)); + Assert.Throws(() => AsyncEnumerable.SkipLast(default(IAsyncEnumerable), 5)); } [Fact] - public void SkipLast1() + public async Task SkipLast1Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void SkipLast2() + public async Task SkipLast2Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(5); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] @@ -47,17 +47,17 @@ public async Task SkipLast3() } [Fact] - public void SkipLast4() + public async Task SkipLast4Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(0); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index 186aed0bba..453eeef4fc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -15,61 +15,61 @@ public class SkipWhile : AsyncEnumerableTests [Fact] public void SkipWhile_Null() { - AssertThrows(() => AsyncEnumerable.SkipWhile(default, x => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(default, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.SkipWhile(default, x => true)); + Assert.Throws(() => AsyncEnumerable.SkipWhile(default, (x, i) => true)); + Assert.Throws(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.SkipWhile(Return42, default(Func))); } [Fact] - public void SkipWhile1() + public async Task SkipWhile1Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => x < 3); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void SkipWhile2() + public async Task SkipWhile2Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => false); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void SkipWhile3() + public async Task SkipWhile3Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => true); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void SkipWhile4() + public async Task SkipWhile4Async() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => x < 3); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 3); - HasNext(e, 2); - HasNext(e, 1); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 3); + await HasNextAsync(e, 2); + await HasNextAsync(e, 1); + await NoNextAsync(e); } [Fact] @@ -84,39 +84,39 @@ public void SkipWhile5() } [Fact] - public void SkipWhile6() + public async Task SkipWhile6Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => i < 2); var e = ys.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void SkipWhile7() + public async Task SkipWhile7Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => false); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void SkipWhile8() + public async Task SkipWhile8Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => true); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index 6a3c1f3d69..c3bc10cc51 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -15,53 +15,53 @@ public class Take : AsyncEnumerableTests [Fact] public void Take_Null() { - AssertThrows(() => AsyncEnumerable.Take(default, 5)); + Assert.Throws(() => AsyncEnumerable.Take(default, 5)); } [Fact] - public void Take0() + public async Task Take0Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(-2); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void Take1() + public async Task Take1Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(2); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void Take2() + public async Task Take2Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(10); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void Take3() + public async Task Take3Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Take(0); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs index d06dcfd7b8..9f7edc2592 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs @@ -15,40 +15,40 @@ public class TakeLast : AsyncEnumerableTests [Fact] public void TakeLast_Null() { - AssertThrows(() => AsyncEnumerable.TakeLast(default(IAsyncEnumerable), 5)); + Assert.Throws(() => AsyncEnumerable.TakeLast(default(IAsyncEnumerable), 5)); } [Fact] - public void TakeLast0() + public async Task TakeLast0() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(-2); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void TakeLast1() + public async Task TakeLast1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); var e = xs.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void TakeLast2() + public async Task TakeLast2() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(5); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] @@ -60,13 +60,13 @@ public async Task TakeLast3() } [Fact] - public void TakeLast_BugFix_TakeLast_Zero_TakesForever() + public async Task TakeLast_BugFix_TakeLast_Zero_TakesForever() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(0); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index 44640f2e39..0b8de6ff1a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -15,58 +15,58 @@ public class TakeWhile : AsyncEnumerableTests [Fact] public void TakeWhile_Null() { - AssertThrows(() => AsyncEnumerable.TakeWhile(default, x => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(default, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.TakeWhile(default, x => true)); + Assert.Throws(() => AsyncEnumerable.TakeWhile(default, (x, i) => true)); + Assert.Throws(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.TakeWhile(Return42, default(Func))); } [Fact] - public void TakeWhile1() + public async Task TakeWhile1Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => x < 3); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void TakeWhile2() + public async Task TakeWhile2Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => false); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void TakeWhile3() + public async Task TakeWhile3Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => true); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void TakeWhile4() + public async Task TakeWhile4Async() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => x < 3); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] @@ -81,39 +81,39 @@ public void TakeWhile5() } [Fact] - public void TakeWhile6() + public async Task TakeWhile6Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => i < 2); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void TakeWhile7() + public async Task TakeWhile7Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => false); var e = ys.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void TakeWhile8() + public async Task TakeWhile8Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => true); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index 28e6df470b..f0239cb002 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -13,7 +13,7 @@ public class Throw : AsyncEnumerableTests [Fact] public void Throw_Null() { - AssertThrows(() => Throw(default)); + Assert.Throws(() => Throw(default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index efd9d6bd14..d37dcf7088 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -15,30 +15,30 @@ public class ToAsyncEnumerable : AsyncEnumerableTests [Fact] public void ToAsyncEnumerable_Null() { - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IEnumerable))); - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); - AssertThrows(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); + Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(IEnumerable))); + Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); + Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); } [Fact] - public void ToAsyncEnumerable1() + public async Task ToAsyncEnumerable1Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void ToAsyncEnumerable2() + public async Task ToAsyncEnumerable2Async() { var ex = new Exception("Bang"); var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 42); + await HasNextAsync(e, 42); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } @@ -49,7 +49,7 @@ private IEnumerable ToAsyncEnumerable_Sequence(Exception e) } [Fact] - public void ToAsyncEnumerable3() + public async Task ToAsyncEnumerable3Async() { var subscribed = false; @@ -69,8 +69,8 @@ public void ToAsyncEnumerable3() Assert.True(subscribed); - HasNext(e, 42); - NoNext(e); + await HasNextAsync(e, 42); + await NoNextAsync(e); } [Fact] @@ -98,17 +98,17 @@ public void ToAsyncEnumerable4() } [Fact] - public void ToAsyncEnumerable5() + public async Task ToAsyncEnumerable5Async() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs index aaaadbb7f0..454eeab556 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToEnumerable.cs @@ -13,7 +13,7 @@ public class ToEnumerable : AsyncEnumerableTests [Fact] public void ToEnumerable_Null() { - AssertThrows(() => AsyncEnumerable.ToEnumerable(null)); + Assert.Throws(() => AsyncEnumerable.ToEnumerable(null)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index 4539d44ebd..1dbfa56b51 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -16,7 +16,7 @@ public class ToObservable : AsyncEnumerableTests [Fact] public void ToObservable_Null() { - AssertThrows(() => AsyncEnumerable.ToObservable(null)); + Assert.Throws(() => AsyncEnumerable.ToObservable(null)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs index a405f7b068..58543c593d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Union.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -14,46 +15,46 @@ public class Union : AsyncEnumerableTests [Fact] public void Union_Null() { - AssertThrows(() => AsyncEnumerable.Union(default, Return42)); + Assert.Throws(() => AsyncEnumerable.Union(default, Return42)); - AssertThrows(() => AsyncEnumerable.Union(default, Return42, new Eq())); - AssertThrows(() => AsyncEnumerable.Union(Return42, default, new Eq())); + Assert.Throws(() => AsyncEnumerable.Union(default, Return42, new Eq())); + Assert.Throws(() => AsyncEnumerable.Union(Return42, default, new Eq())); } [Fact] - public void Union1() + public async Task Union1() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); var res = xs.Union(ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 5); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void Union2() + public async Task Union2() { var xs = new[] { 1, 2, -3 }.ToAsyncEnumerable(); var ys = new[] { 3, 5, -1, 4 }.ToAsyncEnumerable(); var res = xs.Union(ys, new Eq()); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, -3); - HasNext(e, 5); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, -3); + await HasNextAsync(e, 5); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void Union3() + public async Task Union3() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 3, 5, 1, 4 }.ToAsyncEnumerable(); @@ -61,14 +62,14 @@ public void Union3() var res = xs.Union(ys).Union(zs); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 4); - HasNext(e, 7); - HasNext(e, 8); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 5); + await HasNextAsync(e, 4); + await HasNextAsync(e, 7); + await HasNextAsync(e, 8); + await NoNextAsync(e); } private sealed class Eq : IEqualityComparer diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index 79d366f872..d85c16966c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -15,66 +15,66 @@ public class Where : AsyncEnumerableTests [Fact] public void Where_Null() { - AssertThrows(() => AsyncEnumerable.Where(default, x => true)); - AssertThrows(() => AsyncEnumerable.Where(default, (x, i) => true)); - AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); - AssertThrows(() => AsyncEnumerable.Where(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.Where(default, x => true)); + Assert.Throws(() => AsyncEnumerable.Where(default, (x, i) => true)); + Assert.Throws(() => AsyncEnumerable.Where(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.Where(Return42, default(Func))); } [Fact] - public void Where1() + public async Task Where1() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0); var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 4); - HasNext(e, 6); - HasNext(e, 2); - HasNext(e, 0); - NoNext(e); + await HasNextAsync(e, 8); + await HasNextAsync(e, 4); + await HasNextAsync(e, 6); + await HasNextAsync(e, 2); + await HasNextAsync(e, 0); + await NoNextAsync(e); } [Fact] - public void Where2() + public async Task Where2() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where((x, i) => i % 2 == 0); var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 7); - HasNext(e, 6); - HasNext(e, 2); - HasNext(e, 0); - NoNext(e); + await HasNextAsync(e, 8); + await HasNextAsync(e, 7); + await HasNextAsync(e, 6); + await HasNextAsync(e, 2); + await HasNextAsync(e, 0); + await NoNextAsync(e); } [Fact] - public void Where3() + public async Task Where3() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); var ys = xs.Where(x => { if (x == 4) throw ex; return true; }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 5); - HasNext(e, 7); + await HasNextAsync(e, 8); + await HasNextAsync(e, 5); + await HasNextAsync(e, 7); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] - public void Where4() + public async Task Where4() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); var ys = xs.Where((x, i) => { if (i == 3) throw ex; return true; }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 5); - HasNext(e, 7); + await HasNextAsync(e, 8); + await HasNextAsync(e, 5); + await HasNextAsync(e, 7); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } @@ -102,14 +102,14 @@ public void Where6() [Fact] - public void Where7() + public async Task Where7() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0).Where(x => x > 5); var e = ys.GetAsyncEnumerator(); - HasNext(e, 8); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 8); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index adefa66cba..66004338bd 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -15,51 +15,51 @@ public class Zip : AsyncEnumerableTests [Fact] public void Zip_Null() { - AssertThrows(() => AsyncEnumerable.Zip(default, Return42, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(Return42, default, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerable.Zip(Return42, Return42, default(Func))); + Assert.Throws(() => AsyncEnumerable.Zip(default, Return42, (x, y) => x + y)); + Assert.Throws(() => AsyncEnumerable.Zip(Return42, default, (x, y) => x + y)); + Assert.Throws(() => AsyncEnumerable.Zip(Return42, Return42, default(Func))); } [Fact] - public void Zip1() + public async Task Zip1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - HasNext(e, 1 * 4); - HasNext(e, 2 * 5); - HasNext(e, 3 * 6); - NoNext(e); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); } [Fact] - public void Zip2() + public async Task Zip2Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - HasNext(e, 1 * 4); - HasNext(e, 2 * 5); - HasNext(e, 3 * 6); - NoNext(e); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); } [Fact] - public void Zip3() + public async Task Zip3Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - HasNext(e, 1 * 4); - HasNext(e, 2 * 5); - HasNext(e, 3 * 6); - NoNext(e); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs index da027268d9..52dfc1f8d5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs @@ -12,43 +12,43 @@ namespace Tests public class Optimizations : AsyncEnumerableTests { [Fact] - public void SelectWhere2() + public async Task SelectWhere2Async() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(i => i + 2).Where(i => i % 2 == 0); var e = ys.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 2); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void WhereSelect2() + public async Task WhereSelect2Async() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2); var e = ys.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 2); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] - public void WhereSelect3() + public async Task WhereSelect3Async() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2).Select(i => i + 2); var e = ys.GetAsyncEnumerator(); - HasNext(e, 4); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 4); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void AppendPrepend1() + public async Task AppendPrepend1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -62,17 +62,17 @@ public void AppendPrepend1() var e = res.GetAsyncEnumerator(); - HasNext(e, 10); - HasNext(e, 9); - HasNext(e, 7); - HasNext(e, 4); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 8); - NoNext(e); + await HasNextAsync(e, 10); + await HasNextAsync(e, 9); + await HasNextAsync(e, 7); + await HasNextAsync(e, 4); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await HasNextAsync(e, 8); + await NoNextAsync(e); } [Fact] @@ -183,7 +183,7 @@ public async Task AppendPrepend7() } [Fact] - public void AppendPrepend8() + public async Task AppendPrepend8Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -192,12 +192,12 @@ public void AppendPrepend8() var e = res.GetAsyncEnumerator(); - HasNext(e, 5); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 5); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] From 9b1c16ec0a0c6538b033db74d670c2cb19f8ea72 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 16:30:52 -0800 Subject: [PATCH 496/862] Reduce places where magic timeout values are used. --- .../System/Linq/AsyncEnumerableTests.cs | 10 ++++++++++ .../System/Linq/Operators/Aggregate.cs | 14 +++++++------- .../System/Linq/Operators/All.cs | 4 ++-- .../System/Linq/Operators/Any.cs | 4 ++-- .../System/Linq/Operators/Concat.cs | 4 ++-- .../System/Linq/Operators/Count.cs | 2 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 ++-- .../System/Linq/Operators/ElementAt.cs | 2 +- .../System/Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/First.cs | 4 ++-- .../System/Linq/Operators/FirstOrDefault.cs | 4 ++-- .../System/Linq/Operators/ForEachAsync.cs | 8 ++++---- .../System/Linq/Operators/GroupBy.cs | 6 +++--- .../System/Linq/Operators/GroupJoin.cs | 10 +++++----- .../System/Linq/Operators/Join.cs | 10 +++++----- .../System/Linq/Operators/Last.cs | 4 ++-- .../System/Linq/Operators/LastOrDefault.cs | 4 ++-- .../System/Linq/Operators/LongCount.cs | 2 +- .../System/Linq/Operators/OrderBy.cs | 8 ++++---- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/SelectMany.cs | 16 ++++++++-------- .../System/Linq/Operators/SequenceEqual.cs | 8 ++++---- .../System/Linq/Operators/Single.cs | 4 ++-- .../System/Linq/Operators/SingleOrDefault.cs | 4 ++-- .../System/Linq/Operators/Skip.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 4 ++-- .../System/Linq/Operators/Take.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 4 ++-- .../System/Linq/Operators/ToArray.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/Where.cs | 10 ++++------ .../System/Linq/Operators/Zip.cs | 7 +++---- 32 files changed, 90 insertions(+), 83 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 77c67142b6..28009017f1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -46,6 +46,16 @@ public void AssertThrows(Action a, Func assert) } } + public void AssertThrowsAsync(Task t, Exception e) + { + AssertThrows(() => t.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(e)); + } + + public void AssertThrowsAsync(ValueTask t, Exception e) + { + AssertThrows(() => t.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(e)); + } + public async Task NoNextAsync(IAsyncEnumerator e) { Assert.False(await e.MoveNextAsync()); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index f0e43879e2..67a14c6bfb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -58,7 +58,7 @@ public void Aggregate3() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate((x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } [Fact] @@ -67,7 +67,7 @@ public void Aggregate4() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } [Fact] @@ -92,7 +92,7 @@ public void Aggregate7() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } [Fact] @@ -101,7 +101,7 @@ public void Aggregate8() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } [Fact] @@ -126,7 +126,7 @@ public void Aggregate11() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } [Fact] @@ -135,7 +135,7 @@ public void Aggregate12() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => { throw ex; }, x => x + 1); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } [Fact] @@ -144,7 +144,7 @@ public void Aggregate13() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y, x => { throw ex; }); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index f6f17f2213..c8661c2828 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -41,7 +41,7 @@ public void All3() { var ex = new Exception("Bang!"); var res = Throw(ex).All(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -49,7 +49,7 @@ public void All4() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 6f8145a228..b5e9a5be41 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -43,7 +43,7 @@ public void Any3() { var ex = new Exception("Bang!"); var res = Throw(ex).Any(x => x % 2 == 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -51,7 +51,7 @@ public void Any4() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 36f9f43a07..0d1f30de26 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -44,7 +44,7 @@ public async Task Concat2Async() await HasNextAsync(e, 1); await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -54,7 +54,7 @@ public void Concat3() var ys = Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index d9a1127cf6..962a41e9e2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -46,7 +46,7 @@ public void Count3() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index ad28c44a4f..0ec7a112e6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -92,7 +92,7 @@ public void DefaultIfEmpty7() var xs = Throw(ex).DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -102,7 +102,7 @@ public void DefaultIfEmpty8() var xs = Throw(ex).DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index d4464f5ab6..c164f0f396 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -63,7 +63,7 @@ public void ElementAt6() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAt(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index cf07f5573c..0f57ab85df 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -67,7 +67,7 @@ public void ElementAtOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAtOrDefault(15); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index b1adb66c69..ab5630b243 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -65,7 +65,7 @@ public void First6() { var ex = new Exception("Bang!"); var res = Throw(ex).First(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -73,7 +73,7 @@ public void First7() { var ex = new Exception("Bang!"); var res = Throw(ex).First(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 208d89159e..8a5ce641d4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -65,7 +65,7 @@ public void FirstOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -73,7 +73,7 @@ public void FirstOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index b41c04de95..677f6cd157 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -53,7 +53,7 @@ public void ForEachAsync3() var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(xs.ForEachAsync(x => { throw ex; }), ex); } [Fact] @@ -62,7 +62,7 @@ public void ForEachAsync4() var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(xs.ForEachAsync((x, i) => { throw ex; }), ex); } [Fact] @@ -71,7 +71,7 @@ public void ForEachAsync5() var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrows(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(xs.ForEachAsync(x => { throw ex; }), ex); } [Fact] @@ -80,7 +80,7 @@ public void ForEachAsync6() var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrows(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(xs.ForEachAsync((x, i) => { throw ex; }), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 6b30b2a5a3..da8610ad54 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -172,7 +172,7 @@ public void GroupBy4() var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -237,7 +237,7 @@ public void GroupBy7() var ys = xs.GroupBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -249,7 +249,7 @@ public void GroupBy8() var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); //Assert.True(e.MoveNext().Result); //var g1 = e.Current; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index 42ee01a9e6..f4398fe400 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -68,7 +68,7 @@ public void GroupJoin3() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -81,7 +81,7 @@ public void GroupJoin4() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -94,7 +94,7 @@ public void GroupJoin5() var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -107,7 +107,7 @@ public void GroupJoin6() var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -126,7 +126,7 @@ public async Task GroupJoin7() var e = res.GetAsyncEnumerator(); await HasNextAsync(e, "0 - 36"); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index 4d8e12af7a..95b50376e7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -96,7 +96,7 @@ public void Join5() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -109,7 +109,7 @@ public void Join6() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -122,7 +122,7 @@ public void Join7() var res = xs.Join(ys, x => { throw ex; }, y => y, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -135,7 +135,7 @@ public void Join8() var res = xs.Join(ys, x => x, y => { throw ex; }, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -148,7 +148,7 @@ public void Join9() var res = xs.Join(ys, x => x, y => y, (x, y) => { throw ex; }); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 6b19e968d1..06bb41cea4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -65,7 +65,7 @@ public void Last6() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -73,7 +73,7 @@ public void Last7() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 319fead808..7996f52b5d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -65,7 +65,7 @@ public void LastOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -73,7 +73,7 @@ public void LastOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index be1ede264a..920e4c31cd 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -46,7 +46,7 @@ public void LongCount3() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); - AssertThrows(() => ys.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(ys, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index b23b31b64c..582424be6e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -62,7 +62,7 @@ public void OrderBy2() var ys = xs.OrderBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -82,7 +82,7 @@ public void ThenBy2() var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -105,7 +105,7 @@ public void OrderByDescending2() var ys = xs.OrderByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -125,7 +125,7 @@ public void ThenByDescending2() var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index e6851f1a1f..48c77b2ee5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -60,7 +60,7 @@ public void Reverse4() var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index ef039623e3..76ccf800ea 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -61,7 +61,7 @@ public async Task SelectMany2Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -72,7 +72,7 @@ public void SelectMany3() var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -92,7 +92,7 @@ public async Task SelectMany4Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -128,7 +128,7 @@ public async Task SelectMany6Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -139,7 +139,7 @@ public void SelectMany7() var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -159,7 +159,7 @@ public async Task SelectMany8Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -211,7 +211,7 @@ public async Task SelectMany11Async() await HasNextAsync(e, 6); await HasNextAsync(e, 8); await HasNextAsync(e, 9); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -230,7 +230,7 @@ public async Task SelectMany12Async() await HasNextAsync(e, 3); await HasNextAsync(e, 8); await HasNextAsync(e, 10); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 14f30fb16d..35028062b0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -80,7 +80,7 @@ public void SequenceEqual6() var ys = Throw(ex); var res = xs.SequenceEqual(ys); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -91,7 +91,7 @@ public void SequenceEqual7() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -145,7 +145,7 @@ public void SequenceEqual13() var ys = Throw(ex); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -156,7 +156,7 @@ public void SequenceEqual14() var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 944269b1da..921f590e1f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -65,7 +65,7 @@ public void Single6() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -73,7 +73,7 @@ public void Single7() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index d69bbfda6b..d4b361a272 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -65,7 +65,7 @@ public void SingleOrDefault6() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] @@ -73,7 +73,7 @@ public void SingleOrDefault7() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index c36d8609b9..a566cce587 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -72,7 +72,7 @@ public void Skip4() var ys = xs.Skip(2); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index 453eeef4fc..b229edab35 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -80,7 +80,7 @@ public void SkipWhile5() var ys = xs.SkipWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -127,7 +127,7 @@ public void SkipWhile9() var ys = xs.SkipWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index c3bc10cc51..8cc22b4453 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -72,7 +72,7 @@ public void Take4() var ys = xs.Take(2); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index 0b8de6ff1a..26daf59d12 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -77,7 +77,7 @@ public void TakeWhile5() var ys = xs.TakeWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -124,7 +124,7 @@ public void TakeWhile9() var ys = xs.TakeWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 170d3c4a2f..9ac8e5934d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -41,7 +41,7 @@ public void ToArray3() { var ex = new Exception("Bang!"); var res = Throw(ex).ToArray(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index ad2c72c6fb..01d3de4b55 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -41,7 +41,7 @@ public void ToList3() { var ex = new Exception("Bang!"); var res = Throw(ex).ToList(); - AssertThrows(() => res.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index d85c16966c..91378209e8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -61,7 +60,7 @@ public async Task Where3() await HasNextAsync(e, 8); await HasNextAsync(e, 5); await HasNextAsync(e, 7); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -75,7 +74,7 @@ public async Task Where4() await HasNextAsync(e, 8); await HasNextAsync(e, 5); await HasNextAsync(e, 7); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -86,7 +85,7 @@ public void Where5() var ys = xs.Where(x => true); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -97,10 +96,9 @@ public void Where6() var ys = xs.Where((x, i) => true); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } - [Fact] public async Task Where7() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index 66004338bd..e17b4aa407 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -71,7 +70,7 @@ public void Zip4() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -83,7 +82,7 @@ public void Zip5() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -95,7 +94,7 @@ public void Zip6() var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; }); var e = res.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] From b6d07f2348850181214a86cf5e0df568a0b7f1cb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 16:35:34 -0800 Subject: [PATCH 497/862] Remove another AssertThrows helper. --- .../System/Linq/AsyncEnumerableTests.cs | 6 ---- .../System/Linq/Operators/Count.cs | 28 +++++++++++++------ .../System/Linq/Operators/LongCount.cs | 28 +++++++++++++------ 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 28009017f1..98e7a907f5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -19,12 +19,6 @@ public class AsyncEnumerableTests protected const int WaitTimeoutMs = 5000; #pragma warning disable xUnit1013 // Public method should be marked as test - public void AssertThrows(Action a) - where E : Exception - { - Assert.Throws(a); - } - public void AssertThrows(Action a, Func assert) where E : Exception { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 962a41e9e2..4e658cd9b1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -26,19 +26,17 @@ public async Task Count_Null() } [Fact] - public void Count1() + public async Task Count1() { - Assert.Equal(0, new int[0].ToAsyncEnumerable().Count().Result); - Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count().Result); - AssertThrows(() => Throw(new Exception("Bang!")).Count().Wait(WaitTimeoutMs)); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().Count()); + Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().Count()); } [Fact] - public void Count2() + public async Task Count2() { - Assert.Equal(0, new int[0].ToAsyncEnumerable().Count(x => x < 3).Result); - Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3).Result); - AssertThrows(() => Throw(new Exception("Bang!")).Count(x => x < 3).Wait(WaitTimeoutMs)); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().Count(x => x < 3)); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3)); } [Fact] @@ -48,5 +46,19 @@ public void Count3() var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); AssertThrowsAsync(ys, ex); } + + [Fact] + public void Count4() + { + var ex = new Exception("Bang!"); + AssertThrowsAsync(Throw(ex).Count(), ex); + } + + [Fact] + public void Count5() + { + var ex = new Exception("Bang!"); + AssertThrowsAsync(Throw(ex).Count(x => x < 3), ex); + } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 920e4c31cd..9f36205b01 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -26,19 +26,17 @@ public async Task LongCount_Null() } [Fact] - public void LongCount1() + public async Task LongCount1() { - Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount().Result); - Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount().Result); - AssertThrows(() => Throw(new Exception("Bang!")).LongCount().Wait(WaitTimeoutMs)); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCount()); + Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount()); } [Fact] - public void LongCount2() + public async Task LongCount2() { - Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount(x => x < 3).Result); - Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3).Result); - AssertThrows(() => Throw(new Exception("Bang!")).LongCount(x => x < 3).Wait(WaitTimeoutMs)); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCount(x => x < 3)); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3)); } [Fact] @@ -48,5 +46,19 @@ public void LongCount3() var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); AssertThrowsAsync(ys, ex); } + + [Fact] + public void LongCount4() + { + var ex = new Exception("Bang!"); + AssertThrowsAsync(Throw(ex).LongCount(), ex); + } + + [Fact] + public void LongCount5() + { + var ex = new Exception("Bang!"); + AssertThrowsAsync(Throw(ex).LongCount(x => x < 3), ex); + } } } From b05e9154634fc1c5caff168523f4f1ecea11b8fe Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 17:52:52 -0800 Subject: [PATCH 498/862] Centralize the use of timeouts. --- .../System/Linq/AsyncEnumerableTests.cs | 9 +- .../System/Linq/Operators/Aggregate.cs | 22 ++-- .../System/Linq/Operators/All.cs | 8 +- .../System/Linq/Operators/Any.cs | 16 +-- .../System/Linq/Operators/Average.cs | 100 +++++++++--------- .../System/Linq/Operators/Contains.cs | 16 +-- .../System/Linq/Operators/ElementAt.cs | 14 +-- .../Linq/Operators/ElementAtOrDefault.cs | 24 ++--- .../System/Linq/Operators/First.cs | 22 ++-- .../System/Linq/Operators/FirstOrDefault.cs | 32 +++--- .../System/Linq/Operators/ForEachAsync.cs | 8 +- .../System/Linq/Operators/GroupBy.cs | 89 ++++++---------- .../System/Linq/Operators/Last.cs | 22 ++-- .../System/Linq/Operators/LastOrDefault.cs | 32 +++--- .../System/Linq/Operators/Max.cs | 66 ++++++------ .../System/Linq/Operators/Min.cs | 66 ++++++------ .../System/Linq/Operators/Select.cs | 4 +- .../System/Linq/Operators/SequenceEqual.cs | 46 ++++---- .../System/Linq/Operators/Single.cs | 24 ++--- .../System/Linq/Operators/SingleOrDefault.cs | 36 +++---- .../System/Linq/Operators/Sum.cs | 60 +++++------ .../System/Linq/Operators/Throw.cs | 6 +- .../System/Linq/Operators/ToArray.cs | 8 +- .../Linq/Operators/ToAsyncEnumerable.cs | 14 +-- .../System/Linq/Operators/ToDictionary.cs | 22 ++-- .../System/Linq/Operators/ToHashSet.cs | 4 +- .../System/Linq/Operators/ToList.cs | 8 +- .../System/Linq/Operators/ToLookup.cs | 36 +++---- 28 files changed, 396 insertions(+), 418 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 98e7a907f5..1ecc4f971e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -14,9 +14,9 @@ namespace Tests public class AsyncEnumerableTests { protected static readonly IAsyncEnumerable Return42 = new[] { 42 }.ToAsyncEnumerable(); - protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; + private static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; - protected const int WaitTimeoutMs = 5000; + private const int WaitTimeoutMs = 5000; #pragma warning disable xUnit1013 // Public method should be marked as test public void AssertThrows(Action a, Func assert) @@ -40,6 +40,11 @@ public void AssertThrows(Action a, Func assert) } } + public void AssertThrowsAsync(Task t) + { + AssertThrows(() => t.Wait(WaitTimeoutMs), ex => ex.Flatten().InnerExceptions.Single() is TException); + } + public void AssertThrowsAsync(Task t, Exception e) { AssertThrows(() => t.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(e)); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 67a14c6bfb..5a5a5de97c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -37,11 +37,11 @@ public async Task Aggregate_Null() } [Fact] - public void Aggregate1() + public async Task Aggregate1Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate((x, y) => x * y); - Assert.Equal(24, ys.Result); + Assert.Equal(24, await ys); } [Fact] @@ -49,7 +49,7 @@ public void Aggregate2() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.Aggregate((x, y) => x * y); - AssertThrows(() => ys.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(ys); } [Fact] @@ -71,19 +71,19 @@ public void Aggregate4() } [Fact] - public void Aggregate5() + public async Task Aggregate5Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y); - Assert.Equal(24, ys.Result); + Assert.Equal(24, await ys); } [Fact] - public void Aggregate6() + public async Task Aggregate6Async() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y); - Assert.Equal(1, ys.Result); + Assert.Equal(1, await ys); } [Fact] @@ -105,19 +105,19 @@ public void Aggregate8() } [Fact] - public void Aggregate9() + public async Task Aggregate9Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - Assert.Equal(25, ys.Result); + Assert.Equal(25, await ys); } [Fact] - public void Aggregate10() + public async Task Aggregate10Async() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - Assert.Equal(2, ys.Result); + Assert.Equal(2, await ys); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index c8661c2828..8e4415c9f0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -23,17 +23,17 @@ public async Task All_Null() } [Fact] - public void All1() + public async Task All1Async() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); - Assert.False(res.Result); + Assert.False(await res); } [Fact] - public void All2() + public async Task All2Async() { var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); - Assert.True(res.Result); + Assert.True(await res); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index b5e9a5be41..02cadb04b6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -25,17 +25,17 @@ public async Task Any_Null() } [Fact] - public void Any1() + public async Task Any1Async() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(x => x % 2 == 0); - Assert.True(res.Result); + Assert.True(await res); } [Fact] - public void Any2() + public async Task Any2Async() { var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(x => x % 2 != 0); - Assert.False(res.Result); + Assert.False(await res); } [Fact] @@ -55,17 +55,17 @@ public void Any4() } [Fact] - public void Any5() + public async Task Any5Async() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(); - Assert.True(res.Result); + Assert.True(await res); } [Fact] - public void Any6() + public async Task Any6Async() { var res = new int[0].ToAsyncEnumerable().Any(); - Assert.False(res.Result); + Assert.False(await res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs index 673a4da1e3..e6b29e8c69 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs @@ -84,173 +84,173 @@ public async Task Average_Null() } [Fact] - public void Average1() + public async Task Average1() { var xs = new[] { 1, 2, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average2() + public async Task Average2() { var xs = new[] { 1, default(int?), 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average3() + public async Task Average3() { var xs = new[] { 1L, 2L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average4() + public async Task Average4() { var xs = new[] { 1L, default(long?), 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average5() + public async Task Average5() { var xs = new[] { 1.0, 2.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average6() + public async Task Average6() { var xs = new[] { 1.0, default(double?), 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average7() + public async Task Average7() { var xs = new[] { 1.0f, 2.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average8() + public async Task Average8() { var xs = new[] { 1.0f, default(float?), 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average9() + public async Task Average9() { var xs = new[] { 1.0m, 2.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average10() + public async Task Average10() { var xs = new[] { 1.0m, default(decimal?), 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), ys.Average().Result); - Assert.Equal(xs.Average(), ys.Average(x => x).Result); + Assert.Equal(xs.Average(), await ys.Average()); + Assert.Equal(xs.Average(), await ys.Average(x => x)); } [Fact] - public void Average11() + public async Task Average11() { var xs = new int[0]; var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + await Assert.ThrowsAsync(() => ys.Average()); } [Fact] - public void Average12() + public async Task Average12() { var xs = new int?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); + Assert.Null(await ys.Average()); } [Fact] - public void Average13() + public async Task Average13() { var xs = new long[0]; var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + await Assert.ThrowsAsync(() => ys.Average()); } [Fact] - public void Average14() + public async Task Average14() { var xs = new long?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); + Assert.Null(await ys.Average()); } [Fact] - public void Average15() + public async Task Average15() { var xs = new double[0]; var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + await Assert.ThrowsAsync(() => ys.Average()); } [Fact] - public void Average16() + public async Task Average16() { var xs = new double?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); + Assert.Null(await ys.Average()); } [Fact] - public void Average17() + public async Task Average17() { var xs = new float[0]; var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + await Assert.ThrowsAsync(() => ys.Average()); } [Fact] - public void Average18() + public async Task Average18() { var xs = new float?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); + Assert.Null(await ys.Average()); } [Fact] - public void Average19() + public async Task Average19() { var xs = new decimal[0]; var ys = xs.ToAsyncEnumerable(); - AssertThrows(() => ys.Average().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + await Assert.ThrowsAsync(() => ys.Average()); } [Fact] - public void Average20() + public async Task Average20() { var xs = new decimal?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(ys.Average().Result); + Assert.Null(await ys.Average()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index 30a89c088b..ded6f8856f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -24,35 +24,35 @@ public async Task Contains_Null() } [Fact] - public void Contains1() + public async Task Contains1Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.Contains(3); - Assert.True(ys.Result); + Assert.True(await ys); } [Fact] - public void Contains2() + public async Task Contains2Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.Contains(6); - Assert.False(ys.Result); + Assert.False(await ys); } [Fact] - public void Contains3() + public async Task Contains3Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.Contains(-3, new Eq()); - Assert.True(ys.Result); + Assert.True(await ys); } [Fact] - public void Contains4() + public async Task Contains4Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.Contains(-6, new Eq()); - Assert.False(ys.Result); + Assert.False(await ys); } private sealed class Eq : IEqualityComparer diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index c164f0f396..8955c12792 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -27,35 +27,35 @@ public async Task ElementAt_Null() public void ElementAt1() { var res = AsyncEnumerable.Empty().ElementAt(0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); + AssertThrowsAsync(res); } [Fact] - public void ElementAt2() + public async Task ElementAt2Async() { var res = Return42.ElementAt(0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] public void ElementAt3() { var res = Return42.ElementAt(1); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); + AssertThrowsAsync(res); } [Fact] - public void ElementAt4() + public async Task ElementAt4Async() { var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(1); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] public void ElementAt5() { var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(7); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException); + AssertThrowsAsync(res); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index 0f57ab85df..b4c6e021a0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -21,45 +21,45 @@ public async Task ElementAtOrDefault_Null() } [Fact] - public void ElementAtOrDefault1() + public async Task ElementAtOrDefault1Async() { var res = AsyncEnumerable.Empty().ElementAtOrDefault(0); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void ElementAtOrDefault2() + public async Task ElementAtOrDefault2Async() { var res = Return42.ElementAtOrDefault(0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void ElementAtOrDefault3() + public async Task ElementAtOrDefault3Async() { var res = Return42.ElementAtOrDefault(1); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void ElementAtOrDefault4() + public async Task ElementAtOrDefault4Async() { var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(1); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void ElementAtOrDefault5() + public async Task ElementAtOrDefault5Async() { var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(7); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void ElementAtOrDefault6() + public async Task ElementAtOrDefault6Async() { var res = Return42.ElementAtOrDefault(-1); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index ab5630b243..a6441ac86e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -29,35 +29,35 @@ public async Task First_Null() public void First1() { var res = AsyncEnumerable.Empty().First(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] public void First2() { var res = AsyncEnumerable.Empty().First(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] public void First3() { var res = Return42.First(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] - public void First4() + public async Task First4Async() { var res = Return42.First(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void First5() + public async Task First5Async() { var res = Return42.First(x => x % 2 == 0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] @@ -77,17 +77,17 @@ public void First7() } [Fact] - public void First8() + public async Task First8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void First9() + public async Task First9Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(x => x % 2 != 0); - Assert.Equal(45, res.Result); + Assert.Equal(45, await res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 8a5ce641d4..8bbc83d0f1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -26,38 +26,38 @@ public async Task FirstOrDefault_Null() } [Fact] - public void FirstOrDefault1() + public async Task FirstOrDefault1Async() { var res = AsyncEnumerable.Empty().FirstOrDefault(); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void FirstOrDefault2() + public async Task FirstOrDefault2Async() { var res = AsyncEnumerable.Empty().FirstOrDefault(x => true); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void FirstOrDefault3() + public async Task FirstOrDefault3Async() { var res = Return42.FirstOrDefault(x => x % 2 != 0); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void FirstOrDefault4() + public async Task FirstOrDefault4Async() { var res = Return42.FirstOrDefault(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void FirstOrDefault5() + public async Task FirstOrDefault5Async() { var res = Return42.FirstOrDefault(x => x % 2 == 0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] @@ -77,24 +77,24 @@ public void FirstOrDefault7() } [Fact] - public void FirstOrDefault8() + public async Task FirstOrDefault8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void FirstOrDefault9() + public async Task FirstOrDefault9Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x % 2 != 0); - Assert.Equal(45, res.Result); + Assert.Equal(45, await res); } [Fact] - public void FirstOrDefault10() + public async Task FirstOrDefault10Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x < 10); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 677f6cd157..ef8ac8b05c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -28,22 +28,22 @@ public async Task ForEachAsync_Null() } [Fact] - public void ForEachAsync1() + public async Task ForEachAsync1() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - xs.ForEachAsync(x => sum += x).Wait(WaitTimeoutMs); + await xs.ForEachAsync(x => sum += x); Assert.Equal(10, sum); } [Fact] - public void ForEachAsync2() + public async Task ForEachAsync2() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - xs.ForEachAsync((x, i) => sum += x * i).Wait(WaitTimeoutMs); + await xs.ForEachAsync((x, i) => sum += x * i); Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index da8610ad54..3450af59e5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -67,7 +67,7 @@ public async Task GroupBy1() var e = res.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.Equal(2, e.Current.Key); var g1 = e.Current.GetAsyncEnumerator(); await HasNextAsync(g1, xs[0]); @@ -76,19 +76,19 @@ public async Task GroupBy1() await HasNextAsync(g1, xs[5]); await NoNextAsync(g1); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.Equal(6, e.Current.Key); var g2 = e.Current.GetAsyncEnumerator(); await HasNextAsync(g2, xs[1]); await NoNextAsync(g2); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.Equal(1, e.Current.Key); var g3 = e.Current.GetAsyncEnumerator(); await HasNextAsync(g3, xs[3]); await NoNextAsync(g3); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.Equal(4, e.Current.Key); var g4 = e.Current.GetAsyncEnumerator(); await HasNextAsync(g4, xs[6]); @@ -116,19 +116,19 @@ public async Task GroupBy2() var e = res.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g1 = e.Current; Assert.Equal(2, g1.Key); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g2 = e.Current; Assert.Equal(6, g2.Key); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g3 = e.Current; Assert.Equal(1, g3.Key); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g4 = e.Current; Assert.Equal(4, g4.Key); @@ -178,55 +178,32 @@ public void GroupBy4() [Fact] public void GroupBy5() { - var xs = GetXs().ToAsyncEnumerable(); + var ex = new Exception("Bang!"); + var xs = GetXs(ex).ToAsyncEnumerable(); var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - - //Assert.True(e.MoveNext().Result); - //var g1 = e.Current; - //Assert.Equal(g1.Key, 42); - //var g1e = g1.GetEnumerator(); - //await HasNextAsync(g1e, 42); - - //Assert.True(e.MoveNext().Result); - //var g2 = e.Current; - //Assert.Equal(g2.Key, 43); - //var g2e = g2.GetEnumerator(); - //await HasNextAsync(g2e, 43); - - - //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] public void GroupBy6() { - var xs = GetXs().ToAsyncEnumerable(); + var ex = new Exception("Bang!"); + var xs = GetXs(ex).ToAsyncEnumerable(); var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - - //Assert.True(e.MoveNext().Result); - //var g1 = e.Current; - //Assert.Equal(g1.Key, 42); - //var g1e = g1.GetEnumerator(); - //await HasNextAsync(g1e, 42); - //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); - - + AssertThrowsAsync(e.MoveNextAsync(), ex); } - private static IEnumerable GetXs() + private static IEnumerable GetXs(Exception ex) { yield return 42; yield return 43; - throw new Exception("Bang!"); + throw ex; } [Fact] @@ -251,13 +228,13 @@ public void GroupBy8() AssertThrowsAsync(e.MoveNextAsync(), ex); - //Assert.True(e.MoveNext().Result); + //Assert.True(await e.MoveNext()); //var g1 = e.Current; //Assert.Equal(g1.Key, 1); //var g1e = g1.GetEnumerator(); //await HasNextAsync(g1e, 1); - //Assert.True(e.MoveNext().Result); + //Assert.True(await e.MoveNext()); //var g2 = e.Current; //Assert.Equal(g2.Key, 2); //var g2e = g2.GetEnumerator(); @@ -276,7 +253,7 @@ public async Task GroupBy9() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -286,7 +263,7 @@ public async Task GroupBy9() await HasNextAsync(g1e, 'j'); await NoNextAsync(g1e); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -295,7 +272,7 @@ public async Task GroupBy9() await HasNextAsync(g2e, 'h'); await NoNextAsync(g2e); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -341,7 +318,7 @@ public async Task GroupBy12() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -351,7 +328,7 @@ public async Task GroupBy12() await HasNextAsync(g1e, 9); await NoNextAsync(g1e); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -360,7 +337,7 @@ public async Task GroupBy12() await HasNextAsync(g2e, 7); await NoNextAsync(g2e); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -380,7 +357,7 @@ public async Task GroupBy13() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -390,7 +367,7 @@ public async Task GroupBy13() await HasNextAsync(g1e, 'j'); await NoNextAsync(g1e); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -399,7 +376,7 @@ public async Task GroupBy13() await HasNextAsync(g2e, 'h'); await NoNextAsync(g2e); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -445,7 +422,7 @@ public async Task GroupBy16() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -456,7 +433,7 @@ public async Task GroupBy16() await NoNextAsync(g1e); await g1e.DisposeAsync(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g2 = e.Current; Assert.Equal(1, g2.Key); var g2e = g2.GetAsyncEnumerator(); @@ -466,7 +443,7 @@ public async Task GroupBy16() await NoNextAsync(g2e); await g2e.DisposeAsync(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g3 = e.Current; Assert.Equal(2, g3.Key); var g3e = g3.GetAsyncEnumerator(); @@ -490,7 +467,7 @@ public async Task GroupBy17() var e = ys.GetAsyncEnumerator(); await e.DisposeAsync(); - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } [Fact] @@ -501,7 +478,7 @@ public async Task GroupBy18() var e = ys.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); var g1 = e.Current; Assert.Equal(0, g1.Key); var g1e = g1.GetAsyncEnumerator(); @@ -515,7 +492,7 @@ public async Task GroupBy18() await NoNextAsync(g1e); await g1e.DisposeAsync(); - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 06bb41cea4..0431196304 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -29,35 +29,35 @@ public async Task Last_Null() public void Last1() { var res = AsyncEnumerable.Empty().Last(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] public void Last2() { var res = AsyncEnumerable.Empty().Last(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] public void Last3() { var res = Return42.Last(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] - public void Last4() + public async Task Last4Async() { var res = Return42.Last(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void Last5() + public async Task Last5Async() { var res = Return42.Last(x => x % 2 == 0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] @@ -77,17 +77,17 @@ public void Last7() } [Fact] - public void Last8() + public async Task Last8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Last(); - Assert.Equal(90, res.Result); + Assert.Equal(90, await res); } [Fact] - public void Last9() + public async Task Last9Async() { var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Last(x => x % 2 != 0); - Assert.Equal(45, res.Result); + Assert.Equal(45, await res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 7996f52b5d..f7506bdc06 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -26,38 +26,38 @@ public async Task LastOrDefault_Null() } [Fact] - public void LastOrDefault1() + public async Task LastOrDefault1Async() { var res = AsyncEnumerable.Empty().LastOrDefault(); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void LastOrDefault2() + public async Task LastOrDefault2Async() { var res = AsyncEnumerable.Empty().LastOrDefault(x => true); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void LastOrDefault3() + public async Task LastOrDefault3Async() { var res = Return42.LastOrDefault(x => x % 2 != 0); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void LastOrDefault4() + public async Task LastOrDefault4Async() { var res = Return42.LastOrDefault(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void LastOrDefault5() + public async Task LastOrDefault5Async() { var res = Return42.LastOrDefault(x => x % 2 == 0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] @@ -77,24 +77,24 @@ public void LastOrDefault7() } [Fact] - public void LastOrDefault8() + public async Task LastOrDefault8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(); - Assert.Equal(90, res.Result); + Assert.Equal(90, await res); } [Fact] - public void LastOrDefault9() + public async Task LastOrDefault9Async() { var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x % 2 != 0); - Assert.Equal(45, res.Result); + Assert.Equal(45, await res); } [Fact] - public void LastOrDefault10() + public async Task LastOrDefault10Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x < 10); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs index 6e05802dfd..e201d6a521 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -92,102 +92,102 @@ public async Task Max_Null() } [Fact] - public void Max1() + public async Task Max1Async() { var xs = new[] { 2, 7, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max2() + public async Task Max2Async() { var xs = new[] { 2, default(int?), 3, 1 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max3() + public async Task Max3Async() { var xs = new[] { 2L, 7L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max4() + public async Task Max4Async() { var xs = new[] { 2L, default(long?), 3L, 1L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max5() + public async Task Max5Async() { var xs = new[] { 2.0, 7.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max6() + public async Task Max6Async() { var xs = new[] { 2.0, default(double?), 3.0, 1.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max7() + public async Task Max7Async() { var xs = new[] { 2.0f, 7.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max8() + public async Task Max8Async() { var xs = new[] { 2.0f, default(float?), 3.0f, 1.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max9() + public async Task Max9Async() { var xs = new[] { 2.0m, 7.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max10() + public async Task Max10Async() { var xs = new[] { 2.0m, default(decimal?), 3.0m, 1.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } [Fact] - public void Max11() + public async Task Max11Async() { var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), ys.Max().Result); - Assert.Equal(xs.Max(), ys.Max(x => x).Result); + Assert.Equal(xs.Max(), await ys.Max()); + Assert.Equal(xs.Max(), await ys.Max(x => x)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs index 04c7c74fe8..9c08bb558a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -92,102 +92,102 @@ public async Task Min_Null() } [Fact] - public void Min1() + public async Task Min1Async() { var xs = new[] { 2, 1, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min2() + public async Task Min2Async() { var xs = new[] { 2, default(int?), 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min3() + public async Task Min3Async() { var xs = new[] { 2L, 1L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min4() + public async Task Min4Async() { var xs = new[] { 2L, default(long?), 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min5() + public async Task Min5Async() { var xs = new[] { 2.0, 1.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min6() + public async Task Min6Async() { var xs = new[] { 2.0, default(double?), 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min7() + public async Task Min7Async() { var xs = new[] { 2.0f, 1.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min8() + public async Task Min8Async() { var xs = new[] { 2.0f, default(float?), 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min9() + public async Task Min9Async() { var xs = new[] { 2.0m, 1.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min10() + public async Task Min10Async() { var xs = new[] { 2.0m, default(decimal?), 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } [Fact] - public void Min11() + public async Task Min11Async() { var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), ys.Min().Result); - Assert.Equal(xs.Min(), ys.Min(x => x).Result); + Assert.Equal(xs.Min(), await ys.Min()); + Assert.Equal(xs.Min(), await ys.Min(x => x)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index 2201b2a319..84c367d3af 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -54,7 +54,7 @@ public void Select3() var ys = xs.Select(x => 1 / x); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); + AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] @@ -64,7 +64,7 @@ public void Select4() var ys = xs.Select((x, i) => 1 / i); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is DivideByZeroException); + AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 35028062b0..003bae70ca 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -30,46 +30,46 @@ public async Task SequenceEqual_Null() } [Fact] - public void SequenceEqual1() + public async Task SequenceEqual1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(xs); - Assert.True(res.Result); + Assert.True(await res); } [Fact] - public void SequenceEqual2() + public async Task SequenceEqual2Async() { var xs = AsyncEnumerable.Empty(); var res = xs.SequenceEqual(xs); - Assert.True(res.Result); + Assert.True(await res); } [Fact] - public void SequenceEqual3() + public async Task SequenceEqual3Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); - Assert.False(res.Result); + Assert.False(await res); } [Fact] - public void SequenceEqual4() + public async Task SequenceEqual4Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); - Assert.False(res.Result); + Assert.False(await res); } [Fact] - public void SequenceEqual5() + public async Task SequenceEqual5Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); - Assert.False(res.Result); + Assert.False(await res); } [Fact] @@ -95,46 +95,46 @@ public void SequenceEqual7() } [Fact] - public void SequenceEqual8() + public async Task SequenceEqual8Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(xs, new Eq()); - Assert.True(res.Result); + Assert.True(await res); } [Fact] - public void SequenceEqual9() + public async Task SequenceEqual9Async() { var xs = AsyncEnumerable.Empty(); var res = xs.SequenceEqual(xs, new Eq()); - Assert.True(res.Result); + Assert.True(await res); } [Fact] - public void SequenceEqual10() + public async Task SequenceEqual10Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - Assert.False(res.Result); + Assert.False(await res); } [Fact] - public void SequenceEqual11() + public async Task SequenceEqual11Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - Assert.False(res.Result); + Assert.False(await res); } [Fact] - public void SequenceEqual12() + public async Task SequenceEqual12Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - Assert.False(res.Result); + Assert.False(await res); } [Fact] @@ -160,12 +160,12 @@ public void SequenceEqual14() } [Fact] - public void SequenceEqual15() + public async Task SequenceEqual15Async() { var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - Assert.True(res.Result); + Assert.True(await res); } [Fact] @@ -174,7 +174,7 @@ public void SequenceEqual16() var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new EqEx()); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + AssertThrowsAsync(res); } private sealed class EqEx : IEqualityComparer diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 921f590e1f..45f4982ef6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -29,35 +29,35 @@ public async Task Single_Null() public void Single1() { var res = AsyncEnumerable.Empty().Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] public void Single2() { var res = AsyncEnumerable.Empty().Single(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] public void Single3() { var res = Return42.Single(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] - public void Single4() + public async Task Single4Async() { var res = Return42.Single(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void Single5() + public async Task Single5Async() { var res = Return42.Single(x => x % 2 == 0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] @@ -80,28 +80,28 @@ public void Single7() public void Single8() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] - public void Single9() + public async Task Single9Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); - Assert.Equal(45, res.Result); + Assert.Equal(45, await res); } [Fact] public void Single10() { var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] public void Single11() { var res = new int[0].ToAsyncEnumerable().Single(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index d4b361a272..b5bbce56ca 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -26,38 +26,38 @@ public async Task SingleOrDefault_Null() } [Fact] - public void SingleOrDefault1() + public async Task SingleOrDefault1Async() { var res = AsyncEnumerable.Empty().SingleOrDefault(); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void SingleOrDefault2() + public async Task SingleOrDefault2Async() { var res = AsyncEnumerable.Empty().SingleOrDefault(x => true); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void SingleOrDefault3() + public async Task SingleOrDefault3Async() { var res = Return42.SingleOrDefault(x => x % 2 != 0); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] - public void SingleOrDefault4() + public async Task SingleOrDefault4Async() { var res = Return42.SingleOrDefault(); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] - public void SingleOrDefault5() + public async Task SingleOrDefault5Async() { var res = Return42.SingleOrDefault(x => x % 2 == 0); - Assert.Equal(42, res.Result); + Assert.Equal(42, await res); } [Fact] @@ -80,35 +80,35 @@ public void SingleOrDefault7() public void SingleOrDefault8() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] - public void SingleOrDefault9() + public async Task SingleOrDefault9Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x % 2 != 0); - Assert.Equal(45, res.Result); + Assert.Equal(45, await res); } [Fact] - public void SingleOrDefault10() + public async Task SingleOrDefault10Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x < 10); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } [Fact] public void SingleOrDefault11() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => true); - AssertThrows(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + AssertThrowsAsync(res); } [Fact] - public void SingleOrDefault12() + public async Task SingleOrDefault12Async() { var res = new int[0].ToAsyncEnumerable().SingleOrDefault(); - Assert.Equal(0, res.Result); + Assert.Equal(0, await res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs index a281b6044a..7e57b9116d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs @@ -84,93 +84,93 @@ public async Task Sum_Null() } [Fact] - public void Sum1() + public async Task Sum1Async() { var xs = new[] { 1, 2, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum2() + public async Task Sum2Async() { var xs = new[] { 1, default(int?), 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum3() + public async Task Sum3Async() { var xs = new[] { 1L, 2L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum4() + public async Task Sum4Async() { var xs = new[] { 1L, default(long?), 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum5() + public async Task Sum5Async() { var xs = new[] { 1.0, 2.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum6() + public async Task Sum6Async() { var xs = new[] { 1.0, default(double?), 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum7() + public async Task Sum7Async() { var xs = new[] { 1.0f, 2.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum8() + public async Task Sum8Async() { var xs = new[] { 1.0f, default(float?), 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum9() + public async Task Sum9Async() { var xs = new[] { 1.0m, 2.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } [Fact] - public void Sum10() + public async Task Sum10Async() { var xs = new[] { 1.0m, default(decimal?), 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), ys.Sum().Result); - Assert.Equal(xs.Sum(), ys.Sum(x => x).Result); + Assert.Equal(xs.Sum(), await ys.Sum()); + Assert.Equal(xs.Sum(), await ys.Sum(x => x)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index f0239cb002..0cdbdfae57 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -23,11 +23,7 @@ public void Throw1() var xs = Throw(ex); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); - } - - private void Nop(object o) - { + AssertThrowsAsync(e.MoveNextAsync(), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 9ac8e5934d..ded616236d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -21,19 +21,19 @@ public async Task ToArray_Null() } [Fact] - public void ToArray1() + public async Task ToArray1() { var xs = new[] { 42, 25, 39 }; var res = xs.ToAsyncEnumerable().ToArray(); - Assert.True(res.Result.SequenceEqual(xs)); + Assert.True((await res).SequenceEqual(xs)); } [Fact] - public void ToArray2() + public async Task ToArray2() { var xs = AsyncEnumerable.Empty(); var res = xs.ToArray(); - Assert.True(res.Result.Length == 0); + Assert.True((await res).Length == 0); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index d37dcf7088..1ee9b59e46 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -39,7 +39,7 @@ public async Task ToAsyncEnumerable2Async() var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); await HasNextAsync(e, 42); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrowsAsync(e.MoveNextAsync(), ex); } private IEnumerable ToAsyncEnumerable_Sequence(Exception e) @@ -94,7 +94,7 @@ public void ToAsyncEnumerable4() Assert.True(subscribed); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -223,16 +223,16 @@ public void ToAsyncEnumerable12() } [Fact] - public void ToAsyncEnumerable_With_Completed_Task() + public async Task ToAsyncEnumerable_With_Completed_TaskAsync() { var task = Task.Factory.StartNew(() => 36); var xs = task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.Equal(36, e.Current); - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } [Fact] @@ -245,7 +245,7 @@ public void ToAsyncEnumerable_With_Faulted_Task() var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -257,7 +257,7 @@ public void ToAsyncEnumerable_With_Canceled_Task() var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() is TaskCanceledException); + AssertThrowsAsync(e.MoveNextAsync().AsTask()); } private sealed class MyObservable : IObservable diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index 8f86667ad8..5c898d6144 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -46,10 +46,10 @@ public async Task ToDictionary_Null() } [Fact] - public void ToDictionary1() + public async Task ToDictionary1Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2).Result; + var res = await xs.ToDictionary(x => x % 2); Assert.True(res[0] == 4); Assert.True(res[1] == 1); } @@ -58,14 +58,14 @@ public void ToDictionary1() public void ToDictionary2() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ToDictionary(x => x % 2).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); + AssertThrowsAsync(xs.ToDictionary(x => x % 2)); } [Fact] - public void ToDictionary3() + public async Task ToDictionary3Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2, x => x + 1).Result; + var res = await xs.ToDictionary(x => x % 2, x => x + 1); Assert.True(res[0] == 5); Assert.True(res[1] == 2); } @@ -74,14 +74,14 @@ public void ToDictionary3() public void ToDictionary4() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ToDictionary(x => x % 2, x => x + 1).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); + AssertThrowsAsync(xs.ToDictionary(x => x % 2, x => x + 1)); } [Fact] - public void ToDictionary5() + public async Task ToDictionary5Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2, new Eq()).Result; + var res = await xs.ToDictionary(x => x % 2, new Eq()); Assert.True(res[0] == 4); Assert.True(res[1] == 1); } @@ -90,14 +90,14 @@ public void ToDictionary5() public void ToDictionary6() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrows(() => xs.ToDictionary(x => x % 2, new Eq()).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentException); + AssertThrowsAsync(xs.ToDictionary(x => x % 2, new Eq())); } [Fact] - public void ToDictionary7() + public async Task ToDictionary7Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToDictionary(x => x % 2, x => x, new Eq()).Result; + var res = await xs.ToDictionary(x => x % 2, x => x, new Eq()); Assert.True(res[0] == 4); Assert.True(res[1] == 1); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index 775c38d46c..12950c9a93 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -23,11 +23,11 @@ public async Task ToHashSet_Null() } [Fact] - public void ToHashSet1() + public async Task ToHashSet1() { var xs = new[] { 1, 2, 1, 2, 3, 4, 1, 2, 3, 4 }; var res = xs.ToAsyncEnumerable().ToHashSet(); - Assert.True(res.Result.OrderBy(x => x).SequenceEqual(new[] { 1, 2, 3, 4 })); + Assert.True((await res).OrderBy(x => x).SequenceEqual(new[] { 1, 2, 3, 4 })); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index 01d3de4b55..a9f80daf9e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -21,19 +21,19 @@ public async Task ToList_Null() } [Fact] - public void ToList1() + public async Task ToList1() { var xs = new[] { 42, 25, 39 }; var res = xs.ToAsyncEnumerable().ToList(); - Assert.True(res.Result.SequenceEqual(xs)); + Assert.True((await res).SequenceEqual(xs)); } [Fact] - public void ToList2() + public async Task ToList2() { var xs = AsyncEnumerable.Empty(); var res = xs.ToList(); - Assert.True(res.Result.Count == 0); + Assert.True((await res).Count == 0); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index ec8ae2bd33..13e0f4befc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -47,10 +47,10 @@ public async Task ToLookup_Null() } [Fact] - public void ToLookup1() + public async Task ToLookup1Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; + var res = await xs.ToLookup(x => x % 2); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -59,10 +59,10 @@ public void ToLookup1() } [Fact] - public void ToLookup2() + public async Task ToLookup2Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; + var res = await xs.ToLookup(x => x % 2); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -72,10 +72,10 @@ public void ToLookup2() } [Fact] - public void ToLookup3() + public async Task ToLookup3Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, x => x + 1).Result; + var res = await xs.ToLookup(x => x % 2, x => x + 1); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(5, res[0]); @@ -84,10 +84,10 @@ public void ToLookup3() } [Fact] - public void ToLookup4() + public async Task ToLookup4Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, x => x + 1).Result; + var res = await xs.ToLookup(x => x % 2, x => x + 1); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(5, res[0]); @@ -97,10 +97,10 @@ public void ToLookup4() } [Fact] - public void ToLookup5() + public async Task ToLookup5Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, new Eq()).Result; + var res = await xs.ToLookup(x => x % 2, new Eq()); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -109,10 +109,10 @@ public void ToLookup5() } [Fact] - public void ToLookup6() + public async Task ToLookup6Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, new Eq()).Result; + var res = await xs.ToLookup(x => x % 2, new Eq()); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -122,19 +122,19 @@ public void ToLookup6() } [Fact] - public void ToLookup7() + public async Task ToLookup7Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; + var res = await xs.ToLookup(x => x % 2); foreach (var g in res) Assert.True(g.Key == 0 || g.Key == 1); } [Fact] - public void ToLookup8() + public async Task ToLookup8Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2).Result; + var res = await xs.ToLookup(x => x % 2); #pragma warning disable IDE0007 // Use implicit type foreach (IGrouping g in (IEnumerable)res) Assert.True(g.Key == 0 || g.Key == 1); @@ -142,10 +142,10 @@ public void ToLookup8() } [Fact] - public void ToLookup9() + public async Task ToLookup9Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = xs.ToLookup(x => x % 2, x => x, new Eq()).Result; + var res = await xs.ToLookup(x => x % 2, x => x, new Eq()); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); From af2829e5a438e3b3c80add9e5a9996380689d1e4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 17:58:58 -0800 Subject: [PATCH 499/862] Minor test fixes. --- .../System/Linq/AsyncEnumerableTests.cs | 54 +++++++++---------- .../System/Linq/Operators/GroupBy.cs | 16 ------ .../ValueTaskHelpers.cs | 2 - 3 files changed, 24 insertions(+), 48 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 1ecc4f971e..93f17f760c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -19,27 +19,6 @@ public class AsyncEnumerableTests private const int WaitTimeoutMs = 5000; #pragma warning disable xUnit1013 // Public method should be marked as test - public void AssertThrows(Action a, Func assert) - where E : Exception - { - var hasFailed = false; - - try - { - a(); - } - catch (E e) - { - Assert.True(assert(e)); - hasFailed = true; - } - - if (!hasFailed) - { - Assert.True(false); - } - } - public void AssertThrowsAsync(Task t) { AssertThrows(() => t.Wait(WaitTimeoutMs), ex => ex.Flatten().InnerExceptions.Single() is TException); @@ -76,16 +55,10 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) await en1.DisposeAsync(); await en2.DisposeAsync(); - var e1t = enumerable.ToList(); - var e2t = enumerable.ToList(); - - await Task.WhenAll(e1t, e2t); - + var res1 = await enumerable.ToList(); + var res2 = await enumerable.ToList(); - var e1Result = e1t.Result; - var e2Result = e2t.Result; - - e1Result.ShouldAllBeEquivalentTo(e2Result); + res1.ShouldAllBeEquivalentTo(res2); } #pragma warning restore xUnit1013 // Public method should be marked as test @@ -109,5 +82,26 @@ protected static IAsyncEnumerable Throw(Exception exception) dispose: null) ); } + + private void AssertThrows(Action a, Func assert) + where E : Exception + { + var hasFailed = false; + + try + { + a(); + } + catch (E e) + { + Assert.True(assert(e)); + hasFailed = true; + } + + if (!hasFailed) + { + Assert.True(false); + } + } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 3450af59e5..253db16e8e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -227,22 +227,6 @@ public void GroupBy8() var e = ys.GetAsyncEnumerator(); AssertThrowsAsync(e.MoveNextAsync(), ex); - - //Assert.True(await e.MoveNext()); - //var g1 = e.Current; - //Assert.Equal(g1.Key, 1); - //var g1e = g1.GetEnumerator(); - //await HasNextAsync(g1e, 1); - - //Assert.True(await e.MoveNext()); - //var g2 = e.Current; - //Assert.Equal(g2.Key, 2); - //var g2e = g2.GetEnumerator(); - //await HasNextAsync(g2e, 2); - - - //AssertThrows(() => g1e.MoveNext().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); - //AssertThrows(() => g2e.MoveNext().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs b/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs index 5726bc09e6..45bb73371b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/ValueTaskHelpers.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; using Xunit.Sdk; From 934fcd563c0025876635b9234498a31ef59c610a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 18:04:52 -0800 Subject: [PATCH 500/862] Making more tests async. --- .../System/Linq/AsyncEnumerableTests.cs | 29 ++++++++++------- .../System/Linq/Operators/Aggregate.cs | 32 +++++++++---------- .../System/Linq/Operators/All.cs | 8 ++--- .../System/Linq/Operators/Any.cs | 8 ++--- .../System/Linq/Operators/Concat.cs | 6 ++-- .../System/Linq/Operators/Count.cs | 12 +++---- .../System/Linq/Operators/DefaultIfEmpty.cs | 8 ++--- .../System/Linq/Operators/ElementAt.cs | 16 +++++----- .../Linq/Operators/ElementAtOrDefault.cs | 4 +-- .../System/Linq/Operators/First.cs | 20 ++++++------ .../System/Linq/Operators/FirstOrDefault.cs | 8 ++--- .../System/Linq/Operators/ForEachAsync.cs | 16 +++++----- .../System/Linq/Operators/GroupBy.cs | 20 ++++++------ .../System/Linq/Operators/GroupJoin.cs | 18 +++++------ .../System/Linq/Operators/Join.cs | 20 ++++++------ .../System/Linq/Operators/Last.cs | 20 ++++++------ .../System/Linq/Operators/LastOrDefault.cs | 8 ++--- .../System/Linq/Operators/LongCount.cs | 12 +++---- .../System/Linq/Operators/OrderBy.cs | 16 +++++----- .../System/Linq/Operators/Reverse.cs | 4 +-- .../System/Linq/Operators/Select.cs | 8 ++--- .../System/Linq/Operators/SelectMany.cs | 20 ++++++------ .../System/Linq/Operators/SequenceEqual.cs | 20 ++++++------ .../System/Linq/Operators/Single.cs | 32 +++++++++---------- .../System/Linq/Operators/SingleOrDefault.cs | 16 +++++----- .../System/Linq/Operators/Skip.cs | 4 +-- .../System/Linq/Operators/SkipWhile.cs | 8 ++--- .../System/Linq/Operators/Take.cs | 4 +-- .../System/Linq/Operators/TakeWhile.cs | 8 ++--- .../System/Linq/Operators/Throw.cs | 4 +-- .../System/Linq/Operators/ToArray.cs | 4 +-- .../Linq/Operators/ToAsyncEnumerable.cs | 14 ++++---- .../System/Linq/Operators/ToDictionary.cs | 12 +++---- .../System/Linq/Operators/ToList.cs | 4 +-- .../System/Linq/Operators/Where.cs | 12 +++---- .../System/Linq/Operators/Zip.cs | 12 +++---- 36 files changed, 236 insertions(+), 231 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 93f17f760c..f8fe5100b8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -14,38 +14,44 @@ namespace Tests public class AsyncEnumerableTests { protected static readonly IAsyncEnumerable Return42 = new[] { 42 }.ToAsyncEnumerable(); - private static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; private const int WaitTimeoutMs = 5000; -#pragma warning disable xUnit1013 // Public method should be marked as test - public void AssertThrowsAsync(Task t) + protected async Task AssertThrowsAsync(Task t) + where TException : Exception { - AssertThrows(() => t.Wait(WaitTimeoutMs), ex => ex.Flatten().InnerExceptions.Single() is TException); + await Assert.ThrowsAsync(() => t); } - public void AssertThrowsAsync(Task t, Exception e) + protected async Task AssertThrowsAsync(Task t, Exception e) { - AssertThrows(() => t.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(e)); + try + { + await t; + } + catch (Exception ex) + { + Assert.Same(e, ex); + } } - public void AssertThrowsAsync(ValueTask t, Exception e) + protected Task AssertThrowsAsync(ValueTask t, Exception e) { - AssertThrows(() => t.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(e)); + return AssertThrowsAsync(t.AsTask(), e); } - public async Task NoNextAsync(IAsyncEnumerator e) + protected async Task NoNextAsync(IAsyncEnumerator e) { Assert.False(await e.MoveNextAsync()); } - public async Task HasNextAsync(IAsyncEnumerator e, T value) + protected async Task HasNextAsync(IAsyncEnumerator e, T value) { Assert.True(await e.MoveNextAsync()); Assert.Equal(value, e.Current); } - public async Task SequenceIdentity(IAsyncEnumerable enumerable) + protected async Task SequenceIdentity(IAsyncEnumerable enumerable) { var en1 = enumerable.GetAsyncEnumerator(); var en2 = enumerable.GetAsyncEnumerator(); @@ -60,7 +66,6 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) res1.ShouldAllBeEquivalentTo(res2); } -#pragma warning restore xUnit1013 // Public method should be marked as test protected static IAsyncEnumerable Throw(Exception exception) { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 5a5a5de97c..ce7d4a9967 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -45,29 +45,29 @@ public async Task Aggregate1Async() } [Fact] - public void Aggregate2() + public async Task Aggregate2Async() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.Aggregate((x, y) => x * y); - AssertThrowsAsync(ys); + await AssertThrowsAsync(ys); } [Fact] - public void Aggregate3() + public async Task Aggregate3Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate((x, y) => x * y); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] - public void Aggregate4() + public async Task Aggregate4Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] @@ -87,21 +87,21 @@ public async Task Aggregate6Async() } [Fact] - public void Aggregate7() + public async Task Aggregate7Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] - public void Aggregate8() + public async Task Aggregate8Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] @@ -121,30 +121,30 @@ public async Task Aggregate10Async() } [Fact] - public void Aggregate11() + public async Task Aggregate11Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] - public void Aggregate12() + public async Task Aggregate12Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => { throw ex; }, x => x + 1); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] - public void Aggregate13() + public async Task Aggregate13Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Aggregate(1, (x, y) => x * y, x => { throw ex; }); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 8e4415c9f0..02cee9be08 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -37,19 +37,19 @@ public async Task All2Async() } [Fact] - public void All3() + public async Task All3Async() { var ex = new Exception("Bang!"); var res = Throw(ex).All(x => x % 2 == 0); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void All4() + public async Task All4Async() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 02cadb04b6..ec33b34f3a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -39,19 +39,19 @@ public async Task Any2Async() } [Fact] - public void Any3() + public async Task Any3Async() { var ex = new Exception("Bang!"); var res = Throw(ex).Any(x => x % 2 == 0); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void Any4() + public async Task Any4Async() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 0d1f30de26..7c08a2a5e7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -44,17 +44,17 @@ public async Task Concat2Async() await HasNextAsync(e, 1); await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Concat3() + public async Task Concat3Async() { var ex = new Exception("Bang"); var ys = Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 4e658cd9b1..8ff9c4a801 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -40,25 +40,25 @@ public async Task Count2() } [Fact] - public void Count3() + public async Task Count3Async() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] - public void Count4() + public async Task Count4Async() { var ex = new Exception("Bang!"); - AssertThrowsAsync(Throw(ex).Count(), ex); + await AssertThrowsAsync(Throw(ex).Count(), ex); } [Fact] - public void Count5() + public async Task Count5Async() { var ex = new Exception("Bang!"); - AssertThrowsAsync(Throw(ex).Count(x => x < 3), ex); + await AssertThrowsAsync(Throw(ex).Count(x => x < 3), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index 0ec7a112e6..9c1264d282 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -86,23 +86,23 @@ public async Task DefaultIfEmpty6() } [Fact] - public void DefaultIfEmpty7() + public async Task DefaultIfEmpty7Async() { var ex = new Exception("Bang!"); var xs = Throw(ex).DefaultIfEmpty(); var e = xs.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void DefaultIfEmpty8() + public async Task DefaultIfEmpty8Async() { var ex = new Exception("Bang!"); var xs = Throw(ex).DefaultIfEmpty(24); var e = xs.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index 8955c12792..7fb1511689 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -24,10 +24,10 @@ public async Task ElementAt_Null() } [Fact] - public void ElementAt1() + public async Task ElementAt1Async() { var res = AsyncEnumerable.Empty().ElementAt(0); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] @@ -38,10 +38,10 @@ public async Task ElementAt2Async() } [Fact] - public void ElementAt3() + public async Task ElementAt3Async() { var res = Return42.ElementAt(1); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] @@ -52,18 +52,18 @@ public async Task ElementAt4Async() } [Fact] - public void ElementAt5() + public async Task ElementAt5Async() { var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(7); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void ElementAt6() + public async Task ElementAt6Async() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAt(15); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index b4c6e021a0..f9591ee10a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -63,11 +63,11 @@ public async Task ElementAtOrDefault6Async() } [Fact] - public void ElementAtOrDefault7() + public async Task ElementAtOrDefault7Async() { var ex = new Exception("Bang!"); var res = Throw(ex).ElementAtOrDefault(15); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index a6441ac86e..949a7d4db2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -26,24 +26,24 @@ public async Task First_Null() } [Fact] - public void First1() + public async Task First1Async() { var res = AsyncEnumerable.Empty().First(); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void First2() + public async Task First2Async() { var res = AsyncEnumerable.Empty().First(x => true); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void First3() + public async Task First3Async() { var res = Return42.First(x => x % 2 != 0); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] @@ -61,19 +61,19 @@ public async Task First5Async() } [Fact] - public void First6() + public async Task First6Async() { var ex = new Exception("Bang!"); var res = Throw(ex).First(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void First7() + public async Task First7Async() { var ex = new Exception("Bang!"); var res = Throw(ex).First(x => true); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 8bbc83d0f1..fce4cd50c4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -61,19 +61,19 @@ public async Task FirstOrDefault5Async() } [Fact] - public void FirstOrDefault6() + public async Task FirstOrDefault6Async() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void FirstOrDefault7() + public async Task FirstOrDefault7Async() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefault(x => true); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index ef8ac8b05c..77666650af 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -48,39 +48,39 @@ public async Task ForEachAsync2() } [Fact] - public void ForEachAsync3() + public async Task ForEachAsync3Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrowsAsync(xs.ForEachAsync(x => { throw ex; }), ex); + await AssertThrowsAsync(xs.ForEachAsync(x => { throw ex; }), ex); } [Fact] - public void ForEachAsync4() + public async Task ForEachAsync4Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - AssertThrowsAsync(xs.ForEachAsync((x, i) => { throw ex; }), ex); + await AssertThrowsAsync(xs.ForEachAsync((x, i) => { throw ex; }), ex); } [Fact] - public void ForEachAsync5() + public async Task ForEachAsync5Async() { var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrowsAsync(xs.ForEachAsync(x => { throw ex; }), ex); + await AssertThrowsAsync(xs.ForEachAsync(x => { throw ex; }), ex); } [Fact] - public void ForEachAsync6() + public async Task ForEachAsync6Async() { var ex = new Exception("Bang"); var xs = Throw(ex); - AssertThrowsAsync(xs.ForEachAsync((x, i) => { throw ex; }), ex); + await AssertThrowsAsync(xs.ForEachAsync((x, i) => { throw ex; }), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 253db16e8e..4246ee0a4e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -165,18 +165,18 @@ public async Task GroupBy3() } [Fact] - public void GroupBy4() + public async Task GroupBy4Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.GroupBy(x => x); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void GroupBy5() + public async Task GroupBy5Async() { var ex = new Exception("Bang!"); var xs = GetXs(ex).ToAsyncEnumerable(); @@ -184,11 +184,11 @@ public void GroupBy5() var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void GroupBy6() + public async Task GroupBy6Async() { var ex = new Exception("Bang!"); var xs = GetXs(ex).ToAsyncEnumerable(); @@ -196,7 +196,7 @@ public void GroupBy6() var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } private static IEnumerable GetXs(Exception ex) @@ -207,18 +207,18 @@ private static IEnumerable GetXs(Exception ex) } [Fact] - public void GroupBy7() + public async Task GroupBy7Async() { var ex = new Exception("Bang!"); var xs = Return42; var ys = xs.GroupBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void GroupBy8() + public async Task GroupBy8Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -226,7 +226,7 @@ public void GroupBy8() var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index f4398fe400..9a50170ff8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -59,7 +59,7 @@ public async Task GroupJoin2() } [Fact] - public void GroupJoin3() + public async Task GroupJoin3Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -68,11 +68,11 @@ public void GroupJoin3() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void GroupJoin4() + public async Task GroupJoin4Async() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -81,11 +81,11 @@ public void GroupJoin4() var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void GroupJoin5() + public async Task GroupJoin5Async() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -94,11 +94,11 @@ public void GroupJoin5() var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void GroupJoin6() + public async Task GroupJoin6Async() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -107,7 +107,7 @@ public void GroupJoin6() var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -126,7 +126,7 @@ public async Task GroupJoin7() var e = res.GetAsyncEnumerator(); await HasNextAsync(e, "0 - 36"); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs index 95b50376e7..affd94d1c7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Join.cs @@ -87,7 +87,7 @@ public async Task Join4() } [Fact] - public void Join5() + public async Task Join5Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -96,11 +96,11 @@ public void Join5() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Join6() + public async Task Join6Async() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -109,11 +109,11 @@ public void Join6() var res = xs.Join(ys, x => x % 3, y => y % 3, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Join7() + public async Task Join7Async() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -122,11 +122,11 @@ public void Join7() var res = xs.Join(ys, x => { throw ex; }, y => y, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Join8() + public async Task Join8Async() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -135,11 +135,11 @@ public void Join8() var res = xs.Join(ys, x => x, y => { throw ex; }, (x, y) => x + y); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Join9() + public async Task Join9Async() { var ex = new Exception("Bang!"); var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); @@ -148,7 +148,7 @@ public void Join9() var res = xs.Join(ys, x => x, y => y, (x, y) => { throw ex; }); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 0431196304..0d39e3809c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -26,24 +26,24 @@ public async Task Last_Null() } [Fact] - public void Last1() + public async Task Last1Async() { var res = AsyncEnumerable.Empty().Last(); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void Last2() + public async Task Last2Async() { var res = AsyncEnumerable.Empty().Last(x => true); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void Last3() + public async Task Last3Async() { var res = Return42.Last(x => x % 2 != 0); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] @@ -61,19 +61,19 @@ public async Task Last5Async() } [Fact] - public void Last6() + public async Task Last6Async() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void Last7() + public async Task Last7Async() { var ex = new Exception("Bang!"); var res = Throw(ex).Last(x => true); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index f7506bdc06..092f9d6d0b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -61,19 +61,19 @@ public async Task LastOrDefault5Async() } [Fact] - public void LastOrDefault6() + public async Task LastOrDefault6Async() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void LastOrDefault7() + public async Task LastOrDefault7Async() { var ex = new Exception("Bang!"); var res = Throw(ex).LastOrDefault(x => true); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 9f36205b01..8e82b6fcac 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -40,25 +40,25 @@ public async Task LongCount2() } [Fact] - public void LongCount3() + public async Task LongCount3Async() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); - AssertThrowsAsync(ys, ex); + await AssertThrowsAsync(ys, ex); } [Fact] - public void LongCount4() + public async Task LongCount4Async() { var ex = new Exception("Bang!"); - AssertThrowsAsync(Throw(ex).LongCount(), ex); + await AssertThrowsAsync(Throw(ex).LongCount(), ex); } [Fact] - public void LongCount5() + public async Task LongCount5Async() { var ex = new Exception("Bang!"); - AssertThrowsAsync(Throw(ex).LongCount(x => x < 3), ex); + await AssertThrowsAsync(Throw(ex).LongCount(x => x < 3), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index 582424be6e..5e54413f89 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -55,14 +55,14 @@ public async Task OrderBy1() } [Fact] - public void OrderBy2() + public async Task OrderBy2Async() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -75,14 +75,14 @@ public async Task OrderBy3() } [Fact] - public void ThenBy2() + public async Task ThenBy2Async() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(x => x).ThenBy(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -98,14 +98,14 @@ public async Task OrderByDescending1() } [Fact] - public void OrderByDescending2() + public async Task OrderByDescending2Async() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -118,14 +118,14 @@ public async Task OrderByDescending3() } [Fact] - public void ThenByDescending2() + public async Task ThenByDescending2Async() { var ex = new Exception("Bang!"); var xs = new[] { 2, 6, 1, 5, 7, 8, 9, 3, 4, 0 }.ToAsyncEnumerable(); var ys = xs.OrderBy(x => x).ThenByDescending(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index 48c77b2ee5..96665a7975 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -53,14 +53,14 @@ public async Task Reverse3Async() } [Fact] - public void Reverse4() + public async Task Reverse4Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = xs.Reverse(); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index 84c367d3af..21d1d0d4c5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -48,23 +48,23 @@ public async Task Select2() } [Fact] - public void Select3() + public async Task Select3Async() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(x => 1 / x); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync().AsTask()); + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public void Select4() + public async Task Select4Async() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); var ys = xs.Select((x, i) => 1 / i); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync().AsTask()); + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs index 76ccf800ea..7502951ce7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -61,18 +61,18 @@ public async Task SelectMany2Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void SelectMany3() + public async Task SelectMany3Async() { var ex = new Exception("Bang"); var xs = Throw(ex); var ys = xs.SelectMany(x => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -92,7 +92,7 @@ public async Task SelectMany4Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -128,18 +128,18 @@ public async Task SelectMany6Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void SelectMany7() + public async Task SelectMany7Async() { var ex = new Exception("Bang"); var xs = Throw(ex); var ys = xs.SelectMany((x, i) => Enumerable.Range(0, x).ToAsyncEnumerable()); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -159,7 +159,7 @@ public async Task SelectMany8Async() await HasNextAsync(e, 0); await HasNextAsync(e, 0); await HasNextAsync(e, 1); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -211,7 +211,7 @@ public async Task SelectMany11Async() await HasNextAsync(e, 6); await HasNextAsync(e, 8); await HasNextAsync(e, 9); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -230,7 +230,7 @@ public async Task SelectMany12Async() await HasNextAsync(e, 3); await HasNextAsync(e, 8); await HasNextAsync(e, 10); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 003bae70ca..e572984bc6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -73,25 +73,25 @@ public async Task SequenceEqual5Async() } [Fact] - public void SequenceEqual6() + public async Task SequenceEqual6Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = Throw(ex); var res = xs.SequenceEqual(ys); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void SequenceEqual7() + public async Task SequenceEqual7Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] @@ -138,25 +138,25 @@ public async Task SequenceEqual12Async() } [Fact] - public void SequenceEqual13() + public async Task SequenceEqual13Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = Throw(ex); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void SequenceEqual14() + public async Task SequenceEqual14Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new Eq()); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] @@ -169,12 +169,12 @@ public async Task SequenceEqual15Async() } [Fact] - public void SequenceEqual16() + public async Task SequenceEqual16Async() { var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); var res = xs.SequenceEqual(ys, new EqEx()); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } private sealed class EqEx : IEqualityComparer diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 45f4982ef6..3b8a969f37 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -26,24 +26,24 @@ public async Task Single_Null() } [Fact] - public void Single1() + public async Task Single1Async() { var res = AsyncEnumerable.Empty().Single(); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void Single2() + public async Task Single2Async() { var res = AsyncEnumerable.Empty().Single(x => true); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void Single3() + public async Task Single3Async() { var res = Return42.Single(x => x % 2 != 0); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] @@ -61,26 +61,26 @@ public async Task Single5Async() } [Fact] - public void Single6() + public async Task Single6Async() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void Single7() + public async Task Single7Async() { var ex = new Exception("Bang!"); var res = Throw(ex).Single(x => true); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void Single8() + public async Task Single8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] @@ -91,17 +91,17 @@ public async Task Single9Async() } [Fact] - public void Single10() + public async Task Single10Async() { var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] - public void Single11() + public async Task Single11Async() { var res = new int[0].ToAsyncEnumerable().Single(); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index b5bbce56ca..51e73bdd2f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -61,26 +61,26 @@ public async Task SingleOrDefault5Async() } [Fact] - public void SingleOrDefault6() + public async Task SingleOrDefault6Async() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void SingleOrDefault7() + public async Task SingleOrDefault7Async() { var ex = new Exception("Bang!"); var res = Throw(ex).SingleOrDefault(x => true); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] - public void SingleOrDefault8() + public async Task SingleOrDefault8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] @@ -98,10 +98,10 @@ public async Task SingleOrDefault10Async() } [Fact] - public void SingleOrDefault11() + public async Task SingleOrDefault11Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => true); - AssertThrowsAsync(res); + await AssertThrowsAsync(res); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index a566cce587..b475ab548b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -65,14 +65,14 @@ public async Task Skip3() } [Fact] - public void Skip4() + public async Task Skip4Async() { var ex = new Exception("Bang"); var xs = Throw(ex); var ys = xs.Skip(2); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index b229edab35..b6e52fc06e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -73,14 +73,14 @@ public async Task SkipWhile4Async() } [Fact] - public void SkipWhile5() + public async Task SkipWhile5Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -120,14 +120,14 @@ public async Task SkipWhile8Async() } [Fact] - public void SkipWhile9() + public async Task SkipWhile9Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index 8cc22b4453..e3e2bc4741 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -65,14 +65,14 @@ public async Task Take3Async() } [Fact] - public void Take4() + public async Task Take4Async() { var ex = new Exception("Bang"); var xs = Throw(ex); var ys = xs.Take(2); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index 26daf59d12..f10cf34a28 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -70,14 +70,14 @@ public async Task TakeWhile4Async() } [Fact] - public void TakeWhile5() + public async Task TakeWhile5Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(new Func(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -117,14 +117,14 @@ public async Task TakeWhile8Async() } [Fact] - public void TakeWhile9() + public async Task TakeWhile9Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(new Func((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index 0cdbdfae57..a57655157a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -17,13 +17,13 @@ public void Throw_Null() } [Fact] - public void Throw1() + public async System.Threading.Tasks.Task Throw1Async() { var ex = new Exception("Bang"); var xs = Throw(ex); var e = xs.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index ded616236d..907ebc12f7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -37,11 +37,11 @@ public async Task ToArray2() } [Fact] - public void ToArray3() + public async Task ToArray3Async() { var ex = new Exception("Bang!"); var res = Throw(ex).ToArray(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index 1ee9b59e46..379514096c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -39,7 +39,7 @@ public async Task ToAsyncEnumerable2Async() var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); await HasNextAsync(e, 42); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } private IEnumerable ToAsyncEnumerable_Sequence(Exception e) @@ -74,7 +74,7 @@ public async Task ToAsyncEnumerable3Async() } [Fact] - public void ToAsyncEnumerable4() + public async Task ToAsyncEnumerable4Async() { var ex = new Exception("Bang!"); var subscribed = false; @@ -94,7 +94,7 @@ public void ToAsyncEnumerable4() Assert.True(subscribed); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -236,7 +236,7 @@ public async Task ToAsyncEnumerable_With_Completed_TaskAsync() } [Fact] - public void ToAsyncEnumerable_With_Faulted_Task() + public async Task ToAsyncEnumerable_With_Faulted_TaskAsync() { var ex = new InvalidOperationException(); var tcs = new TaskCompletionSource(); @@ -245,11 +245,11 @@ public void ToAsyncEnumerable_With_Faulted_Task() var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void ToAsyncEnumerable_With_Canceled_Task() + public async Task ToAsyncEnumerable_With_Canceled_TaskAsync() { var tcs = new TaskCompletionSource(); tcs.SetCanceled(); @@ -257,7 +257,7 @@ public void ToAsyncEnumerable_With_Canceled_Task() var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync().AsTask()); + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } private sealed class MyObservable : IObservable diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index 5c898d6144..7d423c5269 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -55,10 +55,10 @@ public async Task ToDictionary1Async() } [Fact] - public void ToDictionary2() + public async Task ToDictionary2Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrowsAsync(xs.ToDictionary(x => x % 2)); + await AssertThrowsAsync(xs.ToDictionary(x => x % 2)); } [Fact] @@ -71,10 +71,10 @@ public async Task ToDictionary3Async() } [Fact] - public void ToDictionary4() + public async Task ToDictionary4Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrowsAsync(xs.ToDictionary(x => x % 2, x => x + 1)); + await AssertThrowsAsync(xs.ToDictionary(x => x % 2, x => x + 1)); } [Fact] @@ -87,10 +87,10 @@ public async Task ToDictionary5Async() } [Fact] - public void ToDictionary6() + public async Task ToDictionary6Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - AssertThrowsAsync(xs.ToDictionary(x => x % 2, new Eq())); + await AssertThrowsAsync(xs.ToDictionary(x => x % 2, new Eq())); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index a9f80daf9e..6fb4a91004 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -37,11 +37,11 @@ public async Task ToList2() } [Fact] - public void ToList3() + public async Task ToList3Async() { var ex = new Exception("Bang!"); var res = Throw(ex).ToList(); - AssertThrowsAsync(res, ex); + await AssertThrowsAsync(res, ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index 91378209e8..70c5ec4cc3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -60,7 +60,7 @@ public async Task Where3() await HasNextAsync(e, 8); await HasNextAsync(e, 5); await HasNextAsync(e, 7); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -74,29 +74,29 @@ public async Task Where4() await HasNextAsync(e, 8); await HasNextAsync(e, 5); await HasNextAsync(e, 7); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Where5() + public async Task Where5Async() { var ex = new Exception("Bang"); var xs = Throw(ex); var ys = xs.Where(x => true); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Where6() + public async Task Where6Async() { var ex = new Exception("Bang"); var xs = Throw(ex); var ys = xs.Where((x, i) => true); var e = ys.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index e17b4aa407..e2a082170c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -62,7 +62,7 @@ public async Task Zip3Async() } [Fact] - public void Zip4() + public async Task Zip4Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -70,11 +70,11 @@ public void Zip4() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Zip5() + public async Task Zip5Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -82,11 +82,11 @@ public void Zip5() var res = xs.Zip(ys, (x, y) => x * y); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Zip6() + public async Task Zip6Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -94,7 +94,7 @@ public void Zip6() var res = xs.Zip(ys, (x, y) => { if (x > 0) throw ex; return x * y; }); var e = res.GetAsyncEnumerator(); - AssertThrowsAsync(e.MoveNextAsync(), ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] From a46327f5ef7a43f1511b2444e51b665e5e71285c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 18:14:37 -0800 Subject: [PATCH 501/862] Clean up some namespaces. --- .../Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/Count.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs | 1 - .../System/Linq/Operators/ElementAtOrDefault.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/First.cs | 1 - .../System/Linq/Operators/FirstOrDefault.cs | 1 - .../Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs | 1 - .../System/Linq/Operators/LastOrDefault.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/OfType.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/Select.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/Single.cs | 1 - .../System/Linq/Operators/SingleOrDefault.cs | 1 - .../Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs | 1 - .../Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/Throw.cs | 1 - .../System.Linq.Async.Tests/System/Linq/Operators/ToList.cs | 1 - 20 files changed, 20 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs index 1ce2622fb0..9402d381a5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 8ff9c4a801..303013f920 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index 7fb1511689..96d2d93eef 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index f9591ee10a..089181c056 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 949a7d4db2..66f74bf19d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index fce4cd50c4..666cbc9842 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 0d39e3809c..27d3405c2a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 092f9d6d0b..9a33522977 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 8e82b6fcac..4c75e8cc0e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs index 8bbea8ee0c..d48cb92eab 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index 96665a7975..ae6c073f0e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index 21d1d0d4c5..d266058b86 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 3b8a969f37..41e98ed641 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 51e73bdd2f..86bc8b1a9f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs index b475ab548b..115368b692 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Skip.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index b6e52fc06e..cd151184b0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs index e3e2bc4741..08dc47ae1f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Take.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index f10cf34a28..1300981e37 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index a57655157a..30d56e6906 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Linq; using Xunit; namespace Tests diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index 6fb4a91004..c6039190ed 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; From 61dba5ec5611f1c78ce7a98c6c02a2155ec8be74 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 21:28:19 -0800 Subject: [PATCH 502/862] Remove unnecessary TaskExt. --- .../System.Interactive.Async.Tests.csproj | 1 - .../System/Linq/Operators/CreateEnumerator.cs | 4 ++-- .../System/Linq/Operators/ToObservable.cs | 8 ++++---- Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs | 14 -------------- 4 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index b6bd310725..c3405f7184 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -28,7 +28,6 @@ - diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index f291e57f35..29a5738866 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -15,13 +15,13 @@ public class CreateEnumerator : AsyncEnumerableTests [Fact] public void CreateEnumerator_Null() { - Assert.Throws(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => TaskExt.CompletedTask)); + Assert.Throws(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => new ValueTask())); } [Fact] public void CreateEnumerator_Throws() { - var iter = AsyncEnumerable.CreateEnumerator(() => TaskExt.True, () => 3, () => TaskExt.CompletedTask); + var iter = AsyncEnumerable.CreateEnumerator(() => new ValueTask(false), () => 3, () => new ValueTask()); var enu = (IAsyncEnumerable)iter; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index 1dbfa56b51..a85a3b167f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -143,9 +143,9 @@ public void ToObservable_DisposesEnumeratorOnCompletion() var ae = AsyncEnumerable.CreateEnumerable( _ => AsyncEnumerable.CreateEnumerator( - () => TaskExt.False, + () => new ValueTask(false), () => { throw new InvalidOperationException(); }, - () => { evt.Set(); return TaskExt.CompletedTask; })); + () => { evt.Set(); return default; })); ae .ToObservable() @@ -186,7 +186,7 @@ public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed() () => { evt.Set(); - return TaskExt.CompletedTask; + return default; })); subscription = ae @@ -234,7 +234,7 @@ public void ToObservable_DesNotCallMoveNextAgainWhenSubscriptionIsDisposed() () => { evt.Set(); - return TaskExt.CompletedTask; + return default; })); subscription = ae diff --git a/Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs b/Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs deleted file mode 100644 index 0f8caa233f..0000000000 --- a/Ix.NET/Source/System.Linq.Async.Tests/TaskExt.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -namespace System.Threading.Tasks -{ - internal static class TaskExt - { - public static readonly ValueTask True = new ValueTask(true); - public static readonly ValueTask False = new ValueTask(false); - public static readonly ValueTask CompletedTask = new ValueTask(Task.FromResult(true)); - public static readonly ValueTask Never = new ValueTask(new TaskCompletionSource().Task); - } -} From 58ebc89a3ff636470fa54215fe023fecafaa047d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 21:32:09 -0800 Subject: [PATCH 503/862] Remove AssertThrows from Ix.Async tests. --- .../System/Linq/AsyncEnumerableExTests.cs | 6 ---- .../System/Linq/Operators/Buffer.cs | 10 +++---- .../System/Linq/Operators/Catch.cs | 12 ++++---- .../System/Linq/Operators/Concat.cs | 4 +-- .../System/Linq/Operators/Defer.cs | 2 +- .../System/Linq/Operators/Distinct.cs | 10 +++---- .../Linq/Operators/DistinctUntilChanged.cs | 12 ++++---- .../System/Linq/Operators/Do.cs | 28 +++++++++---------- .../System/Linq/Operators/Expand.cs | 4 +-- .../System/Linq/Operators/Finally.cs | 4 +-- .../System/Linq/Operators/Generate.cs | 6 ++-- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../Linq/Operators/OnErrorResumeNext.cs | 8 +++--- .../System/Linq/Operators/Repeat.cs | 6 ++-- .../System/Linq/Operators/Retry.cs | 6 ++-- .../System/Linq/Operators/Scan.cs | 8 +++--- .../System/Linq/Operators/SelectMany.cs | 5 ++-- .../System/Linq/Operators/StartWith.cs | 5 ++-- .../System/Linq/Operators/Using.cs | 4 +-- 19 files changed, 67 insertions(+), 75 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index b866cd5f1a..86960a780a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -20,12 +20,6 @@ public class AsyncEnumerableExTests protected const int WaitTimeoutMs = 5000; #pragma warning disable xUnit1013 // Public method should be marked as test - public void AssertThrows(Action a) - where E : Exception - { - Assert.Throws(a); - } - public void AssertThrows(Action a, Func assert) where E : Exception { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs index c202579461..6962f4f0fe 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs @@ -15,12 +15,12 @@ public class Buffer : AsyncEnumerableExTests [Fact] public void Buffer_Null() { - AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1, 1)); + Assert.Throws(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1)); + Assert.Throws(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable), 1, 1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(Return42, -1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(Return42, -1, 1)); - AssertThrows(() => AsyncEnumerableEx.Buffer(Return42, 1, -1)); + Assert.Throws(() => AsyncEnumerableEx.Buffer(Return42, -1)); + Assert.Throws(() => AsyncEnumerableEx.Buffer(Return42, -1, 1)); + Assert.Throws(() => AsyncEnumerableEx.Buffer(Return42, 1, -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs index 96d51746bd..280c9734e8 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -15,13 +15,13 @@ public class Catch : AsyncEnumerableExTests [Fact] public void Catch_Null() { - AssertThrows(() => AsyncEnumerableEx.Catch(default, x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Catch(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerableEx.Catch(default, x => default(IAsyncEnumerable))); + Assert.Throws(() => AsyncEnumerableEx.Catch(Return42, default(Func>))); - AssertThrows(() => AsyncEnumerableEx.Catch(default, Return42)); - AssertThrows(() => AsyncEnumerableEx.Catch(Return42, default)); - AssertThrows(() => AsyncEnumerableEx.Catch(default)); - AssertThrows(() => AsyncEnumerableEx.Catch(default(IEnumerable>))); + Assert.Throws(() => AsyncEnumerableEx.Catch(default, Return42)); + Assert.Throws(() => AsyncEnumerableEx.Catch(Return42, default)); + Assert.Throws(() => AsyncEnumerableEx.Catch(default)); + Assert.Throws(() => AsyncEnumerableEx.Catch(default(IEnumerable>))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs index d0f063c603..ce879fa315 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs @@ -15,8 +15,8 @@ public class Concat : AsyncEnumerableExTests [Fact] public void Concat_Null() { - AssertThrows(() => AsyncEnumerableEx.Concat(default(IAsyncEnumerable[]))); - AssertThrows(() => AsyncEnumerableEx.Concat(default(IEnumerable>))); + Assert.Throws(() => AsyncEnumerableEx.Concat(default(IAsyncEnumerable[]))); + Assert.Throws(() => AsyncEnumerableEx.Concat(default(IEnumerable>))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs index 8265d3e12f..0fb6f89fbb 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs @@ -14,7 +14,7 @@ public class Defer : AsyncEnumerableExTests [Fact] public void Defer_Null() { - AssertThrows(() => AsyncEnumerableEx.Defer(default(Func>))); + Assert.Throws(() => AsyncEnumerableEx.Defer(default(Func>))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index 144d785fa5..c050eb9ceb 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -15,13 +15,13 @@ public class Distinct : AsyncEnumerableExTests [Fact] public void Distinct_Null() { - AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerableEx.Distinct(Return42, default(Func))); - AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x)); + Assert.Throws(() => AsyncEnumerableEx.Distinct(Return42, default(Func))); - AssertThrows(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.Distinct(Return42, default(Func), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerableEx.Distinct(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerableEx.Distinct(Return42, default(Func), EqualityComparer.Default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs index 0103fca7c6..774c244a65 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -15,15 +15,15 @@ public class DistinctUntilChanged : AsyncEnumerableExTests [Fact] public void DistinctUntilChanged_Null() { - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); + Assert.Throws(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerableEx.DistinctUntilChanged(default, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x)); + Assert.Throws(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func))); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); - AssertThrows(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerableEx.DistinctUntilChanged(default(IAsyncEnumerable), x => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerableEx.DistinctUntilChanged(Return42, default(Func), EqualityComparer.Default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index 4c01c05ca6..f0585fc2d9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -15,24 +15,24 @@ public class Do : AsyncEnumerableExTests [Fact] public void Do_Null() { - AssertThrows(() => AsyncEnumerableEx.Do(default, x => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(Action))); + Assert.Throws(() => AsyncEnumerableEx.Do(default, x => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(default, x => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); + Assert.Throws(() => AsyncEnumerableEx.Do(default, x => { }, () => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, default, () => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(default, x => { }, ex => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default, ex => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); + Assert.Throws(() => AsyncEnumerableEx.Do(default, x => { }, ex => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, default, ex => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, x => { }, default(Action))); - AssertThrows(() => AsyncEnumerableEx.Do(default, x => { }, ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default, ex => { }, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, default, () => { })); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, x => { }, ex => { }, default)); + Assert.Throws(() => AsyncEnumerableEx.Do(default, x => { }, ex => { }, () => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, default, ex => { }, () => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, x => { }, default, () => { })); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, x => { }, ex => { }, default)); - AssertThrows(() => AsyncEnumerableEx.Do(default, new MyObs())); - AssertThrows(() => AsyncEnumerableEx.Do(Return42, default(IObserver))); + Assert.Throws(() => AsyncEnumerableEx.Do(default, new MyObs())); + Assert.Throws(() => AsyncEnumerableEx.Do(Return42, default(IObserver))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs index c611698bbb..a1d0e4dcc7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs @@ -15,8 +15,8 @@ public class Expand : AsyncEnumerableExTests [Fact] public void Expand_Null() { - AssertThrows(() => AsyncEnumerableEx.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Expand(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerableEx.Expand(default(IAsyncEnumerable), x => default(IAsyncEnumerable))); + Assert.Throws(() => AsyncEnumerableEx.Expand(Return42, default(Func>))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index d0cf28e577..35bc844f5c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -15,8 +15,8 @@ public class Finally : AsyncEnumerableExTests [Fact] public void Finally_Null() { - AssertThrows(() => AsyncEnumerableEx.Finally(default(IAsyncEnumerable), () => { })); - AssertThrows(() => AsyncEnumerableEx.Finally(Return42, default(Action))); + Assert.Throws(() => AsyncEnumerableEx.Finally(default(IAsyncEnumerable), () => { })); + Assert.Throws(() => AsyncEnumerableEx.Finally(Return42, default(Action))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs index 60dc0bb9c3..e5388cfd8a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs @@ -14,9 +14,9 @@ public class Generate : AsyncEnumerableExTests [Fact] public void Generate_Null() { - AssertThrows(() => AsyncEnumerableEx.Generate(0, default, x => x, x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, default, x => x)); - AssertThrows(() => AsyncEnumerableEx.Generate(0, x => true, x => x, default)); + Assert.Throws(() => AsyncEnumerableEx.Generate(0, default, x => x, x => x)); + Assert.Throws(() => AsyncEnumerableEx.Generate(0, x => true, default, x => x)); + Assert.Throws(() => AsyncEnumerableEx.Generate(0, x => true, x => x, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs index 8615420452..3613e2bac7 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -15,7 +15,7 @@ public class IgnoreElements : AsyncEnumerableExTests [Fact] public void IgnoreElements_Null() { - AssertThrows(() => AsyncEnumerableEx.IgnoreElements(default(IAsyncEnumerable))); + Assert.Throws(() => AsyncEnumerableEx.IgnoreElements(default(IAsyncEnumerable))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs index 40b664a9f2..7892f893c4 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -15,10 +15,10 @@ public class OnErrorResumeNext : AsyncEnumerableExTests [Fact] public void OnErrorResumeNext_Null() { - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default, Return42)); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(Return42, default)); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default)); - AssertThrows(() => AsyncEnumerableEx.OnErrorResumeNext(default(IEnumerable>))); + Assert.Throws(() => AsyncEnumerableEx.OnErrorResumeNext(default, Return42)); + Assert.Throws(() => AsyncEnumerableEx.OnErrorResumeNext(Return42, default)); + Assert.Throws(() => AsyncEnumerableEx.OnErrorResumeNext(default)); + Assert.Throws(() => AsyncEnumerableEx.OnErrorResumeNext(default(IEnumerable>))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs index 0fc089e5bd..abff08b99f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs @@ -37,9 +37,9 @@ public async Task RepeatValue2() [Fact] public void RepeatSequence_Null() { - AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); - AssertThrows(() => AsyncEnumerableEx.Repeat(Return42, -1)); + Assert.Throws(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable))); + Assert.Throws(() => AsyncEnumerableEx.Repeat(default(IAsyncEnumerable), 3)); + Assert.Throws(() => AsyncEnumerableEx.Repeat(Return42, -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs index ea0d528943..2da702ff05 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs @@ -14,10 +14,10 @@ public class Retry : AsyncEnumerableExTests [Fact] public void Retry_Null() { - AssertThrows(() => AsyncEnumerableEx.Retry(default)); + Assert.Throws(() => AsyncEnumerableEx.Retry(default)); - AssertThrows(() => AsyncEnumerableEx.Retry(default, 1)); - AssertThrows(() => AsyncEnumerableEx.Retry(Return42, -1)); + Assert.Throws(() => AsyncEnumerableEx.Retry(default, 1)); + Assert.Throws(() => AsyncEnumerableEx.Retry(Return42, -1)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs index c692239009..c3bc007373 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs @@ -15,11 +15,11 @@ public class Scan : AsyncEnumerableExTests [Fact] public void Scan_Null() { - AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); - AssertThrows(() => AsyncEnumerableEx.Scan(Return42, 3, default(Func))); + Assert.Throws(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), 3, (x, y) => x + y)); + Assert.Throws(() => AsyncEnumerableEx.Scan(Return42, 3, default(Func))); - AssertThrows(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), (x, y) => x + y)); - AssertThrows(() => AsyncEnumerableEx.Scan(Return42, default(Func))); + Assert.Throws(() => AsyncEnumerableEx.Scan(default(IAsyncEnumerable), (x, y) => x + y)); + Assert.Throws(() => AsyncEnumerableEx.Scan(Return42, default(Func))); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs index 977b60f177..7790897890 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using Xunit; @@ -14,8 +13,8 @@ public class SelectMany : AsyncEnumerableExTests [Fact] public void SelectMany_Null() { - AssertThrows(() => AsyncEnumerableEx.SelectMany(default, Return42)); - AssertThrows(() => AsyncEnumerableEx.SelectMany(Return42, default)); + Assert.Throws(() => AsyncEnumerableEx.SelectMany(default, Return42)); + Assert.Throws(() => AsyncEnumerableEx.SelectMany(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index 90279ba874..d05ff5ee53 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using Xunit; @@ -14,8 +13,8 @@ public class StartWith : AsyncEnumerableExTests [Fact] public void StartWith_Null() { - AssertThrows(() => AsyncEnumerableEx.StartWith(default, new[] { 1 })); - AssertThrows(() => AsyncEnumerableEx.StartWith(Return42, default)); + Assert.Throws(() => AsyncEnumerableEx.StartWith(default, new[] { 1 })); + Assert.Throws(() => AsyncEnumerableEx.StartWith(Return42, default)); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index 17d90712b5..5fb996e767 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -15,8 +15,8 @@ public class Using : AsyncEnumerableExTests [Fact] public void Using_Null() { - AssertThrows(() => AsyncEnumerableEx.Using(default, _ => default(IAsyncEnumerable))); - AssertThrows(() => AsyncEnumerableEx.Using(() => new MyD(null), default)); + Assert.Throws(() => AsyncEnumerableEx.Using(default, _ => default(IAsyncEnumerable))); + Assert.Throws(() => AsyncEnumerableEx.Using(() => new MyD(null), default)); } [Fact] From 2404199f2ffed2b73f8ba5f73499699a99cfc310 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 21:34:13 -0800 Subject: [PATCH 504/862] Switch to async variants of NoNext and HasNext. --- .../System/Linq/AsyncEnumerableExTests.cs | 8 +- .../System/Linq/Operators/Catch.cs | 146 +++++++++--------- .../System/Linq/Operators/Concat.cs | 44 +++--- .../System/Linq/Operators/Defer.cs | 10 +- .../System/Linq/Operators/Distinct.cs | 14 +- .../Linq/Operators/DistinctUntilChanged.cs | 44 +++--- .../System/Linq/Operators/Do.cs | 36 ++--- .../System/Linq/Operators/Expand.cs | 24 +-- .../System/Linq/Operators/Finally.cs | 20 +-- .../System/Linq/Operators/Generate.cs | 20 +-- .../System/Linq/Operators/IgnoreElements.cs | 12 +- .../Linq/Operators/OnErrorResumeNext.cs | 88 +++++------ .../System/Linq/Operators/Repeat.cs | 72 ++++----- .../System/Linq/Operators/Retry.cs | 30 ++-- .../System/Linq/Operators/Return.cs | 4 +- .../System/Linq/Operators/Scan.cs | 18 +-- .../System/Linq/Operators/SelectMany.cs | 16 +- .../System/Linq/Operators/StartWith.cs | 24 +-- .../System/Linq/Operators/Using.cs | 6 +- 19 files changed, 318 insertions(+), 318 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 86960a780a..51fa65c353 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -41,14 +41,14 @@ public void AssertThrows(Action a, Func assert) } } - public void NoNext(IAsyncEnumerator e) + protected async Task NoNextAsync(IAsyncEnumerator e) { - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } - public void HasNext(IAsyncEnumerator e, T value) + protected async Task HasNextAsync(IAsyncEnumerator e, T value) { - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.Equal(value, e.Current); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs index 280c9734e8..0f6a8b1a7a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -25,7 +25,7 @@ public void Catch_Null() } [Fact] - public void Catch1() + public async Task Catch1Async() { var err = false; var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -34,16 +34,16 @@ public void Catch1() var res = xs.Catch(ex_ => { err = true; return ys; }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); Assert.False(err); } [Fact] - public void Catch2() + public async Task Catch2Async() { var ex = new InvalidOperationException("Bang!"); @@ -54,23 +54,23 @@ public void Catch2() var res = xs.Catch(ex_ => { err = true; return ys; }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); Assert.False(err); - HasNext(e, 4); + await HasNextAsync(e, 4); Assert.True(err); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void Catch3() + public async Task Catch3Async() { var ex = new InvalidOperationException("Bang!"); @@ -81,23 +81,23 @@ public void Catch3() var res = xs.Catch(ex_ => { err = true; return ys; }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); Assert.False(err); - HasNext(e, 4); + await HasNextAsync(e, 4); Assert.True(err); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void Catch4() + public async Task Catch4Async() { var ex = new DivideByZeroException(); @@ -108,9 +108,9 @@ public void Catch4() var res = xs.Catch(ex_ => { err = true; return ys; }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); @@ -118,7 +118,7 @@ public void Catch4() } [Fact] - public void Catch5() + public async Task Catch5Async() { var ex = new InvalidOperationException("Bang!"); var ex2 = new Exception("Oops!"); @@ -129,15 +129,15 @@ public void Catch5() var res = xs.Catch(ex_ => { if (ex_.Message == "Bang!") throw ex2; return ys; }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex2)); } [Fact] - public void Catch6() + public async Task Catch6Async() { var ex = new InvalidOperationException("Bang!"); @@ -147,24 +147,24 @@ public void Catch6() var res = xs.Catch(ex_ => { err = true; return xs; }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); Assert.False(err); - HasNext(e, 1); + await HasNextAsync(e, 1); Assert.True(err); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] - public void Catch7() + public async Task Catch7Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); @@ -172,14 +172,14 @@ public void Catch7() var res = AsyncEnumerableEx.Catch(xs, ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); } [Fact] - public void Catch8() + public async Task Catch8Async() { var ex = new InvalidOperationException("Bang!"); @@ -189,17 +189,17 @@ public void Catch8() var res = AsyncEnumerableEx.Catch(xs, ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void Catch9() + public async Task Catch9Async() { var ex = new InvalidOperationException("Bang!"); @@ -209,27 +209,27 @@ public void Catch9() var res = AsyncEnumerableEx.Catch(new[] { xs, xs, ys, ys }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void Catch10() + public async Task Catch10Async() { var res = CatchXss().Catch(); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); } @@ -241,7 +241,7 @@ private IEnumerable> CatchXss() } [Fact] - public void Catch11() + public async Task Catch11Async() { var ex = new InvalidOperationException("Bang!"); @@ -250,23 +250,23 @@ public void Catch11() var res = AsyncEnumerableEx.Catch(new[] { xs, xs }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] - public void Catch12() + public async Task Catch12Async() { var res = AsyncEnumerableEx.Catch(Enumerable.Empty>()); var e = res.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs index ce879fa315..74a66d78ff 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs @@ -20,7 +20,7 @@ public void Concat_Null() } [Fact] - public void Concat4() + public async Task Concat4Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5 }.ToAsyncEnumerable(); @@ -29,19 +29,19 @@ public void Concat4() var res = AsyncEnumerableEx.Concat(xs, ys, zs); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 8); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await HasNextAsync(e, 7); + await HasNextAsync(e, 8); + await NoNextAsync(e); } [Fact] - public void Concat5() + public async Task Concat5Async() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -51,25 +51,25 @@ public void Concat5() var res = AsyncEnumerableEx.Concat(xs, ys, zs); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } [Fact] - public void Concat6() + public async Task Concat6Async() { var res = AsyncEnumerableEx.Concat(ConcatXss()); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs index 0fb6f89fbb..7698e8244a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs @@ -18,22 +18,22 @@ public void Defer_Null() } [Fact] - public void Defer1() + public async System.Threading.Tasks.Task Defer1Async() { var x = 0; var xs = AsyncEnumerableEx.Defer(() => new[] { x }.ToAsyncEnumerable()); { var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - NoNext(e); + await HasNextAsync(e, 0); + await NoNextAsync(e); } { x++; var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - NoNext(e); + await HasNextAsync(e, 1); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index c050eb9ceb..131b394c39 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -25,15 +25,15 @@ public void Distinct_Null() } [Fact] - public void Distinct1() + public async Task Distinct1Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Distinct(x => x / 2); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 4); + await NoNextAsync(e); } [Fact] @@ -71,13 +71,13 @@ public async Task Distinct9() } [Fact] - public void Distinct11() + public async Task Distinct11Async() { var xs = AsyncEnumerable.Empty().Distinct(k => k); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs index 774c244a65..644733fe59 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -27,47 +27,47 @@ public void DistinctUntilChanged_Null() } [Fact] - public void DistinctUntilChanged1() + public async Task DistinctUntilChanged1Async() { var xs = new[] { 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 6, 7, 3, 2, 2, 1, 1 }.ToAsyncEnumerable().DistinctUntilChanged(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 7); - HasNext(e, 3); - HasNext(e, 2); - HasNext(e, 1); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await HasNextAsync(e, 7); + await HasNextAsync(e, 3); + await HasNextAsync(e, 2); + await HasNextAsync(e, 1); + await NoNextAsync(e); } [Fact] - public void DistinctUntilChanged2() + public async Task DistinctUntilChanged2Async() { var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => (x + 1) / 2); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 3); - HasNext(e, 5); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 3); + await HasNextAsync(e, 5); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void DistinctUntilChanged3() + public async Task DistinctUntilChanged3Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4, 3, 5, 2 }.ToAsyncEnumerable().DistinctUntilChanged(x => { if (x == 4) throw ex; return x; }); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index f0585fc2d9..a079379936 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -36,22 +36,22 @@ public void Do_Null() } [Fact] - public void Do1() + public async Task Do1Async() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Do(x => sum += x); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); + await HasNextAsync(e, 1); Assert.Equal(1, sum); - HasNext(e, 2); + await HasNextAsync(e, 2); Assert.Equal(3, sum); - HasNext(e, 3); + await HasNextAsync(e, 3); Assert.Equal(6, sum); - HasNext(e, 4); + await HasNextAsync(e, 4); Assert.Equal(10, sum); - NoNext(e); + await NoNextAsync(e); } [Fact] @@ -66,7 +66,7 @@ public void Do2() } [Fact] - public void Do3() + public async Task Do3Async() { var sum = 0; var fail = false; @@ -75,22 +75,22 @@ public void Do3() var ys = xs.Do(x => sum += x, ex => { fail = true; }, () => { done = true; }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); + await HasNextAsync(e, 1); Assert.Equal(1, sum); - HasNext(e, 2); + await HasNextAsync(e, 2); Assert.Equal(3, sum); - HasNext(e, 3); + await HasNextAsync(e, 3); Assert.Equal(6, sum); - HasNext(e, 4); + await HasNextAsync(e, 4); Assert.Equal(10, sum); - NoNext(e); + await NoNextAsync(e); Assert.False(fail); Assert.True(done); } [Fact] - public void Do4() + public async Task Do4Async() { var sum = 0; var done = false; @@ -98,15 +98,15 @@ public void Do4() var ys = xs.Do(x => sum += x, () => { done = true; }); var e = ys.GetAsyncEnumerator(); - HasNext(e, 1); + await HasNextAsync(e, 1); Assert.Equal(1, sum); - HasNext(e, 2); + await HasNextAsync(e, 2); Assert.Equal(3, sum); - HasNext(e, 3); + await HasNextAsync(e, 3); Assert.Equal(6, sum); - HasNext(e, 4); + await HasNextAsync(e, 4); Assert.Equal(10, sum); - NoNext(e); + await NoNextAsync(e); Assert.True(done); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs index a1d0e4dcc7..3a716256d2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs @@ -20,19 +20,19 @@ public void Expand_Null() } [Fact] - public void Expand1() + public async Task Expand1Async() { var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => AsyncEnumerableEx.Return(x - 1).Repeat(x - 1)); var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 1); - HasNext(e, 1); - NoNext(e); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 1); + await HasNextAsync(e, 1); + await NoNextAsync(e); } [Fact] @@ -46,13 +46,13 @@ public void Expand2() } [Fact] - public void Expand3() + public async Task Expand3Async() { var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(x => default(IAsyncEnumerable)); var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NullReferenceException); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index 35bc844f5c..db8a8e7d08 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -20,7 +20,7 @@ public void Finally_Null() } [Fact] - public void Finally1() + public async Task Finally1Async() { var b = false; @@ -29,13 +29,13 @@ public void Finally1() var e = xs.GetAsyncEnumerator(); Assert.False(b); - NoNext(e); + await NoNextAsync(e); Assert.True(b); } [Fact] - public void Finally2() + public async Task Finally2Async() { var b = false; @@ -44,10 +44,10 @@ public void Finally2() var e = xs.GetAsyncEnumerator(); Assert.False(b); - HasNext(e, 42); + await HasNextAsync(e, 42); Assert.False(b); - NoNext(e); + await NoNextAsync(e); Assert.True(b); } @@ -70,7 +70,7 @@ public void Finally3() } [Fact] - public void Finally4() + public async Task Finally4Async() { var b = false; @@ -79,13 +79,13 @@ public void Finally4() var e = xs.GetAsyncEnumerator(); Assert.False(b); - HasNext(e, 1); + await HasNextAsync(e, 1); Assert.False(b); - HasNext(e, 2); + await HasNextAsync(e, 2); Assert.False(b); - NoNext(e); + await NoNextAsync(e); Assert.True(b); } @@ -100,7 +100,7 @@ public async Task Finally5() var e = xs.GetAsyncEnumerator(); Assert.False(b); - HasNext(e, 1); + await HasNextAsync(e, 1); await e.DisposeAsync(); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs index e5388cfd8a..a27a776110 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs @@ -25,12 +25,12 @@ public async Task Generate1() var xs = AsyncEnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x); var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); - HasNext(e, 1); - HasNext(e, 4); - HasNext(e, 9); - HasNext(e, 16); - NoNext(e); + await HasNextAsync(e, 0); + await HasNextAsync(e, 1); + await HasNextAsync(e, 4); + await HasNextAsync(e, 9); + await HasNextAsync(e, 16); + await NoNextAsync(e); await e.DisposeAsync(); } @@ -45,24 +45,24 @@ public void Generate2() } [Fact] - public void Generate3() + public async Task Generate3Async() { var ex = new Exception("Bang!"); var xs = AsyncEnumerableEx.Generate(0, x => true, x => x + 1, x => { if (x == 1) throw ex; return x * x; }); var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); + await HasNextAsync(e, 0); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } [Fact] - public void Generate4() + public async Task Generate4Async() { var ex = new Exception("Bang!"); var xs = AsyncEnumerableEx.Generate(0, x => true, x => { throw ex; }, x => x * x); var e = xs.GetAsyncEnumerator(); - HasNext(e, 0); + await HasNextAsync(e, 0); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs index 3613e2bac7..0eb0b01cbc 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -19,30 +19,30 @@ public void IgnoreElements_Null() } [Fact] - public void IgnoreElements1() + public async Task IgnoreElements1Async() { var xs = AsyncEnumerable.Empty().IgnoreElements(); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void IgnoreElements2() + public async Task IgnoreElements2Async() { var xs = Return42.IgnoreElements(); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] - public void IgnoreElements3() + public async Task IgnoreElements3Async() { var xs = AsyncEnumerable.Range(0, 10).IgnoreElements(); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs index 7892f893c4..d6522ec399 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -22,7 +22,7 @@ public void OnErrorResumeNext_Null() } [Fact] - public void OnErrorResumeNext7() + public async Task OnErrorResumeNext7Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); @@ -30,17 +30,17 @@ public void OnErrorResumeNext7() var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void OnErrorResumeNext8() + public async Task OnErrorResumeNext8Async() { var ex = new InvalidOperationException("Bang!"); @@ -50,17 +50,17 @@ public void OnErrorResumeNext8() var res = AsyncEnumerableEx.OnErrorResumeNext(xs, ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void OnErrorResumeNext9() + public async Task OnErrorResumeNext9Async() { var ex = new InvalidOperationException("Bang!"); @@ -70,30 +70,30 @@ public void OnErrorResumeNext9() var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs, ys, ys }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - HasNext(e, 4); - HasNext(e, 5); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await HasNextAsync(e, 4); + await HasNextAsync(e, 5); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] - public void OnErrorResumeNext10() + public async Task OnErrorResumeNext10Async() { var res = OnErrorResumeNextXss().OnErrorResumeNext(); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); } @@ -105,7 +105,7 @@ private IEnumerable> OnErrorResumeNextXss() } [Fact] - public void OnErrorResumeNext11() + public async Task OnErrorResumeNext11Async() { var ex = new InvalidOperationException("Bang!"); @@ -114,22 +114,22 @@ public void OnErrorResumeNext11() var res = AsyncEnumerableEx.OnErrorResumeNext(new[] { xs, xs }); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); } [Fact] - public void OnErrorResumeNext12() + public async Task OnErrorResumeNext12Async() { var res = AsyncEnumerableEx.OnErrorResumeNext(Enumerable.Empty>()); var e = res.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs index abff08b99f..2464faceee 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs @@ -18,11 +18,11 @@ public async Task RepeatValue1() var xs = AsyncEnumerableEx.Repeat(2); var e = xs.GetAsyncEnumerator(); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); - HasNext(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); + await HasNextAsync(e, 2); await e.DisposeAsync(); } @@ -43,67 +43,67 @@ public void RepeatSequence_Null() } [Fact] - public void RepeatSequence1() + public async Task RepeatSequence1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); } [Fact] - public void RepeatSequence2() + public async Task RepeatSequence2Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Repeat(3); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); } [Fact] - public void RepeatSequence3() + public async Task RepeatSequence3Async() { var i = 0; var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(3); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); Assert.Equal(3, i); } [Fact] - public void RepeatSequence4() + public async Task RepeatSequence4Async() { var i = 0; var xs = RepeatXs(() => i++).ToAsyncEnumerable().Repeat(0); var e = xs.GetAsyncEnumerator(); - NoNext(e); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs index 2da702ff05..d86a597a3d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs @@ -21,21 +21,21 @@ public void Retry_Null() } [Fact] - public void Retry1() + public async System.Threading.Tasks.Task Retry1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var res = xs.Retry(); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); } [Fact] - public void Retry2() + public async System.Threading.Tasks.Task Retry2Async() { var ex = new InvalidOperationException("Bang!"); @@ -44,15 +44,15 @@ public void Retry2() var res = xs.Retry(); var e = res.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); - HasNext(e, 1); - HasNext(e, 2); - HasNext(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs index e55b35c728..8137b11d36 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs @@ -10,10 +10,10 @@ namespace Tests public class Return : AsyncEnumerableExTests { [Fact] - public void Return1() + public async System.Threading.Tasks.Task Return1Async() { var xs = AsyncEnumerableEx.Return(42); - HasNext(xs.GetAsyncEnumerator(), 42); + await HasNextAsync(xs.GetAsyncEnumerator(), 42); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs index c3bc007373..e2867ba0b8 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs @@ -23,26 +23,26 @@ public void Scan_Null() } [Fact] - public void Scan1() + public async Task Scan1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, (x, y) => x + y); var e = xs.GetAsyncEnumerator(); - HasNext(e, 9); - HasNext(e, 11); - HasNext(e, 14); - NoNext(e); + await HasNextAsync(e, 9); + await HasNextAsync(e, 11); + await HasNextAsync(e, 14); + await NoNextAsync(e); } [Fact] - public void Scan2() + public async Task Scan2Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan((x, y) => x + y); var e = xs.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 6); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 6); + await NoNextAsync(e); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs index 7790897890..fc0b04973f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -18,7 +18,7 @@ public void SelectMany_Null() } [Fact] - public void SelectMany1() + public async System.Threading.Tasks.Task SelectMany1Async() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 4 }.ToAsyncEnumerable(); @@ -26,13 +26,13 @@ public void SelectMany1() var res = xs.SelectMany(ys); var e = res.GetAsyncEnumerator(); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 3); - HasNext(e, 4); - HasNext(e, 3); - HasNext(e, 4); - NoNext(e); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index d05ff5ee53..b9102414c2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -18,37 +18,37 @@ public void StartWith_Null() } [Fact] - public void StartWith1() + public async System.Threading.Tasks.Task StartWith1Async() { var xs = AsyncEnumerable.Empty().StartWith(1, 2); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); - NoNext(e); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await NoNextAsync(e); } [Fact] - public void StartWith2() + public async System.Threading.Tasks.Task StartWith2Async() { var xs = Return42.StartWith(40, 41); var e = xs.GetAsyncEnumerator(); - HasNext(e, 40); - HasNext(e, 41); - HasNext(e, 42); - NoNext(e); + await HasNextAsync(e, 40); + await HasNextAsync(e, 41); + await HasNextAsync(e, 42); + await NoNextAsync(e); } [Fact] - public void StartWith3() + public async System.Threading.Tasks.Task StartWith3Async() { var ex = new Exception("Bang!"); var xs = Throw(ex).StartWith(1, 2); var e = xs.GetAsyncEnumerator(); - HasNext(e, 1); - HasNext(e, 2); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index 5fb996e767..15aee80a9b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -102,7 +102,7 @@ public async Task Using3() } [Fact] - public void Using4() + public async Task Using4Async() { var i = 0; var disposed = new TaskCompletionSource(); @@ -122,11 +122,11 @@ public void Using4() Assert.Equal(0, i); - HasNext(e, 42); + await HasNextAsync(e, 42); Assert.Equal(1, i); - NoNext(e); + await NoNextAsync(e); Assert.True(disposed.Task.Result); } From f4d047357973c6ed599e2657c55d9031585fd393 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 21:34:42 -0800 Subject: [PATCH 505/862] Improve SequenceIdentity. --- .../System/Linq/AsyncEnumerableExTests.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 51fa65c353..50c7dea5d6 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -52,7 +52,7 @@ protected async Task HasNextAsync(IAsyncEnumerator e, T value) Assert.Equal(value, e.Current); } - public async Task SequenceIdentity(IAsyncEnumerable enumerable) + protected async Task SequenceIdentity(IAsyncEnumerable enumerable) { var en1 = enumerable.GetAsyncEnumerator(); var en2 = enumerable.GetAsyncEnumerator(); @@ -62,16 +62,10 @@ public async Task SequenceIdentity(IAsyncEnumerable enumerable) await en1.DisposeAsync(); await en2.DisposeAsync(); - var e1t = enumerable.ToList(); - var e2t = enumerable.ToList(); + var res1 = await enumerable.ToList(); + var res2 = await enumerable.ToList(); - await Task.WhenAll(e1t, e2t); - - - var e1Result = e1t.Result; - var e2Result = e2t.Result; - - e1Result.ShouldAllBeEquivalentTo(e2Result); + res1.ShouldAllBeEquivalentTo(res2); } #pragma warning restore xUnit1013 // Public method should be marked as test } From edd33696e8a5f59bf0b5123ee16b8c84f12a6435 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 21:36:14 -0800 Subject: [PATCH 506/862] Remove timeout. --- .../System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index f8fe5100b8..6fb820ded2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -15,8 +15,6 @@ public class AsyncEnumerableTests { protected static readonly IAsyncEnumerable Return42 = new[] { 42 }.ToAsyncEnumerable(); - private const int WaitTimeoutMs = 5000; - protected async Task AssertThrowsAsync(Task t) where TException : Exception { From ab166038dddb04ff46b15ca7364880b840a07ceb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 12 Nov 2018 21:50:15 -0800 Subject: [PATCH 507/862] Modernize Ix.Async tests. --- .../AsyncTests.Bugs.cs | 12 ++++---- .../System/Linq/AsyncEnumerableExTests.cs | 29 +++++++++---------- .../System/Linq/Operators/Buffer.cs | 28 +++++++++--------- .../System/Linq/Operators/Catch.cs | 17 ++++++----- .../System/Linq/Operators/Concat.cs | 11 +++---- .../System/Linq/Operators/Defer.cs | 3 +- .../Linq/Operators/DistinctUntilChanged.cs | 2 +- .../System/Linq/Operators/Do.cs | 12 ++++---- .../System/Linq/Operators/Expand.cs | 6 ++-- .../System/Linq/Operators/Finally.cs | 4 +-- .../System/Linq/Operators/Generate.cs | 8 ++--- .../System/Linq/Operators/IgnoreElements.cs | 4 +-- .../System/Linq/Operators/MaxBy.cs | 20 ++++++------- .../System/Linq/Operators/MinBy.cs | 20 ++++++------- .../Linq/Operators/OnErrorResumeNext.cs | 9 +++--- .../System/Linq/Operators/Repeat.cs | 8 ++--- .../System/Linq/Operators/Retry.cs | 5 ++-- .../System/Linq/Operators/Return.cs | 3 +- .../System/Linq/Operators/Scan.cs | 8 ++--- .../System/Linq/Operators/SelectMany.cs | 3 +- .../System/Linq/Operators/StartWith.cs | 9 +++--- .../System/Linq/Operators/Using.cs | 8 ++--- 22 files changed, 117 insertions(+), 112 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 98e2cfadb1..5befee2552 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -41,9 +41,9 @@ public async void CorrectDispose() await disposed.Task; - Assert.True(disposed.Task.Result); + Assert.True(await disposed.Task); - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); var next = await e.MoveNextAsync(); Assert.False(next); @@ -92,22 +92,22 @@ public async Task TakeOneFromSelectMany() } [Fact] - public void SelectManyDisposeInvokedOnlyOnce() + public async Task SelectManyDisposeInvokedOnlyOnceAsync() { var disposeCounter = new DisposeCounter(); - var result = new[] { 1 }.ToAsyncEnumerable().SelectMany(i => disposeCounter).Select(i => i).ToList().Result; + var result = await new[] { 1 }.ToAsyncEnumerable().SelectMany(i => disposeCounter).Select(i => i).ToList(); Assert.Empty(result); Assert.Equal(1, disposeCounter.DisposeCount); } [Fact] - public void SelectManyInnerDispose() + public async Task SelectManyInnerDisposeAsync() { var disposes = Enumerable.Range(0, 10).Select(_ => new DisposeCounter()).ToList(); - var result = AsyncEnumerable.Range(0, 10).SelectMany(i => disposes[i]).Select(i => i).ToList().Result; + var result = await AsyncEnumerable.Range(0, 10).SelectMany(i => disposes[i]).Select(i => i).ToList(); Assert.Empty(result); Assert.True(disposes.All(d => d.DisposeCount == 1)); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 50c7dea5d6..24cd11ef7e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -15,30 +15,28 @@ public class AsyncEnumerableExTests { protected static readonly IAsyncEnumerable Return42 = AsyncEnumerableEx.Return(42); protected static IAsyncEnumerable Throw(Exception exception) => AsyncEnumerableEx.Throw(exception); - protected static Func SingleInnerExceptionMatches(Exception ex) => e => ((AggregateException)e).Flatten().InnerExceptions.Single() == ex; - protected const int WaitTimeoutMs = 5000; - -#pragma warning disable xUnit1013 // Public method should be marked as test - public void AssertThrows(Action a, Func assert) - where E : Exception + protected async Task AssertThrowsAsync(Task t) + where TException : Exception { - var hasFailed = false; + await Assert.ThrowsAsync(() => t); + } + protected async Task AssertThrowsAsync(Task t, Exception e) + { try { - a(); + await t; } - catch (E e) + catch (Exception ex) { - Assert.True(assert(e)); - hasFailed = true; + Assert.Same(e, ex); } + } - if (!hasFailed) - { - Assert.True(false); - } + protected Task AssertThrowsAsync(ValueTask t, Exception e) + { + return AssertThrowsAsync(t.AsTask(), e); } protected async Task NoNextAsync(IAsyncEnumerator e) @@ -67,6 +65,5 @@ protected async Task SequenceIdentity(IAsyncEnumerable enumerable) res1.ShouldAllBeEquivalentTo(res2); } -#pragma warning restore xUnit1013 // Public method should be marked as test } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs index 6962f4f0fe..1575d2a32c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Buffer.cs @@ -24,57 +24,57 @@ public void Buffer_Null() } [Fact] - public void Buffer1() + public async Task Buffer1Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2); var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 3, 4 })); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 5 })); - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } [Fact] - public void Buffer2() + public async Task Buffer2Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2); var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 1, 2, 3 })); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 3, 4, 5 })); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 5 })); - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } [Fact] - public void Buffer3() + public async Task Buffer3Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2, 3); var e = xs.GetAsyncEnumerator(); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 1, 2 })); - Assert.True(e.MoveNextAsync().Result); + Assert.True(await e.MoveNextAsync()); Assert.True(e.Current.SequenceEqual(new[] { 4, 5 })); - Assert.False(e.MoveNextAsync().Result); + Assert.False(await e.MoveNextAsync()); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs index 0f6a8b1a7a..50b44d3e02 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Catch.cs @@ -112,7 +112,7 @@ public async Task Catch4Async() await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); Assert.False(err); } @@ -133,7 +133,7 @@ public async Task Catch5Async() await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex2)); + await AssertThrowsAsync(e.MoveNextAsync(), ex2); } [Fact] @@ -160,7 +160,7 @@ public async Task Catch6Async() await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -224,20 +224,21 @@ public async Task Catch9Async() [Fact] public async Task Catch10Async() { - var res = CatchXss().Catch(); + var ex = new Exception("Bang!"); + var res = CatchXss(ex).Catch(); var e = res.GetAsyncEnumerator(); await HasNextAsync(e, 1); await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } - private IEnumerable> CatchXss() + private IEnumerable> CatchXss(Exception ex) { yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(new Exception("!!!"))); - throw new Exception("Bang!"); + throw ex; } [Fact] @@ -257,7 +258,7 @@ public async Task Catch11Async() await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs index 74a66d78ff..41e53c8628 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Concat.cs @@ -56,13 +56,14 @@ public async Task Concat5Async() await HasNextAsync(e, 3); await HasNextAsync(e, 4); await HasNextAsync(e, 5); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] public async Task Concat6Async() { - var res = AsyncEnumerableEx.Concat(ConcatXss()); + var ex = new Exception("Bang"); + var res = AsyncEnumerableEx.Concat(ConcatXss(ex)); var e = res.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -70,7 +71,7 @@ public async Task Concat6Async() await HasNextAsync(e, 3); await HasNextAsync(e, 4); await HasNextAsync(e, 5); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -85,11 +86,11 @@ public async Task Concat9() await SequenceIdentity(res); } - private static IEnumerable> ConcatXss() + private static IEnumerable> ConcatXss(Exception ex) { yield return new[] { 1, 2, 3 }.ToAsyncEnumerable(); yield return new[] { 4, 5 }.ToAsyncEnumerable(); - throw new Exception("Bang!"); + throw ex; } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs index 7698e8244a..91284173c0 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Defer.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -18,7 +19,7 @@ public void Defer_Null() } [Fact] - public async System.Threading.Tasks.Task Defer1Async() + public async Task Defer1Async() { var x = 0; var xs = AsyncEnumerableEx.Defer(() => new[] { x }.ToAsyncEnumerable()); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs index 644733fe59..01d8bb9aef 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/DistinctUntilChanged.cs @@ -68,7 +68,7 @@ public async Task DistinctUntilChanged3Async() await HasNextAsync(e, 1); await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs index a079379936..393776fb48 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Do.cs @@ -55,14 +55,14 @@ public async Task Do1Async() } [Fact] - public void Do2() + public async Task Do2() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Do(x => { throw ex; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -112,7 +112,7 @@ public async Task Do4Async() } [Fact] - public void Do5() + public async Task Do5() { var ex = new Exception("Bang"); var exa = default(Exception); @@ -122,7 +122,7 @@ public void Do5() var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }, () => { done = true; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); Assert.False(hasv); Assert.False(done); @@ -130,7 +130,7 @@ public void Do5() } [Fact] - public void Do6() + public async Task Do6() { var ex = new Exception("Bang"); var exa = default(Exception); @@ -139,7 +139,7 @@ public void Do6() var ys = xs.Do(x => { hasv = true; }, exx => { exa = exx; }); var e = ys.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ex_.InnerException == ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); Assert.False(hasv); Assert.Same(exa, ex); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs index 3a716256d2..8bbe045547 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Expand.cs @@ -36,13 +36,13 @@ public async Task Expand1Async() } [Fact] - public void Expand2() + public async Task Expand2() { var ex = new Exception("Bang!"); var xs = new[] { 2, 3 }.ToAsyncEnumerable().Expand(new Func>(x => { throw ex; })); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -53,7 +53,7 @@ public async Task Expand3Async() var e = xs.GetAsyncEnumerator(); await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NullReferenceException); + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs index db8a8e7d08..95f178b7ab 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Finally.cs @@ -53,7 +53,7 @@ public async Task Finally2Async() } [Fact] - public void Finally3() + public async Task Finally3Async() { var ex = new Exception("Bang!"); @@ -64,7 +64,7 @@ public void Finally3() var e = xs.GetAsyncEnumerator(); Assert.False(b); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); Assert.True(b); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs index a27a776110..14fa7d1c08 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Generate.cs @@ -35,13 +35,13 @@ public async Task Generate1() } [Fact] - public void Generate2() + public async Task Generate2Async() { var ex = new Exception("Bang!"); var xs = AsyncEnumerableEx.Generate(0, x => { throw ex; }, x => x + 1, x => x * x); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -52,7 +52,7 @@ public async Task Generate3Async() var e = xs.GetAsyncEnumerator(); await HasNextAsync(e, 0); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] @@ -63,7 +63,7 @@ public async Task Generate4Async() var e = xs.GetAsyncEnumerator(); await HasNextAsync(e, 0); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).InnerExceptions.Single() == ex); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs index 0eb0b01cbc..34e1441a85 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IgnoreElements.cs @@ -46,13 +46,13 @@ public async Task IgnoreElements3Async() } [Fact] - public void IgnoreElements4() + public async Task IgnoreElements4Async() { var ex = new Exception("Bang!"); var xs = Throw(ex).IgnoreElements(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index 5140860cb3..4618e15e18 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -30,47 +30,47 @@ public async Task MaxBy_Null() } [Fact] - public void MaxBy1() + public async Task MaxBy1Async() { var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => x / 2); - var res = xs.Result; + var res = await xs; Assert.True(res.SequenceEqual(new[] { 7, 6 })); } [Fact] - public void MaxBy2() + public async Task MaxBy2() { var xs = new int[0].ToAsyncEnumerable().MaxBy(x => x / 2); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + await AssertThrowsAsync(xs); } [Fact] - public void MaxBy3() + public async Task MaxBy3() { var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 3) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(xs, ex); } [Fact] - public void MaxBy4() + public async Task MaxBy4() { var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 4) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(xs, ex); } [Fact] - public void MaxBy5() + public async Task MaxBy5() { var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MaxBy(x => x, Comparer.Default); - AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(xs, ex); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index 03f617b345..9c9705c05f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -30,47 +30,47 @@ public async Task MinBy_Null() } [Fact] - public void MinBy1() + public async Task MinBy1Async() { var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => x / 2); - var res = xs.Result; + var res = await xs; Assert.True(res.SequenceEqual(new[] { 3, 2 })); } [Fact] - public void MinBy2() + public async Task MinBy2Async() { var xs = new int[0].ToAsyncEnumerable().MinBy(x => x / 2); - AssertThrows(() => xs.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is InvalidOperationException); + await AssertThrowsAsync(xs); } [Fact] - public void MinBy3() + public async Task MinBy3Async() { var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 3) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(xs, ex); } [Fact] - public void MinBy4() + public async Task MinBy4Async() { var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 4) throw ex; return x; }); - AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(xs, ex); } [Fact] - public void MinBy5() + public async Task MinBy5Async() { var ex = new Exception("Bang!"); var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MinBy(x => x, Comparer.Default); - AssertThrows(() => xs.Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(xs, ex); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs index d6522ec399..856bf21394 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/OnErrorResumeNext.cs @@ -88,20 +88,21 @@ public async Task OnErrorResumeNext9Async() [Fact] public async Task OnErrorResumeNext10Async() { - var res = OnErrorResumeNextXss().OnErrorResumeNext(); + var ex = new Exception("Bang!"); + var res = OnErrorResumeNextXss(ex).OnErrorResumeNext(); var e = res.GetAsyncEnumerator(); await HasNextAsync(e, 1); await HasNextAsync(e, 2); await HasNextAsync(e, 3); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single().Message == "Bang!"); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } - private IEnumerable> OnErrorResumeNextXss() + private IEnumerable> OnErrorResumeNextXss(Exception ex) { yield return new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(new Exception("!!!"))); - throw new Exception("Bang!"); + throw ex; } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs index 2464faceee..2edd8605eb 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Repeat.cs @@ -115,21 +115,21 @@ public async Task RepeatSequence5() } [Fact] - public void RepeatSequence6() + public async Task RepeatSequence6Async() { var xs = new FailRepeat().ToAsyncEnumerable().Repeat(); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public void RepeatSequence7() + public async Task RepeatSequence7Async() { var xs = new FailRepeat().ToAsyncEnumerable().Repeat(3); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is NotImplementedException); + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } private static IEnumerable RepeatXs(Action started) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs index d86a597a3d..7086a232f9 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Retry.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -21,7 +22,7 @@ public void Retry_Null() } [Fact] - public async System.Threading.Tasks.Task Retry1Async() + public async Task Retry1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -35,7 +36,7 @@ public async System.Threading.Tasks.Task Retry1Async() } [Fact] - public async System.Threading.Tasks.Task Retry2Async() + public async Task Retry2Async() { var ex = new InvalidOperationException("Bang!"); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs index 8137b11d36..e158db05de 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Return.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -10,7 +11,7 @@ namespace Tests public class Return : AsyncEnumerableExTests { [Fact] - public async System.Threading.Tasks.Task Return1Async() + public async Task Return1Async() { var xs = AsyncEnumerableEx.Return(42); await HasNextAsync(xs.GetAsyncEnumerator(), 42); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs index e2867ba0b8..8eb6caaefe 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Scan.cs @@ -46,23 +46,23 @@ public async Task Scan2Async() } [Fact] - public void Scan3() + public async Task Scan3() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(8, new Func((x, y) => { throw ex; })); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public void Scan4() + public async Task Scan4() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable().Scan(new Func((x, y) => { throw ex; })); var e = xs.GetAsyncEnumerator(); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs index fc0b04973f..bc2538d17b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/SelectMany.cs @@ -4,6 +4,7 @@ using System; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -18,7 +19,7 @@ public void SelectMany_Null() } [Fact] - public async System.Threading.Tasks.Task SelectMany1Async() + public async Task SelectMany1Async() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 4 }.ToAsyncEnumerable(); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs index b9102414c2..8880df1008 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/StartWith.cs @@ -4,6 +4,7 @@ using System; using System.Linq; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -18,7 +19,7 @@ public void StartWith_Null() } [Fact] - public async System.Threading.Tasks.Task StartWith1Async() + public async Task StartWith1Async() { var xs = AsyncEnumerable.Empty().StartWith(1, 2); @@ -29,7 +30,7 @@ public async System.Threading.Tasks.Task StartWith1Async() } [Fact] - public async System.Threading.Tasks.Task StartWith2Async() + public async Task StartWith2Async() { var xs = Return42.StartWith(40, 41); @@ -41,7 +42,7 @@ public async System.Threading.Tasks.Task StartWith2Async() } [Fact] - public async System.Threading.Tasks.Task StartWith3Async() + public async Task StartWith3Async() { var ex = new Exception("Bang!"); var xs = Throw(ex).StartWith(1, 2); @@ -49,7 +50,7 @@ public async System.Threading.Tasks.Task StartWith3Async() var e = xs.GetAsyncEnumerator(); await HasNextAsync(e, 1); await HasNextAsync(e, 2); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs index 15aee80a9b..6a83a08a8c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Using.cs @@ -128,11 +128,11 @@ public async Task Using4Async() await NoNextAsync(e); - Assert.True(disposed.Task.Result); + Assert.True(await disposed.Task); } [Fact] - public void Using5() + public async Task Using5Async() { var ex = new Exception("Bang!"); var i = 0; @@ -153,11 +153,11 @@ public void Using5() Assert.Equal(0, i); - AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), SingleInnerExceptionMatches(ex)); + await AssertThrowsAsync(e.MoveNextAsync(), ex); Assert.Equal(1, i); - Assert.True(disposed.Task.Result); + Assert.True(await disposed.Task); } [Fact] From c52d01bcc29e5fbe48e127f6c0dac61ae1623db7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 09:32:10 -0800 Subject: [PATCH 508/862] Stylistic nit. --- .../Source/System.Linq.Async/System/Linq/Operators/ForEach.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 4002d43892..25f0a0b577 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #if !HAS_AWAIT_FOREACH + using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -189,4 +190,5 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so } } } + #endif From 9538f92c3c78e04d1b17dff45ed374c52784c864 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 09:36:44 -0800 Subject: [PATCH 509/862] Improve Aggregate performance. --- .../System/Linq/Operators/Aggregate.cs | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 1a83841dc4..33095bb28b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -161,28 +161,28 @@ private static async Task AggregateCore( private static async Task AggregateCore(IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) { - var first = true; - var acc = default(TSource); - var e = source.GetAsyncEnumerator(cancellationToken); try { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var acc = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = first ? e.Current : accumulator(acc, e.Current); - first = false; + acc = accumulator(acc, e.Current); } + + return acc; } finally { await e.DisposeAsync().ConfigureAwait(false); } - - if (first) - throw Error.NoElements(); - - return acc; } private static async Task AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) @@ -229,28 +229,28 @@ private static async Task AggregateCore( private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { - var first = true; - var acc = default(TSource); - var e = source.GetAsyncEnumerator(cancellationToken); try { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var acc = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = first ? e.Current : await accumulator(acc, e.Current).ConfigureAwait(false); - first = false; + acc = await accumulator(acc, e.Current).ConfigureAwait(false); } + + return acc; } finally { await e.DisposeAsync().ConfigureAwait(false); } - - if (first) - throw Error.NoElements(); - - return acc; } } } From 7184e4f28a491e161eefdab9fea9426d8ca9fecc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 09:49:46 -0800 Subject: [PATCH 510/862] Remove CreateEnumerator. --- .../System/Linq/Operators/Never.cs | 2 +- .../System/Linq/Operators/Throw.cs | 2 +- .../System/Linq/AsyncEnumerableTests.cs | 2 +- .../System/Linq/Operators/CreateEnumerator.cs | 4 ++-- .../System/Linq/Operators/ToObservable.cs | 6 +++--- .../System.Linq.Async/System/Linq/Operators/Cast.cs | 1 - .../System.Linq.Async/System/Linq/Operators/Create.cs | 10 ---------- .../System/Linq/Operators/ToAsyncEnumerable.cs | 4 ++-- 8 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index c6886fc10b..e643dcf6bf 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable Never() // seem correct either, given that we return a *cold* sequence. // - return AsyncEnumerable.CreateEnumerable(_ => AsyncEnumerable.CreateEnumerator(() => TaskExt.Never, current: null, dispose: null)); + return AsyncEnumerable.CreateEnumerable(_ => AsyncEnumerator.Create(() => TaskExt.Never, current: null, dispose: null)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index 739a440054..e4ab45a118 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -27,7 +27,7 @@ public static IAsyncEnumerable Throw(Exception exception) // return AsyncEnumerable.CreateEnumerable( - _ => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerator.Create( () => moveNextThrows, current: null, dispose: null) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 6fb820ded2..db7c015ee6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -79,7 +79,7 @@ protected static IAsyncEnumerable Throw(Exception exception) #endif return AsyncEnumerable.CreateEnumerable( - _ => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerator.Create( () => moveNextThrows, current: null, dispose: null) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index 29a5738866..c5024f966f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -15,13 +15,13 @@ public class CreateEnumerator : AsyncEnumerableTests [Fact] public void CreateEnumerator_Null() { - Assert.Throws(() => AsyncEnumerable.CreateEnumerator(default, () => 3, () => new ValueTask())); + Assert.Throws(() => AsyncEnumerator.Create(default, () => 3, () => new ValueTask())); } [Fact] public void CreateEnumerator_Throws() { - var iter = AsyncEnumerable.CreateEnumerator(() => new ValueTask(false), () => 3, () => new ValueTask()); + var iter = AsyncEnumerator.Create(() => new ValueTask(false), () => 3, () => new ValueTask()); var enu = (IAsyncEnumerable)iter; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index a85a3b167f..e0847d0598 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -142,7 +142,7 @@ public void ToObservable_DisposesEnumeratorOnCompletion() var evt = new ManualResetEvent(false); var ae = AsyncEnumerable.CreateEnumerable( - _ => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerator.Create( () => new ValueTask(false), () => { throw new InvalidOperationException(); }, () => { evt.Set(); return default; })); @@ -176,7 +176,7 @@ public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed() var subscriptionAssignedTcs = new TaskCompletionSource(); var ae = AsyncEnumerable.CreateEnumerable( - _ => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerator.Create( async () => { await subscriptionAssignedTcs.Task; @@ -222,7 +222,7 @@ public void ToObservable_DesNotCallMoveNextAgainWhenSubscriptionIsDisposed() var subscriptionAssignedTcs = new TaskCompletionSource(); var ae = AsyncEnumerable.CreateEnumerable( - _ => AsyncEnumerable.CreateEnumerator( + _ => AsyncEnumerator.Create( async () => { await subscriptionAssignedTcs.Task; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index 8633aa39f5..e13c9ec720 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index 97f0299391..11e85895fb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -19,16 +19,6 @@ public static IAsyncEnumerable CreateEnumerable(Func(getEnumerator); } - public static IAsyncEnumerator CreateEnumerator(Func> moveNext, Func current, Func dispose) - { - return AsyncEnumerator.Create(moveNext, current, dispose); - } - - private static IAsyncEnumerator CreateEnumerator(Func, ValueTask> moveNext, Func current, Func dispose) - { - return AsyncEnumerator.Create(moveNext, current, dispose); - } - private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable { private readonly Func> _getEnumerator; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 15a1b45d4e..75517583f2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -38,7 +38,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task { if (Interlocked.CompareExchange(ref called, 1, 0) == 0) @@ -69,7 +69,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva var ctr = ct.Register(subscription.Dispose); - return CreateEnumerator( + return AsyncEnumerator.Create( tcs => { var hasValue = false; From 5cb620389bec4598923a1e42f07cedecc5a754dc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 09:51:41 -0800 Subject: [PATCH 511/862] Minor cleanup. --- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs index 11e85895fb..f9921a85b4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; -using System.Threading.Tasks; namespace System.Linq { From 717fff54c3399f4562e195e9617ca3ebf8e6f1ae Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 09:56:45 -0800 Subject: [PATCH 512/862] Remove enumerator to enumerable conversion. --- .../System/Linq/AsyncEnumerator.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 2aa0610ec5..1e2ea21622 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -76,20 +76,6 @@ public static IAsyncEnumerator WithCancellation(this IAsyncEnumerator s ); } - /// - /// Wraps the specified enumerator in an enumerable. - /// - /// The type of the elements returned by the enumerator. - /// The enumerator to wrap. - /// An enumerable wrapping the specified enumerator. - public static IAsyncEnumerable AsEnumerable(this IAsyncEnumerator source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AsyncEnumerable.CreateEnumerable(_ => source); - } - internal static IAsyncEnumerator Create(Func, ValueTask> moveNext, Func current, Func dispose) { return new AnonymousAsyncIterator( From 7d76a44fc54e68f02aaf7e42af5a44a97d112a2a Mon Sep 17 00:00:00 2001 From: "Bart J.F. De Smet" Date: Tue, 13 Nov 2018 10:24:47 -0800 Subject: [PATCH 513/862] Remove TaskExt usage in Never --- .../System.Interactive.Async/System/Linq/Operators/Never.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index 55271a0f15..62376689e4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -46,14 +46,14 @@ public ValueTask DisposeAsync() { _registration.Dispose(); _task = null; - return TaskExt.CompletedTask; + return default; } public ValueTask MoveNextAsync() { if (_once) { - return TaskExt.False; + return new ValueTask(false); } _once = true; _task = new TaskCompletionSource(); From 725636c71e38a083492ccdcb13739debdcfcc0c6 Mon Sep 17 00:00:00 2001 From: "Bart J.F. De Smet" Date: Tue, 13 Nov 2018 10:25:44 -0800 Subject: [PATCH 514/862] Remove TaskExt usage in Return --- .../System/Linq/Operators/Return.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs index 9443ae4962..f3ed5fffe3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -45,17 +45,17 @@ public ReturnEnumerator(TValue current) public ValueTask DisposeAsync() { Current = default; - return TaskExt.CompletedTask; + return default; } public ValueTask MoveNextAsync() { if (_once) { - return TaskExt.False; + return new ValueTask(false); } _once = true; - return TaskExt.True; + return new ValueTask(true); } } } From 2ff3fb55f3f49a969c449bce42068e4888572d46 Mon Sep 17 00:00:00 2001 From: "Bart J.F. De Smet" Date: Tue, 13 Nov 2018 10:26:47 -0800 Subject: [PATCH 515/862] Remove TaskExt usage in Throw --- .../System.Interactive.Async/System/Linq/Operators/Throw.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index b1d34dce2e..4446e6c0e5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -62,14 +62,14 @@ public ThrowEnumerator(ValueTask moveNextThrows) public ValueTask DisposeAsync() { - _moveNextThrows = TaskExt.False; - return TaskExt.CompletedTask; + _moveNextThrows = new ValueTask(false); + return default; } public ValueTask MoveNextAsync() { var result = _moveNextThrows; - _moveNextThrows = TaskExt.False; + _moveNextThrows = new ValueTask(false); return result; } From f971c7bc63d4e23fd97901b3452ab2e552d56962 Mon Sep 17 00:00:00 2001 From: "Bart J.F. De Smet" Date: Tue, 13 Nov 2018 10:35:11 -0800 Subject: [PATCH 516/862] Fix build break in Never tests --- .../System/Linq/Operators/Never.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs index e53a0f635f..68f9a8980a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs @@ -1,7 +1,8 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System; using System.Linq; using System.Threading; using System.Threading.Tasks; From 5e94397deefa81999e6213d4d46954154f9983e8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 10:45:32 -0800 Subject: [PATCH 517/862] Add support for IAsyncListProvider to Return. --- .../System/Linq/Operators/Return.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs index f3ed5fffe3..abf2571112 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -15,9 +15,9 @@ public static IAsyncEnumerable Return(TValue value) return new ReturnEnumerable(value); } - // FIXME: AsyncListPartition is internal to the project System.Linq.Async - // project, not sure how to expose it here - private sealed class ReturnEnumerable : IAsyncEnumerable + // REVIEW: Add support for IAsyncPartition. + + private sealed class ReturnEnumerable : IAsyncEnumerable, IAsyncIListProvider { private readonly TValue _value; @@ -31,10 +31,14 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellatio return new ReturnEnumerator(_value); } + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(1); + + public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(new[] { _value }); + + public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List(1) { _value }); + private sealed class ReturnEnumerator : IAsyncEnumerator { - public TValue Current { get; private set; } - private bool _once; public ReturnEnumerator(TValue current) @@ -42,6 +46,8 @@ public ReturnEnumerator(TValue current) Current = current; } + public TValue Current { get; private set; } + public ValueTask DisposeAsync() { Current = default; @@ -54,6 +60,7 @@ public ValueTask MoveNextAsync() { return new ValueTask(false); } + _once = true; return new ValueTask(true); } From 30e9bf266f37972e4c8ef2506f1a7f13f293b6eb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 10:48:30 -0800 Subject: [PATCH 518/862] Fix Throw factory. --- .../System/Linq/Operators/Throw.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index 86520d1de0..6abca00a40 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -23,16 +23,7 @@ public static IAsyncEnumerable Throw(Exception exception) var moveNextThrows = new ValueTask(Task.FromException(exception)); #endif - // - // REVIEW: Honor cancellation using conditional expression in MoveNextAsync? - // - - return AsyncEnumerable.CreateEnumerable( - _ => AsyncEnumerator.Create( - () => moveNextThrows, - current: null, - dispose: null) - ); + return new ThrowEnumerable(moveNextThrows); } private sealed class ThrowEnumerable : IAsyncEnumerable From 17b314286948b013874b105821cecef54481bb78 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 10:56:51 -0800 Subject: [PATCH 519/862] Adding a comment on granting cancellation in iterators. --- Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 7f80d75cc7..a5a12b3d4f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -30,6 +30,9 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati enumerator._state = AsyncIteratorState.Allocated; enumerator._cancellationToken = cancellationToken; + // REVIEW: If the final interface contains a CancellationToken here, should we check for a cancellation request + // either here or in the first call to MoveNextAsync? + return enumerator; } From f12d4482ccc4ac2aed71b75f1ae7b76ff5dd5700 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 11:10:41 -0800 Subject: [PATCH 520/862] Minor edits of Never. --- .../System/Linq/Operators/Never.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index 62376689e4..541f1ceb3c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; @@ -27,14 +26,10 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellatio private sealed class NeverAsyncEnumerator : IAsyncEnumerator { - public TValue Current => throw new InvalidOperationException(); - private readonly CancellationToken _token; private CancellationTokenRegistration _registration; - private bool _once; - private TaskCompletionSource _task; public NeverAsyncEnumerator(CancellationToken token) @@ -42,6 +37,8 @@ public NeverAsyncEnumerator(CancellationToken token) _token = token; } + public TValue Current => throw new InvalidOperationException(); + public ValueTask DisposeAsync() { _registration.Dispose(); @@ -55,6 +52,7 @@ public ValueTask MoveNextAsync() { return new ValueTask(false); } + _once = true; _task = new TaskCompletionSource(); _registration = _token.Register(state => ((NeverAsyncEnumerator)state)._task.SetCanceled(), this); From c8d4e326b7bc5388aaff1415a7a2fe45685ede07 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 11:13:44 -0800 Subject: [PATCH 521/862] Simplify Never test. --- .../System/Linq/Operators/Never.cs | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs index 68f9a8980a..cacdff4772 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. @@ -23,7 +23,7 @@ public async Task Never1() } [Fact] - public void CancelToken_Unblocks() + public async Task CancelToken_UnblocksAsync() { var cts = new CancellationTokenSource(); @@ -31,27 +31,13 @@ public void CancelToken_Unblocks() try { - var t = Task.Run(async () => - { - await Task.Delay(100); - cts.Cancel(); - }); + cts.CancelAfter(100); - try - { - Assert.True(en.MoveNextAsync().AsTask().Wait(2000)); - } - catch (AggregateException ex) - { - if (!(ex.InnerException is TaskCanceledException)) - { - throw; - } - } + await Assert.ThrowsAsync(() => en.MoveNextAsync().AsTask()); } finally { - en.DisposeAsync().AsTask().Wait(2000); + await en.DisposeAsync(); } } } From 35baf55cdc921d304d0967cf864ba3415dcdd130 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 11:17:50 -0800 Subject: [PATCH 522/862] Add test for Throw. --- .../System/Linq/Operators/Throw.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Throw.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Throw.cs new file mode 100644 index 0000000000..cea8d38ea0 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Throw.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class Throw : AsyncEnumerableExTests + { + [Fact] + public async Task Throw1() + { + var ex = new Exception("Bang!"); + var xs = AsyncEnumerableEx.Throw(ex); + var e = xs.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + Assert.False(await e.MoveNextAsync()); + } + } +} From 6e6f2c82331299c040f717a15fab956b831379f7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 11:26:22 -0800 Subject: [PATCH 523/862] Add some comments to Timeout. --- .../System/Linq/Operators/Timeout.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index 4708bad2c9..dbec0d98f2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -87,9 +87,20 @@ protected override async ValueTask MoveNextCore() if (winner == delay) { - // we still have to wait for the "next" to complete - // before we can dispose _enumerator - _loserTask = next.ContinueWith(async (t, state) => await ((IAsyncDisposable)state).DisposeAsync(), _enumerator); + // NB: We still have to wait for the MoveNextAsync operation to complete before we can + // dispose _enumerator. The resulting task will be used by DisposeAsync. Also note + // that throwing an exception here causes a call to DisposeAsync, where we pick up + // the task prepared below. + + // NB: Any exception reported by a timed out MoveNextAsync operation won't be reported + // to the caller, but the task's exception is not marked as observed, so unhandled + // exception handlers can still observe the exception. + + // REVIEW: Should exceptions reported by a timed out MoveNextAsync operation come out + // when attempting to call DisposeAsync? + + _loserTask = next.ContinueWith((_, state) => ((IAsyncDisposable)state).DisposeAsync().AsTask(), _enumerator); + throw new TimeoutException(); } From 6a3dfda57489bf5c2a329d2964d853f0a5ce47f9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 11:30:16 -0800 Subject: [PATCH 524/862] Move Create and AsAsyncEnumerable. --- .../System/Linq/Operators/Defer.cs | 1 - .../System/Linq/AsyncEnumerable.cs | 22 ++++++++++-- .../Linq/Operators/AsAsyncEnumerable.cs | 15 ++++++++ .../System/Linq/Operators/Create.cs | 35 ------------------- 4 files changed, 35 insertions(+), 38 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AsAsyncEnumerable.cs delete mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index a01e982f15..c2689a22db 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -117,6 +117,5 @@ private sealed class DisposedEnumerator : IAsyncEnumerator } } } - } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 074d1b7e3b..f820326c04 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -8,8 +8,26 @@ namespace System.Linq { public static partial class AsyncEnumerable { - // NB: Synchronous LINQ to Objects doesn't hide the implementation of the source either. + public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) + { + if (getEnumerator == null) + throw Error.ArgumentNull(nameof(getEnumerator)); - public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEnumerable source) => source; + return new AnonymousAsyncEnumerable(getEnumerator); + } + + private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable + { + private readonly Func> _getEnumerator; + + public AnonymousAsyncEnumerable(Func> getEnumerator) + { + Debug.Assert(getEnumerator != null); + + _getEnumerator = getEnumerator; + } + + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => _getEnumerator(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AsAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AsAsyncEnumerable.cs new file mode 100644 index 0000000000..074d1b7e3b --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AsAsyncEnumerable.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + // NB: Synchronous LINQ to Objects doesn't hide the implementation of the source either. + + public static IAsyncEnumerable AsAsyncEnumerable(this IAsyncEnumerable source) => source; + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs deleted file mode 100644 index f9921a85b4..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Create.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) - { - if (getEnumerator == null) - throw Error.ArgumentNull(nameof(getEnumerator)); - - return new AnonymousAsyncEnumerable(getEnumerator); - } - - private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable - { - private readonly Func> _getEnumerator; - - public AnonymousAsyncEnumerable(Func> getEnumerator) - { - Debug.Assert(getEnumerator != null); - - _getEnumerator = getEnumerator; - } - - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => _getEnumerator(cancellationToken); - } - } -} From fc3552e2e21876b0be0ac83e8cb43f303f4f077c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 11:30:50 -0800 Subject: [PATCH 525/862] Fix some namespaces. --- Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index f820326c04..f9921a85b4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; namespace System.Linq { From f73236d97f6efcc76e1fea184fa52a29f01359a9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 11:51:45 -0800 Subject: [PATCH 526/862] Don't pay for the _current field if unused. --- .../System/Linq/AsyncIterator.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index a5a12b3d4f..46c673219b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -8,15 +8,14 @@ namespace System.Linq { - internal abstract partial class AsyncIterator : IAsyncEnumerable, IAsyncEnumerator + internal abstract class AsyncIteratorBase : IAsyncEnumerable, IAsyncEnumerator { private readonly int _threadId; - protected TSource _current; protected AsyncIteratorState _state = AsyncIteratorState.New; protected CancellationToken _cancellationToken; - protected AsyncIterator() + protected AsyncIteratorBase() { _threadId = Environment.CurrentManagedThreadId; } @@ -38,13 +37,12 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati public virtual ValueTask DisposeAsync() { - _current = default; _state = AsyncIteratorState.Disposed; return default; } - public TSource Current => _current; + public abstract TSource Current { get; } public async ValueTask MoveNextAsync() { @@ -73,6 +71,20 @@ public async ValueTask MoveNextAsync() protected abstract ValueTask MoveNextCore(); } + internal abstract partial class AsyncIterator : AsyncIteratorBase + { + protected TSource _current; + + public override TSource Current => _current; + + public override ValueTask DisposeAsync() + { + _current = default; + + return base.DisposeAsync(); + } + } + internal enum AsyncIteratorState { New = 0, From 3a3c59ba42bb4d1ed985b1c41c6b849f118ec95b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 12:20:31 -0800 Subject: [PATCH 527/862] Change signature of Clone. --- .../System/Linq/Operators/Amb.cs | 4 ++-- .../System/Linq/Operators/Buffer.cs | 2 +- .../System/Linq/Operators/Catch.cs | 6 +++--- .../System/Linq/Operators/Concat.cs | 4 ++-- .../System/Linq/Operators/Distinct.cs | 4 ++-- .../Linq/Operators/DistinctUntilChanged.cs | 6 +++--- .../System/Linq/Operators/Do.cs | 4 ++-- .../System/Linq/Operators/Expand.cs | 4 ++-- .../System/Linq/Operators/Finally.cs | 4 ++-- .../System/Linq/Operators/Generate.cs | 2 +- .../System/Linq/Operators/IgnoreElements.cs | 2 +- .../System/Linq/Operators/Merge.cs | 2 +- .../System/Linq/Operators/OnErrorResumeNext.cs | 2 +- .../System/Linq/Operators/Repeat.cs | 4 ++-- .../System/Linq/Operators/Scan.cs | 8 ++++---- .../System/Linq/Operators/Timeout.cs | 2 +- .../System/Linq/Operators/Using.cs | 4 ++-- .../System/Linq/AsyncEnumerablePartition.cs | 2 +- .../System/Linq/AsyncEnumerator.cs | 2 +- .../System/Linq/AsyncIterator.Opt.cs | 2 +- .../System/Linq/AsyncIterator.cs | 6 +++--- .../System/Linq/AsyncListPartition.cs | 2 +- .../System/Linq/Operators/AppendPrepend.cs | 4 ++-- .../System/Linq/Operators/Cast.cs | 2 +- .../System/Linq/Operators/Concat.cs | 4 ++-- .../System/Linq/Operators/DefaultIfEmpty.cs | 2 +- .../System/Linq/Operators/Distinct.cs | 2 +- .../System/Linq/Operators/Except.cs | 2 +- .../System/Linq/Operators/GroupBy.cs | 14 ++++++++------ .../System/Linq/Operators/Intersect.cs | 2 +- .../System/Linq/Operators/Join.cs | 4 ++-- .../System/Linq/Operators/OfType.cs | 2 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 4 ++-- .../System/Linq/Operators/Range.cs | 2 +- .../System/Linq/Operators/Repeat.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/Select.cs | 12 ++++++------ .../System/Linq/Operators/SelectMany.cs | 16 ++++++++-------- .../System/Linq/Operators/Skip.cs | 2 +- .../System/Linq/Operators/SkipLast.cs | 4 ++-- .../System/Linq/Operators/SkipWhile.cs | 8 ++++---- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 8 ++++---- .../System/Linq/Operators/ToAsyncEnumerable.cs | 6 +++--- .../System/Linq/Operators/Union.cs | 4 ++-- .../System/Linq/Operators/Where.cs | 15 +++++++-------- .../System/Linq/Operators/Zip.cs | 4 ++-- 47 files changed, 104 insertions(+), 103 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 690175b87e..830f7c417e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -53,7 +53,7 @@ public AmbAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable Clone() + public override AsyncIteratorBase Clone() { return new AmbAsyncIterator(_first, _second); } @@ -148,7 +148,7 @@ public AmbAsyncIteratorN(IAsyncEnumerable[] sources) _sources = sources; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AmbAsyncIteratorN(_sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 892781b818..7a676ae61e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -53,7 +53,7 @@ public BufferAsyncIterator(IAsyncEnumerable source, int count, int skip _skip = skip; } - public override AsyncIterator> Clone() + public override AsyncIteratorBase> Clone() { return new BufferAsyncIterator(_source, _count, _skip); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 62fe08cb59..a0cdf891b3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -82,7 +82,7 @@ public CatchAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new CatchAsyncIterator(_source, _handler); } @@ -175,7 +175,7 @@ public CatchAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new CatchAsyncIteratorWithTask(_source, _handler); } @@ -267,7 +267,7 @@ public CatchAsyncIterator(IEnumerable> sources) _sources = sources; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new CatchAsyncIterator(_sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index b5d9fc626a..e6f2671c91 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -51,7 +51,7 @@ public ConcatEnumerableAsyncIterator(IEnumerable> sour _source = source; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new ConcatEnumerableAsyncIterator(_source); } @@ -140,7 +140,7 @@ public ConcatAsyncEnumerableAsyncIterator(IAsyncEnumerable Clone() + public override AsyncIteratorBase Clone() { return new ConcatAsyncEnumerableAsyncIterator(_source); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index b5c1dee8b2..3220740a14 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -125,7 +125,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return count; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DistinctAsyncIterator(_source, _keySelector, _comparer); } @@ -270,7 +270,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell return count; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DistinctAsyncIteratorWithTask(_source, _keySelector, _comparer); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index fbe357e88b..2358f68212 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -101,7 +101,7 @@ public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, IEqua _comparer = comparer ?? EqualityComparer.Default; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DistinctUntilChangedAsyncIterator(_source, _comparer); } @@ -172,7 +172,7 @@ public DistinctUntilChangedAsyncIterator(IAsyncEnumerable source, Func< _comparer = comparer ?? EqualityComparer.Default; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DistinctUntilChangedAsyncIterator(_source, _keySelector, _comparer); } @@ -243,7 +243,7 @@ public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable sourc _comparer = comparer ?? EqualityComparer.Default; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DistinctUntilChangedAsyncIteratorWithTask(_source, _keySelector, _comparer); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index 987e0d0314..06628ac7f1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -147,7 +147,7 @@ public DoAsyncIterator(IAsyncEnumerable source, Action onNext, _onCompleted = onCompleted; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DoAsyncIterator(_source, _onNext, _onError, _onCompleted); } @@ -223,7 +223,7 @@ public DoAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new DoAsyncIteratorWithTask(_source, _onNext, _onError, _onCompleted); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 7fc494443f..e12b6333df 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -49,7 +49,7 @@ public ExpandAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new ExpandAsyncIterator(_source, _selector); } @@ -139,7 +139,7 @@ public ExpandAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new ExpandAsyncIteratorWithTask(_source, _selector); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 4d9f70c4c0..52bc64d620 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -47,7 +47,7 @@ public FinallyAsyncIterator(IAsyncEnumerable source, Action finallyActi _finallyAction = finallyAction; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new FinallyAsyncIterator(_source, _finallyAction); } @@ -105,7 +105,7 @@ public FinallyAsyncIteratorWithTask(IAsyncEnumerable source, Func _finallyAction = finallyAction; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new FinallyAsyncIteratorWithTask(_source, _finallyAction); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 4c16e90252..897325aa93 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -46,7 +46,7 @@ public GenerateAsyncIterator(TState initialState, Func condition, _resultSelector = resultSelector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new GenerateAsyncIterator(_initialState, _condition, _iterate, _resultSelector); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index 9c5cb77c6b..29064bf701 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -31,7 +31,7 @@ public IgnoreElementsAsyncIterator(IAsyncEnumerable source) _source = source; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new IgnoreElementsAsyncIterator(_source); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 61bb76ea20..14955d0b40 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -50,7 +50,7 @@ public MergeAsyncIterator(IAsyncEnumerable[] sources) _sources = sources; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new MergeAsyncIterator(_sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs index ec998483d7..6b928fd772 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/OnErrorResumeNext.cs @@ -56,7 +56,7 @@ public OnErrorResumeNextAsyncIterator(IEnumerable> sou _sources = sources; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new OnErrorResumeNextAsyncIterator(_sources); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index 4509c934a9..0ab6e03f62 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -43,7 +43,7 @@ public RepeatElementAsyncIterator(TResult element) _element = element; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new RepeatElementAsyncIterator(_element); } @@ -76,7 +76,7 @@ public RepeatSequenceAsyncIterator(IAsyncEnumerable source, int count) _currentCount = count; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new RepeatSequenceAsyncIterator(_source, _count); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index de9626dc77..0a589b4dfa 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -70,7 +70,7 @@ public ScanAsyncEnumerable(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new ScanAsyncEnumerable(_source, _accumulator); } @@ -144,7 +144,7 @@ public ScanAsyncEnumerable(IAsyncEnumerable source, TAccumulate seed, F _accumulator = accumulator; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new ScanAsyncEnumerable(_source, _seed, _accumulator); } @@ -208,7 +208,7 @@ public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new ScanAsyncEnumerableWithTask(_source, _accumulator); } @@ -282,7 +282,7 @@ public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, TAccumulate _accumulator = accumulator; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new ScanAsyncEnumerableWithTask(_source, _seed, _accumulator); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index dbec0d98f2..ff56076096 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -40,7 +40,7 @@ public TimeoutAsyncIterator(IAsyncEnumerable source, TimeSpan timeout) _timeout = timeout; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new TimeoutAsyncIterator(_source, _timeout); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 0347733dd7..18bfee2dba 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -48,7 +48,7 @@ public UsingAsyncIterator(Func resourceFactory, Func Clone() + public override AsyncIteratorBase Clone() { return new UsingAsyncIterator(_resourceFactory, _enumerableFactory); } @@ -117,7 +117,7 @@ public UsingAsyncIteratorWithTask(Func> resourceFactory, Func Clone() + public override AsyncIteratorBase Clone() { return new UsingAsyncIteratorWithTask(_resourceFactory, _enumerableFactory); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index cdeff0f874..b770b3f095 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -46,7 +46,7 @@ internal AsyncEnumerablePartition(IAsyncEnumerable source, int minIndex private int Limit => (_maxIndexInclusive + 1) - _minIndexInclusive; // This is that upper bound. - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AsyncEnumerablePartition(_source, _minIndexInclusive, _maxIndexInclusive); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 1e2ea21622..401dc08e69 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -108,7 +108,7 @@ public AnonymousAsyncIterator(Func> moveNext, Func currentFun GetAsyncEnumerator(default); } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator."); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs index 9754db0ce4..88cfce091d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs @@ -7,7 +7,7 @@ namespace System.Linq { - internal partial class AsyncIterator + internal partial class AsyncIteratorBase { public virtual IAsyncEnumerable Select(Func selector) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 46c673219b..9b03d05598 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -8,7 +8,7 @@ namespace System.Linq { - internal abstract class AsyncIteratorBase : IAsyncEnumerable, IAsyncEnumerator + internal abstract partial class AsyncIteratorBase : IAsyncEnumerable, IAsyncEnumerator { private readonly int _threadId; @@ -66,12 +66,12 @@ public async ValueTask MoveNextAsync() } } - public abstract AsyncIterator Clone(); + public abstract AsyncIteratorBase Clone(); protected abstract ValueTask MoveNextCore(); } - internal abstract partial class AsyncIterator : AsyncIteratorBase + internal abstract class AsyncIterator : AsyncIteratorBase { protected TSource _current; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 8a0525f7c4..9b23beb9cc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -33,7 +33,7 @@ public AsyncListPartition(IList source, int minIndexInclusive, int maxI _index = 0; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AsyncListPartition(_source, _minIndexInclusive, _maxIndexInclusive); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 9bd581c51a..ed5e803859 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -105,7 +105,7 @@ public AppendPrepend1AsyncIterator(IAsyncEnumerable source, TSource ite _appending = appending; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AppendPrepend1AsyncIterator(_source, _item, _appending); } @@ -297,7 +297,7 @@ public AppendPrependNAsyncIterator(IAsyncEnumerable source, SingleLinke _appendCount = appendCount; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AppendPrependNAsyncIterator(_source, _prepended, _appended, _prependCount, _appendCount); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index e13c9ec720..fe456ec37f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -36,7 +36,7 @@ public CastAsyncIterator(IAsyncEnumerable source) _source = source; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new CastAsyncIterator(_source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 2a6c5458ce..4fb17a8178 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -37,7 +37,7 @@ internal Concat2AsyncIterator(IAsyncEnumerable first, IAsyncEnumerable< _second = second; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new Concat2AsyncIterator(_first, _second); } @@ -205,7 +205,7 @@ internal ConcatNAsyncIterator(ConcatAsyncIterator previousConcat, IAsyn _nextIndex = nextIndex; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new ConcatNAsyncIterator(_previousConcat, _next, _nextIndex); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index e11ec3067b..b11295a388 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -43,7 +43,7 @@ public DefaultIfEmptyAsyncIterator(IAsyncEnumerable source, TSource def _defaultValue = defaultValue; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DefaultIfEmptyAsyncIterator(_source, _defaultValue); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index e6e20aeeb3..e4e00ce2b8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -71,7 +71,7 @@ async Task Core() } } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new DistinctAsyncIterator(_source, _comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 3c073eb79e..9b69ba5da0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -50,7 +50,7 @@ public ExceptAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable Clone() + public override AsyncIteratorBase Clone() { return new ExceptAsyncIterator(_first, _second, _comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 57d454a754..a9c6c00d7a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -225,7 +225,7 @@ public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new GroupedResultAsyncEnumerable(_source, _keySelector, _resultSelector, _comparer); } @@ -318,7 +318,7 @@ public GroupedResultAsyncEnumerableWithTask(IAsyncEnumerable source, Fu _comparer = comparer; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new GroupedResultAsyncEnumerableWithTask(_source, _keySelector, _resultSelector, _comparer); } @@ -411,7 +411,7 @@ public GroupedAsyncEnumerable(IAsyncEnumerable source, Func> Clone() + public override AsyncIteratorBase> Clone() { return new GroupedAsyncEnumerable(_source, _keySelector, _elementSelector, _comparer); } @@ -504,7 +504,7 @@ public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> Clone() + public override AsyncIteratorBase> Clone() { return new GroupedAsyncEnumerableWithTask(_source, _keySelector, _elementSelector, _comparer); } @@ -594,10 +594,11 @@ public GroupedAsyncEnumerable(IAsyncEnumerable source, Func> Clone() + public override AsyncIteratorBase> Clone() { return new GroupedAsyncEnumerable(_source, _keySelector, _comparer); } + public override async ValueTask DisposeAsync() { if (_enumerator != null) @@ -683,10 +684,11 @@ public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> Clone() + public override AsyncIteratorBase> Clone() { return new GroupedAsyncEnumerableWithTask(_source, _keySelector, _comparer); } + public override async ValueTask DisposeAsync() { if (_enumerator != null) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 973e3f06ac..799648659f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -50,7 +50,7 @@ public IntersectAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable< _comparer = comparer; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new IntersectAsyncIterator(_first, _second, _comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index ff389e820e..8b3dc5c289 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -102,7 +102,7 @@ public JoinAsyncIterator(IAsyncEnumerable outer, IAsyncEnumerable Clone() + public override AsyncIteratorBase Clone() { return new JoinAsyncIterator(_outer, _inner, _outerKeySelector, _innerKeySelector, _resultSelector, _comparer); } @@ -229,7 +229,7 @@ public JoinAsyncIteratorWithTask(IAsyncEnumerable outer, IAsyncEnumerabl _comparer = comparer; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new JoinAsyncIteratorWithTask(_outer, _inner, _outerKeySelector, _innerKeySelector, _resultSelector, _comparer); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index 752a15b903..7f9cc30d34 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -31,7 +31,7 @@ public OfTypeAsyncIterator(IAsyncEnumerable source) _source = source; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new OfTypeAsyncIterator(_source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 562fb46949..7969ba8dad 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -88,7 +88,7 @@ public OrderedAsyncEnumerable(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new OrderedAsyncEnumerable(_source, _keySelector, _comparer, _descending, _parent); } @@ -125,7 +125,7 @@ public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new OrderedAsyncEnumerableWithTask(_source, _keySelector, _comparer, _descending, _parent); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index ff612e8688..4d558ab05a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -39,7 +39,7 @@ public RangeAsyncIterator(int start, int count) _end = start + count; } - public override AsyncIterator Clone() => new RangeAsyncIterator(_start, _end - _start); + public override AsyncIteratorBase Clone() => new RangeAsyncIterator(_start, _end - _start); public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_end - _start); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 61aa982744..9f4c719ca7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -30,7 +30,7 @@ public RepeatAsyncIterator(TResult element, int count) _count = count; } - public override AsyncIterator Clone() => new RepeatAsyncIterator(_element, _count); + public override AsyncIteratorBase Clone() => new RepeatAsyncIterator(_element, _count); public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_count); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index 31adbe7b65..ee046bb144 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -76,7 +76,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT return _source.Count(cancellationToken); } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new ReverseAsyncIterator(_source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 2935957cb5..b931db209b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -93,7 +93,7 @@ public SelectEnumerableAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectEnumerableAsyncIterator(_source, _selector); } @@ -154,7 +154,7 @@ public SelectEnumerableWithIndexAsyncIterator(IAsyncEnumerable source, _selector = selector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SelectEnumerableWithIndexAsyncIterator(_source, _selector); } @@ -217,7 +217,7 @@ public SelectIListIterator(IList source, Func selecto _selector = selector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SelectIListIterator(_source, _selector); } @@ -328,7 +328,7 @@ public SelectEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, F _selector = selector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SelectEnumerableAsyncIteratorWithTask(_source, _selector); } @@ -389,7 +389,7 @@ public SelectEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable _selector = selector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SelectEnumerableWithIndexAsyncIteratorWithTask(_source, _selector); } @@ -457,7 +457,7 @@ public SelectIListIteratorWithTask(IList source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectIListIteratorWithTask(_source, _selector); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 6bc693e522..0a19edce7b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -120,7 +120,7 @@ public SelectManyAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectManyAsyncIterator(_source, _selector); } @@ -211,7 +211,7 @@ public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectManyAsyncIteratorWithTask(_source, _selector); } @@ -306,7 +306,7 @@ public SelectManyAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectManyAsyncIterator(_source, _collectionSelector, _resultSelector); } @@ -404,7 +404,7 @@ public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectManyAsyncIteratorWithTask(_source, _collectionSelector, _resultSelector); } @@ -503,7 +503,7 @@ public SelectManyWithIndexAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectManyWithIndexAsyncIterator(_source, _collectionSelector, _resultSelector); } @@ -609,7 +609,7 @@ public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source _resultSelector = resultSelector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SelectManyWithIndexAsyncIteratorWithTask(_source, _collectionSelector, _resultSelector); } @@ -711,7 +711,7 @@ public SelectManyWithIndexAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SelectManyWithIndexAsyncIterator(_source, _selector); } @@ -809,7 +809,7 @@ public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source _selector = selector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SelectManyWithIndexAsyncIteratorWithTask(_source, _selector); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs index ffa09fb1fc..03918dee05 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Skip.cs @@ -17,7 +17,7 @@ public static IAsyncEnumerable Skip(this IAsyncEnumerable || source is IAsyncPartition) + if (source is AsyncIteratorBase || source is IAsyncPartition) { return source; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 57cd7bbb66..fd6daac5be 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable SkipLast(this IAsyncEnumerable< { // Return source if not actually skipping, but only if it's a type from here, to avoid // issues if collections are used as keys or otherwise must not be aliased. - if (source is AsyncIterator) + if (source is AsyncIteratorBase) { return source; } @@ -47,7 +47,7 @@ public SkipLastAsyncIterator(IAsyncEnumerable source, int count) _count = count; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SkipLastAsyncIterator(_source, _count); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index fb1a99377e..1182b09b41 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -68,7 +68,7 @@ public SkipWhileAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SkipWhileAsyncIterator(_source, _predicate); } @@ -145,7 +145,7 @@ public SkipWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SkipWhileWithIndexAsyncIterator(_source, _predicate); } @@ -228,7 +228,7 @@ public SkipWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new SkipWhileAsyncIteratorWithTask(_source, _predicate); } @@ -305,7 +305,7 @@ public SkipWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, _predicate = predicate; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new SkipWhileWithIndexAsyncIteratorWithTask(_source, _predicate); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 46bfe65f0c..28c009db1f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -41,7 +41,7 @@ public TakeLastAsyncIterator(IAsyncEnumerable source, int count) _count = count; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new TakeLastAsyncIterator(_source, _count); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 15f8ca093b..f932b8a3f6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -67,7 +67,7 @@ public TakeWhileAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new TakeWhileAsyncIterator(_source, _predicate); } @@ -132,7 +132,7 @@ public TakeWhileWithIndexAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new TakeWhileWithIndexAsyncIterator(_source, _predicate); } @@ -202,7 +202,7 @@ public TakeWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new TakeWhileAsyncIteratorWithTask(_source, _predicate); } @@ -267,7 +267,7 @@ public TakeWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, _predicate = predicate; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new TakeWhileWithIndexAsyncIteratorWithTask(_source, _predicate); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 75517583f2..f71bde926c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -136,7 +136,7 @@ public AsyncEnumerableAdapter(IEnumerable source) _source = source; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AsyncEnumerableAdapter(_source); } @@ -205,7 +205,7 @@ public AsyncIListEnumerableAdapter(IList source) _source = source; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AsyncIListEnumerableAdapter(_source); } @@ -309,7 +309,7 @@ public AsyncICollectionEnumerableAdapter(ICollection source) _source = source; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new AsyncICollectionEnumerableAdapter(_source); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 983180d8ce..c27a1d7126 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -213,7 +213,7 @@ public UnionAsyncIterator2(IAsyncEnumerable first, IAsyncEnumerable Clone() => new UnionAsyncIterator2(_first, _second, _comparer); + public override AsyncIteratorBase Clone() => new UnionAsyncIterator2(_first, _second, _comparer); internal override IAsyncEnumerable GetEnumerable(int index) { @@ -255,7 +255,7 @@ public UnionAsyncIteratorN(SingleLinkedNode> sources, _headIndex = headIndex; } - public override AsyncIterator Clone() => new UnionAsyncIteratorN(_sources, _headIndex, _comparer); + public override AsyncIteratorBase Clone() => new UnionAsyncIteratorN(_sources, _headIndex, _comparer); internal override IAsyncEnumerable GetEnumerable(int index) => index > _headIndex ? null : _sources.GetNode(_headIndex - index).Item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index e8786f6431..796578e42d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -18,7 +17,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable iterator) + if (source is AsyncIteratorBase iterator) { return iterator.Where(predicate); } @@ -44,7 +43,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable iterator) + if (source is AsyncIteratorBase iterator) { return iterator.Where(predicate); } @@ -88,7 +87,7 @@ public WhereEnumerableAsyncIterator(IAsyncEnumerable source, Func Clone() + public override AsyncIteratorBase Clone() { return new WhereEnumerableAsyncIterator(_source, _predicate); } @@ -159,7 +158,7 @@ public WhereEnumerableWithIndexAsyncIterator(IAsyncEnumerable source, F _predicate = predicate; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new WhereEnumerableWithIndexAsyncIterator(_source, _predicate); } @@ -225,7 +224,7 @@ public WhereEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Fu _predicate = predicate; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new WhereEnumerableAsyncIteratorWithTask(_source, _predicate); } @@ -291,7 +290,7 @@ public WhereEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable s _predicate = predicate; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new WhereEnumerableWithIndexAsyncIteratorWithTask(_source, _predicate); } @@ -361,7 +360,7 @@ public WhereSelectEnumerableAsyncIterator(IAsyncEnumerable source, Func _selector = selector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new WhereSelectEnumerableAsyncIterator(_source, _predicate, _selector); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 1b52e171fb..1cb61f5901 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -55,7 +55,7 @@ public ZipAsyncIterator(IAsyncEnumerable first, IAsyncEnumerable Clone() + public override AsyncIteratorBase Clone() { return new ZipAsyncIterator(_first, _second, _selector); } @@ -127,7 +127,7 @@ public ZipAsyncIteratorWithTask(IAsyncEnumerable first, IAsyncEnumerable _selector = selector; } - public override AsyncIterator Clone() + public override AsyncIteratorBase Clone() { return new ZipAsyncIteratorWithTask(_first, _second, _selector); } From 65fd9d020135194d322d49341386b1921ba16f20 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 13:27:09 -0800 Subject: [PATCH 528/862] Add performance remarks. --- .../Source/System.Linq.Async/System/Linq/AsyncIterator.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 9b03d05598..804ba8ca65 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -8,6 +8,14 @@ namespace System.Linq { + // REVIEW: The base class below was introduced to avoid the overhead of storing a field of type TSource if the + // value of the iterator can trivially be inferred from another field (e.g. in Repeat). It is also used + // by the Defer operator in System.Interactive.Async. For some operators such as Where, Skip, Take, and + // Concat, it could be used to retrieve the value from the underlying enumerator. However, performance + // of this approach is a bit worse in some cases, so we don't go ahead with it for now. One decision to + // make is whether it's okay for Current to throw an exception when MoveNextAsync returns false, e.g. + // by omitting a null check for an enumerator field. + internal abstract partial class AsyncIteratorBase : IAsyncEnumerable, IAsyncEnumerator { private readonly int _threadId; From 1ddf3537015ddd6818212c15a17963d88990a420 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 13:27:23 -0800 Subject: [PATCH 529/862] Rewrite Defer to be lazy in all cases. --- .../System/Linq/Operators/Defer.cs | 148 ++++++++++-------- 1 file changed, 86 insertions(+), 62 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index c2689a22db..f8c76bdeae 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -17,7 +17,7 @@ public static IAsyncEnumerable Defer(Func factory().GetAsyncEnumerator(ct)); + return new DeferIterator(factory); } public static IAsyncEnumerable Defer(Func>> factory) @@ -25,96 +25,120 @@ public static IAsyncEnumerable Defer(Func(async ct => (await factory().ConfigureAwait(false)).GetAsyncEnumerator(ct)); + return new AsyncDeferIterator(factory); } - private sealed class AnonymousAsyncEnumerableWithTask : IAsyncEnumerable + private sealed class DeferIterator : AsyncIteratorBase { - private readonly Func>> _getEnumerator; + private readonly Func> _factory; + private IAsyncEnumerator _enumerator; - public AnonymousAsyncEnumerableWithTask(Func>> getEnumerator) + public DeferIterator(Func> factory) { - Debug.Assert(getEnumerator != null); + Debug.Assert(factory != null); - _getEnumerator = getEnumerator; + _factory = factory; } - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new Enumerator(_getEnumerator, cancellationToken); + public override T Current => _enumerator == null ? default : _enumerator.Current; - private sealed class Enumerator : IAsyncEnumerator + public override AsyncIteratorBase Clone() { - private Func>> _getEnumerator; - private readonly CancellationToken _cancellationToken; - private IAsyncEnumerator _enumerator; + return new DeferIterator(_factory); + } - public Enumerator(Func>> getEnumerator, CancellationToken cancellationToken) + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) { - Debug.Assert(getEnumerator != null); - - _getEnumerator = getEnumerator; - _cancellationToken = cancellationToken; + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; } - public T Current - { - get - { - if (_enumerator == null) - throw new InvalidOperationException(); + await base.DisposeAsync().ConfigureAwait(false); + } - return _enumerator.Current; - } + protected override ValueTask MoveNextCore() + { + if (_enumerator == null) + { + return InitializeAndMoveNextAsync(); } - public async ValueTask DisposeAsync() - { - var old = Interlocked.Exchange(ref _enumerator, DisposedEnumerator.Instance); + return _enumerator.MoveNextAsync(); + } - if (_enumerator != null) - { - await _enumerator.DisposeAsync().ConfigureAwait(false); - } - } + private async ValueTask InitializeAndMoveNextAsync() + { + // NB: Using an async method to ensure any exception is reported via the task. - public ValueTask MoveNextAsync() + try { - if (_enumerator == null) - { - return InitAndMoveNextAsync(); - } - - return _enumerator.MoveNextAsync(); + _enumerator = _factory().GetAsyncEnumerator(_cancellationToken); } - - private async ValueTask InitAndMoveNextAsync() + catch (Exception ex) { - try - { - _enumerator = await _getEnumerator(_cancellationToken).ConfigureAwait(false); - } - catch (Exception ex) - { - _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); - throw; - } - finally - { - _getEnumerator = null; - } - - return await _enumerator.MoveNextAsync().ConfigureAwait(false); + _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); + throw; } - private sealed class DisposedEnumerator : IAsyncEnumerator + return await _enumerator.MoveNextAsync().ConfigureAwait(false); + } + } + + private sealed class AsyncDeferIterator : AsyncIteratorBase + { + private readonly Func>> _factory; + private IAsyncEnumerator _enumerator; + + public AsyncDeferIterator(Func< Task>> factory) + { + Debug.Assert(factory != null); + + _factory = factory; + } + + public override T Current => _enumerator == null ? default : _enumerator.Current; + + public override AsyncIteratorBase Clone() + { + return new AsyncDeferIterator(_factory); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) { - public static readonly DisposedEnumerator Instance = new DisposedEnumerator(); + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } - public T Current => throw new ObjectDisposedException("this"); + await base.DisposeAsync().ConfigureAwait(false); + } - public ValueTask DisposeAsync() => default; + protected override ValueTask MoveNextCore() + { + if (_enumerator == null) + { + return InitializeAndMoveNextAsync(); + } - public ValueTask MoveNextAsync() => throw new ObjectDisposedException("this"); + return _enumerator.MoveNextAsync(); + } + + private async ValueTask InitializeAndMoveNextAsync() + { + try + { + _enumerator = (await _factory().ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); + } + catch (Exception ex) + { + _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); + throw; } + + return await _enumerator.MoveNextAsync().ConfigureAwait(false); } } } From 06a4ec0e794cc71d04ddc5868d09c984117c851a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 13 Nov 2018 13:42:22 -0800 Subject: [PATCH 530/862] Remove unusd cancellation tokens. --- .../System/Linq/AsyncEnumerablePartition.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index b770b3f095..ca57364a0f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -93,7 +93,7 @@ async Task Core() // At the same time, however, we are guaranteed that our max count can fit // in an int because if that is true, then _minIndexInclusive must > 0. - var count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en, cancellationToken).ConfigureAwait(false); + var count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en).ConfigureAwait(false); Debug.Assert(count != (uint)int.MaxValue + 1 || _minIndexInclusive > 0, "Our return value will be incorrect."); return Math.Max((int)count - _minIndexInclusive, 0); } @@ -122,7 +122,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (!_hasSkipped) { - if (!await SkipBeforeFirstAsync(_enumerator, CancellationToken.None).ConfigureAwait(false)) + if (!await SkipBeforeFirstAsync(_enumerator).ConfigureAwait(false)) { // Reached the end before we finished skipping. break; @@ -228,7 +228,7 @@ public async Task> TryGetElementAsync(int index, CancellationToke { Debug.Assert(_minIndexInclusive + index >= 0, $"Adding {nameof(index)} caused {nameof(_minIndexInclusive)} to overflow."); - if (await SkipBeforeAsync(_minIndexInclusive + index, en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) + if (await SkipBeforeAsync(_minIndexInclusive + index, en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { return new Maybe(en.Current); } @@ -248,7 +248,7 @@ public async Task> TryGetFirstAsync(CancellationToken cancellatio try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { return new Maybe(en.Current); } @@ -267,7 +267,7 @@ public async Task> TryGetLastAsync(CancellationToken cancellation try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { var remaining = Limit - 1; // Max number of items left, not counting the current element. var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. @@ -297,7 +297,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { var remaining = Limit - 1; // Max number of items left, not counting the current element. var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. @@ -335,7 +335,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken try { - if (await SkipBeforeFirstAsync(en, cancellationToken).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) + if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { var remaining = Limit - 1; // Max number of items left, not counting the current element. var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. @@ -356,21 +356,21 @@ public async Task> ToListAsync(CancellationToken cancellationToken return list; } - private Task SkipBeforeFirstAsync(IAsyncEnumerator en, CancellationToken cancellationToken) => SkipBeforeAsync(_minIndexInclusive, en, cancellationToken); + private Task SkipBeforeFirstAsync(IAsyncEnumerator en) => SkipBeforeAsync(_minIndexInclusive, en); - private static async Task SkipBeforeAsync(int index, IAsyncEnumerator en, CancellationToken cancellationToken) + private static async Task SkipBeforeAsync(int index, IAsyncEnumerator en) { - var n = await SkipAndCountAsync(index, en, cancellationToken).ConfigureAwait(false); + var n = await SkipAndCountAsync(index, en).ConfigureAwait(false); return n == index; } - private static async Task SkipAndCountAsync(int index, IAsyncEnumerator en, CancellationToken cancellationToken) + private static async Task SkipAndCountAsync(int index, IAsyncEnumerator en) { Debug.Assert(index >= 0); - return (int)await SkipAndCountAsync((uint)index, en, cancellationToken).ConfigureAwait(false); + return (int)await SkipAndCountAsync((uint)index, en).ConfigureAwait(false); } - private static async Task SkipAndCountAsync(uint index, IAsyncEnumerator en, CancellationToken cancellationToken) + private static async Task SkipAndCountAsync(uint index, IAsyncEnumerator en) { Debug.Assert(en != null); From 92515218cccc476443fd61c35a4f2dae6d5bbb1f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 14 Nov 2018 10:58:36 -0800 Subject: [PATCH 531/862] Fix ToEnumerable's use of ValueTask. --- .../System/Linq/Operators/ToEnumerable.cs | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs index ce57fb1961..1c7c7e65dc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs @@ -3,11 +3,15 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { + // REVIEW: This type of blocking is an anti-pattern. We may want to move it to System.Interactive.Async + // and remove it from System.Linq.Async API surface. + public static IEnumerable ToEnumerable(this IAsyncEnumerable source) { if (source == null) @@ -23,7 +27,7 @@ IEnumerable Core() { while (true) { - if (!e.MoveNextAsync().GetAwaiter().GetResult()) + if (!Wait(e.MoveNextAsync())) break; yield return e.Current; @@ -31,10 +35,38 @@ IEnumerable Core() } finally { - // Wait - e.DisposeAsync().GetAwaiter().GetResult(); + Wait(e.DisposeAsync()); } } } + + // NB: ValueTask and ValueTask do not have to support blocking on a call to GetResult when backed by + // an IValueTaskSource or IValueTaskSource implementation. Convert to a Task or Task to do so + // in case the task hasn't completed yet. + + private static void Wait(ValueTask task) + { + var awaiter = task.GetAwaiter(); + + if (!awaiter.IsCompleted) + { + task.AsTask().GetAwaiter().GetResult(); + return; + } + + awaiter.GetResult(); + } + + private static T Wait(ValueTask task) + { + var awaiter = task.GetAwaiter(); + + if (!awaiter.IsCompleted) + { + return task.AsTask().GetAwaiter().GetResult(); + } + + return awaiter.GetResult(); + } } } From aacb761f4057909eab0a5807f61cbf1e3453927d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 14 Nov 2018 12:58:53 -0800 Subject: [PATCH 532/862] Switch to ValueTask for predicates, selectors, etc. We await those ourselves and they are expected to be called in a high-frequency manner, so this seems to be the right choice. The only drawback is when these operators are used using method group conversion of a Task-returning async method, which is likely rare in query expressions where one typically uses (async) lambdas, and there's a workaround Task-to-ValueTask conversion. We can't overload on ValueTask and Task return types, so this seems the best way forward. --- .../AsyncQueryableExTests.Generated.cs | 108 +- .../AsyncQueryableExTests.Generated.tt | 2 + ...m.Interactive.Async.Providers.Tests.csproj | 4 + .../System.Interactive.Async.Providers.csproj | 2 +- .../System/Linq/AsyncQueryableEx.Generated.cs | 116 +- .../System/Linq/AsyncQueryableEx.Generated.tt | 2 + .../System/Linq/Operators/Catch.cs | 6 +- .../System/Linq/Operators/Distinct.cs | 10 +- .../Linq/Operators/DistinctUntilChanged.cs | 10 +- .../System/Linq/Operators/Expand.cs | 6 +- .../System/Linq/Operators/MaxBy.cs | 10 +- .../System/Linq/Operators/MinBy.cs | 12 +- .../System/Linq/Operators/Scan.cs | 12 +- .../System/Linq/Operators/Using.cs | 6 +- .../AsyncQueryableTests.Generated.cs | 1796 ++++++++--------- .../AsyncQueryableTests.Generated.tt | 2 + .../System.Linq.Async.Queryable.Tests.csproj | 4 + .../System/Linq/AsyncQueryable.Generated.cs | 816 ++++---- .../System/Linq/AsyncQueryable.Generated.tt | 2 + .../System/Linq/AsyncEnumerablePartition.cs | 2 +- .../System/Linq/AsyncIterator.Opt.cs | 4 +- .../System/Linq/AsyncListPartition.cs | 2 +- .../System/Linq/IOrderedAsyncEnumerable.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 18 +- .../System/Linq/Operators/All.cs | 6 +- .../System/Linq/Operators/Any.cs | 6 +- .../Linq/Operators/Average.Generated.cs | 40 +- .../System/Linq/Operators/Count.cs | 6 +- .../System/Linq/Operators/First.cs | 6 +- .../System/Linq/Operators/FirstOrDefault.cs | 8 +- .../System/Linq/Operators/GroupBy.cs | 32 +- .../System/Linq/Operators/GroupJoin.cs | 28 +- .../System/Linq/Operators/Join.cs | 12 +- .../System/Linq/Operators/Last.cs | 6 +- .../System/Linq/Operators/LastOrDefault.cs | 8 +- .../System/Linq/Operators/LongCount.cs | 6 +- .../System/Linq/Operators/Lookup.cs | 10 +- .../System/Linq/Operators/Max.Generic.cs | 2 +- .../System/Linq/Operators/Max.Primitive.cs | 20 +- .../System/Linq/Operators/Max.cs | 4 +- .../System/Linq/Operators/Min.Generic.cs | 2 +- .../System/Linq/Operators/Min.Primitive.cs | 20 +- .../System/Linq/Operators/Min.cs | 4 +- .../System/Linq/Operators/MinMax.Generated.cs | 80 +- .../System/Linq/Operators/OrderBy.cs | 16 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 10 +- .../System/Linq/Operators/Select.cs | 22 +- .../System/Linq/Operators/SelectMany.cs | 28 +- .../System/Linq/Operators/Single.cs | 6 +- .../System/Linq/Operators/SingleOrDefault.cs | 6 +- .../System/Linq/Operators/SkipWhile.cs | 12 +- .../System/Linq/Operators/Sum.Generated.cs | 60 +- .../System/Linq/Operators/TakeWhile.cs | 12 +- .../System/Linq/Operators/ToDictionary.cs | 26 +- .../System/Linq/Operators/ToLookup.cs | 26 +- .../System/Linq/Operators/Where.cs | 16 +- .../System/Linq/Operators/Zip.cs | 6 +- 57 files changed, 1761 insertions(+), 1745 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs index 13b31d3491..d13f076201 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs @@ -70,10 +70,10 @@ public void Catch2() [Fact] public void Catch3() { - AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "handler"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "handler"); - var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => default(Task>)); + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0) => default(ValueTask>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -102,10 +102,10 @@ public void Distinct1() [Fact] public void Distinct2() { - AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -125,11 +125,11 @@ public void Distinct3() [Fact] public void Distinct4() { - AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -169,10 +169,10 @@ public void DistinctUntilChanged3() [Fact] public void DistinctUntilChanged4() { - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -192,11 +192,11 @@ public void DistinctUntilChanged5() [Fact] public void DistinctUntilChanged6() { - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -323,10 +323,10 @@ public void Expand1() [Fact] public void Expand2() { - AssertEx.Throws(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), (int arg0) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); + var res = AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>)); res = res.Take(5); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); @@ -415,10 +415,10 @@ public void MaxBy1() [Fact] public void MaxBy2() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -435,10 +435,10 @@ public void MaxBy3() [Fact] public void MaxBy4() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -456,11 +456,11 @@ public void MaxBy5() [Fact] public void MaxBy6() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -478,11 +478,11 @@ public void MaxBy7() [Fact] public void MaxBy8() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -529,10 +529,10 @@ public void MinBy1() [Fact] public void MinBy2() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -549,10 +549,10 @@ public void MinBy3() [Fact] public void MinBy4() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -570,11 +570,11 @@ public void MinBy5() [Fact] public void MinBy6() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -592,11 +592,11 @@ public void MinBy7() [Fact] public void MinBy8() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -667,10 +667,10 @@ public void Scan1() [Fact] public void Scan2() { - AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -689,10 +689,10 @@ public void Scan3() [Fact] public void Scan4() { - AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task)); + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt index 7b43d2d153..c409ad5d73 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt @@ -4,6 +4,8 @@ <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> +<#@ assembly name="System.Runtime" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net46\System.Interactive.Async.dll" #> <#@ import namespace="System.Linq" #> diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj index 94ad2219d1..2bfd2ccfa1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj @@ -40,4 +40,8 @@ + + + + diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index 77ce7508d5..c716f03892 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Providers Library used to build query providers and express queries over async enumerable sequences. Interactive Extensions - Async Providers Library - net45;netstandard2.0 + net45;net46;netstandard1.4;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 5700ad04dd..eb1493265c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -78,7 +78,7 @@ public static IAsyncQueryable Catch(this IAsyncQue #endif } - public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -86,7 +86,7 @@ public static IAsyncQueryable Catch(this IAsyncQue throw new ArgumentNullException(nameof(handler)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); #endif @@ -104,7 +104,7 @@ public static IAsyncQueryable Concat(this IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -112,13 +112,13 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -126,13 +126,13 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -142,13 +142,13 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -158,7 +158,7 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -190,7 +190,7 @@ public static IAsyncQueryable DistinctUntilChanged(this IAsync #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -198,13 +198,13 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -212,13 +212,13 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -228,13 +228,13 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -244,7 +244,7 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -406,7 +406,7 @@ public static IAsyncQueryable Expand(this IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -414,7 +414,7 @@ public static IAsyncQueryable Expand(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); #endif @@ -512,7 +512,7 @@ public static Task Max(this IAsyncQueryable source, I #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -520,13 +520,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -534,13 +534,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -548,13 +548,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -564,13 +564,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -578,13 +578,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -594,13 +594,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -610,13 +610,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -626,7 +626,7 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -672,7 +672,7 @@ public static Task Min(this IAsyncQueryable source, I #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -680,13 +680,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -694,13 +694,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -708,13 +708,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -724,13 +724,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -738,13 +738,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -754,13 +754,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -770,13 +770,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -786,7 +786,7 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -854,7 +854,7 @@ public static IAsyncQueryable Retry(this IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -862,13 +862,13 @@ public static IAsyncQueryable Scan(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); #endif } - public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -876,7 +876,7 @@ public static IAsyncQueryable Scan(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); #endif @@ -896,7 +896,7 @@ public static IAsyncQueryable Scan(this IAsyn #endif } - public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -904,7 +904,7 @@ public static IAsyncQueryable Scan(this IAsyn throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); #endif diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt index 1023430931..66440fb702 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -4,6 +4,8 @@ <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> +<#@ assembly name="System.Runtime" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net46\System.Interactive.Async.dll" #> <#@ import namespace="System.Linq" #> diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index a0cdf891b3..815ea16df1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -23,7 +23,7 @@ public static IAsyncEnumerable Catch(this IAsyncEn return new CatchAsyncIterator(source, handler); } - public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func>> handler) + public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func>> handler) where TException : Exception { if (source == null) @@ -160,13 +160,13 @@ protected override async ValueTask MoveNextCore() private sealed class CatchAsyncIteratorWithTask : AsyncIterator where TException : Exception { - private readonly Func>> _handler; + private readonly Func>> _handler; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; private bool _isDone; - public CatchAsyncIteratorWithTask(IAsyncEnumerable source, Func>> handler) + public CatchAsyncIteratorWithTask(IAsyncEnumerable source, Func>> handler) { Debug.Assert(source != null); Debug.Assert(handler != null); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 3220740a14..895ae029ac 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -31,7 +31,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer); } - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer: null); } - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -58,7 +58,7 @@ private static IAsyncEnumerable DistinctCore(IAsyncEnume return new DistinctAsyncIterator(source, keySelector, comparer); } - private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); } @@ -211,13 +211,13 @@ private async Task> FillSetAsync(CancellationToken cancellationTok private sealed class DistinctAsyncIteratorWithTask : AsyncIterator, IAsyncIListProvider { private readonly IEqualityComparer _comparer; - private readonly Func> _keySelector; + private readonly Func> _keySelector; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; private Set _set; - public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { Debug.Assert(source != null); Debug.Assert(keySelector != null); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 2358f68212..49e511f5a4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -47,7 +47,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this return DistinctUntilChangedCore(source, keySelector, comparer); } - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,7 +57,7 @@ public static IAsyncEnumerable DistinctUntilChanged(this return DistinctUntilChangedCore(source, keySelector, comparer: null); } - public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -79,7 +79,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); } - private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); } @@ -229,14 +229,14 @@ protected override async ValueTask MoveNextCore() private sealed class DistinctUntilChangedAsyncIteratorWithTask : AsyncIterator { private readonly IEqualityComparer _comparer; - private readonly Func> _keySelector; + private readonly Func> _keySelector; private readonly IAsyncEnumerable _source; private TKey _currentKeyValue; private IAsyncEnumerator _enumerator; private bool _hasCurrentKey; - public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public DistinctUntilChangedAsyncIteratorWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { _source = source; _keySelector = keySelector; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index e12b6333df..82ee0ff921 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable(source, selector); } - public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func>> selector) + public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -123,14 +123,14 @@ protected override async ValueTask MoveNextCore() private sealed class ExpandAsyncIteratorWithTask : AsyncIterator { - private readonly Func>> _selector; + private readonly Func>> _selector; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; private Queue> _queue; - public ExpandAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) + public ExpandAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index ece27c46c5..32d2487d90 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -50,7 +50,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector) + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ public static Task> MaxBy(this IAsyncEnumerable(source, keySelector, comparer: null, CancellationToken.None); } - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task> MaxBy(this IAsyncEnumerable(source, keySelector, comparer: null, cancellationToken); } - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -100,7 +100,7 @@ private static Task> MaxByCore(IAsyncEnumerable comparer.Compare(key, minValue), cancellationToken); } - private static Task> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + private static Task> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index b721613e9d..382541f52d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -50,7 +50,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector) + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ public static Task> MinBy(this IAsyncEnumerable(source, keySelector, comparer: null, CancellationToken.None); } - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task> MinBy(this IAsyncEnumerable(source, keySelector, comparer: null, cancellationToken); } - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -100,7 +100,7 @@ private static Task> MinByCore(IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); } - private static Task> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + private static Task> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { @@ -150,7 +150,7 @@ private static async Task> ExtremaBy(IAsyncEnumera return result; } - private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) + private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) { var result = new List(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 0a589b4dfa..6be9e4c501 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -31,7 +31,7 @@ public static IAsyncEnumerable Scan(this IAsy return new ScanAsyncEnumerable(source, seed, accumulator); } - public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func> accumulator) + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func> accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable(source, accumulator); } - public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -191,7 +191,7 @@ protected override async ValueTask MoveNextCore() private sealed class ScanAsyncEnumerableWithTask : AsyncIterator { - private readonly Func> _accumulator; + private readonly Func> _accumulator; private readonly IAsyncEnumerable _source; private TSource _accumulated; @@ -199,7 +199,7 @@ private sealed class ScanAsyncEnumerableWithTask : AsyncIterator source, Func> accumulator) + public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, Func> accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); @@ -265,14 +265,14 @@ protected override async ValueTask MoveNextCore() private sealed class ScanAsyncEnumerableWithTask : AsyncIterator { - private readonly Func> _accumulator; + private readonly Func> _accumulator; private readonly TAccumulate _seed; private readonly IAsyncEnumerable _source; private TAccumulate _accumulated; private IAsyncEnumerator _enumerator; - public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + public ScanAsyncEnumerableWithTask(IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { Debug.Assert(source != null); Debug.Assert(accumulator != null); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 18bfee2dba..0641fff7d2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable Using(Func(resourceFactory, enumerableFactory); } - public static IAsyncEnumerable Using(Func> resourceFactory, Func>> enumerableFactory) where TResource : IDisposable + public static IAsyncEnumerable Using(Func> resourceFactory, Func>> enumerableFactory) where TResource : IDisposable { if (resourceFactory == null) throw Error.ArgumentNull(nameof(resourceFactory)); @@ -101,14 +101,14 @@ protected override async ValueTask MoveNextCore() private sealed class UsingAsyncIteratorWithTask : AsyncIterator where TResource : IDisposable { - private readonly Func>> _enumerableFactory; + private readonly Func>> _enumerableFactory; private readonly Func> _resourceFactory; private IAsyncEnumerable _enumerable; private IAsyncEnumerator _enumerator; private TResource _resource; - public UsingAsyncIteratorWithTask(Func> resourceFactory, Func>> enumerableFactory) + public UsingAsyncIteratorWithTask(Func> resourceFactory, Func>> enumerableFactory) { Debug.Assert(resourceFactory != null); Debug.Assert(enumerableFactory != null); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index fe99079374..0c25ccaf45 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -27,10 +27,10 @@ public void Aggregate1() [Fact] public void Aggregate2() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -47,10 +47,10 @@ public void Aggregate3() [Fact] public void Aggregate4() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -67,10 +67,10 @@ public void Aggregate5() [Fact] public void Aggregate6() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -87,10 +87,10 @@ public void Aggregate7() [Fact] public void Aggregate8() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -108,11 +108,11 @@ public void Aggregate9() [Fact] public void Aggregate10() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -130,11 +130,11 @@ public void Aggregate11() [Fact] public void Aggregate12() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(Task), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -151,10 +151,10 @@ public void All1() [Fact] public void All2() { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -171,10 +171,10 @@ public void All3() [Fact] public void All4() { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -209,10 +209,10 @@ public void Any3() [Fact] public void Any4() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -229,10 +229,10 @@ public void Any5() [Fact] public void Any6() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -248,6 +248,15 @@ public void Append1() [Fact] public void Average1() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average2() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -256,7 +265,7 @@ public void Average1() } [Fact] - public void Average2() + public void Average3() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -265,7 +274,7 @@ public void Average2() } [Fact] - public void Average3() + public void Average4() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -274,7 +283,7 @@ public void Average3() } [Fact] - public void Average4() + public void Average5() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -283,7 +292,7 @@ public void Average4() } [Fact] - public void Average5() + public void Average6() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -292,7 +301,7 @@ public void Average5() } [Fact] - public void Average6() + public void Average7() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -301,7 +310,7 @@ public void Average6() } [Fact] - public void Average7() + public void Average8() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -310,7 +319,7 @@ public void Average7() } [Fact] - public void Average8() + public void Average9() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -319,7 +328,7 @@ public void Average8() } [Fact] - public void Average9() + public void Average10() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -327,15 +336,6 @@ public void Average9() AssertEx.SucceedOrFailProper(() => res.Wait()); } - [Fact] - public void Average10() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - [Fact] public void Average11() { @@ -428,6 +428,16 @@ public void Average20() [Fact] public void Average21() + { + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void Average22() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -437,17 +447,17 @@ public void Average21() } [Fact] - public void Average22() + public void Average23() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average23() + public void Average24() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -457,17 +467,17 @@ public void Average23() } [Fact] - public void Average24() + public void Average25() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average25() + public void Average26() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -477,17 +487,17 @@ public void Average25() } [Fact] - public void Average26() + public void Average27() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average27() + public void Average28() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -497,17 +507,17 @@ public void Average27() } [Fact] - public void Average28() + public void Average29() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average29() + public void Average30() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -517,17 +527,17 @@ public void Average29() } [Fact] - public void Average30() + public void Average31() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average31() + public void Average32() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -537,17 +547,17 @@ public void Average31() } [Fact] - public void Average32() + public void Average33() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average33() + public void Average34() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -557,17 +567,17 @@ public void Average33() } [Fact] - public void Average34() + public void Average35() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average35() + public void Average36() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -577,17 +587,17 @@ public void Average35() } [Fact] - public void Average36() + public void Average37() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average37() + public void Average38() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -597,17 +607,17 @@ public void Average37() } [Fact] - public void Average38() + public void Average39() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average39() + public void Average40() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -617,17 +627,17 @@ public void Average39() } [Fact] - public void Average40() + public void Average41() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average41() + public void Average42() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -637,17 +647,17 @@ public void Average41() } [Fact] - public void Average42() + public void Average43() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average43() + public void Average44() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -657,17 +667,17 @@ public void Average43() } [Fact] - public void Average44() + public void Average45() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average45() + public void Average46() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -677,17 +687,17 @@ public void Average45() } [Fact] - public void Average46() + public void Average47() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average47() + public void Average48() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -697,17 +707,17 @@ public void Average47() } [Fact] - public void Average48() + public void Average49() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average49() + public void Average50() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -717,17 +727,17 @@ public void Average49() } [Fact] - public void Average50() + public void Average51() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average51() + public void Average52() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -737,17 +747,17 @@ public void Average51() } [Fact] - public void Average52() + public void Average53() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average53() + public void Average54() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -757,17 +767,17 @@ public void Average53() } [Fact] - public void Average54() + public void Average55() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average55() + public void Average56() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -777,17 +787,17 @@ public void Average55() } [Fact] - public void Average56() + public void Average57() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average57() + public void Average58() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -797,17 +807,17 @@ public void Average57() } [Fact] - public void Average58() + public void Average59() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average59() + public void Average60() { AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -816,16 +826,6 @@ public void Average59() AssertEx.SucceedOrFailProper(() => res.Wait()); } - [Fact] - public void Average60() - { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - [Fact] public void Cast1() { @@ -916,10 +916,10 @@ public void Count3() [Fact] public void Count4() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -936,10 +936,10 @@ public void Count5() [Fact] public void Count6() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1074,10 +1074,10 @@ public void First3() [Fact] public void First4() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1094,10 +1094,10 @@ public void First5() [Fact] public void First6() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1132,10 +1132,10 @@ public void FirstOrDefault3() [Fact] public void FirstOrDefault4() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1152,10 +1152,10 @@ public void FirstOrDefault5() [Fact] public void FirstOrDefault6() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1173,10 +1173,10 @@ public void GroupBy1() [Fact] public void GroupBy2() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1196,11 +1196,11 @@ public void GroupBy3() [Fact] public void GroupBy4() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1208,11 +1208,11 @@ public void GroupBy4() [Fact] public void GroupBy5() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1220,11 +1220,11 @@ public void GroupBy5() [Fact] public void GroupBy6() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1244,11 +1244,11 @@ public void GroupBy7() [Fact] public void GroupBy8() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1256,12 +1256,12 @@ public void GroupBy8() [Fact] public void GroupBy9() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1269,12 +1269,12 @@ public void GroupBy9() [Fact] public void GroupBy10() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1295,12 +1295,12 @@ public void GroupBy11() [Fact] public void GroupBy12() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression, Task>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1321,12 +1321,12 @@ public void GroupBy13() [Fact] public void GroupBy14() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1348,13 +1348,13 @@ public void GroupBy15() [Fact] public void GroupBy16() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1376,13 +1376,13 @@ public void GroupJoin1() [Fact] public void GroupJoin2() { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task)); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1405,14 +1405,14 @@ public void GroupJoin3() [Fact] public void GroupJoin4() { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression, Task>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, IAsyncEnumerable arg1) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1457,13 +1457,13 @@ public void Join1() [Fact] public void Join2() { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1486,14 +1486,14 @@ public void Join3() [Fact] public void Join4() { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), default(Expression>>), (int arg0, int arg1) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(Task), (int arg0) => default(Task), (int arg0, int arg1) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1529,10 +1529,10 @@ public void Last3() [Fact] public void Last4() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1549,10 +1549,10 @@ public void Last5() [Fact] public void Last6() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1587,10 +1587,10 @@ public void LastOrDefault3() [Fact] public void LastOrDefault4() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1607,10 +1607,10 @@ public void LastOrDefault5() [Fact] public void LastOrDefault6() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1645,10 +1645,10 @@ public void LongCount3() [Fact] public void LongCount4() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1665,46 +1665,46 @@ public void LongCount5() [Fact] public void LongCount6() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max1() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max2() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max3() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max4() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1720,81 +1720,81 @@ public void Max5() [Fact] public void Max6() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max7() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max8() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max9() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max10() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max11() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max12() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max13() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max14() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1810,45 +1810,45 @@ public void Max15() [Fact] public void Max16() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max17() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max18() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max19() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max20() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1873,400 +1873,400 @@ public void Max22() [Fact] public void Max23() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max24() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max25() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max26() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max27() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max28() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max29() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max30() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max31() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max32() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max33() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max34() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max35() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max36() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max37() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max38() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max39() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max40() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max41() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max42() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max43() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max44() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max45() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max46() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max47() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max48() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max49() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max50() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max51() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max52() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max53() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max54() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max55() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max56() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max57() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max58() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max59() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max60() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max61() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Max62() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2283,10 +2283,10 @@ public void Max63() [Fact] public void Max64() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2303,190 +2303,190 @@ public void Max65() [Fact] public void Max66() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min1() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min2() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min3() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min4() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min5() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min6() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min7() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min8() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min9() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min10() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min11() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min12() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min13() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min14() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min15() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min16() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min17() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min18() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min19() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min20() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2511,410 +2511,410 @@ public void Min22() [Fact] public void Min23() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min24() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min25() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min26() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min27() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min28() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min29() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min30() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min31() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min32() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min33() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min34() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min35() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min36() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min37() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min38() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min39() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min40() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min41() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min42() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min43() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min44() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min45() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min46() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min47() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min48() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min49() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min50() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min51() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min52() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min53() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min54() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min55() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min56() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min57() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min58() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min59() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min60() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min61() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min62() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Min63() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2931,10 +2931,10 @@ public void Min64() [Fact] public void Min65() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2970,10 +2970,10 @@ public void OrderBy1() [Fact] public void OrderBy2() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); } [Fact] @@ -2989,11 +2989,11 @@ public void OrderBy3() [Fact] public void OrderBy4() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] @@ -3008,10 +3008,10 @@ public void OrderByDescending1() [Fact] public void OrderByDescending2() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); } [Fact] @@ -3027,11 +3027,11 @@ public void OrderByDescending3() [Fact] public void OrderByDescending4() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] @@ -3079,10 +3079,10 @@ public void Select2() [Fact] public void Select3() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3090,10 +3090,10 @@ public void Select3() [Fact] public void Select4() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3112,10 +3112,10 @@ public void SelectMany1() [Fact] public void SelectMany2() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3134,10 +3134,10 @@ public void SelectMany3() [Fact] public void SelectMany4() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3157,11 +3157,11 @@ public void SelectMany5() [Fact] public void SelectMany6() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(Task>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task>), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3181,11 +3181,11 @@ public void SelectMany7() [Fact] public void SelectMany8() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(Task>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task>), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3263,30 +3263,30 @@ public void Single3() [Fact] public void Single4() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Single5() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Single6() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3321,10 +3321,10 @@ public void SingleOrDefault3() [Fact] public void SingleOrDefault4() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3341,10 +3341,10 @@ public void SingleOrDefault5() [Fact] public void SingleOrDefault6() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3393,10 +3393,10 @@ public void SkipWhile2() [Fact] public void SkipWhile3() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3404,10 +3404,10 @@ public void SkipWhile3() [Fact] public void SkipWhile4() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3415,580 +3415,580 @@ public void SkipWhile4() [Fact] public void Sum1() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum2() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum3() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum4() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum5() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum6() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum7() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum8() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum9() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum10() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum11() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum12() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum13() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum14() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum15() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum16() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum17() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum18() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum19() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum20() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum21() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum22() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum23() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum24() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum25() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum26() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum27() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum28() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum29() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum30() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum31() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum32() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum33() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum34() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum35() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum36() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum37() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum38() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum39() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum40() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum41() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum42() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum43() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum44() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum45() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum46() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum47() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum48() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum49() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum50() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum51() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum52() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum53() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum54() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum55() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum56() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum57() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum58() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum59() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void Sum60() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4036,10 +4036,10 @@ public void TakeWhile2() [Fact] public void TakeWhile3() { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -4047,10 +4047,10 @@ public void TakeWhile3() [Fact] public void TakeWhile4() { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -4067,10 +4067,10 @@ public void ThenBy1() [Fact] public void ThenBy2() { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task)); + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); } [Fact] @@ -4086,11 +4086,11 @@ public void ThenBy3() [Fact] public void ThenBy4() { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] @@ -4105,10 +4105,10 @@ public void ThenByDescending1() [Fact] public void ThenByDescending2() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); } [Fact] @@ -4124,11 +4124,11 @@ public void ThenByDescending3() [Fact] public void ThenByDescending4() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(Task), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(Task), Comparer.Default); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] @@ -4162,10 +4162,10 @@ public void ToDictionary1() [Fact] public void ToDictionary2() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4182,10 +4182,10 @@ public void ToDictionary3() [Fact] public void ToDictionary4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4203,11 +4203,11 @@ public void ToDictionary5() [Fact] public void ToDictionary6() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4225,11 +4225,11 @@ public void ToDictionary7() [Fact] public void ToDictionary8() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4247,11 +4247,11 @@ public void ToDictionary9() [Fact] public void ToDictionary10() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4269,11 +4269,11 @@ public void ToDictionary11() [Fact] public void ToDictionary12() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4292,12 +4292,12 @@ public void ToDictionary13() [Fact] public void ToDictionary14() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4316,12 +4316,12 @@ public void ToDictionary15() [Fact] public void ToDictionary16() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4394,10 +4394,10 @@ public void ToLookup1() [Fact] public void ToLookup2() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4414,10 +4414,10 @@ public void ToLookup3() [Fact] public void ToLookup4() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4435,11 +4435,11 @@ public void ToLookup5() [Fact] public void ToLookup6() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4457,11 +4457,11 @@ public void ToLookup7() [Fact] public void ToLookup8() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4479,11 +4479,11 @@ public void ToLookup9() [Fact] public void ToLookup10() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task)); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4501,11 +4501,11 @@ public void ToLookup11() [Fact] public void ToLookup12() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), CancellationToken.None); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4524,12 +4524,12 @@ public void ToLookup13() [Fact] public void ToLookup14() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4548,12 +4548,12 @@ public void ToLookup15() [Fact] public void ToLookup16() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task), (int arg0) => default(Task), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4605,10 +4605,10 @@ public void Where2() [Fact] public void Where3() { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Task)); + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -4616,10 +4616,10 @@ public void Where3() [Fact] public void Where4() { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -4639,11 +4639,11 @@ public void Zip1() [Fact] public void Zip2() { - AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1) => default(Task)), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(Task)); + var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt index fb72f0f634..20fff5ab21 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt @@ -4,6 +4,8 @@ <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> +<#@ assembly name="System.Runtime" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj index 387c637782..e1c1ca58e1 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -40,4 +40,8 @@ + + + + diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 342bb03a53..760c38fa53 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -12,7 +12,7 @@ namespace System.Linq { public static partial class AsyncQueryable { - public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator) + public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -20,13 +20,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) + public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -34,13 +34,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -48,13 +48,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -62,7 +62,7 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -82,7 +82,7 @@ public static Task Aggregate(this IAsyncQuery #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -90,7 +90,7 @@ public static Task Aggregate(this IAsyncQuery throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #endif @@ -110,7 +110,7 @@ public static Task Aggregate(this IAsyncQuery #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -118,7 +118,7 @@ public static Task Aggregate(this IAsyncQuery throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -140,7 +140,7 @@ public static Task Aggregate(this IAsync #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector) + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -150,7 +150,7 @@ public static Task Aggregate(this IAsync throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #endif @@ -172,7 +172,7 @@ public static Task Aggregate(this IAsync #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -182,7 +182,7 @@ public static Task Aggregate(this IAsync throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -202,7 +202,7 @@ public static Task All(this IAsyncQueryable source, Expr #endif } - public static Task All(this IAsyncQueryable source, Expression>> predicate) + public static Task All(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -210,7 +210,7 @@ public static Task All(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -230,7 +230,7 @@ public static Task All(this IAsyncQueryable source, Expr #endif } - public static Task All(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task All(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -238,7 +238,7 @@ public static Task All(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -282,7 +282,7 @@ public static Task Any(this IAsyncQueryable source, Expr #endif } - public static Task Any(this IAsyncQueryable source, Expression>> predicate) + public static Task Any(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -290,7 +290,7 @@ public static Task Any(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -310,7 +310,7 @@ public static Task Any(this IAsyncQueryable source, Expr #endif } - public static Task Any(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task Any(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -318,7 +318,7 @@ public static Task Any(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -716,7 +716,7 @@ public static Task Average(this IAsyncQueryable source #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -724,13 +724,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -738,13 +738,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -752,13 +752,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -766,13 +766,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -780,13 +780,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -794,13 +794,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -808,13 +808,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -822,13 +822,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -836,13 +836,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task Average(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -850,7 +850,7 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif @@ -996,7 +996,7 @@ public static Task Average(this IAsyncQueryable source #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1004,13 +1004,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1018,13 +1018,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1032,13 +1032,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1046,13 +1046,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1060,13 +1060,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1074,13 +1074,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1088,13 +1088,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1102,13 +1102,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1116,13 +1116,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1130,7 +1130,7 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1252,7 +1252,7 @@ public static Task Count(this IAsyncQueryable source, Exp #endif } - public static Task Count(this IAsyncQueryable source, Expression>> predicate) + public static Task Count(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1260,7 +1260,7 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -1280,7 +1280,7 @@ public static Task Count(this IAsyncQueryable source, Exp #endif } - public static Task Count(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task Count(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1288,7 +1288,7 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1460,7 +1460,7 @@ public static Task First(this IAsyncQueryable source, #endif } - public static Task First(this IAsyncQueryable source, Expression>> predicate) + public static Task First(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1468,7 +1468,7 @@ public static Task First(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -1488,7 +1488,7 @@ public static Task First(this IAsyncQueryable source, #endif } - public static Task First(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task First(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1496,7 +1496,7 @@ public static Task First(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1540,7 +1540,7 @@ public static Task FirstOrDefault(this IAsyncQueryable FirstOrDefault(this IAsyncQueryable source, Expression>> predicate) + public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1548,7 +1548,7 @@ public static Task FirstOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -1568,7 +1568,7 @@ public static Task FirstOrDefault(this IAsyncQueryable FirstOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1576,13 +1576,13 @@ public static Task FirstOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1590,13 +1590,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1604,13 +1604,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1620,13 +1620,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1636,13 +1636,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1652,13 +1652,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1668,13 +1668,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1684,13 +1684,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1700,13 +1700,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1718,13 +1718,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1736,13 +1736,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1754,13 +1754,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1772,13 +1772,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1790,13 +1790,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1808,13 +1808,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1828,13 +1828,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1848,13 +1848,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1868,13 +1868,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1888,13 +1888,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, Task>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1910,13 +1910,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, Task>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1932,7 +1932,7 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -1968,7 +1968,7 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1982,13 +1982,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -2002,13 +2002,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -2024,13 +2024,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -2046,7 +2046,7 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -2090,7 +2090,7 @@ public static Task Last(this IAsyncQueryable source, #endif } - public static Task Last(this IAsyncQueryable source, Expression>> predicate) + public static Task Last(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2098,7 +2098,7 @@ public static Task Last(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -2118,7 +2118,7 @@ public static Task Last(this IAsyncQueryable source, #endif } - public static Task Last(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task Last(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2126,7 +2126,7 @@ public static Task Last(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -2170,7 +2170,7 @@ public static Task LastOrDefault(this IAsyncQueryable #endif } - public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate) + public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2178,7 +2178,7 @@ public static Task LastOrDefault(this IAsyncQueryable throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -2198,7 +2198,7 @@ public static Task LastOrDefault(this IAsyncQueryable #endif } - public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2206,7 +2206,7 @@ public static Task LastOrDefault(this IAsyncQueryable throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -2250,7 +2250,7 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) + public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2258,7 +2258,7 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -2278,7 +2278,7 @@ public static Task LongCount(this IAsyncQueryable source #endif } - public static Task LongCount(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task LongCount(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2286,7 +2286,7 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -2696,7 +2696,7 @@ public static Task Max(this IAsyncQueryable source, Expr #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2704,13 +2704,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2718,13 +2718,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2732,13 +2732,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2746,13 +2746,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2760,13 +2760,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2774,13 +2774,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2788,13 +2788,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2802,13 +2802,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2816,13 +2816,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2830,7 +2830,7 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif @@ -2976,7 +2976,7 @@ public static Task Max(this IAsyncQueryable source, Expr #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2984,13 +2984,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2998,13 +2998,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3012,13 +3012,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3026,13 +3026,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3040,13 +3040,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3054,13 +3054,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3068,13 +3068,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3082,13 +3082,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3096,13 +3096,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3110,13 +3110,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task Max(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3124,13 +3124,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task Max(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3138,13 +3138,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3152,13 +3152,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3166,7 +3166,7 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -3576,7 +3576,7 @@ public static Task Min(this IAsyncQueryable source, Expr #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3584,13 +3584,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3598,13 +3598,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3612,13 +3612,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3626,13 +3626,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3640,13 +3640,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3654,13 +3654,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3668,13 +3668,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3682,13 +3682,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3696,13 +3696,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3710,7 +3710,7 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif @@ -3856,7 +3856,7 @@ public static Task Min(this IAsyncQueryable source, Expr #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3864,13 +3864,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3878,13 +3878,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3892,13 +3892,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3906,13 +3906,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3920,13 +3920,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3934,13 +3934,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3948,13 +3948,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3962,13 +3962,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3976,13 +3976,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3990,13 +3990,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task Min(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4004,13 +4004,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task Min(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4018,13 +4018,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4032,13 +4032,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4046,7 +4046,7 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4064,7 +4064,7 @@ public static IAsyncQueryable OfType(this IAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4072,13 +4072,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4086,13 +4086,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4102,13 +4102,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4118,13 +4118,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4132,13 +4132,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4146,13 +4146,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4162,13 +4162,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4178,7 +4178,7 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif @@ -4208,7 +4208,7 @@ public static IAsyncQueryable Reverse(this IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4216,13 +4216,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4230,13 +4230,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4244,13 +4244,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4258,7 +4258,7 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif @@ -4292,7 +4292,7 @@ public static IAsyncQueryable SelectMany(this IAsyncQ #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4300,13 +4300,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4314,7 +4314,7 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif @@ -4352,7 +4352,7 @@ public static IAsyncQueryable SelectMany #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4362,13 +4362,13 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4378,7 +4378,7 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif @@ -4482,7 +4482,7 @@ public static Task Single(this IAsyncQueryable source #endif } - public static Task Single(this IAsyncQueryable source, Expression>> predicate) + public static Task Single(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4490,7 +4490,7 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -4510,7 +4510,7 @@ public static Task Single(this IAsyncQueryable source #endif } - public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4518,7 +4518,7 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4562,7 +4562,7 @@ public static Task SingleOrDefault(this IAsyncQueryable SingleOrDefault(this IAsyncQueryable source, Expression>> predicate) + public static Task SingleOrDefault(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4570,7 +4570,7 @@ public static Task SingleOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif @@ -4590,7 +4590,7 @@ public static Task SingleOrDefault(this IAsyncQueryable SingleOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4598,7 +4598,7 @@ public static Task SingleOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4656,7 +4656,7 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4664,13 +4664,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4678,7 +4678,7 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif @@ -5064,7 +5064,7 @@ public static Task Sum(this IAsyncQueryable source, Expr #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5072,13 +5072,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5086,13 +5086,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5100,13 +5100,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5114,13 +5114,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5128,13 +5128,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5142,13 +5142,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5156,13 +5156,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5170,13 +5170,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5184,13 +5184,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task Sum(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5198,7 +5198,7 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif @@ -5344,7 +5344,7 @@ public static Task Sum(this IAsyncQueryable source, Expr #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5352,13 +5352,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5366,13 +5366,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5380,13 +5380,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5394,13 +5394,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5408,13 +5408,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5422,13 +5422,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5436,13 +5436,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5450,13 +5450,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5464,13 +5464,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5478,7 +5478,7 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -5536,7 +5536,7 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5544,13 +5544,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5558,13 +5558,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5572,13 +5572,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5586,13 +5586,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5602,13 +5602,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5618,13 +5618,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5632,13 +5632,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5646,13 +5646,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5662,13 +5662,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5678,7 +5678,7 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif @@ -5708,7 +5708,7 @@ public static Task ToArray(this IAsyncQueryable sou #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5716,13 +5716,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5730,13 +5730,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5744,13 +5744,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5760,13 +5760,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5774,13 +5774,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5790,13 +5790,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5806,13 +5806,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5822,13 +5822,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5838,13 +5838,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5854,13 +5854,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5870,13 +5870,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5888,13 +5888,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5904,13 +5904,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5922,13 +5922,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5940,13 +5940,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5958,7 +5958,7 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -6040,7 +6040,7 @@ public static Task> ToList(this IAsyncQueryable #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6048,13 +6048,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6062,13 +6062,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6076,13 +6076,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6092,13 +6092,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6106,13 +6106,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6122,13 +6122,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6138,13 +6138,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6154,13 +6154,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6170,13 +6170,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6186,13 +6186,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6202,13 +6202,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6220,13 +6220,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6236,13 +6236,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6254,13 +6254,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6272,13 +6272,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6290,7 +6290,7 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -6354,7 +6354,7 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6362,13 +6362,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6376,13 +6376,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -6392,13 +6392,13 @@ public static IAsyncQueryable Zip(this IAsync throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); #else return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); #endif } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -6408,7 +6408,7 @@ public static IAsyncQueryable Zip(this IAsync throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); #else return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); #endif diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index f3bd03219e..ecb36b91d6 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -4,6 +4,8 @@ <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> +<#@ assembly name="System.Runtime" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index ca57364a0f..11647b4703 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -158,7 +158,7 @@ public override IAsyncEnumerable Select(Func return new SelectIPartitionIterator(this, selector); } - public override IAsyncEnumerable Select(Func> selector) + public override IAsyncEnumerable Select(Func> selector) { return new SelectIPartitionIterator(this, selector); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs index 88cfce091d..e6d2ecf616 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs @@ -14,7 +14,7 @@ public virtual IAsyncEnumerable Select(Func return new AsyncEnumerable.SelectEnumerableAsyncIterator(this, selector); } - public virtual IAsyncEnumerable Select(Func> selector) + public virtual IAsyncEnumerable Select(Func> selector) { return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask(this, selector); } @@ -24,7 +24,7 @@ public virtual IAsyncEnumerable Where(Func predicate) return new AsyncEnumerable.WhereEnumerableAsyncIterator(this, predicate); } - public virtual IAsyncEnumerable Where(Func> predicate) + public virtual IAsyncEnumerable Where(Func> predicate) { return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 9b23beb9cc..979d778fcd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -57,7 +57,7 @@ public override IEnumerable Select(Func sele return new SelectListPartitionIterator(_source, selector, _minIndexInclusive, _maxIndexInclusive); } - public override IEnumerable Select(Func> selector) + public override IEnumerable Select(Func> selector) { return new SelectListPartitionIterator(_source, selector, _minIndexInclusive, _maxIndexInclusive); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs index 20b07ad3c0..706b4ef784 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs @@ -10,6 +10,6 @@ namespace System.Linq public interface IOrderedAsyncEnumerable : IAsyncEnumerable { IOrderedAsyncEnumerable CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending); - IOrderedAsyncEnumerable CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending); + IOrderedAsyncEnumerable CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 33095bb28b..c3429a98bc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -30,7 +30,7 @@ public static Task Aggregate(this IAsyncEnumerable so return AggregateCore(source, accumulator, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator) + public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task Aggregate(this IAsyncEnumerable so return AggregateCore(source, accumulator, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task Aggregate(this IAsyncEnume return AggregateCore(source, seed, accumulator, x => x, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task Aggregate(this IAsyncEnume return AggregateCore(source, seed, accumulator, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ public static Task Aggregate(this IAsync return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ public static Task Aggregate(this IAsync return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -185,7 +185,7 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) + private static async Task AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) { var acc = seed; @@ -206,7 +206,7 @@ private static async Task AggregateCore(IAsyncEnumera return acc; } - private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { var acc = seed; @@ -227,7 +227,7 @@ private static async Task AggregateCore( return await resultSelector(acc).ConfigureAwait(false); } - private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 7ef963ec32..75e1764c17 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -30,7 +30,7 @@ public static Task All(this IAsyncEnumerable source, Fun return AllCore(source, predicate, cancellationToken); } - public static Task All(this IAsyncEnumerable source, Func> predicate) + public static Task All(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task All(this IAsyncEnumerable source, Fun return AllCore(source, predicate, CancellationToken.None); } - public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ private static async Task AllCore(IAsyncEnumerable sourc return true; } - private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 8c14e01e13..47940748e2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -46,7 +46,7 @@ public static Task Any(this IAsyncEnumerable source, Fun return AnyCore(source, predicate, cancellationToken); } - public static Task Any(this IAsyncEnumerable source, Func> predicate) + public static Task Any(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Any(this IAsyncEnumerable source, Fun return AnyCore(source, predicate, CancellationToken.None); } - public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -100,7 +100,7 @@ private static async Task AnyCore(IAsyncEnumerable sourc return false; } - private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 576ab7a3d1..f669a88ccd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -46,7 +46,7 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -102,7 +102,7 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -112,7 +112,7 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -158,7 +158,7 @@ public static Task Average(this IAsyncEnumerable source return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -168,7 +168,7 @@ public static Task Average(this IAsyncEnumerable source return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -214,7 +214,7 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -224,7 +224,7 @@ public static Task Average(this IAsyncEnumerable sourc return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -270,7 +270,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -280,7 +280,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -326,7 +326,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -336,7 +336,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -382,7 +382,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -392,7 +392,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -438,7 +438,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -448,7 +448,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -494,7 +494,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -504,7 +504,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -550,7 +550,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task Average(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -560,7 +560,7 @@ public static Task Average(this IAsyncEnumerable sour return source.Select(selector).Average(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 3c75999834..8d9159f35a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -47,7 +47,7 @@ public static Task Count(this IAsyncEnumerable source, Fu return CountCore(source, predicate, cancellationToken); } - public static Task Count(this IAsyncEnumerable source, Func> predicate) + public static Task Count(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,7 +57,7 @@ public static Task Count(this IAsyncEnumerable source, Fu return CountCore(source, predicate, CancellationToken.None); } - public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -133,7 +133,7 @@ private static async Task CountCore(IAsyncEnumerable sour return count; } - private static async Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var count = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 61bce80290..074eb18d16 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -46,7 +46,7 @@ public static Task First(this IAsyncEnumerable source return FirstCore(source, predicate, cancellationToken); } - public static Task First(this IAsyncEnumerable source, Func> predicate) + public static Task First(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task First(this IAsyncEnumerable source return FirstCore(source, predicate, CancellationToken.None); } - public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ private static async Task FirstCore(IAsyncEnumerable return first.HasValue ? first.Value : throw Error.NoElements(); } - private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index fb4a4bf2e8..ae628eff0a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -46,7 +46,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< return first.HasValue ? first.Value : default; } - private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); @@ -151,7 +151,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< return new Maybe(); } - private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index a9c6c00d7a..ea37b78e0a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -31,7 +31,7 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, comparer); } - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, comparer: null); } - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -75,7 +75,7 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, comparer); } - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -87,7 +87,7 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, comparer: null); } - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -123,7 +123,7 @@ public static IAsyncEnumerable GroupBy(this IAs return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); } - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector) + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -135,7 +135,7 @@ public static IAsyncEnumerable GroupBy(this IAs return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); } - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -175,7 +175,7 @@ public static IAsyncEnumerable GroupBy resultSelector(g.Key, g)); } - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, Task> resultSelector) + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -189,7 +189,7 @@ public static IAsyncEnumerable GroupBy(keySelector, elementSelector, comparer: null).Select(g => resultSelector(g.Key, g)); } - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, Task> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -299,14 +299,14 @@ async Task Core() internal sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable _source; - private readonly Func> _keySelector; - private readonly Func, Task> _resultSelector; + private readonly Func> _keySelector; + private readonly Func, ValueTask> _resultSelector; private readonly IEqualityComparer _comparer; private Internal.LookupWithTask _lookup; private IAsyncEnumerator _enumerator; - public GroupedResultAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func, Task> resultSelector, IEqualityComparer comparer) + public GroupedResultAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -485,14 +485,14 @@ async Task Core() internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; - private readonly Func> _keySelector; - private readonly Func> _elementSelector; + private readonly Func> _keySelector; + private readonly Func> _elementSelector; private readonly IEqualityComparer _comparer; private Internal.LookupWithTask _lookup; private IEnumerator> _enumerator; - public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -668,13 +668,13 @@ async Task Core() internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; - private readonly Func> _keySelector; + private readonly Func> _keySelector; private readonly IEqualityComparer _comparer; private Internal.LookupWithTask _lookup; private IEnumerator> _enumerator; - public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { Debug.Assert(source != null); Debug.Assert(keySelector != null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 7ab385e812..9ab3b4b9f6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -42,7 +42,7 @@ public static IAsyncEnumerable GroupJoin return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector) + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -58,7 +58,7 @@ public static IAsyncEnumerable GroupJoin return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, Task> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -172,17 +172,17 @@ private sealed class GroupJoinAsyncEnumerableWithTask _comparer; private readonly IAsyncEnumerable _inner; - private readonly Func> _innerKeySelector; + private readonly Func> _innerKeySelector; private readonly IAsyncEnumerable _outer; - private readonly Func> _outerKeySelector; - private readonly Func, Task> _resultSelector; + private readonly Func> _outerKeySelector; + private readonly Func, ValueTask> _resultSelector; public GroupJoinAsyncEnumerableWithTask( IAsyncEnumerable outer, IAsyncEnumerable inner, - Func> outerKeySelector, - Func> innerKeySelector, - Func, Task> resultSelector, + Func> outerKeySelector, + Func> innerKeySelector, + Func, ValueTask> resultSelector, IEqualityComparer comparer) { _outer = outer; @@ -207,10 +207,10 @@ private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator _comparer; private readonly IAsyncEnumerable _inner; - private readonly Func> _innerKeySelector; + private readonly Func> _innerKeySelector; private readonly IAsyncEnumerator _outer; - private readonly Func> _outerKeySelector; - private readonly Func, Task> _resultSelector; + private readonly Func> _outerKeySelector; + private readonly Func, ValueTask> _resultSelector; private readonly CancellationToken _cancellationToken; private Internal.LookupWithTask _lookup; @@ -218,9 +218,9 @@ private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator outer, IAsyncEnumerable inner, - Func> outerKeySelector, - Func> innerKeySelector, - Func, Task> resultSelector, + Func> outerKeySelector, + Func> innerKeySelector, + Func, ValueTask> resultSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 8b3dc5c289..6918f7cb0d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -43,7 +43,7 @@ public static IAsyncEnumerable Join(this return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -59,7 +59,7 @@ public static IAsyncEnumerable Join(this return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -206,14 +206,14 @@ internal sealed class JoinAsyncIteratorWithTask : { private readonly IAsyncEnumerable _outer; private readonly IAsyncEnumerable _inner; - private readonly Func> _outerKeySelector; - private readonly Func> _innerKeySelector; - private readonly Func> _resultSelector; + private readonly Func> _outerKeySelector; + private readonly Func> _innerKeySelector; + private readonly Func> _resultSelector; private readonly IEqualityComparer _comparer; private IAsyncEnumerator _outerEnumerator; - public JoinAsyncIteratorWithTask(IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + public JoinAsyncIteratorWithTask(IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { Debug.Assert(outer != null); Debug.Assert(inner != null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index ad8d404609..5152986e21 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -46,7 +46,7 @@ public static Task Last(this IAsyncEnumerable source, return LastCore(source, predicate, cancellationToken); } - public static Task Last(this IAsyncEnumerable source, Func> predicate) + public static Task Last(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Last(this IAsyncEnumerable source, return LastCore(source, predicate, CancellationToken.None); } - public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ private static async Task LastCore(IAsyncEnumerable s return last.HasValue ? last.Value : throw Error.NoElements(); } - private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 19251cd5e7..64f1264694 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -46,7 +46,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); @@ -165,7 +165,7 @@ private static async Task> TryGetLast(IAsyncEnumerable(); } - private static async Task> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var last = default(TSource); var hasLast = false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 85c6e7b177..5ee7d42fff 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -46,7 +46,7 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, predicate, cancellationToken); } - public static Task LongCount(this IAsyncEnumerable source, Func> predicate) + public static Task LongCount(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, predicate, CancellationToken.None); } - public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -117,7 +117,7 @@ private static async Task LongCountCore(IAsyncEnumerable return count; } - private static async Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var count = 0L; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index e2ec58e35c..cac5b05abe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -369,7 +369,7 @@ public IEnumerator> GetEnumerator() } } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -398,7 +398,7 @@ internal static async Task> CreateAsync( return lookup; } - internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -423,7 +423,7 @@ internal static async Task> CreateAsync(IAsyncEnu return lookup; } - internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { var lookup = new LookupWithTask(comparer); @@ -499,7 +499,7 @@ internal int InternalGetHashCode(TKey key) return (key == null) ? 0 : _comparer.GetHashCode(key) & 0x7FFFFFFF; } - internal async Task ToArray(Func, Task> resultSelector) + internal async Task ToArray(Func, ValueTask> resultSelector) { var array = new TResult[Count]; var index = 0; @@ -518,7 +518,7 @@ internal async Task ToArray(Func> ToList(Func, Task> resultSelector) + internal async Task> ToList(Func, ValueTask> resultSelector) { var list = new List(Count); var g = _lastGrouping; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs index 7e13ef9e8a..73541c5e00 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs @@ -140,7 +140,7 @@ private static async Task MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; var value = default(TResult); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs index 62b98ce2ff..048152a33d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs @@ -916,7 +916,7 @@ private static async Task MaxCore(IAsyncEnumerable so return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { int value; @@ -947,7 +947,7 @@ private static async Task MaxCore(IAsyncEnumerable source return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { int? value = null; @@ -1011,7 +1011,7 @@ private static async Task MaxCore(IAsyncEnumerable source return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { long value; @@ -1042,7 +1042,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { long? value = null; @@ -1100,7 +1100,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { float value; @@ -1141,7 +1141,7 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { float? value = null; @@ -1197,7 +1197,7 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { double value; @@ -1243,7 +1243,7 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { double? value = null; @@ -1299,7 +1299,7 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { decimal value; @@ -1330,7 +1330,7 @@ private static async Task MaxCore(IAsyncEnumerable so return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { decimal? value = null; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index e1caec504d..a44e31f02d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -46,7 +46,7 @@ public static Task Max(this IAsyncEnumerable return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Max(this IAsyncEnumerable return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs index 6d7288c287..8279a6c379 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs @@ -140,7 +140,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; var value = default(TResult); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs index 2bf592d52d..ac848e7de1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs @@ -792,7 +792,7 @@ private static async Task MinCore(IAsyncEnumerable so return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { int value; @@ -823,7 +823,7 @@ private static async Task MinCore(IAsyncEnumerable source return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { int? value = null; @@ -869,7 +869,7 @@ private static async Task MinCore(IAsyncEnumerable source return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { long value; @@ -900,7 +900,7 @@ private static async Task MinCore(IAsyncEnumerable sourc return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { long? value = null; @@ -942,7 +942,7 @@ private static async Task MinCore(IAsyncEnumerable sourc return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { float value; @@ -986,7 +986,7 @@ private static async Task MinCore(IAsyncEnumerable sour return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { float? value = null; @@ -1032,7 +1032,7 @@ private static async Task MinCore(IAsyncEnumerable sour return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { double value; @@ -1067,7 +1067,7 @@ private static async Task MinCore(IAsyncEnumerable sou return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { double? value = null; @@ -1113,7 +1113,7 @@ private static async Task MinCore(IAsyncEnumerable sou return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { decimal value; @@ -1144,7 +1144,7 @@ private static async Task MinCore(IAsyncEnumerable so return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { decimal? value = null; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index a32add57cd..a516294623 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -46,7 +46,7 @@ public static Task Min(this IAsyncEnumerable return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Min(this IAsyncEnumerable return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 201b5f1fbf..db5117834c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -46,7 +46,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -102,7 +102,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -112,7 +112,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -158,7 +158,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -168,7 +168,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -214,7 +214,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -224,7 +224,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -270,7 +270,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -280,7 +280,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -326,7 +326,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -336,7 +336,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -382,7 +382,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -392,7 +392,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -438,7 +438,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -448,7 +448,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -494,7 +494,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -504,7 +504,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -550,7 +550,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task Max(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -560,7 +560,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -606,7 +606,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -616,7 +616,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -662,7 +662,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -672,7 +672,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -718,7 +718,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -728,7 +728,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -774,7 +774,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -784,7 +784,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -830,7 +830,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -840,7 +840,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -886,7 +886,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -896,7 +896,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -942,7 +942,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -952,7 +952,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -998,7 +998,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1008,7 +1008,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1054,7 +1054,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1064,7 +1064,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1110,7 +1110,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task Min(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1120,7 +1120,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index 6980367d0d..e41dc7e9e6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -19,7 +19,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn return OrderBy(source, keySelector, comparer: null); } - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -38,7 +38,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); } - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -58,7 +58,7 @@ public static IOrderedAsyncEnumerable OrderByDescending( return source.OrderByDescending(keySelector, comparer: null); } - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -78,7 +78,7 @@ public static IOrderedAsyncEnumerable OrderByDescending( return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); } - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -98,7 +98,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.ThenBy(keySelector, Comparer.Default); } - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -118,7 +118,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,7 +138,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, Comparer.Default, descending: true); } - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -158,7 +158,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 7969ba8dad..520681092c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -23,7 +23,7 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere return new OrderedAsyncEnumerable(_source, keySelector, comparer, descending, this); } - IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending) + IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending) { return new OrderedAsyncEnumerableWithTask(_source, keySelector, comparer, descending, this); } @@ -110,10 +110,10 @@ internal sealed class OrderedAsyncEnumerableWithTask : OrderedAs { private readonly IComparer _comparer; private readonly bool _descending; - private readonly Func> _keySelector; + private readonly Func> _keySelector; private readonly OrderedAsyncEnumerable _parent; - public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) + public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) { Debug.Assert(source != null); Debug.Assert(keySelector != null); @@ -282,9 +282,9 @@ internal override async ValueTask ComputeKeys(TElement[] elements, int count) internal sealed class AsyncKeySelectorAsyncEnumerableSorter : AsyncEnumerableSorterBase { - private readonly Func> _keySelector; + private readonly Func> _keySelector; - public AsyncKeySelectorAsyncEnumerableSorter(Func> keySelector, IComparer comparer, bool descending, AsyncEnumerableSorter next) + public AsyncKeySelectorAsyncEnumerableSorter(Func> keySelector, IComparer comparer, bool descending, AsyncEnumerableSorter next) : base(comparer, descending, next) { _keySelector = keySelector; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index b931db209b..ddd4a0cc9a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -39,7 +39,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum return new SelectEnumerableWithIndexAsyncIterator(source, selector); } - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,7 +57,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum return new SelectEnumerableAsyncIteratorWithTask(source, selector); } - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -72,7 +72,7 @@ private static Func CombineSelectors selector2(selector1(x)); } - private static Func> CombineSelectors(Func> selector1, Func> selector2) + private static Func> CombineSelectors(Func> selector1, Func> selector2) { return async x => await selector2(await selector1(x).ConfigureAwait(false)).ConfigureAwait(false); } @@ -314,12 +314,12 @@ protected override async ValueTask MoveNextCore() internal sealed class SelectEnumerableAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _selector; + private readonly Func> _selector; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; - public SelectEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) + public SelectEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); @@ -344,7 +344,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public override IAsyncEnumerable Select(Func> selector) + public override IAsyncEnumerable Select(Func> selector) { return new SelectEnumerableAsyncIteratorWithTask(_source, CombineSelectors(_selector, selector)); } @@ -375,12 +375,12 @@ protected override async ValueTask MoveNextCore() internal sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _selector; + private readonly Func> _selector; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; private int _index; - public SelectEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) + public SelectEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); @@ -444,11 +444,11 @@ protected override async ValueTask MoveNextCore() internal sealed class SelectIListIteratorWithTask : AsyncIterator, IAsyncIListProvider { - private readonly Func> _selector; + private readonly Func> _selector; private readonly IList _source; private IEnumerator _enumerator; - public SelectIListIteratorWithTask(IList source, Func> selector) + public SelectIListIteratorWithTask(IList source, Func> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); @@ -500,7 +500,7 @@ async Task Core() } } - public override IAsyncEnumerable Select(Func> selector) + public override IAsyncEnumerable Select(Func> selector) { return new SelectIListIteratorWithTask(_source, CombineSelectors(_selector, selector)); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 0a19edce7b..b881898a8a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable SelectMany(this IAsync return new SelectManyAsyncIterator(source, selector); } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static IAsyncEnumerable SelectMany(this IAsync return new SelectManyWithIndexAsyncIterator(source, selector); } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -63,7 +63,7 @@ public static IAsyncEnumerable SelectMany(source, selector, resultSelector); } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -87,7 +87,7 @@ public static IAsyncEnumerable SelectMany(source, selector, resultSelector); } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -195,14 +195,14 @@ private sealed class SelectManyAsyncIteratorWithTask : AsyncIt private const int State_Source = 1; private const int State_Result = 2; - private readonly Func>> _selector; + private readonly Func>> _selector; private readonly IAsyncEnumerable _source; private int _mode; private IAsyncEnumerator _resultEnumerator; private IAsyncEnumerator _sourceEnumerator; - public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) + public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); @@ -384,8 +384,8 @@ private sealed class SelectManyAsyncIteratorWithTask>> _collectionSelector; - private readonly Func> _resultSelector; + private readonly Func>> _collectionSelector; + private readonly Func> _resultSelector; private readonly IAsyncEnumerable _source; private TSource _currentSource; @@ -393,7 +393,7 @@ private sealed class SelectManyAsyncIteratorWithTask _resultEnumerator; private IAsyncEnumerator _sourceEnumerator; - public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + public SelectManyAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { Debug.Assert(source != null); Debug.Assert(collectionSelector != null); @@ -588,8 +588,8 @@ private sealed class SelectManyWithIndexAsyncIteratorWithTask>> _collectionSelector; - private readonly Func> _resultSelector; + private readonly Func>> _collectionSelector; + private readonly Func> _resultSelector; private readonly IAsyncEnumerable _source; private TSource _currentSource; @@ -598,7 +598,7 @@ private sealed class SelectManyWithIndexAsyncIteratorWithTask _resultEnumerator; private IAsyncEnumerator _sourceEnumerator; - public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { Debug.Assert(source != null); Debug.Assert(collectionSelector != null); @@ -792,7 +792,7 @@ private sealed class SelectManyWithIndexAsyncIteratorWithTask private const int State_Source = 1; private const int State_Result = 2; - private readonly Func>> _selector; + private readonly Func>> _selector; private readonly IAsyncEnumerable _source; private int _index; @@ -800,7 +800,7 @@ private sealed class SelectManyWithIndexAsyncIteratorWithTask private IAsyncEnumerator _resultEnumerator; private IAsyncEnumerator _sourceEnumerator; - public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) + public SelectManyWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func>> selector) { Debug.Assert(source != null); Debug.Assert(selector != null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 7a1be099f0..82edfcc7d5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -46,7 +46,7 @@ public static Task Single(this IAsyncEnumerable sourc return SingleCore(source, predicate, cancellationToken); } - public static Task Single(this IAsyncEnumerable source, Func> predicate) + public static Task Single(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Single(this IAsyncEnumerable sourc return SingleCore(source, predicate, CancellationToken.None); } - public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -134,7 +134,7 @@ private static async Task SingleCore(IAsyncEnumerable } } - private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 8d2f33e2c6..adaba84d66 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -46,7 +46,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -135,7 +135,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable } } - private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 1182b09b41..bef6799482 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -31,7 +31,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable return new SkipWhileWithIndexAsyncIterator(source, predicate); } - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable return new SkipWhileAsyncIteratorWithTask(source, predicate); } - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -213,13 +213,13 @@ protected override async ValueTask MoveNextCore() private sealed class SkipWhileAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _predicate; + private readonly Func> _predicate; private readonly IAsyncEnumerable _source; private bool _doMoveNext; private IAsyncEnumerator _enumerator; - public SkipWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + public SkipWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); @@ -289,14 +289,14 @@ protected override async ValueTask MoveNextCore() private sealed class SkipWhileWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _predicate; + private readonly Func> _predicate; private readonly IAsyncEnumerable _source; private bool _doMoveNext; private IAsyncEnumerator _enumerator; private int _index; - public SkipWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + public SkipWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index f6da90f919..fb5aa302bf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -46,7 +46,7 @@ public static Task Sum(this IAsyncEnumerable source, Func return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Sum(this IAsyncEnumerable source, Func return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -116,7 +116,7 @@ private static async Task SumCore(IAsyncEnumerable source return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0; @@ -178,7 +178,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -188,7 +188,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -248,7 +248,7 @@ private static async Task SumCore(IAsyncEnumerable sourc return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0L; @@ -310,7 +310,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -320,7 +320,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -374,7 +374,7 @@ private static async Task SumCore(IAsyncEnumerable sour return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0.0f; @@ -433,7 +433,7 @@ public static Task Sum(this IAsyncEnumerable source, F return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -443,7 +443,7 @@ public static Task Sum(this IAsyncEnumerable source, F return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -497,7 +497,7 @@ private static async Task SumCore(IAsyncEnumerable sou return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0.0; @@ -556,7 +556,7 @@ public static Task Sum(this IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -566,7 +566,7 @@ public static Task Sum(this IAsyncEnumerable source, return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -620,7 +620,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0m; @@ -679,7 +679,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -689,7 +689,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -749,7 +749,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0; @@ -811,7 +811,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -821,7 +821,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -881,7 +881,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0L; @@ -943,7 +943,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -953,7 +953,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1007,7 +1007,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0.0f; @@ -1066,7 +1066,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1076,7 +1076,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1130,7 +1130,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0.0; @@ -1189,7 +1189,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task Sum(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1199,7 +1199,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1253,7 +1253,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var sum = 0m; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index f932b8a3f6..6e275ef72c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -31,7 +31,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable return new TakeWhileWithIndexAsyncIterator(source, predicate); } - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable return new TakeWhileAsyncIteratorWithTask(source, predicate); } - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -188,12 +188,12 @@ protected override async ValueTask MoveNextCore() private sealed class TakeWhileAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _predicate; + private readonly Func> _predicate; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; - public TakeWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + public TakeWhileAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); @@ -252,13 +252,13 @@ protected override async ValueTask MoveNextCore() private sealed class TakeWhileWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _predicate; + private readonly Func> _predicate; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; private int _index; - public TakeWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + public TakeWhileWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(predicate != null); Debug.Assert(source != null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index ef0637d68c..4f106a5b90 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -30,24 +30,24 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, CancellationToken.None); + return ToDictionaryCore(source, keySelector, x => new ValueTask(x), EqualityComparer.Default, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), EqualityComparer.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, x => new ValueTask(x), EqualityComparer.Default, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -70,24 +70,24 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None); + return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken); + return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); } public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector) @@ -114,7 +114,7 @@ public static Task> ToDictionary.Default, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ public static Task> ToDictionary.Default, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -162,7 +162,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -174,7 +174,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -212,7 +212,7 @@ private static async Task> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + private static async Task> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index effa307cc5..d9c24a2f45 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -30,24 +30,24 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => x, comparer: null, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer: null, CancellationToken.None); + return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer: null, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer: null, cancellationToken); + return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer: null, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -70,24 +70,24 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => x, comparer, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer, CancellationToken.None); + return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => Task.FromResult(x), comparer, cancellationToken); + return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); } public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector) @@ -114,7 +114,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer: null, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -162,7 +162,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -174,7 +174,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -191,7 +191,7 @@ private static async Task> ToLookupCore.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); } - private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { return await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 796578e42d..5a70885a45 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -36,7 +36,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable(source, predicate); } - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -52,7 +52,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable(source, predicate); } - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +67,7 @@ private static Func CombinePredicates(Func predicate1(x) && predicate2(x); } - private static Func> CombinePredicates(Func> predicate1, Func> predicate2) + private static Func> CombinePredicates(Func> predicate1, Func> predicate2) { return async x => await predicate1(x).ConfigureAwait(false) && await predicate2(x).ConfigureAwait(false); } @@ -211,11 +211,11 @@ protected override async ValueTask MoveNextCore() internal sealed class WhereEnumerableAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _predicate; + private readonly Func> _predicate; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; - public WhereEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + public WhereEnumerableAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(source != null); Debug.Assert(predicate != null); @@ -240,7 +240,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public override IAsyncEnumerable Where(Func> predicate) + public override IAsyncEnumerable Where(Func> predicate) { return new WhereEnumerableAsyncIteratorWithTask(_source, CombinePredicates(_predicate, predicate)); } @@ -275,13 +275,13 @@ protected override async ValueTask MoveNextCore() internal sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { - private readonly Func> _predicate; + private readonly Func> _predicate; private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; private int _index; - public WhereEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) + public WhereEnumerableWithIndexAsyncIteratorWithTask(IAsyncEnumerable source, Func> predicate) { Debug.Assert(source != null); Debug.Assert(predicate != null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 1cb61f5901..89cb49fb67 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -23,7 +23,7 @@ public static IAsyncEnumerable Zip(this IAsyn return new ZipAsyncIterator(first, second, selector); } - public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -111,12 +111,12 @@ private sealed class ZipAsyncIteratorWithTask : AsyncI { private readonly IAsyncEnumerable _first; private readonly IAsyncEnumerable _second; - private readonly Func> _selector; + private readonly Func> _selector; private IAsyncEnumerator _firstEnumerator; private IAsyncEnumerator _secondEnumerator; - public ZipAsyncIteratorWithTask(IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + public ZipAsyncIteratorWithTask(IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { Debug.Assert(first != null); Debug.Assert(second != null); From d8d858a2547f376981c472e4cbaae7b1f3e75a9a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 14 Nov 2018 13:09:53 -0800 Subject: [PATCH 533/862] Fix some T4 files for ValueTask overload generation. --- Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj | 4 ++++ .../System/Linq/Operators/Average.Generated.tt | 4 ++-- .../System/Linq/Operators/MinMax.Generated.tt | 4 ++-- .../System.Linq.Async/System/Linq/Operators/Sum.Generated.tt | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 1d19bf9f63..72ae7239e9 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -41,4 +41,8 @@ + + + + diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 8cc4c4a6f1..37aba77696 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -71,7 +71,7 @@ foreach (var o in os) return source.Select(selector).Average(cancellationToken); } - public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector) + public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -81,7 +81,7 @@ foreach (var o in os) return source.Select(selector).Average(CancellationToken.None); } - public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 0bdde028c4..2a4fdb6930 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -58,7 +58,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, selector, cancellationToken); } - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector) + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -68,7 +68,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, selector, CancellationToken.None); } - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index d3c9e2fe64..1a2050473e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -71,7 +71,7 @@ foreach (var o in os) return SumCore(source, selector, cancellationToken); } - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector) + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -81,7 +81,7 @@ foreach (var o in os) return SumCore(source, selector, CancellationToken.None); } - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); From 6700700e904a1c1cc0c336f15d835f32aacb2740 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 14 Nov 2018 13:13:31 -0800 Subject: [PATCH 534/862] One more T4 fix. --- .../System.Linq.Async/System/Linq/Operators/Sum.Generated.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 1a2050473e..841a044966 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -167,7 +167,7 @@ else return sum; } - private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { var sum = <#=o.zero#>; From 8be48111637aa7091ed8cb570145852b6e5afd1c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 14 Nov 2018 13:54:03 -0800 Subject: [PATCH 535/862] Moving to Async naming convention. --- .../AsyncQueryableExTests.Generated.cs | 188 +- .../System/Linq/AsyncQueryableEx.Generated.cs | 88 +- .../AsyncTests.Bugs.cs | 6 +- .../System/Linq/AsyncEnumerableExTests.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 6 +- .../System/Linq/Operators/IsEmpty.cs | 5 +- .../System/Linq/Operators/Max.cs | 4 +- .../System/Linq/Operators/MaxBy.cs | 26 +- .../System/Linq/Operators/Min.cs | 4 +- .../System/Linq/Operators/MinBy.cs | 26 +- .../TaskExtTests.cs | 4 +- .../System/Linq/Operators/IsEmpty.cs | 6 +- .../System/Linq/Operators/Max.cs | 4 +- .../System/Linq/Operators/MaxBy.cs | 16 +- .../System/Linq/Operators/Min.cs | 4 +- .../System/Linq/Operators/MinBy.cs | 16 +- .../AsyncQueryableTests.Generated.cs | 2840 ++++++++--------- .../System/Linq/AsyncQueryable.Generated.cs | 1496 ++++----- .../System/Linq/AsyncEnumerableTests.cs | 4 +- .../System/Linq/Operators/Aggregate.cs | 54 +- .../System/Linq/Operators/All.cs | 16 +- .../System/Linq/Operators/Any.cs | 24 +- .../System/Linq/Operators/Append.cs | 24 +- .../System/Linq/Operators/Average.cs | 180 +- .../System/Linq/Operators/Concat.cs | 6 +- .../System/Linq/Operators/Contains.cs | 16 +- .../System/Linq/Operators/Count.cs | 26 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 12 +- .../System/Linq/Operators/Distinct.cs | 6 +- .../System/Linq/Operators/ElementAt.cs | 20 +- .../Linq/Operators/ElementAtOrDefault.cs | 18 +- .../System/Linq/Operators/First.cs | 30 +- .../System/Linq/Operators/FirstOrDefault.cs | 32 +- .../System/Linq/Operators/GroupBy.cs | 88 +- .../System/Linq/Operators/GroupJoin.cs | 14 +- .../System/Linq/Operators/Last.cs | 30 +- .../System/Linq/Operators/LastOrDefault.cs | 32 +- .../System/Linq/Operators/LongCount.cs | 26 +- .../System/Linq/Operators/Max.cs | 190 +- .../System/Linq/Operators/Min.cs | 190 +- .../System/Linq/Operators/Prepend.cs | 24 +- .../System/Linq/Operators/Reverse.cs | 8 +- .../System/Linq/Operators/SequenceEqual.cs | 48 +- .../System/Linq/Operators/Single.cs | 34 +- .../System/Linq/Operators/SingleOrDefault.cs | 36 +- .../System/Linq/Operators/Sum.cs | 170 +- .../System/Linq/Operators/ToArray.cs | 14 +- .../Linq/Operators/ToAsyncEnumerable.cs | 6 +- .../System/Linq/Operators/ToDictionary.cs | 54 +- .../System/Linq/Operators/ToHashSet.cs | 8 +- .../System/Linq/Operators/ToList.cs | 10 +- .../System/Linq/Operators/ToLookup.cs | 58 +- .../System/Linq/Optimizations.cs | 12 +- .../System/Linq/AsyncEnumerablePartition.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 24 +- .../System/Linq/Operators/All.cs | 8 +- .../System/Linq/Operators/Any.cs | 12 +- .../System/Linq/Operators/AppendPrepend.cs | 4 +- .../Linq/Operators/Average.Generated.cs | 200 +- .../Linq/Operators/Average.Generated.tt | 20 +- .../System/Linq/Operators/Concat.cs | 2 +- .../System/Linq/Operators/Contains.cs | 8 +- .../System/Linq/Operators/Count.cs | 12 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 6 +- .../System/Linq/Operators/ElementAt.cs | 4 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/First.cs | 12 +- .../System/Linq/Operators/FirstOrDefault.cs | 12 +- .../System/Linq/Operators/Last.cs | 12 +- .../System/Linq/Operators/LastOrDefault.cs | 12 +- .../System/Linq/Operators/LongCount.cs | 12 +- .../System/Linq/Operators/Max.cs | 12 +- .../System/Linq/Operators/Min.cs | 12 +- .../System/Linq/Operators/MinMax.Generated.cs | 240 +- .../System/Linq/Operators/MinMax.Generated.tt | 12 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 2 +- .../System/Linq/Operators/Reverse.cs | 8 +- .../System/Linq/Operators/SequenceEqual.cs | 8 +- .../System/Linq/Operators/Single.cs | 12 +- .../System/Linq/Operators/SingleOrDefault.cs | 12 +- .../System/Linq/Operators/Sum.Generated.cs | 120 +- .../System/Linq/Operators/Sum.Generated.tt | 12 +- .../System/Linq/Operators/ToArray.cs | 6 +- .../System/Linq/Operators/ToDictionary.cs | 32 +- .../System/Linq/Operators/ToHashSet.cs | 8 +- .../System/Linq/Operators/ToList.cs | 4 +- .../System/Linq/Operators/ToLookup.cs | 32 +- 87 files changed, 3580 insertions(+), 3581 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs index d13f076201..bafdc05d41 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs @@ -365,124 +365,124 @@ public void IgnoreElements1() } [Fact] - public void IsEmpty1() + public void IsEmptyAsync1() { - AssertEx.Throws(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryableEx.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryableEx.IsEmptyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void IsEmpty2() + public void IsEmptyAsync2() { - AssertEx.Throws(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryableEx.IsEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryableEx.IsEmptyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max1() + public void MaxAsync1() { - AssertEx.Throws(() => AsyncQueryableEx.Max(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); + var res = AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max2() + public void MaxAsync2() { - AssertEx.Throws(() => AsyncQueryableEx.Max(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy1() + public void MaxByAsync1() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy2() + public void MaxByAsync2() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy3() + public void MaxByAsync3() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy4() + public void MaxByAsync4() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy5() + public void MaxByAsync5() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy6() + public void MaxByAsync6() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy7() + public void MaxByAsync7() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxBy8() + public void MaxByAsync8() { - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MaxBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -497,106 +497,106 @@ public void Merge1() } [Fact] - public void Min1() + public void MinAsync1() { - AssertEx.Throws(() => AsyncQueryableEx.Min(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); + var res = AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min2() + public void MinAsync2() { - AssertEx.Throws(() => AsyncQueryableEx.Min(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy1() + public void MinByAsync1() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy2() + public void MinByAsync2() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy3() + public void MinByAsync3() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy4() + public void MinByAsync4() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy5() + public void MinByAsync5() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy6() + public void MinByAsync6() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy7() + public void MinByAsync7() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinBy8() + public void MinByAsync8() { - AssertEx.Throws(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryableEx.MinBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index eb1493265c..a1b5387f94 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -460,31 +460,31 @@ public static IAsyncQueryable IgnoreElements(this IAsyncQuerya #endif } - public static Task IsEmpty(this IAsyncQueryable source) + public static Task IsEmptyAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task IsEmpty(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task IsEmptyAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmpty(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, IComparer comparer) + public static Task MaxAsync(this IAsyncQueryable source, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -492,13 +492,13 @@ public static Task Max(this IAsyncQueryable source, I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Max(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -506,13 +506,13 @@ public static Task Max(this IAsyncQueryable source, I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Max(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -520,13 +520,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -534,13 +534,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -548,13 +548,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -564,13 +564,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -578,13 +578,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -594,13 +594,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -610,13 +610,13 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MaxBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -626,7 +626,7 @@ public static Task> MaxBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -644,7 +644,7 @@ public static IAsyncQueryable Merge(this IAsyncQueryable Min(this IAsyncQueryable source, IComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -652,13 +652,13 @@ public static Task Min(this IAsyncQueryable source, I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Min(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -666,13 +666,13 @@ public static Task Min(this IAsyncQueryable source, I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.Min(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector) + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -680,13 +680,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -694,13 +694,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -708,13 +708,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -724,13 +724,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -738,13 +738,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -754,13 +754,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -770,13 +770,13 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> MinBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -786,7 +786,7 @@ public static Task> MinBy(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 5befee2552..f1d15aeaf5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -88,7 +88,7 @@ public async Task TakeOneFromSelectMany() .Take(1) .Do(_ => { }); - Assert.Equal("Check", await enumerable.First()); + Assert.Equal("Check", await enumerable.FirstAsync()); } [Fact] @@ -96,7 +96,7 @@ public async Task SelectManyDisposeInvokedOnlyOnceAsync() { var disposeCounter = new DisposeCounter(); - var result = await new[] { 1 }.ToAsyncEnumerable().SelectMany(i => disposeCounter).Select(i => i).ToList(); + var result = await new[] { 1 }.ToAsyncEnumerable().SelectMany(i => disposeCounter).Select(i => i).ToListAsync(); Assert.Empty(result); Assert.Equal(1, disposeCounter.DisposeCount); @@ -107,7 +107,7 @@ public async Task SelectManyInnerDisposeAsync() { var disposes = Enumerable.Range(0, 10).Select(_ => new DisposeCounter()).ToList(); - var result = await AsyncEnumerable.Range(0, 10).SelectMany(i => disposes[i]).Select(i => i).ToList(); + var result = await AsyncEnumerable.Range(0, 10).SelectMany(i => disposes[i]).Select(i => i).ToListAsync(); Assert.Empty(result); Assert.True(disposes.All(d => d.DisposeCount == 1)); diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs index 24cd11ef7e..aa57b64794 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/AsyncEnumerableExTests.cs @@ -60,8 +60,8 @@ protected async Task SequenceIdentity(IAsyncEnumerable enumerable) await en1.DisposeAsync(); await en2.DisposeAsync(); - var res1 = await enumerable.ToList(); - var res2 = await enumerable.ToList(); + var res1 = await enumerable.ToListAsync(); + var res2 = await enumerable.ToListAsync(); res1.ShouldAllBeEquivalentTo(res2); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs index 131b394c39..3c69b47297 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Distinct.cs @@ -42,7 +42,7 @@ public async Task Distinct6() var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); var res = new[] { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToArray())); + Assert.True(res.SequenceEqual(await xs.ToArrayAsync())); } [Fact] @@ -51,7 +51,7 @@ public async Task Distinct7() var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); var res = new List { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToList())); + Assert.True(res.SequenceEqual(await xs.ToListAsync())); } [Fact] @@ -59,7 +59,7 @@ public async Task Distinct8() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(k => k); - Assert.Equal(5, await xs.Count()); + Assert.Equal(5, await xs.CountAsync()); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs index c1ce5a71fb..c981bf5853 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -16,8 +15,8 @@ public class IsEmpty : AsyncEnumerableExTests [Fact] public async Task IsEmpty_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmpty(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmptyAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmptyAsync(default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs index 5c5563ea15..cdbae20062 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs @@ -16,9 +16,9 @@ public class Max : AsyncEnumerableExTests [Fact] public async Task Max_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxAsync(default, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Max(default, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxAsync(default, Comparer.Default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index 4618e15e18..ef95ed0b21 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -16,23 +16,23 @@ public class MaxBy : AsyncEnumerableExTests [Fact] public async Task MaxBy_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), Comparer.Default, CancellationToken.None)); } [Fact] public async Task MaxBy1Async() { - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => x / 2); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxByAsync(x => x / 2); var res = await xs; Assert.True(res.SequenceEqual(new[] { 7, 6 })); @@ -41,7 +41,7 @@ public async Task MaxBy1Async() [Fact] public async Task MaxBy2() { - var xs = new int[0].ToAsyncEnumerable().MaxBy(x => x / 2); + var xs = new int[0].ToAsyncEnumerable().MaxByAsync(x => x / 2); await AssertThrowsAsync(xs); } @@ -50,7 +50,7 @@ public async Task MaxBy2() public async Task MaxBy3() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 3) throw ex; return x; }); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxByAsync(x => { if (x == 3) throw ex; return x; }); await AssertThrowsAsync(xs, ex); } @@ -59,7 +59,7 @@ public async Task MaxBy3() public async Task MaxBy4() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxBy(x => { if (x == 4) throw ex; return x; }); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MaxByAsync(x => { if (x == 4) throw ex; return x; }); await AssertThrowsAsync(xs, ex); } @@ -68,7 +68,7 @@ public async Task MaxBy4() public async Task MaxBy5() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MaxBy(x => x, Comparer.Default); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MaxByAsync(x => x, Comparer.Default); await AssertThrowsAsync(xs, ex); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs index 50a1157c78..7c55e0f450 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs @@ -16,9 +16,9 @@ public class Min : AsyncEnumerableExTests [Fact] public async Task Min_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinAsync(default, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.Min(default, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinAsync(default, Comparer.Default, CancellationToken.None)); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index 9c9705c05f..b51167d5b2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -16,23 +16,23 @@ public class MinBy : AsyncEnumerableExTests [Fact] public async Task MinBy_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinBy(Return42, default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), Comparer.Default, CancellationToken.None)); } [Fact] public async Task MinBy1Async() { - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => x / 2); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinByAsync(x => x / 2); var res = await xs; Assert.True(res.SequenceEqual(new[] { 3, 2 })); @@ -41,7 +41,7 @@ public async Task MinBy1Async() [Fact] public async Task MinBy2Async() { - var xs = new int[0].ToAsyncEnumerable().MinBy(x => x / 2); + var xs = new int[0].ToAsyncEnumerable().MinByAsync(x => x / 2); await AssertThrowsAsync(xs); } @@ -50,7 +50,7 @@ public async Task MinBy2Async() public async Task MinBy3Async() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 3) throw ex; return x; }); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinByAsync(x => { if (x == 3) throw ex; return x; }); await AssertThrowsAsync(xs, ex); } @@ -59,7 +59,7 @@ public async Task MinBy3Async() public async Task MinBy4Async() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinBy(x => { if (x == 4) throw ex; return x; }); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().MinByAsync(x => { if (x == 4) throw ex; return x; }); await AssertThrowsAsync(xs, ex); } @@ -68,7 +68,7 @@ public async Task MinBy4Async() public async Task MinBy5Async() { var ex = new Exception("Bang!"); - var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MinBy(x => x, Comparer.Default); + var xs = new[] { 3, 5, 7, 6, 4, 2 }.ToAsyncEnumerable().Concat(Throw(ex)).MinByAsync(x => x, Comparer.Default); await AssertThrowsAsync(xs, ex); } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs index 02aaa6fb0b..0733ad9062 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/TaskExtTests.cs @@ -18,7 +18,7 @@ public async Task ExceptionHandling_ShouldThrowUnwrappedException() try { var asyncEnumerable = AsyncEnumerable.ToAsyncEnumerable(GetEnumerableWithError()); - await asyncEnumerable.ToArray(); + await asyncEnumerable.ToArrayAsync(); } catch (AggregateException) { @@ -41,7 +41,7 @@ public async Task ExceptionHandling_ShouldThrowUnwrappedException2() try { var asyncEnumerable = AsyncEnumerableEx.Generate(15, (x) => { throw new InvalidOperationException(); }, (x) => { return 20; }, (x) => { return 2; }); - await asyncEnumerable.ToArray(); + await asyncEnumerable.ToArrayAsync(); } catch (AggregateException) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index 7788ee89e5..836bfe2de4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task IsEmpty(this IAsyncEnumerable source) + public static Task IsEmptyAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task IsEmpty(this IAsyncEnumerable source) return IsEmptyCore(source, CancellationToken.None); } - public static Task IsEmpty(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task IsEmptyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -28,7 +28,7 @@ public static Task IsEmpty(this IAsyncEnumerable source, private static async Task IsEmptyCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - return !await source.Any(cancellationToken).ConfigureAwait(false); + return !await source.AnyAsync(cancellationToken).ConfigureAwait(false); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 75bc99f24a..2e2e49a537 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task Max(this IAsyncEnumerable source, IComparer comparer) + public static Task MaxAsync(this IAsyncEnumerable source, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, comparer, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index 32d2487d90..a4b988cfe7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task> MaxBy(this IAsyncEnumerable source, Func keySelector) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -50,7 +50,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ public static Task> MaxBy(this IAsyncEnumerable(source, keySelector, comparer: null, CancellationToken.None); } - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task> MaxBy(this IAsyncEnumerable(source, keySelector, comparer: null, cancellationToken); } - public static Task> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task> MaxBy(this IAsyncEnumerable> MaxBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index a332b57906..09337d7636 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task Min(this IAsyncEnumerable source, IComparer comparer) + public static Task MinAsync(this IAsyncEnumerable source, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, comparer, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 382541f52d..42deacd924 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task> MinBy(this IAsyncEnumerable source, Func keySelector) + public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) + public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -50,7 +50,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ public static Task> MinBy(this IAsyncEnumerable(source, keySelector, comparer: null, CancellationToken.None); } - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task> MinBy(this IAsyncEnumerable(source, keySelector, comparer: null, cancellationToken); } - public static Task> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task> MinBy(this IAsyncEnumerable> MinBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index 0c25ccaf45..d77045ab8a 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -15,224 +15,224 @@ namespace Tests public class AsyncQueryableExTests { [Fact] - public void Aggregate1() + public void AggregateAsync1() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate2() + public void AggregateAsync2() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate3() + public void AggregateAsync3() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate4() + public void AggregateAsync4() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate5() + public void AggregateAsync5() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int)); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate6() + public void AggregateAsync6() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate7() + public void AggregateAsync7() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate8() + public void AggregateAsync8() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate9() + public void AggregateAsync9() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate10() + public void AggregateAsync10() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate11() + public void AggregateAsync11() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Aggregate12() + public void AggregateAsync12() { - AssertEx.Throws(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Aggregate(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void All1() + public void AllAsync1() { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void All2() + public void AllAsync2() { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void All3() + public void AllAsync3() { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void All4() + public void AllAsync4() { - AssertEx.Throws(() => AsyncQueryable.All(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.All(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Any1() + public void AnyAsync1() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Any2() + public void AnyAsync2() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Any3() + public void AnyAsync3() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Any4() + public void AnyAsync4() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Any5() + public void AnyAsync5() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Any6() + public void AnyAsync6() { - AssertEx.Throws(() => AsyncQueryable.Any(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Any(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -247,582 +247,582 @@ public void Append1() } [Fact] - public void Average1() + public void AverageAsync1() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average2() + public void AverageAsync2() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average3() + public void AverageAsync3() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average4() + public void AverageAsync4() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average5() + public void AverageAsync5() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average6() + public void AverageAsync6() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average7() + public void AverageAsync7() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average8() + public void AverageAsync8() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average9() + public void AverageAsync9() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average10() + public void AverageAsync10() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average11() + public void AverageAsync11() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average12() + public void AverageAsync12() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average13() + public void AverageAsync13() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average14() + public void AverageAsync14() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average15() + public void AverageAsync15() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average16() + public void AverageAsync16() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average17() + public void AverageAsync17() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average18() + public void AverageAsync18() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average19() + public void AverageAsync19() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average20() + public void AverageAsync20() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Average(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average21() + public void AverageAsync21() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average22() + public void AverageAsync22() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average23() + public void AverageAsync23() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average24() + public void AverageAsync24() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average25() + public void AverageAsync25() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average26() + public void AverageAsync26() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average27() + public void AverageAsync27() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average28() + public void AverageAsync28() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average29() + public void AverageAsync29() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average30() + public void AverageAsync30() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average31() + public void AverageAsync31() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average32() + public void AverageAsync32() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average33() + public void AverageAsync33() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average34() + public void AverageAsync34() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average35() + public void AverageAsync35() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average36() + public void AverageAsync36() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average37() + public void AverageAsync37() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average38() + public void AverageAsync38() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average39() + public void AverageAsync39() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average40() + public void AverageAsync40() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average41() + public void AverageAsync41() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average42() + public void AverageAsync42() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average43() + public void AverageAsync43() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average44() + public void AverageAsync44() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average45() + public void AverageAsync45() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average46() + public void AverageAsync46() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average47() + public void AverageAsync47() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average48() + public void AverageAsync48() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average49() + public void AverageAsync49() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average50() + public void AverageAsync50() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average51() + public void AverageAsync51() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average52() + public void AverageAsync52() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average53() + public void AverageAsync53() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average54() + public void AverageAsync54() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average55() + public void AverageAsync55() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average56() + public void AverageAsync56() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average57() + public void AverageAsync57() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average58() + public void AverageAsync58() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average59() + public void AverageAsync59() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Average60() + public void AverageAsync60() { - AssertEx.Throws(() => AsyncQueryable.Average(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Average(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -848,98 +848,98 @@ public void Concat1() } [Fact] - public void Contains1() + public void ContainsAsync1() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Contains2() + public void ContainsAsync2() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Contains3() + public void ContainsAsync3() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); + var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Contains4() + public void ContainsAsync4() { - AssertEx.Throws(() => AsyncQueryable.Contains(default(IAsyncQueryable), 1, EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.Contains(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Count1() + public void CountAsync1() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Count2() + public void CountAsync2() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Count3() + public void CountAsync3() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Count4() + public void CountAsync4() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Count5() + public void CountAsync5() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Count6() + public void CountAsync6() { - AssertEx.Throws(() => AsyncQueryable.Count(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Count(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -985,38 +985,38 @@ public void Distinct2() } [Fact] - public void ElementAt1() + public void ElementAtAsync1() { - AssertEx.Throws(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ElementAt(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var res = AsyncQueryable.ElementAtAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ElementAt2() + public void ElementAtAsync2() { - AssertEx.Throws(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ElementAt(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + var res = AsyncQueryable.ElementAtAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ElementAtOrDefault1() + public void ElementAtOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ElementAtOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var res = AsyncQueryable.ElementAtOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ElementAtOrDefault2() + public void ElementAtOrDefaultAsync2() { - AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ElementAtOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); + var res = AsyncQueryable.ElementAtOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1044,118 +1044,118 @@ public void Except2() } [Fact] - public void First1() + public void FirstAsync1() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void First2() + public void FirstAsync2() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void First3() + public void FirstAsync3() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void First4() + public void FirstAsync4() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void First5() + public void FirstAsync5() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void First6() + public void FirstAsync6() { - AssertEx.Throws(() => AsyncQueryable.First(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.First(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstOrDefault1() + public void FirstOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstOrDefault2() + public void FirstOrDefaultAsync2() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstOrDefault3() + public void FirstOrDefaultAsync3() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstOrDefault4() + public void FirstOrDefaultAsync4() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstOrDefault5() + public void FirstOrDefaultAsync5() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstOrDefault6() + public void FirstOrDefaultAsync6() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1499,1452 +1499,1452 @@ public void Join4() } [Fact] - public void Last1() + public void LastAsync1() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Last2() + public void LastAsync2() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Last3() + public void LastAsync3() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Last4() + public void LastAsync4() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Last5() + public void LastAsync5() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Last6() + public void LastAsync6() { - AssertEx.Throws(() => AsyncQueryable.Last(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Last(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastOrDefault1() + public void LastOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastOrDefault2() + public void LastOrDefaultAsync2() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastOrDefault3() + public void LastOrDefaultAsync3() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastOrDefault4() + public void LastOrDefaultAsync4() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastOrDefault5() + public void LastOrDefaultAsync5() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastOrDefault6() + public void LastOrDefaultAsync6() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LongCount1() + public void LongCountAsync1() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LongCount2() + public void LongCountAsync2() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LongCount3() + public void LongCountAsync3() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LongCount4() + public void LongCountAsync4() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LongCount5() + public void LongCountAsync5() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LongCount6() + public void LongCountAsync6() { - AssertEx.Throws(() => AsyncQueryable.LongCount(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCount(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max1() + public void MaxAsync1() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max2() + public void MaxAsync2() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max3() + public void MaxAsync3() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max4() + public void MaxAsync4() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max5() + public void MaxAsync5() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max6() + public void MaxAsync6() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max7() + public void MaxAsync7() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max8() + public void MaxAsync8() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max9() + public void MaxAsync9() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max10() + public void MaxAsync10() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max11() + public void MaxAsync11() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max12() + public void MaxAsync12() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max13() + public void MaxAsync13() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max14() + public void MaxAsync14() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max15() + public void MaxAsync15() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max16() + public void MaxAsync16() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max17() + public void MaxAsync17() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max18() + public void MaxAsync18() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max19() + public void MaxAsync19() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max20() + public void MaxAsync20() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max21() + public void MaxAsync21() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max22() + public void MaxAsync22() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max23() + public void MaxAsync23() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max24() + public void MaxAsync24() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max25() + public void MaxAsync25() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max26() + public void MaxAsync26() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max27() + public void MaxAsync27() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max28() + public void MaxAsync28() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max29() + public void MaxAsync29() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max30() + public void MaxAsync30() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max31() + public void MaxAsync31() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max32() + public void MaxAsync32() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max33() + public void MaxAsync33() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max34() + public void MaxAsync34() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max35() + public void MaxAsync35() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max36() + public void MaxAsync36() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max37() + public void MaxAsync37() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max38() + public void MaxAsync38() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max39() + public void MaxAsync39() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max40() + public void MaxAsync40() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max41() + public void MaxAsync41() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max42() + public void MaxAsync42() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max43() + public void MaxAsync43() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max44() + public void MaxAsync44() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max45() + public void MaxAsync45() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max46() + public void MaxAsync46() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max47() + public void MaxAsync47() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max48() + public void MaxAsync48() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max49() + public void MaxAsync49() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max50() + public void MaxAsync50() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max51() + public void MaxAsync51() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max52() + public void MaxAsync52() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max53() + public void MaxAsync53() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max54() + public void MaxAsync54() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max55() + public void MaxAsync55() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max56() + public void MaxAsync56() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max57() + public void MaxAsync57() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max58() + public void MaxAsync58() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max59() + public void MaxAsync59() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max60() + public void MaxAsync60() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max61() + public void MaxAsync61() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max62() + public void MaxAsync62() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max63() + public void MaxAsync63() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max64() + public void MaxAsync64() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max65() + public void MaxAsync65() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Max66() + public void MaxAsync66() { - AssertEx.Throws(() => AsyncQueryable.Max(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Max(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min1() + public void MinAsync1() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min2() + public void MinAsync2() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min3() + public void MinAsync3() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min4() + public void MinAsync4() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min5() + public void MinAsync5() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min6() + public void MinAsync6() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min7() + public void MinAsync7() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min8() + public void MinAsync8() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min9() + public void MinAsync9() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min10() + public void MinAsync10() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min11() + public void MinAsync11() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min12() + public void MinAsync12() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min13() + public void MinAsync13() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min14() + public void MinAsync14() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min15() + public void MinAsync15() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min16() + public void MinAsync16() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min17() + public void MinAsync17() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min18() + public void MinAsync18() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min19() + public void MinAsync19() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min20() + public void MinAsync20() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min21() + public void MinAsync21() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min22() + public void MinAsync22() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min23() + public void MinAsync23() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min24() + public void MinAsync24() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min25() + public void MinAsync25() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min26() + public void MinAsync26() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min27() + public void MinAsync27() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min28() + public void MinAsync28() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min29() + public void MinAsync29() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min30() + public void MinAsync30() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min31() + public void MinAsync31() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min32() + public void MinAsync32() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min33() + public void MinAsync33() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min34() + public void MinAsync34() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min35() + public void MinAsync35() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min36() + public void MinAsync36() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min37() + public void MinAsync37() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min38() + public void MinAsync38() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min39() + public void MinAsync39() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min40() + public void MinAsync40() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min41() + public void MinAsync41() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min42() + public void MinAsync42() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min43() + public void MinAsync43() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min44() + public void MinAsync44() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min45() + public void MinAsync45() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min46() + public void MinAsync46() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min47() + public void MinAsync47() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min48() + public void MinAsync48() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min49() + public void MinAsync49() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min50() + public void MinAsync50() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min51() + public void MinAsync51() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min52() + public void MinAsync52() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min53() + public void MinAsync53() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min54() + public void MinAsync54() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min55() + public void MinAsync55() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min56() + public void MinAsync56() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min57() + public void MinAsync57() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min58() + public void MinAsync58() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min59() + public void MinAsync59() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min60() + public void MinAsync60() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min61() + public void MinAsync61() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min62() + public void MinAsync62() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min63() + public void MinAsync63() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min64() + public void MinAsync64() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min65() + public void MinAsync65() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Min66() + public void MinAsync66() { - AssertEx.Throws(() => AsyncQueryable.Min(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Min(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3191,160 +3191,160 @@ public void SelectMany8() } [Fact] - public void SequenceEqual1() + public void SequenceEqualAsync1() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SequenceEqual2() + public void SequenceEqualAsync2() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); + var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SequenceEqual3() + public void SequenceEqualAsync3() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SequenceEqual4() + public void SequenceEqualAsync4() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.SequenceEqual(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Single1() + public void SingleAsync1() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Single2() + public void SingleAsync2() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Single3() + public void SingleAsync3() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Single4() + public void SingleAsync4() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Single5() + public void SingleAsync5() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Single6() + public void SingleAsync6() { - AssertEx.Throws(() => AsyncQueryable.Single(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Single(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleOrDefault1() + public void SingleOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleOrDefault2() + public void SingleOrDefaultAsync2() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleOrDefault3() + public void SingleOrDefaultAsync3() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleOrDefault4() + public void SingleOrDefaultAsync4() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleOrDefault5() + public void SingleOrDefaultAsync5() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleOrDefault6() + public void SingleOrDefaultAsync6() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefault(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3413,582 +3413,582 @@ public void SkipWhile4() } [Fact] - public void Sum1() + public void SumAsync1() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum2() + public void SumAsync2() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum3() + public void SumAsync3() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum4() + public void SumAsync4() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum5() + public void SumAsync5() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum6() + public void SumAsync6() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum7() + public void SumAsync7() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum8() + public void SumAsync8() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum9() + public void SumAsync9() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum10() + public void SumAsync10() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum11() + public void SumAsync11() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum12() + public void SumAsync12() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum13() + public void SumAsync13() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum14() + public void SumAsync14() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum15() + public void SumAsync15() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum16() + public void SumAsync16() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum17() + public void SumAsync17() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum18() + public void SumAsync18() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum19() + public void SumAsync19() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum20() + public void SumAsync20() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum21() + public void SumAsync21() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum22() + public void SumAsync22() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum23() + public void SumAsync23() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum24() + public void SumAsync24() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum25() + public void SumAsync25() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum26() + public void SumAsync26() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum27() + public void SumAsync27() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum28() + public void SumAsync28() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum29() + public void SumAsync29() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum30() + public void SumAsync30() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum31() + public void SumAsync31() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum32() + public void SumAsync32() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum33() + public void SumAsync33() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum34() + public void SumAsync34() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum35() + public void SumAsync35() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum36() + public void SumAsync36() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum37() + public void SumAsync37() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum38() + public void SumAsync38() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum39() + public void SumAsync39() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum40() + public void SumAsync40() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum41() + public void SumAsync41() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum42() + public void SumAsync42() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum43() + public void SumAsync43() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum44() + public void SumAsync44() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum45() + public void SumAsync45() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum46() + public void SumAsync46() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum47() + public void SumAsync47() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum48() + public void SumAsync48() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum49() + public void SumAsync49() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum50() + public void SumAsync50() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum51() + public void SumAsync51() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum52() + public void SumAsync52() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum53() + public void SumAsync53() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum54() + public void SumAsync54() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum55() + public void SumAsync55() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum56() + public void SumAsync56() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum57() + public void SumAsync57() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum58() + public void SumAsync58() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum59() + public void SumAsync59() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Sum60() + public void SumAsync60() { - AssertEx.Throws(() => AsyncQueryable.Sum(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Sum(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4132,428 +4132,428 @@ public void ThenByDescending4() } [Fact] - public void ToArray1() + public void ToArrayAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToArray(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ToArray(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.ToArrayAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToArray2() + public void ToArrayAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToArray(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ToArray(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.ToArrayAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary1() + public void ToDictionaryAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary2() + public void ToDictionaryAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary3() + public void ToDictionaryAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary4() + public void ToDictionaryAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary5() + public void ToDictionaryAsync5() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary6() + public void ToDictionaryAsync6() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary7() + public void ToDictionaryAsync7() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary8() + public void ToDictionaryAsync8() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary9() + public void ToDictionaryAsync9() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary10() + public void ToDictionaryAsync10() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary11() + public void ToDictionaryAsync11() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary12() + public void ToDictionaryAsync12() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary13() + public void ToDictionaryAsync13() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary14() + public void ToDictionaryAsync14() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary15() + public void ToDictionaryAsync15() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionary16() + public void ToDictionaryAsync16() { - AssertEx.Throws(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionary(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToHashSet1() + public void ToHashSetAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToHashSet2() + public void ToHashSetAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToHashSet3() + public void ToHashSetAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); + var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToHashSet4() + public void ToHashSetAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToHashSet(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToList1() + public void ToListAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToList(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ToList(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.ToListAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToList2() + public void ToListAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToList(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.ToList(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.ToListAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup1() + public void ToLookupAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup2() + public void ToLookupAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup3() + public void ToLookupAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup4() + public void ToLookupAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup5() + public void ToLookupAsync5() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup6() + public void ToLookupAsync6() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup7() + public void ToLookupAsync7() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup8() + public void ToLookupAsync8() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup9() + public void ToLookupAsync9() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup10() + public void ToLookupAsync10() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup11() + public void ToLookupAsync11() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup12() + public void ToLookupAsync12() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup13() + public void ToLookupAsync13() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup14() + public void ToLookupAsync14() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup15() + public void ToLookupAsync15() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookup16() + public void ToLookupAsync16() { - AssertEx.Throws(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToLookup(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 760c38fa53..d6528a1639 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -12,7 +12,7 @@ namespace System.Linq { public static partial class AsyncQueryable { - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator) + public static Task AggregateAsync(this IAsyncQueryable source, Expression> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -20,13 +20,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator) + public static Task AggregateAsync(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -34,13 +34,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -48,13 +48,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Aggregate(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -62,13 +62,13 @@ public static Task Aggregate(this IAsyncQueryable sou throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -76,13 +76,13 @@ public static Task Aggregate(this IAsyncQuery throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -90,13 +90,13 @@ public static Task Aggregate(this IAsyncQuery throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -104,13 +104,13 @@ public static Task Aggregate(this IAsyncQuery throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -118,13 +118,13 @@ public static Task Aggregate(this IAsyncQuery throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -134,13 +134,13 @@ public static Task Aggregate(this IAsync throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -150,13 +150,13 @@ public static Task Aggregate(this IAsync throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -166,13 +166,13 @@ public static Task Aggregate(this IAsync throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Aggregate(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -182,13 +182,13 @@ public static Task Aggregate(this IAsync throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Aggregate(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task All(this IAsyncQueryable source, Expression> predicate) + public static Task AllAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -196,13 +196,13 @@ public static Task All(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task All(this IAsyncQueryable source, Expression>> predicate) + public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -210,13 +210,13 @@ public static Task All(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task All(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -224,13 +224,13 @@ public static Task All(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task All(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -238,37 +238,37 @@ public static Task All(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.All(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Any(this IAsyncQueryable source) + public static Task AnyAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task Any(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Any(this IAsyncQueryable source, Expression> predicate) + public static Task AnyAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -276,13 +276,13 @@ public static Task Any(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Any(this IAsyncQueryable source, Expression>> predicate) + public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -290,13 +290,13 @@ public static Task Any(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Any(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -304,13 +304,13 @@ public static Task Any(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Any(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -318,7 +318,7 @@ public static Task Any(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Any(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -336,247 +336,247 @@ public static IAsyncQueryable Append(this IAsyncQueryable Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -584,13 +584,13 @@ public static Task Average(this IAsyncQueryable source, Cancellati throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -598,13 +598,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -612,13 +612,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -626,13 +626,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -640,13 +640,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -654,13 +654,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -668,13 +668,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -682,13 +682,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -696,13 +696,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -710,13 +710,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -724,13 +724,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -738,13 +738,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -752,13 +752,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -766,13 +766,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -780,13 +780,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -794,13 +794,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -808,13 +808,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -822,13 +822,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -836,13 +836,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -850,13 +850,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -864,13 +864,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -878,13 +878,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -892,13 +892,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -906,13 +906,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -920,13 +920,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -934,13 +934,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -948,13 +948,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -962,13 +962,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -976,13 +976,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -990,13 +990,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1004,13 +1004,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1018,13 +1018,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1032,13 +1032,13 @@ public static Task Average(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1046,13 +1046,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1060,13 +1060,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1074,13 +1074,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1088,13 +1088,13 @@ public static Task Average(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1102,13 +1102,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1116,13 +1116,13 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Average(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1130,7 +1130,7 @@ public static Task Average(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Average(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1162,31 +1162,31 @@ public static IAsyncQueryable Concat(this IAsyncQueryable Contains(this IAsyncQueryable source, TSource value) + public static Task ContainsAsync(this IAsyncQueryable source, TSource value) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) + public static Task ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1194,13 +1194,13 @@ public static Task Contains(this IAsyncQueryable source, throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task Contains(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1208,37 +1208,37 @@ public static Task Contains(this IAsyncQueryable source, throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Contains(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Count(this IAsyncQueryable source) + public static Task CountAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task Count(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Count(this IAsyncQueryable source, Expression> predicate) + public static Task CountAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1246,13 +1246,13 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Count(this IAsyncQueryable source, Expression>> predicate) + public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1260,13 +1260,13 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Count(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1274,13 +1274,13 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Count(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1288,7 +1288,7 @@ public static Task Count(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Count(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1344,49 +1344,49 @@ public static IAsyncQueryable Distinct(this IAsyncQueryable ElementAt(this IAsyncQueryable source, int index) + public static Task ElementAtAsync(this IAsyncQueryable source, int index) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #endif } - public static Task ElementAt(this IAsyncQueryable source, int index, CancellationToken cancellationToken) + public static Task ElementAtAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAt(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task ElementAtOrDefault(this IAsyncQueryable source, int index) + public static Task ElementAtOrDefaultAsync(this IAsyncQueryable source, int index) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); #endif } - public static Task ElementAtOrDefault(this IAsyncQueryable source, int index, CancellationToken cancellationToken) + public static Task ElementAtOrDefaultAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefault(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1422,31 +1422,31 @@ public static IAsyncQueryable Except(this IAsyncQueryable First(this IAsyncQueryable source) + public static Task FirstAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task First(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task First(this IAsyncQueryable source, Expression> predicate) + public static Task FirstAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1454,13 +1454,13 @@ public static Task First(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task First(this IAsyncQueryable source, Expression>> predicate) + public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1468,13 +1468,13 @@ public static Task First(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task First(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1482,13 +1482,13 @@ public static Task First(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task First(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1496,37 +1496,37 @@ public static Task First(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.First(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task FirstOrDefault(this IAsyncQueryable source) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task FirstOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1534,13 +1534,13 @@ public static Task FirstOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1548,13 +1548,13 @@ public static Task FirstOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task FirstOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1562,13 +1562,13 @@ public static Task FirstOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task FirstOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1576,7 +1576,7 @@ public static Task FirstOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -2052,31 +2052,31 @@ public static IAsyncQueryable Join(this #endif } - public static Task Last(this IAsyncQueryable source) + public static Task LastAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task Last(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Last(this IAsyncQueryable source, Expression> predicate) + public static Task LastAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2084,13 +2084,13 @@ public static Task Last(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Last(this IAsyncQueryable source, Expression>> predicate) + public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2098,13 +2098,13 @@ public static Task Last(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Last(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2112,13 +2112,13 @@ public static Task Last(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Last(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2126,37 +2126,37 @@ public static Task Last(this IAsyncQueryable source, throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Last(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LastOrDefault(this IAsyncQueryable source) + public static Task LastOrDefaultAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task LastOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2164,13 +2164,13 @@ public static Task LastOrDefault(this IAsyncQueryable throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2178,13 +2178,13 @@ public static Task LastOrDefault(this IAsyncQueryable throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task LastOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2192,13 +2192,13 @@ public static Task LastOrDefault(this IAsyncQueryable throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LastOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2206,37 +2206,37 @@ public static Task LastOrDefault(this IAsyncQueryable throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LongCount(this IAsyncQueryable source) + public static Task LongCountAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task LongCount(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LongCount(this IAsyncQueryable source, Expression> predicate) + public static Task LongCountAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2244,13 +2244,13 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task LongCount(this IAsyncQueryable source, Expression>> predicate) + public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2258,13 +2258,13 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task LongCount(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2272,13 +2272,13 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task LongCount(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2286,277 +2286,277 @@ public static Task LongCount(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCount(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source) + public static Task MaxAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2564,13 +2564,13 @@ public static Task Max(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2578,13 +2578,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2592,13 +2592,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2606,13 +2606,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2620,13 +2620,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2634,13 +2634,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2648,13 +2648,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2662,13 +2662,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2676,13 +2676,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2690,13 +2690,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2704,13 +2704,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2718,13 +2718,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2732,13 +2732,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2746,13 +2746,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2760,13 +2760,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2774,13 +2774,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2788,13 +2788,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2802,13 +2802,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2816,13 +2816,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2830,13 +2830,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2844,13 +2844,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2858,13 +2858,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2872,13 +2872,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2886,13 +2886,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2900,13 +2900,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2914,13 +2914,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2928,13 +2928,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2942,13 +2942,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2956,13 +2956,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2970,13 +2970,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2984,13 +2984,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2998,13 +2998,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3012,13 +3012,13 @@ public static Task Max(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3026,13 +3026,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3040,13 +3040,13 @@ public static Task Max(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3054,13 +3054,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3068,13 +3068,13 @@ public static Task Max(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3082,13 +3082,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3096,13 +3096,13 @@ public static Task Max(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3110,13 +3110,13 @@ public static Task Max(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3124,13 +3124,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3138,13 +3138,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Max(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3152,13 +3152,13 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Max(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3166,277 +3166,277 @@ public static Task Max(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Max(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3444,13 +3444,13 @@ public static Task Min(this IAsyncQueryable source, C throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3458,13 +3458,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3472,13 +3472,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3486,13 +3486,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3500,13 +3500,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3514,13 +3514,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3528,13 +3528,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3542,13 +3542,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3556,13 +3556,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3570,13 +3570,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3584,13 +3584,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3598,13 +3598,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3612,13 +3612,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3626,13 +3626,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3640,13 +3640,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3654,13 +3654,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3668,13 +3668,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3682,13 +3682,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3696,13 +3696,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3710,13 +3710,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3724,13 +3724,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3738,13 +3738,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3752,13 +3752,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3766,13 +3766,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3780,13 +3780,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3794,13 +3794,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3808,13 +3808,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3822,13 +3822,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3836,13 +3836,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3850,13 +3850,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3864,13 +3864,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3878,13 +3878,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3892,13 +3892,13 @@ public static Task Min(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3906,13 +3906,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3920,13 +3920,13 @@ public static Task Min(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3934,13 +3934,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3948,13 +3948,13 @@ public static Task Min(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3962,13 +3962,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3976,13 +3976,13 @@ public static Task Min(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3990,13 +3990,13 @@ public static Task Min(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4004,13 +4004,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4018,13 +4018,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Min(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4032,13 +4032,13 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Min(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4046,7 +4046,7 @@ public static Task Min(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Min(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4384,7 +4384,7 @@ public static IAsyncQueryable SelectMany #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second) + public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -4392,13 +4392,13 @@ public static Task SequenceEqual(this IAsyncQueryable fi throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second)), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second)), CancellationToken.None); #else return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)), CancellationToken.None); #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -4406,13 +4406,13 @@ public static Task SequenceEqual(this IAsyncQueryable fi throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -4422,13 +4422,13 @@ public static Task SequenceEqual(this IAsyncQueryable fi throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task SequenceEqual(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -4438,37 +4438,37 @@ public static Task SequenceEqual(this IAsyncQueryable fi throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqual(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Single(this IAsyncQueryable source) + public static Task SingleAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task Single(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Single(this IAsyncQueryable source, Expression> predicate) + public static Task SingleAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4476,13 +4476,13 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Single(this IAsyncQueryable source, Expression>> predicate) + public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4490,13 +4490,13 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task Single(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4504,13 +4504,13 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Single(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4518,37 +4518,37 @@ public static Task Single(this IAsyncQueryable source throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Single(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SingleOrDefault(this IAsyncQueryable source) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task SingleOrDefault(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SingleOrDefault(this IAsyncQueryable source, Expression> predicate) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4556,13 +4556,13 @@ public static Task SingleOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task SingleOrDefault(this IAsyncQueryable source, Expression>> predicate) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4570,13 +4570,13 @@ public static Task SingleOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); #endif } - public static Task SingleOrDefault(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4584,13 +4584,13 @@ public static Task SingleOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SingleOrDefault(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4598,7 +4598,7 @@ public static Task SingleOrDefault(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefault(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4684,247 +4684,247 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source) + public static Task SumAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4932,13 +4932,13 @@ public static Task Sum(this IAsyncQueryable source, CancellationToke throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4946,13 +4946,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4960,13 +4960,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4974,13 +4974,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4988,13 +4988,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5002,13 +5002,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5016,13 +5016,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5030,13 +5030,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5044,13 +5044,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5058,13 +5058,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5072,13 +5072,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5086,13 +5086,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5100,13 +5100,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5114,13 +5114,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5128,13 +5128,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5142,13 +5142,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5156,13 +5156,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5170,13 +5170,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5184,13 +5184,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5198,13 +5198,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5212,13 +5212,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5226,13 +5226,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5240,13 +5240,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5254,13 +5254,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5268,13 +5268,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5282,13 +5282,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5296,13 +5296,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5310,13 +5310,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5324,13 +5324,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5338,13 +5338,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5352,13 +5352,13 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5366,13 +5366,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5380,13 +5380,13 @@ public static Task Sum(this IAsyncQueryable source, E throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5394,13 +5394,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5408,13 +5408,13 @@ public static Task Sum(this IAsyncQueryable source, Ex throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5422,13 +5422,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5436,13 +5436,13 @@ public static Task Sum(this IAsyncQueryable source, Exp throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5450,13 +5450,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5464,13 +5464,13 @@ public static Task Sum(this IAsyncQueryable source, Expre throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task Sum(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5478,7 +5478,7 @@ public static Task Sum(this IAsyncQueryable source, Expr throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.Sum(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -5684,31 +5684,31 @@ public static IOrderedAsyncQueryable ThenByDescending(th #endif } - public static Task ToArray(this IAsyncQueryable source) + public static Task ToArrayAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task ToArray(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task ToArrayAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArray(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5716,13 +5716,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5730,13 +5730,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5744,13 +5744,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5760,13 +5760,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5774,13 +5774,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5790,13 +5790,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5806,13 +5806,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5822,13 +5822,13 @@ public static Task> ToDictionary(this I throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5838,13 +5838,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5854,13 +5854,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5870,13 +5870,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5888,13 +5888,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5904,13 +5904,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5922,13 +5922,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5940,13 +5940,13 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToDictionary(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5958,37 +5958,37 @@ public static Task> ToDictionary>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionary(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToHashSet(this IAsyncQueryable source) + public static Task> ToHashSetAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task> ToHashSet(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToHashSet(this IAsyncQueryable source, IEqualityComparer comparer) + public static Task> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5996,13 +5996,13 @@ public static Task> ToHashSet(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToHashSet(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6010,37 +6010,37 @@ public static Task> ToHashSet(this IAsyncQueryable>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSet(default(IAsyncQueryable), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToList(this IAsyncQueryable source) + public static Task> ToListAsync(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); #endif } - public static Task> ToList(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task> ToListAsync(this IAsyncQueryable source, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToList(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6048,13 +6048,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6062,13 +6062,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6076,13 +6076,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6092,13 +6092,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6106,13 +6106,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6122,13 +6122,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6138,13 +6138,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6154,13 +6154,13 @@ public static Task> ToLookup(this IAsyncQu throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6170,13 +6170,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6186,13 +6186,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6202,13 +6202,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6220,13 +6220,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6236,13 +6236,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6254,13 +6254,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6272,13 +6272,13 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task> ToLookup(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6290,7 +6290,7 @@ public static Task> ToLookup(th throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookup(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index db7c015ee6..0aa0ab000a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -59,8 +59,8 @@ protected async Task SequenceIdentity(IAsyncEnumerable enumerable) await en1.DisposeAsync(); await en2.DisposeAsync(); - var res1 = await enumerable.ToList(); - var res2 = await enumerable.ToList(); + var res1 = await enumerable.ToListAsync(); + var res2 = await enumerable.ToListAsync(); res1.ShouldAllBeEquivalentTo(res2); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index ce7d4a9967..c6b7504f82 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -15,32 +15,32 @@ public class Aggregate : AsyncEnumerableTests [Fact] public async Task Aggregate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(default, 0, (x, y) => x + y, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, default, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Aggregate(Return42, 0, (x, y) => x + y, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default, CancellationToken.None)); } [Fact] public async Task Aggregate1Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate((x, y) => x * y); + var ys = xs.AggregateAsync((x, y) => x * y); Assert.Equal(24, await ys); } @@ -48,7 +48,7 @@ public async Task Aggregate1Async() public async Task Aggregate2Async() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.Aggregate((x, y) => x * y); + var ys = xs.AggregateAsync((x, y) => x * y); await AssertThrowsAsync(ys); } @@ -57,7 +57,7 @@ public async Task Aggregate3Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.Aggregate((x, y) => x * y); + var ys = xs.AggregateAsync((x, y) => x * y); await AssertThrowsAsync(ys, ex); } @@ -66,7 +66,7 @@ public async Task Aggregate4Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(new Func((x, y) => { throw ex; })); + var ys = xs.AggregateAsync(new Func((x, y) => { throw ex; })); await AssertThrowsAsync(ys, ex); } @@ -74,7 +74,7 @@ public async Task Aggregate4Async() public async Task Aggregate5Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y); + var ys = xs.AggregateAsync(1, (x, y) => x * y); Assert.Equal(24, await ys); } @@ -82,7 +82,7 @@ public async Task Aggregate5Async() public async Task Aggregate6Async() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y); + var ys = xs.AggregateAsync(1, (x, y) => x * y); Assert.Equal(1, await ys); } @@ -91,7 +91,7 @@ public async Task Aggregate7Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.Aggregate(1, (x, y) => x * y); + var ys = xs.AggregateAsync(1, (x, y) => x * y); await AssertThrowsAsync(ys, ex); } @@ -100,7 +100,7 @@ public async Task Aggregate8Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, new Func((x, y) => { throw ex; })); + var ys = xs.AggregateAsync(1, new Func((x, y) => { throw ex; })); await AssertThrowsAsync(ys, ex); } @@ -108,7 +108,7 @@ public async Task Aggregate8Async() public async Task Aggregate9Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); + var ys = xs.AggregateAsync(1, (x, y) => x * y, x => x + 1); Assert.Equal(25, await ys); } @@ -116,7 +116,7 @@ public async Task Aggregate9Async() public async Task Aggregate10Async() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); + var ys = xs.AggregateAsync(1, (x, y) => x * y, x => x + 1); Assert.Equal(2, await ys); } @@ -125,7 +125,7 @@ public async Task Aggregate11Async() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.Aggregate(1, (x, y) => x * y, x => x + 1); + var ys = xs.AggregateAsync(1, (x, y) => x * y, x => x + 1); await AssertThrowsAsync(ys, ex); } @@ -134,7 +134,7 @@ public async Task Aggregate12Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => { throw ex; }, x => x + 1); + var ys = xs.AggregateAsync(1, (x, y) => { throw ex; }, x => x + 1); await AssertThrowsAsync(ys, ex); } @@ -143,7 +143,7 @@ public async Task Aggregate13Async() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.Aggregate(1, (x, y) => x * y, x => { throw ex; }); + var ys = xs.AggregateAsync(1, (x, y) => x * y, x => { throw ex; }); await AssertThrowsAsync(ys, ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 02cee9be08..ea74474bd3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -15,24 +15,24 @@ public class All : AsyncEnumerableTests [Fact] public async Task All_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.All(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.All(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task All1Async() { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync(x => x % 2 == 0); Assert.False(await res); } [Fact] public async Task All2Async() { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(x => x % 2 == 0); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(x => x % 2 == 0); Assert.True(await res); } @@ -40,7 +40,7 @@ public async Task All2Async() public async Task All3Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).All(x => x % 2 == 0); + var res = Throw(ex).AllAsync(x => x % 2 == 0); await AssertThrowsAsync(res, ex); } @@ -48,7 +48,7 @@ public async Task All3Async() public async Task All4Async() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().All(new Func(x => { throw ex; })); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func(x => { throw ex; })); await AssertThrowsAsync(res, ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index ec33b34f3a..5f68643a36 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -15,26 +15,26 @@ public class Any : AsyncEnumerableTests [Fact] public async Task Any_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Any(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task Any1Async() { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(x => x % 2 == 0); + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync(x => x % 2 == 0); Assert.True(await res); } [Fact] public async Task Any2Async() { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(x => x % 2 != 0); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(x => x % 2 != 0); Assert.False(await res); } @@ -42,7 +42,7 @@ public async Task Any2Async() public async Task Any3Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).Any(x => x % 2 == 0); + var res = Throw(ex).AnyAsync(x => x % 2 == 0); await AssertThrowsAsync(res, ex); } @@ -50,21 +50,21 @@ public async Task Any3Async() public async Task Any4Async() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().Any(new Func(x => { throw ex; })); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(new Func(x => { throw ex; })); await AssertThrowsAsync(res, ex); } [Fact] public async Task Any5Async() { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().Any(); + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync(); Assert.True(await res); } [Fact] public async Task Any6Async() { - var res = new int[0].ToAsyncEnumerable().Any(); + var res = new int[0].ToAsyncEnumerable().AnyAsync(); Assert.False(await res); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs index 633f671ef7..72dac446f6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs @@ -43,7 +43,7 @@ public async Task Append2() var a = new[] { 1, 2, 3, 4 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -56,7 +56,7 @@ public async Task Append3() var a = new List { 1, 2, 3, 4 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -67,7 +67,7 @@ public async Task Append4() var res = xs.Append(4); - Assert.Equal(4, await res.Count()); + Assert.Equal(4, await res.CountAsync()); } [Fact] @@ -79,7 +79,7 @@ public async Task Append5() var a = new[] { 1, 2, 3, 4 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -90,7 +90,7 @@ public async Task Append6() var res = xs.Append(4); - Assert.Equal(4, await res.Count()); + Assert.Equal(4, await res.CountAsync()); } [Fact] @@ -102,7 +102,7 @@ public async Task Append7() var a = new List { 1, 2, 3, 4 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -138,7 +138,7 @@ public async Task AppendN2() var a = new[] { 1, 2, 3, 4, 5, 6 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -153,7 +153,7 @@ public async Task AppendN3() var a = new List { 1, 2, 3, 4, 5, 6 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -166,7 +166,7 @@ public async Task AppendN4() .Append(5) .Append(6); - Assert.Equal(6, await res.Count()); + Assert.Equal(6, await res.CountAsync()); } [Fact] @@ -180,7 +180,7 @@ public async Task AppendN5() var a = new[] { 1, 2, 3, 4, 5, 6 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -195,7 +195,7 @@ public async Task AppendN6() var a = new List { 1, 2, 3, 4, 5, 6 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -208,7 +208,7 @@ public async Task AppendN7() .Append(5) .Append(6); - Assert.Equal(6, await res.Count()); + Assert.Equal(6, await res.CountAsync()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs index e6b29e8c69..d2de51168b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs @@ -16,71 +16,71 @@ public class Average : AsyncEnumerableTests [Fact] public async Task Average_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Average(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); } [Fact] @@ -88,8 +88,8 @@ public async Task Average1() { var xs = new[] { 1, 2, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -97,8 +97,8 @@ public async Task Average2() { var xs = new[] { 1, default(int?), 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -106,8 +106,8 @@ public async Task Average3() { var xs = new[] { 1L, 2L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -115,8 +115,8 @@ public async Task Average4() { var xs = new[] { 1L, default(long?), 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -124,8 +124,8 @@ public async Task Average5() { var xs = new[] { 1.0, 2.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -133,8 +133,8 @@ public async Task Average6() { var xs = new[] { 1.0, default(double?), 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -142,8 +142,8 @@ public async Task Average7() { var xs = new[] { 1.0f, 2.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -151,8 +151,8 @@ public async Task Average8() { var xs = new[] { 1.0f, default(float?), 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -160,8 +160,8 @@ public async Task Average9() { var xs = new[] { 1.0m, 2.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -169,8 +169,8 @@ public async Task Average10() { var xs = new[] { 1.0m, default(decimal?), 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.Average()); - Assert.Equal(xs.Average(), await ys.Average(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } [Fact] @@ -178,7 +178,7 @@ public async Task Average11() { var xs = new int[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.Average()); + await Assert.ThrowsAsync(() => ys.AverageAsync()); } [Fact] @@ -186,7 +186,7 @@ public async Task Average12() { var xs = new int?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.Average()); + Assert.Null(await ys.AverageAsync()); } [Fact] @@ -194,7 +194,7 @@ public async Task Average13() { var xs = new long[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.Average()); + await Assert.ThrowsAsync(() => ys.AverageAsync()); } [Fact] @@ -202,7 +202,7 @@ public async Task Average14() { var xs = new long?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.Average()); + Assert.Null(await ys.AverageAsync()); } [Fact] @@ -210,7 +210,7 @@ public async Task Average15() { var xs = new double[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.Average()); + await Assert.ThrowsAsync(() => ys.AverageAsync()); } [Fact] @@ -218,7 +218,7 @@ public async Task Average16() { var xs = new double?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.Average()); + Assert.Null(await ys.AverageAsync()); } [Fact] @@ -226,7 +226,7 @@ public async Task Average17() { var xs = new float[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.Average()); + await Assert.ThrowsAsync(() => ys.AverageAsync()); } [Fact] @@ -234,7 +234,7 @@ public async Task Average18() { var xs = new float?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.Average()); + Assert.Null(await ys.AverageAsync()); } [Fact] @@ -242,7 +242,7 @@ public async Task Average19() { var xs = new decimal[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.Average()); + await Assert.ThrowsAsync(() => ys.AverageAsync()); } [Fact] @@ -250,7 +250,7 @@ public async Task Average20() { var xs = new decimal?[0]; var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.Average()); + Assert.Null(await ys.AverageAsync()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index 7c08a2a5e7..a15459b070 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -105,7 +105,7 @@ public async Task Concat10() var c = xs.Concat(ys).Concat(zs); var res = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; - Assert.True(res.SequenceEqual(await c.ToArray())); + Assert.True(res.SequenceEqual(await c.ToArrayAsync())); } [Fact] @@ -118,7 +118,7 @@ public async Task Concat11() var c = xs.Concat(ys).Concat(zs); var res = new List { 1, 2, 3, 4, 5, 6, 7, 8 }; - Assert.True(res.SequenceEqual(await c.ToList())); + Assert.True(res.SequenceEqual(await c.ToListAsync())); } [Fact] @@ -130,7 +130,7 @@ public async Task Concat12() var c = xs.Concat(ys).Concat(zs); - Assert.Equal(8, await c.Count()); + Assert.Equal(8, await c.CountAsync()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index ded6f8856f..a98c1b9d38 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -16,18 +16,18 @@ public class Contains : AsyncEnumerableTests [Fact] public async Task Contains_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Contains(default, 42, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, EqualityComparer.Default, CancellationToken.None)); } [Fact] public async Task Contains1Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(3); + var ys = xs.ContainsAsync(3); Assert.True(await ys); } @@ -35,7 +35,7 @@ public async Task Contains1Async() public async Task Contains2Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(6); + var ys = xs.ContainsAsync(6); Assert.False(await ys); } @@ -43,7 +43,7 @@ public async Task Contains2Async() public async Task Contains3Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(-3, new Eq()); + var ys = xs.ContainsAsync(-3, new Eq()); Assert.True(await ys); } @@ -51,7 +51,7 @@ public async Task Contains3Async() public async Task Contains4Async() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); - var ys = xs.Contains(-6, new Eq()); + var ys = xs.ContainsAsync(-6, new Eq()); Assert.False(await ys); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 303013f920..fd0a9b11e4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -15,34 +15,34 @@ public class Count : AsyncEnumerableTests [Fact] public async Task Count_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Count(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task Count1() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().Count()); - Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().Count()); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync()); + Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync()); } [Fact] public async Task Count2() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().Count(x => x < 3)); - Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3)); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync(x => x < 3)); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(x => x < 3)); } [Fact] public async Task Count3Async() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func(x => { throw ex; })); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(new Func(x => { throw ex; })); await AssertThrowsAsync(ys, ex); } @@ -50,14 +50,14 @@ public async Task Count3Async() public async Task Count4Async() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).Count(), ex); + await AssertThrowsAsync(Throw(ex).CountAsync(), ex); } [Fact] public async Task Count5Async() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).Count(x => x < 3), ex); + await AssertThrowsAsync(Throw(ex).CountAsync(x => x < 3), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs index 9c1264d282..7175bf1394 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/DefaultIfEmpty.cs @@ -112,7 +112,7 @@ public async Task DefaultIfEmpty9() var res = new[] { 42 }; - Assert.True(res.SequenceEqual(await xs.ToArray())); + Assert.True(res.SequenceEqual(await xs.ToArrayAsync())); } [Fact] @@ -122,7 +122,7 @@ public async Task DefaultIfEmpty10() var res = new List { 42 }; - Assert.True(res.SequenceEqual(await xs.ToList())); + Assert.True(res.SequenceEqual(await xs.ToListAsync())); } [Fact] @@ -130,7 +130,7 @@ public async Task DefaultIfEmpty11() { var xs = AsyncEnumerable.Empty().DefaultIfEmpty(42); - Assert.Equal(1, await xs.Count()); + Assert.Equal(1, await xs.CountAsync()); } @@ -141,7 +141,7 @@ public async Task DefaultIfEmpty12() var res = new[] { 1, 2, 3, 4 }; - Assert.True(res.SequenceEqual(await xs.ToArray())); + Assert.True(res.SequenceEqual(await xs.ToArrayAsync())); } [Fact] @@ -151,7 +151,7 @@ public async Task DefaultIfEmpty13() var res = new List { 1, 2, 3, 4 }; - Assert.True(res.SequenceEqual(await xs.ToList())); + Assert.True(res.SequenceEqual(await xs.ToListAsync())); } [Fact] @@ -159,7 +159,7 @@ public async Task DefaultIfEmpty14() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().DefaultIfEmpty(24); - Assert.Equal(4, await xs.Count()); + Assert.Equal(4, await xs.CountAsync()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index 481b667294..3917d28925 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -53,7 +53,7 @@ public async Task Distinct3() var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); var res = new[] { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToArray())); + Assert.True(res.SequenceEqual(await xs.ToArrayAsync())); } [Fact] @@ -62,7 +62,7 @@ public async Task Distinct4() var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); var res = new List { 1, 2, 3, 5, 4 }; - Assert.True(res.SequenceEqual(await xs.ToList())); + Assert.True(res.SequenceEqual(await xs.ToListAsync())); } [Fact] @@ -70,7 +70,7 @@ public async Task Distinct5() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); - Assert.Equal(5, await xs.Count()); + Assert.Equal(5, await xs.CountAsync()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index 96d2d93eef..e23b7f8047 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -15,45 +15,45 @@ public class ElementAt : AsyncEnumerableTests [Fact] public async Task ElementAt_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(default, 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(Return42, -1)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(default, 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAt(Return42, -1, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(default, 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(Return42, -1, CancellationToken.None)); } [Fact] public async Task ElementAt1Async() { - var res = AsyncEnumerable.Empty().ElementAt(0); + var res = AsyncEnumerable.Empty().ElementAtAsync(0); await AssertThrowsAsync(res); } [Fact] public async Task ElementAt2Async() { - var res = Return42.ElementAt(0); + var res = Return42.ElementAtAsync(0); Assert.Equal(42, await res); } [Fact] public async Task ElementAt3Async() { - var res = Return42.ElementAt(1); + var res = Return42.ElementAtAsync(1); await AssertThrowsAsync(res); } [Fact] public async Task ElementAt4Async() { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(1); + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtAsync(1); Assert.Equal(42, await res); } [Fact] public async Task ElementAt5Async() { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(7); + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtAsync(7); await AssertThrowsAsync(res); } @@ -61,7 +61,7 @@ public async Task ElementAt5Async() public async Task ElementAt6Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).ElementAt(15); + var res = Throw(ex).ElementAtAsync(15); await AssertThrowsAsync(res, ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index 089181c056..8c9add492c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -15,49 +15,49 @@ public class ElementAtOrDefault : AsyncEnumerableTests [Fact] public async Task ElementAtOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefault(default, 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefaultAsync(default, 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefaultAsync(default, 0, CancellationToken.None)); } [Fact] public async Task ElementAtOrDefault1Async() { - var res = AsyncEnumerable.Empty().ElementAtOrDefault(0); + var res = AsyncEnumerable.Empty().ElementAtOrDefaultAsync(0); Assert.Equal(0, await res); } [Fact] public async Task ElementAtOrDefault2Async() { - var res = Return42.ElementAtOrDefault(0); + var res = Return42.ElementAtOrDefaultAsync(0); Assert.Equal(42, await res); } [Fact] public async Task ElementAtOrDefault3Async() { - var res = Return42.ElementAtOrDefault(1); + var res = Return42.ElementAtOrDefaultAsync(1); Assert.Equal(0, await res); } [Fact] public async Task ElementAtOrDefault4Async() { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(1); + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefaultAsync(1); Assert.Equal(42, await res); } [Fact] public async Task ElementAtOrDefault5Async() { - var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(7); + var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefaultAsync(7); Assert.Equal(0, await res); } [Fact] public async Task ElementAtOrDefault6Async() { - var res = Return42.ElementAtOrDefault(-1); + var res = Return42.ElementAtOrDefaultAsync(-1); Assert.Equal(0, await res); } @@ -65,7 +65,7 @@ public async Task ElementAtOrDefault6Async() public async Task ElementAtOrDefault7Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).ElementAtOrDefault(15); + var res = Throw(ex).ElementAtOrDefaultAsync(15); await AssertThrowsAsync(res, ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 66f74bf19d..fb74226ea1 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -15,47 +15,47 @@ public class First : AsyncEnumerableTests [Fact] public async Task First_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.First(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task First1Async() { - var res = AsyncEnumerable.Empty().First(); + var res = AsyncEnumerable.Empty().FirstAsync(); await AssertThrowsAsync(res); } [Fact] public async Task First2Async() { - var res = AsyncEnumerable.Empty().First(x => true); + var res = AsyncEnumerable.Empty().FirstAsync(x => true); await AssertThrowsAsync(res); } [Fact] public async Task First3Async() { - var res = Return42.First(x => x % 2 != 0); + var res = Return42.FirstAsync(x => x % 2 != 0); await AssertThrowsAsync(res); } [Fact] public async Task First4Async() { - var res = Return42.First(); + var res = Return42.FirstAsync(); Assert.Equal(42, await res); } [Fact] public async Task First5Async() { - var res = Return42.First(x => x % 2 == 0); + var res = Return42.FirstAsync(x => x % 2 == 0); Assert.Equal(42, await res); } @@ -63,7 +63,7 @@ public async Task First5Async() public async Task First6Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).First(); + var res = Throw(ex).FirstAsync(); await AssertThrowsAsync(res, ex); } @@ -71,21 +71,21 @@ public async Task First6Async() public async Task First7Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).First(x => true); + var res = Throw(ex).FirstAsync(x => true); await AssertThrowsAsync(res, ex); } [Fact] public async Task First8Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync(); Assert.Equal(42, await res); } [Fact] public async Task First9Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().First(x => x % 2 != 0); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); Assert.Equal(45, await res); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 666cbc9842..d7e755d1be 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -15,47 +15,47 @@ public class FirstOrDefault : AsyncEnumerableTests [Fact] public async Task FirstOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefault(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task FirstOrDefault1Async() { - var res = AsyncEnumerable.Empty().FirstOrDefault(); + var res = AsyncEnumerable.Empty().FirstOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] public async Task FirstOrDefault2Async() { - var res = AsyncEnumerable.Empty().FirstOrDefault(x => true); + var res = AsyncEnumerable.Empty().FirstOrDefaultAsync(x => true); Assert.Equal(0, await res); } [Fact] public async Task FirstOrDefault3Async() { - var res = Return42.FirstOrDefault(x => x % 2 != 0); + var res = Return42.FirstOrDefaultAsync(x => x % 2 != 0); Assert.Equal(0, await res); } [Fact] public async Task FirstOrDefault4Async() { - var res = Return42.FirstOrDefault(); + var res = Return42.FirstOrDefaultAsync(); Assert.Equal(42, await res); } [Fact] public async Task FirstOrDefault5Async() { - var res = Return42.FirstOrDefault(x => x % 2 == 0); + var res = Return42.FirstOrDefaultAsync(x => x % 2 == 0); Assert.Equal(42, await res); } @@ -63,7 +63,7 @@ public async Task FirstOrDefault5Async() public async Task FirstOrDefault6Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstOrDefault(); + var res = Throw(ex).FirstOrDefaultAsync(); await AssertThrowsAsync(res, ex); } @@ -71,28 +71,28 @@ public async Task FirstOrDefault6Async() public async Task FirstOrDefault7Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstOrDefault(x => true); + var res = Throw(ex).FirstOrDefaultAsync(x => true); await AssertThrowsAsync(res, ex); } [Fact] public async Task FirstOrDefault8Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(); Assert.Equal(42, await res); } [Fact] public async Task FirstOrDefault9Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x % 2 != 0); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => x % 2 != 0); Assert.Equal(45, await res); } [Fact] public async Task FirstOrDefault10Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefault(x => x < 10); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => x < 10); Assert.Equal(0, await res); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 4246ee0a4e..46aff9fed2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -272,7 +272,7 @@ public async Task GroupBy9() public async Task GroupBy10() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, "0 - adgj"); @@ -285,7 +285,7 @@ public async Task GroupBy10() public async Task GroupBy11() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + var ys = xs.GroupBy(x => x % 3, (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, "0 - 0369"); @@ -376,7 +376,7 @@ public async Task GroupBy13() public async Task GroupBy14() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + var ys = xs.GroupBy(x => x, x => (char)('a' + x), (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result, new EqMod(3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, "0 - adgj"); @@ -389,7 +389,7 @@ public async Task GroupBy14() public async Task GroupBy15() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result, new EqMod(3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, "0 - 0369"); @@ -506,38 +506,38 @@ public async Task GroupBy19() public async Task GroupBy20() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result); var arr = new[] { "0 - adgj", "1 - beh", "2 - cfi" }; - Assert.Equal(arr, await ys.ToArray()); + Assert.Equal(arr, await ys.ToArrayAsync()); } [Fact] public async Task GroupBy21() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result); var arr = new List { "0 - adgj", "1 - beh", "2 - cfi" }; - Assert.Equal(arr, await ys.ToList()); + Assert.Equal(arr, await ys.ToListAsync()); } [Fact] public async Task GroupBy22() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result); - Assert.Equal(3, await ys.Count()); + Assert.Equal(3, await ys.CountAsync()); } [Fact] public async Task GroupBy23() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result); + var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x), (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result); await SequenceIdentity(ys); } @@ -552,22 +552,22 @@ public async Task GroupBy24() var g2a = new[] { 'b', 'e', 'h' }; var g3a = new[] { 'c', 'f', 'i' }; - var gar = await ys.ToArray(); + var gar = await ys.ToArrayAsync(); Assert.Equal(3, gar.Length); var gg1 = gar[0]; - var gg1a = await gg1.ToArray(); + var gg1a = await gg1.ToArrayAsync(); Assert.Equal(g1a, gg1a); var gg2 = gar[1]; - var gg2a = await gg2.ToArray(); + var gg2a = await gg2.ToArrayAsync(); Assert.Equal(g2a, gg2a); var gg3 = gar[2]; - var gg3a = await gg3.ToArray(); + var gg3a = await gg3.ToArrayAsync(); Assert.Equal(g3a, gg3a); } @@ -581,20 +581,20 @@ public async Task GroupBy25() var g2a = new List { 'b', 'e', 'h' }; var g3a = new List { 'c', 'f', 'i' }; - var gar = await ys.ToList(); + var gar = await ys.ToListAsync(); Assert.Equal(3, gar.Count); var gg1 = gar[0]; - var gg1a = await gg1.ToList(); + var gg1a = await gg1.ToListAsync(); Assert.Equal(g1a, gg1a); var gg2 = gar[1]; - var gg2a = await gg2.ToList(); + var gg2a = await gg2.ToListAsync(); Assert.Equal(g2a, gg2a); var gg3 = gar[2]; - var gg3a = await gg3.ToList(); + var gg3a = await gg3.ToListAsync(); Assert.Equal(g3a, gg3a); } @@ -604,20 +604,20 @@ public async Task GroupBy26() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - var gar = await ys.ToList(); + var gar = await ys.ToListAsync(); Assert.Equal(3, gar.Count); var gg1 = gar[0]; - var gg1a = await gg1.Count(); + var gg1a = await gg1.CountAsync(); Assert.Equal(4, gg1a); var gg2 = gar[1]; - var gg2a = await gg2.Count(); + var gg2a = await gg2.CountAsync(); Assert.Equal(3, gg2a); var gg3 = gar[2]; - var gg3a = await gg3.Count(); + var gg3a = await gg3.CountAsync(); Assert.Equal(3, gg3a); } @@ -627,7 +627,7 @@ public async Task GroupBy27() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x % 3, x => (char)('a' + x)); - var gar = await ys.Count(); + var gar = await ys.CountAsync(); Assert.Equal(3, gar); } @@ -651,20 +651,20 @@ public async Task GroupBy29() var g2a = new List { 1, 4, 7 }; var g3a = new List { 2, 5, 8 }; - var gar = await ys.ToList(); + var gar = await ys.ToListAsync(); Assert.Equal(3, gar.Count); var gg1 = gar[0]; - var gg1a = await gg1.ToList(); + var gg1a = await gg1.ToListAsync(); Assert.Equal(g1a, gg1a); var gg2 = gar[1]; - var gg2a = await gg2.ToList(); + var gg2a = await gg2.ToListAsync(); Assert.Equal(g2a, gg2a); var gg3 = gar[2]; - var gg3a = await gg3.ToList(); + var gg3a = await gg3.ToListAsync(); Assert.Equal(g3a, gg3a); } @@ -675,20 +675,20 @@ public async Task GroupBy30() var ys = xs.GroupBy(x => x, new EqMod(3)); - var gar = await ys.ToList(); + var gar = await ys.ToListAsync(); Assert.Equal(3, gar.Count); var gg1 = gar[0]; - var gg1a = await gg1.Count(); + var gg1a = await gg1.CountAsync(); Assert.Equal(4, gg1a); var gg2 = gar[1]; - var gg2a = await gg2.Count(); + var gg2a = await gg2.CountAsync(); Assert.Equal(3, gg2a); var gg3 = gar[2]; - var gg3a = await gg3.Count(); + var gg3a = await gg3.CountAsync(); Assert.Equal(3, gg3a); } @@ -702,22 +702,22 @@ public async Task GroupBy31() var g2a = new[] { 1, 4, 7 }; var g3a = new[] { 2, 5, 8 }; - var gar = await ys.ToArray(); + var gar = await ys.ToArrayAsync(); Assert.Equal(3, gar.Length); var gg1 = gar[0]; - var gg1a = await gg1.ToArray(); + var gg1a = await gg1.ToArrayAsync(); Assert.Equal(g1a, gg1a); var gg2 = gar[1]; - var gg2a = await gg2.ToArray(); + var gg2a = await gg2.ToArrayAsync(); Assert.Equal(g2a, gg2a); var gg3 = gar[2]; - var gg3a = await gg3.ToArray(); + var gg3a = await gg3.ToArrayAsync(); Assert.Equal(g3a, gg3a); } @@ -727,7 +727,7 @@ public async Task GroupBy32() var xs = AsyncEnumerable.Range(0, 10); var ys = xs.GroupBy(x => x, new EqMod(3)); - var gar = await ys.Count(); + var gar = await ys.CountAsync(); Assert.Equal(3, gar); } @@ -745,38 +745,38 @@ public async Task GroupBy33() public async Task GroupBy34() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result, new EqMod(3)); var arr = new[] { "0 - 0369", "1 - 147", "2 - 258" }; - Assert.Equal(arr, await ys.ToArray()); + Assert.Equal(arr, await ys.ToArrayAsync()); } [Fact] public async Task GroupBy35() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result, new EqMod(3)); var arr = new List { "0 - 0369", "1 - 147", "2 - 258" }; - Assert.Equal(arr, await ys.ToList()); + Assert.Equal(arr, await ys.ToListAsync()); } [Fact] public async Task GroupBy36() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result, new EqMod(3)); - Assert.Equal(3, await ys.Count()); + Assert.Equal(3, await ys.CountAsync()); } [Fact] public async Task GroupBy37() { var xs = AsyncEnumerable.Range(0, 10); - var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.Aggregate("", (a, c) => a + c).Result, new EqMod(3)); + var ys = xs.GroupBy(x => x, (k, cs) => k + " - " + cs.AggregateAsync("", (a, c) => a + c).Result, new EqMod(3)); await SequenceIdentity(ys); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs index 9a50170ff8..549a511e21 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupJoin.cs @@ -34,7 +34,7 @@ public async Task GroupJoin1() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 4, 7, 6, 2, 3, 4, 8, 9 }.ToAsyncEnumerable(); - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.AggregateAsync("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); await HasNextAsync(e, "0 - 639"); @@ -49,7 +49,7 @@ public async Task GroupJoin2() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.AggregateAsync("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); await HasNextAsync(e, "0 - 36"); @@ -65,7 +65,7 @@ public async Task GroupJoin3Async() var xs = Throw(ex); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.AggregateAsync("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); @@ -78,7 +78,7 @@ public async Task GroupJoin4Async() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = Throw(ex); - var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + var res = xs.GroupJoin(ys, x => x % 3, y => y % 3, (x, i) => x + " - " + i.AggregateAsync("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); @@ -91,7 +91,7 @@ public async Task GroupJoin5Async() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + var res = xs.GroupJoin(ys, x => { throw ex; }, y => y % 3, (x, i) => x + " - " + i.AggregateAsync("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); @@ -104,7 +104,7 @@ public async Task GroupJoin6Async() var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = new[] { 3, 6, 4 }.ToAsyncEnumerable(); - var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.Aggregate("", (s, j) => s + j).Result); + var res = xs.GroupJoin(ys, x => x % 3, y => { throw ex; }, (x, i) => x + " - " + i.AggregateAsync("", (s, j) => s + j).Result); var e = res.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); @@ -121,7 +121,7 @@ public async Task GroupJoin7() { if (x == 1) throw ex; - return x + " - " + i.Aggregate("", (s, j) => s + j).Result; + return x + " - " + i.AggregateAsync("", (s, j) => s + j).Result; }); var e = res.GetAsyncEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 27d3405c2a..a876f0215b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -15,47 +15,47 @@ public class Last : AsyncEnumerableTests [Fact] public async Task Last_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Last(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task Last1Async() { - var res = AsyncEnumerable.Empty().Last(); + var res = AsyncEnumerable.Empty().LastAsync(); await AssertThrowsAsync(res); } [Fact] public async Task Last2Async() { - var res = AsyncEnumerable.Empty().Last(x => true); + var res = AsyncEnumerable.Empty().LastAsync(x => true); await AssertThrowsAsync(res); } [Fact] public async Task Last3Async() { - var res = Return42.Last(x => x % 2 != 0); + var res = Return42.LastAsync(x => x % 2 != 0); await AssertThrowsAsync(res); } [Fact] public async Task Last4Async() { - var res = Return42.Last(); + var res = Return42.LastAsync(); Assert.Equal(42, await res); } [Fact] public async Task Last5Async() { - var res = Return42.Last(x => x % 2 == 0); + var res = Return42.LastAsync(x => x % 2 == 0); Assert.Equal(42, await res); } @@ -63,7 +63,7 @@ public async Task Last5Async() public async Task Last6Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).Last(); + var res = Throw(ex).LastAsync(); await AssertThrowsAsync(res, ex); } @@ -71,21 +71,21 @@ public async Task Last6Async() public async Task Last7Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).Last(x => true); + var res = Throw(ex).LastAsync(x => true); await AssertThrowsAsync(res, ex); } [Fact] public async Task Last8Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Last(); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAsync(); Assert.Equal(90, await res); } [Fact] public async Task Last9Async() { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Last(x => x % 2 != 0); + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastAsync(x => x % 2 != 0); Assert.Equal(45, await res); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 9a33522977..0363541916 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -15,47 +15,47 @@ public class LastOrDefault : AsyncEnumerableTests [Fact] public async Task LastOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefault(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task LastOrDefault1Async() { - var res = AsyncEnumerable.Empty().LastOrDefault(); + var res = AsyncEnumerable.Empty().LastOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] public async Task LastOrDefault2Async() { - var res = AsyncEnumerable.Empty().LastOrDefault(x => true); + var res = AsyncEnumerable.Empty().LastOrDefaultAsync(x => true); Assert.Equal(0, await res); } [Fact] public async Task LastOrDefault3Async() { - var res = Return42.LastOrDefault(x => x % 2 != 0); + var res = Return42.LastOrDefaultAsync(x => x % 2 != 0); Assert.Equal(0, await res); } [Fact] public async Task LastOrDefault4Async() { - var res = Return42.LastOrDefault(); + var res = Return42.LastOrDefaultAsync(); Assert.Equal(42, await res); } [Fact] public async Task LastOrDefault5Async() { - var res = Return42.LastOrDefault(x => x % 2 == 0); + var res = Return42.LastOrDefaultAsync(x => x % 2 == 0); Assert.Equal(42, await res); } @@ -63,7 +63,7 @@ public async Task LastOrDefault5Async() public async Task LastOrDefault6Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastOrDefault(); + var res = Throw(ex).LastOrDefaultAsync(); await AssertThrowsAsync(res, ex); } @@ -71,28 +71,28 @@ public async Task LastOrDefault6Async() public async Task LastOrDefault7Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastOrDefault(x => true); + var res = Throw(ex).LastOrDefaultAsync(x => true); await AssertThrowsAsync(res, ex); } [Fact] public async Task LastOrDefault8Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(); Assert.Equal(90, await res); } [Fact] public async Task LastOrDefault9Async() { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x % 2 != 0); + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); Assert.Equal(45, await res); } [Fact] public async Task LastOrDefault10Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefault(x => x < 10); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(x => x < 10); Assert.Equal(0, await res); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 4c75e8cc0e..724c3f58b8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -15,34 +15,34 @@ public class LongCount : AsyncEnumerableTests [Fact] public async Task LongCount_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCount(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task LongCount1() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCount()); - Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount()); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCountAsync()); + Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAsync()); } [Fact] public async Task LongCount2() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCount(x => x < 3)); - Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3)); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCountAsync(x => x < 3)); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAsync(x => x < 3)); } [Fact] public async Task LongCount3Async() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func(x => { throw ex; })); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAsync(new Func(x => { throw ex; })); await AssertThrowsAsync(ys, ex); } @@ -50,14 +50,14 @@ public async Task LongCount3Async() public async Task LongCount4Async() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).LongCount(), ex); + await AssertThrowsAsync(Throw(ex).LongCountAsync(), ex); } [Fact] public async Task LongCount5Async() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).LongCount(x => x < 3), ex); + await AssertThrowsAsync(Throw(ex).LongCountAsync(x => x < 3), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs index e201d6a521..51bdb95511 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -16,79 +16,79 @@ public class Max : AsyncEnumerableTests [Fact] public async Task Max_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Max(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); } [Fact] @@ -96,8 +96,8 @@ public async Task Max1Async() { var xs = new[] { 2, 7, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -105,8 +105,8 @@ public async Task Max2Async() { var xs = new[] { 2, default(int?), 3, 1 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -114,8 +114,8 @@ public async Task Max3Async() { var xs = new[] { 2L, 7L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -123,8 +123,8 @@ public async Task Max4Async() { var xs = new[] { 2L, default(long?), 3L, 1L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -132,8 +132,8 @@ public async Task Max5Async() { var xs = new[] { 2.0, 7.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -141,8 +141,8 @@ public async Task Max6Async() { var xs = new[] { 2.0, default(double?), 3.0, 1.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -150,8 +150,8 @@ public async Task Max7Async() { var xs = new[] { 2.0f, 7.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -159,8 +159,8 @@ public async Task Max8Async() { var xs = new[] { 2.0f, default(float?), 3.0f, 1.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -168,8 +168,8 @@ public async Task Max9Async() { var xs = new[] { 2.0m, 7.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -177,8 +177,8 @@ public async Task Max10Async() { var xs = new[] { 2.0m, default(decimal?), 3.0m, 1.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } [Fact] @@ -186,8 +186,8 @@ public async Task Max11Async() { var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Max(), await ys.Max()); - Assert.Equal(xs.Max(), await ys.Max(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs index 9c08bb558a..6950981801 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -16,79 +16,79 @@ public class Min : AsyncEnumerableTests [Fact] public async Task Min_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Min(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); } [Fact] @@ -96,8 +96,8 @@ public async Task Min1Async() { var xs = new[] { 2, 1, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -105,8 +105,8 @@ public async Task Min2Async() { var xs = new[] { 2, default(int?), 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -114,8 +114,8 @@ public async Task Min3Async() { var xs = new[] { 2L, 1L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -123,8 +123,8 @@ public async Task Min4Async() { var xs = new[] { 2L, default(long?), 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -132,8 +132,8 @@ public async Task Min5Async() { var xs = new[] { 2.0, 1.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -141,8 +141,8 @@ public async Task Min6Async() { var xs = new[] { 2.0, default(double?), 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -150,8 +150,8 @@ public async Task Min7Async() { var xs = new[] { 2.0f, 1.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -159,8 +159,8 @@ public async Task Min8Async() { var xs = new[] { 2.0f, default(float?), 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -168,8 +168,8 @@ public async Task Min9Async() { var xs = new[] { 2.0m, 1.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -177,8 +177,8 @@ public async Task Min10Async() { var xs = new[] { 2.0m, default(decimal?), 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } [Fact] @@ -186,8 +186,8 @@ public async Task Min11Async() { var xs = new[] { DateTime.Now.AddDays(1), DateTime.Now.Subtract(TimeSpan.FromDays(1)), DateTime.Now.AddDays(2), DateTime.Now }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Min(), await ys.Min()); - Assert.Equal(xs.Min(), await ys.Min(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs index 110c0b9119..95513d3d2d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs @@ -43,7 +43,7 @@ public async Task Prepend2() var a = new[] { 4, 1, 2, 3 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -56,7 +56,7 @@ public async Task Prepend3() var a = new List { 4, 1, 2, 3 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -66,7 +66,7 @@ public async Task Prepend4() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var res = xs.Prepend(4); - Assert.Equal(4, await res.Count()); + Assert.Equal(4, await res.CountAsync()); } [Fact] @@ -78,7 +78,7 @@ public async Task Prepend5() var a = new[] { 4, 1, 2, 3 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -91,7 +91,7 @@ public async Task Prepend6() var a = new List { 4, 1, 2, 3 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -101,7 +101,7 @@ public async Task Prepend7() var xs = AsyncEnumerable.Range(1, 3).Where(i => true); var res = xs.Prepend(4); - Assert.Equal(4, await res.Count()); + Assert.Equal(4, await res.CountAsync()); } [Fact] @@ -145,7 +145,7 @@ public async Task PrependN2() var a = new[] { 6, 5, 4, 1, 2, 3 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -160,7 +160,7 @@ public async Task PrependN3() var a = new List { 6, 5, 4, 1, 2, 3 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -173,7 +173,7 @@ public async Task PrependN4() .Prepend(5) .Prepend(6); - Assert.Equal(6, await res.Count()); + Assert.Equal(6, await res.CountAsync()); } [Fact] @@ -187,7 +187,7 @@ public async Task PrependN5() var a = new[] { 6, 5, 4, 1, 2, 3 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -202,7 +202,7 @@ public async Task PrependN6() var a = new List { 6, 5, 4, 1, 2, 3 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -215,7 +215,7 @@ public async Task PrependN7() .Prepend(5) .Prepend(6); - Assert.Equal(6, await res.Count()); + Assert.Equal(6, await res.CountAsync()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs index ae6c073f0e..a877e82c45 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Reverse.cs @@ -68,7 +68,7 @@ public async Task Reverse5() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.Reverse(); - Assert.Equal(new[] { 3, 2, 1 }, await ys.ToArray()); + Assert.Equal(new[] { 3, 2, 1 }, await ys.ToArrayAsync()); } [Fact] @@ -77,7 +77,7 @@ public async Task Reverse6() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.Reverse(); - Assert.Equal(new[] { 3, 2, 1 }, await ys.ToList()); + Assert.Equal(new[] { 3, 2, 1 }, await ys.ToListAsync()); } [Fact] @@ -86,7 +86,7 @@ public async Task Reverse7() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.Reverse(); - Assert.Equal(3, await ys.Count()); + Assert.Equal(3, await ys.CountAsync()); } [Fact] @@ -104,7 +104,7 @@ public async Task Reverse9() var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = xs.Reverse().Prepend(4); // to trigger onlyIfCheap - Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArray()); + Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArrayAsync()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index e572984bc6..af8fd7768a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -16,24 +16,24 @@ public class SequenceEqual : AsyncEnumerableTests [Fact] public async Task SequenceEqual_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(default, Return42, new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqual(Return42, default, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, new Eq(), CancellationToken.None)); } [Fact] public async Task SequenceEqual1Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(xs); + var res = xs.SequenceEqualAsync(xs); Assert.True(await res); } @@ -41,7 +41,7 @@ public async Task SequenceEqual1Async() public async Task SequenceEqual2Async() { var xs = AsyncEnumerable.Empty(); - var res = xs.SequenceEqual(xs); + var res = xs.SequenceEqualAsync(xs); Assert.True(await res); } @@ -50,7 +50,7 @@ public async Task SequenceEqual3Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); + var res = xs.SequenceEqualAsync(ys); Assert.False(await res); } @@ -59,7 +59,7 @@ public async Task SequenceEqual4Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); + var res = xs.SequenceEqualAsync(ys); Assert.False(await res); } @@ -68,7 +68,7 @@ public async Task SequenceEqual5Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); + var res = xs.SequenceEqualAsync(ys); Assert.False(await res); } @@ -78,7 +78,7 @@ public async Task SequenceEqual6Async() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = Throw(ex); - var res = xs.SequenceEqual(ys); + var res = xs.SequenceEqualAsync(ys); await AssertThrowsAsync(res, ex); } @@ -89,7 +89,7 @@ public async Task SequenceEqual7Async() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys); + var res = xs.SequenceEqualAsync(ys); await AssertThrowsAsync(res, ex); } @@ -98,7 +98,7 @@ public async Task SequenceEqual7Async() public async Task SequenceEqual8Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(xs, new Eq()); + var res = xs.SequenceEqualAsync(xs, new Eq()); Assert.True(await res); } @@ -106,7 +106,7 @@ public async Task SequenceEqual8Async() public async Task SequenceEqual9Async() { var xs = AsyncEnumerable.Empty(); - var res = xs.SequenceEqual(xs, new Eq()); + var res = xs.SequenceEqualAsync(xs, new Eq()); Assert.True(await res); } @@ -115,7 +115,7 @@ public async Task SequenceEqual10Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 3, 2 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); + var res = xs.SequenceEqualAsync(ys, new Eq()); Assert.False(await res); } @@ -124,7 +124,7 @@ public async Task SequenceEqual11Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); + var res = xs.SequenceEqualAsync(ys, new Eq()); Assert.False(await res); } @@ -133,7 +133,7 @@ public async Task SequenceEqual12Async() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); + var res = xs.SequenceEqualAsync(ys, new Eq()); Assert.False(await res); } @@ -143,7 +143,7 @@ public async Task SequenceEqual13Async() var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = Throw(ex); - var res = xs.SequenceEqual(ys, new Eq()); + var res = xs.SequenceEqualAsync(ys, new Eq()); await AssertThrowsAsync(res, ex); } @@ -154,7 +154,7 @@ public async Task SequenceEqual14Async() var ex = new Exception("Bang!"); var xs = Throw(ex); var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); + var res = xs.SequenceEqualAsync(ys, new Eq()); await AssertThrowsAsync(res, ex); } @@ -164,7 +164,7 @@ public async Task SequenceEqual15Async() { var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new Eq()); + var res = xs.SequenceEqualAsync(ys, new Eq()); Assert.True(await res); } @@ -173,7 +173,7 @@ public async Task SequenceEqual16Async() { var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); - var res = xs.SequenceEqual(ys, new EqEx()); + var res = xs.SequenceEqualAsync(ys, new EqEx()); await AssertThrowsAsync(res); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 41e98ed641..836d59d33a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -15,47 +15,47 @@ public class Single : AsyncEnumerableTests [Fact] public async Task Single_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Single(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task Single1Async() { - var res = AsyncEnumerable.Empty().Single(); + var res = AsyncEnumerable.Empty().SingleAsync(); await AssertThrowsAsync(res); } [Fact] public async Task Single2Async() { - var res = AsyncEnumerable.Empty().Single(x => true); + var res = AsyncEnumerable.Empty().SingleAsync(x => true); await AssertThrowsAsync(res); } [Fact] public async Task Single3Async() { - var res = Return42.Single(x => x % 2 != 0); + var res = Return42.SingleAsync(x => x % 2 != 0); await AssertThrowsAsync(res); } [Fact] public async Task Single4Async() { - var res = Return42.Single(); + var res = Return42.SingleAsync(); Assert.Equal(42, await res); } [Fact] public async Task Single5Async() { - var res = Return42.Single(x => x % 2 == 0); + var res = Return42.SingleAsync(x => x % 2 == 0); Assert.Equal(42, await res); } @@ -63,7 +63,7 @@ public async Task Single5Async() public async Task Single6Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).Single(); + var res = Throw(ex).SingleAsync(); await AssertThrowsAsync(res, ex); } @@ -71,35 +71,35 @@ public async Task Single6Async() public async Task Single7Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).Single(x => true); + var res = Throw(ex).SingleAsync(x => true); await AssertThrowsAsync(res, ex); } [Fact] public async Task Single8Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleAsync(); await AssertThrowsAsync(res); } [Fact] public async Task Single9Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleAsync(x => x % 2 != 0); Assert.Equal(45, await res); } [Fact] public async Task Single10Async() { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().Single(x => x % 2 != 0); + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().SingleAsync(x => x % 2 != 0); await AssertThrowsAsync(res); } [Fact] public async Task Single11Async() { - var res = new int[0].ToAsyncEnumerable().Single(); + var res = new int[0].ToAsyncEnumerable().SingleAsync(); await AssertThrowsAsync(res); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 86bc8b1a9f..cbec3332ac 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -15,47 +15,47 @@ public class SingleOrDefault : AsyncEnumerableTests [Fact] public async Task SingleOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefault(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func), CancellationToken.None)); } [Fact] public async Task SingleOrDefault1Async() { - var res = AsyncEnumerable.Empty().SingleOrDefault(); + var res = AsyncEnumerable.Empty().SingleOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] public async Task SingleOrDefault2Async() { - var res = AsyncEnumerable.Empty().SingleOrDefault(x => true); + var res = AsyncEnumerable.Empty().SingleOrDefaultAsync(x => true); Assert.Equal(0, await res); } [Fact] public async Task SingleOrDefault3Async() { - var res = Return42.SingleOrDefault(x => x % 2 != 0); + var res = Return42.SingleOrDefaultAsync(x => x % 2 != 0); Assert.Equal(0, await res); } [Fact] public async Task SingleOrDefault4Async() { - var res = Return42.SingleOrDefault(); + var res = Return42.SingleOrDefaultAsync(); Assert.Equal(42, await res); } [Fact] public async Task SingleOrDefault5Async() { - var res = Return42.SingleOrDefault(x => x % 2 == 0); + var res = Return42.SingleOrDefaultAsync(x => x % 2 == 0); Assert.Equal(42, await res); } @@ -63,7 +63,7 @@ public async Task SingleOrDefault5Async() public async Task SingleOrDefault6Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).SingleOrDefault(); + var res = Throw(ex).SingleOrDefaultAsync(); await AssertThrowsAsync(res, ex); } @@ -71,42 +71,42 @@ public async Task SingleOrDefault6Async() public async Task SingleOrDefault7Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).SingleOrDefault(x => true); + var res = Throw(ex).SingleOrDefaultAsync(x => true); await AssertThrowsAsync(res, ex); } [Fact] public async Task SingleOrDefault8Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(); await AssertThrowsAsync(res); } [Fact] public async Task SingleOrDefault9Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x % 2 != 0); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(x => x % 2 != 0); Assert.Equal(45, await res); } [Fact] public async Task SingleOrDefault10Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => x < 10); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(x => x < 10); Assert.Equal(0, await res); } [Fact] public async Task SingleOrDefault11Async() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefault(x => true); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(x => true); await AssertThrowsAsync(res); } [Fact] public async Task SingleOrDefault12Async() { - var res = new int[0].ToAsyncEnumerable().SingleOrDefault(); + var res = new int[0].ToAsyncEnumerable().SingleOrDefaultAsync(); Assert.Equal(0, await res); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs index 7e57b9116d..ea376cf97a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs @@ -16,71 +16,71 @@ public class Sum : AsyncEnumerableTests [Fact] public async Task Sum_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.Sum(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); } [Fact] @@ -88,8 +88,8 @@ public async Task Sum1Async() { var xs = new[] { 1, 2, 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -97,8 +97,8 @@ public async Task Sum2Async() { var xs = new[] { 1, default(int?), 3 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -106,8 +106,8 @@ public async Task Sum3Async() { var xs = new[] { 1L, 2L, 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -115,8 +115,8 @@ public async Task Sum4Async() { var xs = new[] { 1L, default(long?), 3L }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -124,8 +124,8 @@ public async Task Sum5Async() { var xs = new[] { 1.0, 2.0, 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -133,8 +133,8 @@ public async Task Sum6Async() { var xs = new[] { 1.0, default(double?), 3.0 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -142,8 +142,8 @@ public async Task Sum7Async() { var xs = new[] { 1.0f, 2.0f, 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -151,8 +151,8 @@ public async Task Sum8Async() { var xs = new[] { 1.0f, default(float?), 3.0f }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -160,8 +160,8 @@ public async Task Sum9Async() { var xs = new[] { 1.0m, 2.0m, 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } [Fact] @@ -169,8 +169,8 @@ public async Task Sum10Async() { var xs = new[] { 1.0m, default(decimal?), 3.0m }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Sum(), await ys.Sum()); - Assert.Equal(xs.Sum(), await ys.Sum(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync()); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 907ebc12f7..290c865c2c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -16,15 +16,15 @@ public class ToArray : AsyncEnumerableTests [Fact] public async Task ToArray_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArray(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArrayAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArrayAsync(default, CancellationToken.None)); } [Fact] public async Task ToArray1() { var xs = new[] { 42, 25, 39 }; - var res = xs.ToAsyncEnumerable().ToArray(); + var res = xs.ToAsyncEnumerable().ToArrayAsync(); Assert.True((await res).SequenceEqual(xs)); } @@ -32,7 +32,7 @@ public async Task ToArray1() public async Task ToArray2() { var xs = AsyncEnumerable.Empty(); - var res = xs.ToArray(); + var res = xs.ToArrayAsync(); Assert.True((await res).Length == 0); } @@ -40,14 +40,14 @@ public async Task ToArray2() public async Task ToArray3Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).ToArray(); + var res = Throw(ex).ToArrayAsync(); await AssertThrowsAsync(res, ex); } [Fact] public async Task ToArray4() { - var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArray(); + var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArrayAsync(); var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; Assert.True(ex.SequenceEqual(xs)); @@ -59,7 +59,7 @@ public async Task ToArray5() var res = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; var xs = new HashSet(res); - var arr = await xs.ToAsyncEnumerable().ToArray(); + var arr = await xs.ToAsyncEnumerable().ToArrayAsync(); Assert.True(res.SequenceEqual(arr)); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index 379514096c..4197705c36 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -118,7 +118,7 @@ public async Task ToAsyncEnumerable6() var xs = set.ToAsyncEnumerable(); - var arr = await xs.ToArray(); + var arr = await xs.ToArrayAsync(); Assert.True(set.SetEquals(arr)); } @@ -129,7 +129,7 @@ public async Task ToAsyncEnumerable7() var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); - var arr = await xs.ToList(); + var arr = await xs.ToListAsync(); Assert.True(set.SetEquals(arr)); } @@ -140,7 +140,7 @@ public async Task ToAsyncEnumerable8() var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); - var c = await xs.Count(); + var c = await xs.CountAsync(); Assert.Equal(set.Count, c); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index 7d423c5269..5cd7967787 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -16,40 +16,40 @@ public class ToDictionary : AsyncEnumerableTests [Fact] public async Task ToDictionary_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionary(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); } [Fact] public async Task ToDictionary1Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = await xs.ToDictionary(x => x % 2); + var res = await xs.ToDictionaryAsync(x => x % 2); Assert.True(res[0] == 4); Assert.True(res[1] == 1); } @@ -58,14 +58,14 @@ public async Task ToDictionary1Async() public async Task ToDictionary2Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - await AssertThrowsAsync(xs.ToDictionary(x => x % 2)); + await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2)); } [Fact] public async Task ToDictionary3Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = await xs.ToDictionary(x => x % 2, x => x + 1); + var res = await xs.ToDictionaryAsync(x => x % 2, x => x + 1); Assert.True(res[0] == 5); Assert.True(res[1] == 2); } @@ -74,14 +74,14 @@ public async Task ToDictionary3Async() public async Task ToDictionary4Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - await AssertThrowsAsync(xs.ToDictionary(x => x % 2, x => x + 1)); + await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2, x => x + 1)); } [Fact] public async Task ToDictionary5Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = await xs.ToDictionary(x => x % 2, new Eq()); + var res = await xs.ToDictionaryAsync(x => x % 2, new Eq()); Assert.True(res[0] == 4); Assert.True(res[1] == 1); } @@ -90,14 +90,14 @@ public async Task ToDictionary5Async() public async Task ToDictionary6Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - await AssertThrowsAsync(xs.ToDictionary(x => x % 2, new Eq())); + await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2, new Eq())); } [Fact] public async Task ToDictionary7Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = await xs.ToDictionary(x => x % 2, x => x, new Eq()); + var res = await xs.ToDictionaryAsync(x => x % 2, x => x, new Eq()); Assert.True(res[0] == 4); Assert.True(res[1] == 1); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index 12950c9a93..84f9b8e9b8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -16,17 +16,17 @@ public class ToHashSet : AsyncEnumerableTests [Fact] public async Task ToHashSet_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSet(default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default, EqualityComparer.Default, CancellationToken.None)); } [Fact] public async Task ToHashSet1() { var xs = new[] { 1, 2, 1, 2, 3, 4, 1, 2, 3, 4 }; - var res = xs.ToAsyncEnumerable().ToHashSet(); + var res = xs.ToAsyncEnumerable().ToHashSetAsync(); Assert.True((await res).OrderBy(x => x).SequenceEqual(new[] { 1, 2, 3, 4 })); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index c6039190ed..ff654ae535 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -15,15 +15,15 @@ public class ToList : AsyncEnumerableTests [Fact] public async Task ToList_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToList(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToListAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToListAsync(default, CancellationToken.None)); } [Fact] public async Task ToList1() { var xs = new[] { 42, 25, 39 }; - var res = xs.ToAsyncEnumerable().ToList(); + var res = xs.ToAsyncEnumerable().ToListAsync(); Assert.True((await res).SequenceEqual(xs)); } @@ -31,7 +31,7 @@ public async Task ToList1() public async Task ToList2() { var xs = AsyncEnumerable.Empty(); - var res = xs.ToList(); + var res = xs.ToListAsync(); Assert.True((await res).Count == 0); } @@ -39,7 +39,7 @@ public async Task ToList2() public async Task ToList3Async() { var ex = new Exception("Bang!"); - var res = Throw(ex).ToList(); + var res = Throw(ex).ToListAsync(); await AssertThrowsAsync(res, ex); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index 13e0f4befc..1262103000 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -17,40 +17,40 @@ public class ToLookup : AsyncEnumerableTests [Fact] public async Task ToLookup_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookup(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); } [Fact] public async Task ToLookup1Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2); + var res = await xs.ToLookupAsync(x => x % 2); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -62,7 +62,7 @@ public async Task ToLookup1Async() public async Task ToLookup2Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2); + var res = await xs.ToLookupAsync(x => x % 2); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -75,7 +75,7 @@ public async Task ToLookup2Async() public async Task ToLookup3Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2, x => x + 1); + var res = await xs.ToLookupAsync(x => x % 2, x => x + 1); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(5, res[0]); @@ -87,7 +87,7 @@ public async Task ToLookup3Async() public async Task ToLookup4Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2, x => x + 1); + var res = await xs.ToLookupAsync(x => x % 2, x => x + 1); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(5, res[0]); @@ -100,7 +100,7 @@ public async Task ToLookup4Async() public async Task ToLookup5Async() { var xs = new[] { 1, 4 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2, new Eq()); + var res = await xs.ToLookupAsync(x => x % 2, new Eq()); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -112,7 +112,7 @@ public async Task ToLookup5Async() public async Task ToLookup6Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2, new Eq()); + var res = await xs.ToLookupAsync(x => x % 2, new Eq()); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); @@ -125,7 +125,7 @@ public async Task ToLookup6Async() public async Task ToLookup7Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2); + var res = await xs.ToLookupAsync(x => x % 2); foreach (var g in res) Assert.True(g.Key == 0 || g.Key == 1); } @@ -134,7 +134,7 @@ public async Task ToLookup7Async() public async Task ToLookup8Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2); + var res = await xs.ToLookupAsync(x => x % 2); #pragma warning disable IDE0007 // Use implicit type foreach (IGrouping g in (IEnumerable)res) Assert.True(g.Key == 0 || g.Key == 1); @@ -145,7 +145,7 @@ public async Task ToLookup8Async() public async Task ToLookup9Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - var res = await xs.ToLookup(x => x % 2, x => x, new Eq()); + var res = await xs.ToLookupAsync(x => x % 2, x => x, new Eq()); Assert.True(res.Contains(0)); Assert.True(res.Contains(1)); Assert.Contains(4, res[0]); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs index 52dfc1f8d5..c00e659664 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Optimizations.cs @@ -90,7 +90,7 @@ public async Task AppendPrepend2() var a = new[] { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -108,7 +108,7 @@ public async Task AppendPrepend3() var a = new List { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -125,7 +125,7 @@ public async Task AppendPrepend4() .Prepend(9) .Prepend(10); - Assert.Equal(10, await res.Count()); + Assert.Equal(10, await res.CountAsync()); } [Fact] @@ -143,7 +143,7 @@ public async Task AppendPrepend5() var a = new[] { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - var arr = await res.ToArray(); + var arr = await res.ToArrayAsync(); Assert.Equal(a, arr); } @@ -162,7 +162,7 @@ public async Task AppendPrepend6() var a = new List { 10, 9, 7, 4, 1, 2, 3, 5, 6, 8 }; - var arr = await res.ToList(); + var arr = await res.ToListAsync(); Assert.Equal(a, arr); } @@ -179,7 +179,7 @@ public async Task AppendPrepend7() .Prepend(9) .Prepend(10); - Assert.Equal(10, await res.Count()); + Assert.Equal(10, await res.CountAsync()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 11647b4703..b71888e8ab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -77,7 +77,7 @@ async Task Core() { // If HasLimit is false, we contain everything past _minIndexInclusive. // Therefore, we have to iterate the whole enumerable. - return Math.Max(await _source.Count(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); + return Math.Max(await _source.CountAsync(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); } var en = _source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index c3429a98bc..05e2dd2927 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Aggregate(this IAsyncEnumerable source, Func accumulator) + public static Task AggregateAsync(this IAsyncEnumerable source, Func accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task Aggregate(this IAsyncEnumerable so return AggregateCore(source, accumulator, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task Aggregate(this IAsyncEnumerable so return AggregateCore(source, accumulator, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator) + public static Task AggregateAsync(this IAsyncEnumerable source, Func> accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task Aggregate(this IAsyncEnumerable so return AggregateCore(source, accumulator, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -50,7 +50,7 @@ public static Task Aggregate(this IAsyncEnumerable so return AggregateCore(source, accumulator, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ public static Task Aggregate(this IAsyncEnume return AggregateCore(source, seed, accumulator, x => x, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task Aggregate(this IAsyncEnume return AggregateCore(source, seed, accumulator, x => x, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task Aggregate(this IAsyncEnume return AggregateCore(source, seed, accumulator, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -90,7 +90,7 @@ public static Task Aggregate(this IAsyncEnume return AggregateCore(source, seed, accumulator, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -102,7 +102,7 @@ public static Task Aggregate(this IAsync return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ public static Task Aggregate(this IAsync return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ public static Task Aggregate(this IAsync return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); } - public static Task Aggregate(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 75e1764c17..4629f5cfa6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task All(this IAsyncEnumerable source, Func predicate) + public static Task AllAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task All(this IAsyncEnumerable source, Fun return AllCore(source, predicate, CancellationToken.None); } - public static Task All(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task All(this IAsyncEnumerable source, Fun return AllCore(source, predicate, cancellationToken); } - public static Task All(this IAsyncEnumerable source, Func> predicate) + public static Task AllAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task All(this IAsyncEnumerable source, Fun return AllCore(source, predicate, CancellationToken.None); } - public static Task All(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 47940748e2..2744e8864c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Any(this IAsyncEnumerable source) + public static Task AnyAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Any(this IAsyncEnumerable source) return AnyCore(source, CancellationToken.None); } - public static Task Any(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Any(this IAsyncEnumerable source, Can return AnyCore(source, cancellationToken); } - public static Task Any(this IAsyncEnumerable source, Func predicate) + public static Task AnyAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task Any(this IAsyncEnumerable source, Fun return AnyCore(source, predicate, CancellationToken.None); } - public static Task Any(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task Any(this IAsyncEnumerable source, Fun return AnyCore(source, predicate, cancellationToken); } - public static Task Any(this IAsyncEnumerable source, Func> predicate) + public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Any(this IAsyncEnumerable source, Fun return AnyCore(source, predicate, CancellationToken.None); } - public static Task Any(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index ed5e803859..dc3ef3f851 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -268,7 +268,7 @@ public override async Task GetCountAsync(bool onlyIfCheap, CancellationToke return count == -1 ? -1 : count + 1; } - return !onlyIfCheap || _source is ICollection ? await _source.Count(cancellationToken).ConfigureAwait(false) + 1 : -1; + return !onlyIfCheap || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + 1 : -1; } } @@ -479,7 +479,7 @@ public override async Task GetCountAsync(bool onlyIfCheap, CancellationToke return count == -1 ? -1 : count + _appendCount + _prependCount; } - return !onlyIfCheap || _source is ICollection ? await _source.Count(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1; + return !onlyIfCheap || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index f669a88ccd..82190d77cf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Average(this IAsyncEnumerable source) return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,47 +26,47 @@ public static Task Average(this IAsyncEnumerable source, Cancellati return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -74,7 +74,7 @@ public static Task Average(this IAsyncEnumerable source) return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -82,47 +82,47 @@ public static Task Average(this IAsyncEnumerable source, Cancellat return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -130,7 +130,7 @@ public static Task Average(this IAsyncEnumerable source) return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,47 +138,47 @@ public static Task Average(this IAsyncEnumerable source, Cancellat return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -186,7 +186,7 @@ public static Task Average(this IAsyncEnumerable source) return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -194,47 +194,47 @@ public static Task Average(this IAsyncEnumerable source, Cancell return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -242,7 +242,7 @@ public static Task Average(this IAsyncEnumerable source) return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -250,47 +250,47 @@ public static Task Average(this IAsyncEnumerable source, Cance return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -298,7 +298,7 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -306,47 +306,47 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -354,7 +354,7 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -362,47 +362,47 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -410,7 +410,7 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -418,47 +418,47 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -466,7 +466,7 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -474,47 +474,47 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source) + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -522,7 +522,7 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -530,44 +530,44 @@ public static Task Average(this IAsyncEnumerable sour return AverageCore(source, cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task Average(this IAsyncEnumerable source, Func> selector) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 37aba77696..b8cd9612b8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -35,7 +35,7 @@ foreach (var o in os) { var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; #> - public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -43,7 +43,7 @@ foreach (var o in os) return AverageCore(source, CancellationToken.None); } - public static Task<<#=o.res#>> Average(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,44 +51,44 @@ foreach (var o in os) return AverageCore(source, cancellationToken); } - public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func> selector) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } - public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(CancellationToken.None); + return source.Select(selector).AverageAsync(CancellationToken.None); } - public static Task<<#=o.res#>> Average(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).Average(cancellationToken); + return source.Select(selector).AverageAsync(cancellationToken); } <# diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 4fb17a8178..612670b63f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -122,7 +122,7 @@ async Task Core() checked { - count += await source.Count(cancellationToken).ConfigureAwait(false); + count += await source.CountAsync(cancellationToken).ConfigureAwait(false); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 5c2bafc2e1..95addaf118 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Contains(this IAsyncEnumerable source, TSource value) + public static Task ContainsAsync(this IAsyncEnumerable source, TSource value) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Contains(this IAsyncEnumerable source return ContainsCore(source, value, CancellationToken.None); } - public static Task Contains(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Contains(this IAsyncEnumerable source return ContainsCore(source, value, cancellationToken); } - public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) + public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static Task Contains(this IAsyncEnumerable source return ContainsCore(source, value, comparer, CancellationToken.None); } - public static Task Contains(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 8d9159f35a..a00ea3cff8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -11,7 +11,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Count(this IAsyncEnumerable source) + public static Task CountAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -19,7 +19,7 @@ public static Task Count(this IAsyncEnumerable source) return CountCore(source, CancellationToken.None); } - public static Task Count(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -27,7 +27,7 @@ public static Task Count(this IAsyncEnumerable source, Ca return CountCore(source, cancellationToken); } - public static Task Count(this IAsyncEnumerable source, Func predicate) + public static Task CountAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -37,7 +37,7 @@ public static Task Count(this IAsyncEnumerable source, Fu return CountCore(source, predicate, CancellationToken.None); } - public static Task Count(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -47,7 +47,7 @@ public static Task Count(this IAsyncEnumerable source, Fu return CountCore(source, predicate, cancellationToken); } - public static Task Count(this IAsyncEnumerable source, Func> predicate) + public static Task CountAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,7 +57,7 @@ public static Task Count(this IAsyncEnumerable source, Fu return CountCore(source, predicate, CancellationToken.None); } - public static Task Count(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index b11295a388..59e8cade39 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -95,13 +95,13 @@ protected override async ValueTask MoveNextCore() public async Task ToArrayAsync(CancellationToken cancellationToken) { - var array = await _source.ToArray(cancellationToken).ConfigureAwait(false); + var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); return array.Length == 0 ? new[] { _defaultValue } : array; } public async Task> ToListAsync(CancellationToken cancellationToken) { - var list = await _source.ToList(cancellationToken).ConfigureAwait(false); + var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); if (list.Count == 0) { list.Add(_defaultValue); @@ -115,7 +115,7 @@ public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancell int count; if (!onlyIfCheap || _source is ICollection || _source is ICollection) { - count = await _source.Count(cancellationToken).ConfigureAwait(false); + count = await _source.CountAsync(cancellationToken).ConfigureAwait(false); } else { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 5736d6efb6..0a16541b41 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ElementAt(this IAsyncEnumerable source, int index) + public static Task ElementAtAsync(this IAsyncEnumerable source, int index) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task ElementAt(this IAsyncEnumerable so return ElementAtCore(source, index, CancellationToken.None); } - public static Task ElementAt(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) + public static Task ElementAtAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 08abff8fa5..71e6483938 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ElementAtOrDefault(this IAsyncEnumerable source, int index) + public static Task ElementAtOrDefaultAsync(this IAsyncEnumerable source, int index) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task ElementAtOrDefault(this IAsyncEnumerable ElementAtOrDefault(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) + public static Task ElementAtOrDefaultAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 074eb18d16..c8320beba3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task First(this IAsyncEnumerable source) + public static Task FirstAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task First(this IAsyncEnumerable source return FirstCore(source, CancellationToken.None); } - public static Task First(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task First(this IAsyncEnumerable source return FirstCore(source, cancellationToken); } - public static Task First(this IAsyncEnumerable source, Func predicate) + public static Task FirstAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task First(this IAsyncEnumerable source return FirstCore(source, predicate, CancellationToken.None); } - public static Task First(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task First(this IAsyncEnumerable source return FirstCore(source, predicate, cancellationToken); } - public static Task First(this IAsyncEnumerable source, Func> predicate) + public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task First(this IAsyncEnumerable source return FirstCore(source, predicate, CancellationToken.None); } - public static Task First(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index ae628eff0a..48997586d1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task FirstOrDefault(this IAsyncEnumerable source) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func predicate) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task FirstOrDefault(this IAsyncEnumerable FirstOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 5152986e21..21b16a1980 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Last(this IAsyncEnumerable source) + public static Task LastAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Last(this IAsyncEnumerable source) return LastCore(source, CancellationToken.None); } - public static Task Last(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Last(this IAsyncEnumerable source, return LastCore(source, cancellationToken); } - public static Task Last(this IAsyncEnumerable source, Func predicate) + public static Task LastAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task Last(this IAsyncEnumerable source, return LastCore(source, predicate, CancellationToken.None); } - public static Task Last(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task Last(this IAsyncEnumerable source, return LastCore(source, predicate, cancellationToken); } - public static Task Last(this IAsyncEnumerable source, Func> predicate) + public static Task LastAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Last(this IAsyncEnumerable source, return LastCore(source, predicate, CancellationToken.None); } - public static Task Last(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 64f1264694..a722d8a23b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LastOrDefault(this IAsyncEnumerable source) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func predicate) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task LastOrDefault(this IAsyncEnumerable LastOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 5ee7d42fff..e09d3509e0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LongCount(this IAsyncEnumerable source) + public static Task LongCountAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, CancellationToken.None); } - public static Task LongCount(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, cancellationToken); } - public static Task LongCount(this IAsyncEnumerable source, Func predicate) + public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, predicate, CancellationToken.None); } - public static Task LongCount(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, predicate, cancellationToken); } - public static Task LongCount(this IAsyncEnumerable source, Func> predicate) + public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task LongCount(this IAsyncEnumerable sourc return LongCountCore(source, predicate, CancellationToken.None); } - public static Task LongCount(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index a44e31f02d..d026b2d4b5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Max(this IAsyncEnumerable source) return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task Max(this IAsyncEnumerable return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task Max(this IAsyncEnumerable return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Max(this IAsyncEnumerable return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index a516294623..47a241d29a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Min(this IAsyncEnumerable source) return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task Min(this IAsyncEnumerable return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task Min(this IAsyncEnumerable return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Min(this IAsyncEnumerable return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index db5117834c..58009b2d3a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Max(this IAsyncEnumerable source) return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Max(this IAsyncEnumerable source, CancellationToken return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -66,7 +66,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -74,7 +74,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -82,7 +82,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -92,7 +92,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -102,7 +102,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -112,7 +112,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -122,7 +122,7 @@ public static Task Max(this IAsyncEnumerable source, Func return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -130,7 +130,7 @@ public static Task Max(this IAsyncEnumerable source) return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,7 +138,7 @@ public static Task Max(this IAsyncEnumerable source, CancellationTok return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -148,7 +148,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -158,7 +158,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -168,7 +168,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -178,7 +178,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -186,7 +186,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -194,7 +194,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -204,7 +204,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -214,7 +214,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -224,7 +224,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -234,7 +234,7 @@ public static Task Max(this IAsyncEnumerable source, Fun return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -242,7 +242,7 @@ public static Task Max(this IAsyncEnumerable source) return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -250,7 +250,7 @@ public static Task Max(this IAsyncEnumerable source, CancellationT return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -260,7 +260,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -270,7 +270,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -280,7 +280,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -290,7 +290,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -298,7 +298,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -306,7 +306,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -316,7 +316,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -326,7 +326,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -336,7 +336,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -346,7 +346,7 @@ public static Task Max(this IAsyncEnumerable source, Fu return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -354,7 +354,7 @@ public static Task Max(this IAsyncEnumerable source) return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -362,7 +362,7 @@ public static Task Max(this IAsyncEnumerable source, Cancellatio return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -372,7 +372,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -382,7 +382,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -392,7 +392,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -402,7 +402,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -410,7 +410,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -418,7 +418,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -428,7 +428,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -438,7 +438,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -448,7 +448,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -458,7 +458,7 @@ public static Task Max(this IAsyncEnumerable source, F return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -466,7 +466,7 @@ public static Task Max(this IAsyncEnumerable source) return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -474,7 +474,7 @@ public static Task Max(this IAsyncEnumerable source, Cancellat return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -484,7 +484,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -494,7 +494,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -504,7 +504,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -514,7 +514,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source) + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -522,7 +522,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -530,7 +530,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -540,7 +540,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -550,7 +550,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task Max(this IAsyncEnumerable source, Func> selector) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -560,7 +560,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, CancellationToken.None); } - public static Task Max(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -570,7 +570,7 @@ public static Task Max(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -578,7 +578,7 @@ public static Task Min(this IAsyncEnumerable source) return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -586,7 +586,7 @@ public static Task Min(this IAsyncEnumerable source, CancellationToken return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -596,7 +596,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -606,7 +606,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -616,7 +616,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -626,7 +626,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -634,7 +634,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -642,7 +642,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -652,7 +652,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -662,7 +662,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -672,7 +672,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -682,7 +682,7 @@ public static Task Min(this IAsyncEnumerable source, Func return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -690,7 +690,7 @@ public static Task Min(this IAsyncEnumerable source) return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -698,7 +698,7 @@ public static Task Min(this IAsyncEnumerable source, CancellationTok return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -708,7 +708,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -718,7 +718,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -728,7 +728,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -738,7 +738,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -746,7 +746,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -754,7 +754,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -764,7 +764,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -774,7 +774,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -784,7 +784,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -794,7 +794,7 @@ public static Task Min(this IAsyncEnumerable source, Fun return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -802,7 +802,7 @@ public static Task Min(this IAsyncEnumerable source) return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -810,7 +810,7 @@ public static Task Min(this IAsyncEnumerable source, CancellationT return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -820,7 +820,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -830,7 +830,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -840,7 +840,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -850,7 +850,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -858,7 +858,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -866,7 +866,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -876,7 +876,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -886,7 +886,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -896,7 +896,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -906,7 +906,7 @@ public static Task Min(this IAsyncEnumerable source, Fu return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -914,7 +914,7 @@ public static Task Min(this IAsyncEnumerable source) return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -922,7 +922,7 @@ public static Task Min(this IAsyncEnumerable source, Cancellatio return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -932,7 +932,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -942,7 +942,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -952,7 +952,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -962,7 +962,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -970,7 +970,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -978,7 +978,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -988,7 +988,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -998,7 +998,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1008,7 +1008,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1018,7 +1018,7 @@ public static Task Min(this IAsyncEnumerable source, F return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1026,7 +1026,7 @@ public static Task Min(this IAsyncEnumerable source) return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1034,7 +1034,7 @@ public static Task Min(this IAsyncEnumerable source, Cancellat return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1044,7 +1044,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1054,7 +1054,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1064,7 +1064,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1074,7 +1074,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source) + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1082,7 +1082,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1090,7 +1090,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func selector) + public static Task MinAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1100,7 +1100,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1110,7 +1110,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } - public static Task Min(this IAsyncEnumerable source, Func> selector) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1120,7 +1120,7 @@ public static Task Min(this IAsyncEnumerable source, return MinCore(source, selector, CancellationToken.None); } - public static Task Min(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 2a4fdb6930..e07c216a8d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -22,7 +22,7 @@ foreach (var m in new[] { "Max", "Min" }) foreach (var t in new[] { "int", "int?", "long", "long?", "float", "float?", "double", "double?", "decimal", "decimal?" }) { #> - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, CancellationToken.None); } - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -38,7 +38,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, cancellationToken); } - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -48,7 +48,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, selector, CancellationToken.None); } - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -58,7 +58,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, selector, cancellationToken); } - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -68,7 +68,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, selector, CancellationToken.None); } - public static Task<<#=t#>> <#=m#>(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 520681092c..4a744d9df7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -33,7 +33,7 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - _buffer = await _source.ToArray(_cancellationToken).ConfigureAwait(false); + _buffer = await _source.ToArrayAsync(_cancellationToken).ConfigureAwait(false); // REVIEW: If we add selectors with CancellationToken support, we should feed the token to Sort. diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index ee046bb144..b4ffc6b134 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -36,7 +36,7 @@ public ReverseAsyncIterator(IAsyncEnumerable source) public async Task ToArrayAsync(CancellationToken cancellationToken) { - var array = await _source.ToArray(cancellationToken).ConfigureAwait(false); + var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); // Array.Reverse() involves boxing for non-primitive value types, but // checking that has its own cost, so just use this approach for all types. @@ -52,7 +52,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) public async Task> ToListAsync(CancellationToken cancellationToken) { - var list = await _source.ToList(cancellationToken).ConfigureAwait(false); + var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); list.Reverse(); return list; @@ -73,7 +73,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT } } - return _source.Count(cancellationToken); + return _source.CountAsync(cancellationToken); } public override AsyncIteratorBase Clone() @@ -92,7 +92,7 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - _items = await _source.ToArray(_cancellationToken).ConfigureAwait(false); + _items = await _source.ToArrayAsync(_cancellationToken).ConfigureAwait(false); _index = _items.Length - 1; _state = AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index a60de0aaab..1a41182ed2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second) + public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -20,7 +20,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f return SequenceEqualCore(first, second, comparer: null, CancellationToken.None); } - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -30,7 +30,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f return SequenceEqualCore(first, second, comparer: null, cancellationToken); } - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -40,7 +40,7 @@ public static Task SequenceEqual(this IAsyncEnumerable f return SequenceEqualCore(first, second, comparer, CancellationToken.None); } - public static Task SequenceEqual(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { if (first == null) throw Error.ArgumentNull(nameof(first)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 82edfcc7d5..090dd2cd7b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Single(this IAsyncEnumerable source) + public static Task SingleAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Single(this IAsyncEnumerable sourc return SingleCore(source, CancellationToken.None); } - public static Task Single(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Single(this IAsyncEnumerable sourc return SingleCore(source, cancellationToken); } - public static Task Single(this IAsyncEnumerable source, Func predicate) + public static Task SingleAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task Single(this IAsyncEnumerable sourc return SingleCore(source, predicate, CancellationToken.None); } - public static Task Single(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task Single(this IAsyncEnumerable sourc return SingleCore(source, predicate, cancellationToken); } - public static Task Single(this IAsyncEnumerable source, Func> predicate) + public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Single(this IAsyncEnumerable sourc return SingleCore(source, predicate, CancellationToken.None); } - public static Task Single(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index adaba84d66..102d64f08e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SingleOrDefault(this IAsyncEnumerable source) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func predicate) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task SingleOrDefault(this IAsyncEnumerable SingleOrDefault(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index fb5aa302bf..05680c8866 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task Sum(this IAsyncEnumerable source) return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task Sum(this IAsyncEnumerable source, CancellationToken return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -36,7 +36,7 @@ public static Task Sum(this IAsyncEnumerable source, Func return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,7 +46,7 @@ public static Task Sum(this IAsyncEnumerable source, Func return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -56,7 +56,7 @@ public static Task Sum(this IAsyncEnumerable source, Func return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -142,7 +142,7 @@ private static async Task SumCore(IAsyncEnumerable source return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -150,7 +150,7 @@ public static Task Sum(this IAsyncEnumerable source) return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -158,7 +158,7 @@ public static Task Sum(this IAsyncEnumerable source, CancellationTok return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -168,7 +168,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -178,7 +178,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -188,7 +188,7 @@ public static Task Sum(this IAsyncEnumerable source, Fun return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -274,7 +274,7 @@ private static async Task SumCore(IAsyncEnumerable sourc return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -282,7 +282,7 @@ public static Task Sum(this IAsyncEnumerable source) return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -290,7 +290,7 @@ public static Task Sum(this IAsyncEnumerable source, CancellationT return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -300,7 +300,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -310,7 +310,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -320,7 +320,7 @@ public static Task Sum(this IAsyncEnumerable source, Fu return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -397,7 +397,7 @@ private static async Task SumCore(IAsyncEnumerable sour return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -405,7 +405,7 @@ public static Task Sum(this IAsyncEnumerable source) return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -413,7 +413,7 @@ public static Task Sum(this IAsyncEnumerable source, Cancellatio return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -423,7 +423,7 @@ public static Task Sum(this IAsyncEnumerable source, F return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -433,7 +433,7 @@ public static Task Sum(this IAsyncEnumerable source, F return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -443,7 +443,7 @@ public static Task Sum(this IAsyncEnumerable source, F return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -520,7 +520,7 @@ private static async Task SumCore(IAsyncEnumerable sou return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -528,7 +528,7 @@ public static Task Sum(this IAsyncEnumerable source) return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -536,7 +536,7 @@ public static Task Sum(this IAsyncEnumerable source, Cancellat return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -546,7 +546,7 @@ public static Task Sum(this IAsyncEnumerable source, return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -556,7 +556,7 @@ public static Task Sum(this IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -566,7 +566,7 @@ public static Task Sum(this IAsyncEnumerable source, return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -643,7 +643,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -651,7 +651,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -659,7 +659,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -669,7 +669,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -679,7 +679,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -689,7 +689,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -775,7 +775,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -783,7 +783,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -791,7 +791,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -801,7 +801,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -811,7 +811,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -821,7 +821,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -907,7 +907,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -915,7 +915,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -923,7 +923,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -933,7 +933,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -943,7 +943,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -953,7 +953,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1030,7 +1030,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1038,7 +1038,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1046,7 +1046,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1056,7 +1056,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1066,7 +1066,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1076,7 +1076,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1153,7 +1153,7 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } - public static Task Sum(this IAsyncEnumerable source) + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1161,7 +1161,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1169,7 +1169,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func selector) + public static Task SumAsync(this IAsyncEnumerable source, Func selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1179,7 +1179,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1189,7 +1189,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task Sum(this IAsyncEnumerable source, Func> selector) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1199,7 +1199,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, CancellationToken.None); } - public static Task Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 841a044966..71fe878c05 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -35,7 +35,7 @@ foreach (var o in os) { var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; #> - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -43,7 +43,7 @@ foreach (var o in os) return SumCore(source, CancellationToken.None); } - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +51,7 @@ foreach (var o in os) return SumCore(source, cancellationToken); } - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -61,7 +61,7 @@ foreach (var o in os) return SumCore(source, selector, CancellationToken.None); } - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,7 +71,7 @@ foreach (var o in os) return SumCore(source, selector, cancellationToken); } - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -81,7 +81,7 @@ foreach (var o in os) return SumCore(source, selector, CancellationToken.None); } - public static Task<<#=o.type#>> Sum(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs index 3f660071ea..2325fa6f00 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs @@ -10,15 +10,15 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ToArray(this IAsyncEnumerable source) + public static Task ToArrayAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return ToArray(source, CancellationToken.None); + return ToArrayAsync(source, CancellationToken.None); } - public static Task ToArray(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task ToArrayAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 4f106a5b90..a7859cf902 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => new ValueTask(x), EqualityComparer.Default, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -50,7 +50,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => new ValueTask(x), EqualityComparer.Default, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => x, comparer, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -90,7 +90,7 @@ public static Task> ToDictionary(this I return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -102,7 +102,7 @@ public static Task> ToDictionary.Default, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ public static Task> ToDictionary.Default, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ public static Task> ToDictionary.Default, CancellationToken.None); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,7 +138,7 @@ public static Task> ToDictionary.Default, cancellationToken); } - public static Task> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -150,7 +150,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -162,7 +162,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -174,7 +174,7 @@ public static Task> ToDictionary> ToDictionary(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index d21b01758c..607aff12ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToHashSet(this IAsyncEnumerable source) + public static Task> ToHashSetAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToHashSet(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer) + public static Task> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static Task> ToHashSet(this IAsyncEnumerable> ToHashSet(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index e29c2ebcee..2a748af213 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToList(this IAsyncEnumerable source) + public static Task> ToListAsync(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -18,7 +18,7 @@ public static Task> ToList(this IAsyncEnumerable return ToListCore(source, CancellationToken.None); } - public static Task> ToList(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task> ToListAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index d9c24a2f45..7cc12bb300 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => x, comparer: null, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => x, comparer: null, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,7 +40,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer: null, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -50,7 +50,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer: null, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => x, comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => x, comparer, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -90,7 +90,7 @@ public static Task> ToLookup(this IAsyncEn return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -102,7 +102,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer: null, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer: null, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,7 +138,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -150,7 +150,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -162,7 +162,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer, cancellationToken); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -174,7 +174,7 @@ public static Task> ToLookup(th return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); } - public static Task> ToLookup(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); From af6a43d236c3ecc3f368f1c22f6408c3563ff2c5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 14 Nov 2018 14:04:57 -0800 Subject: [PATCH 536/862] Use ValueTask for internal IAsyncPartition interface. --- .../System/Linq/AsyncEnumerablePartition.cs | 14 +++++++------- .../System/Linq/AsyncListPartition.cs | 18 +++++++++--------- .../System/Linq/IAsyncPartition.cs | 6 +++--- .../System/Linq/Operators/Empty.cs | 6 +++--- .../System/Linq/Operators/FirstOrDefault.cs | 8 ++++---- .../System/Linq/Operators/LastOrDefault.cs | 8 ++++---- .../System/Linq/Operators/Range.cs | 10 +++++----- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index b71888e8ab..b9b9407189 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -217,7 +217,7 @@ public IAsyncPartition Take(int count) return new AsyncEnumerablePartition(_source, _minIndexInclusive, maxIndex); } - public async Task> TryGetElementAsync(int index, CancellationToken cancellationToken) + public async ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) { // If the index is negative or >= our max count, return early. if (index >= 0 && (!HasLimit || index < Limit)) @@ -242,7 +242,7 @@ public async Task> TryGetElementAsync(int index, CancellationToke return new Maybe(); } - public async Task> TryGetFirstAsync(CancellationToken cancellationToken) + public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { var en = _source.GetAsyncEnumerator(cancellationToken); @@ -261,7 +261,7 @@ public async Task> TryGetFirstAsync(CancellationToken cancellatio return new Maybe(); } - public async Task> TryGetLastAsync(CancellationToken cancellationToken) + public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { var en = _source.GetAsyncEnumerator(cancellationToken); @@ -356,21 +356,21 @@ public async Task> ToListAsync(CancellationToken cancellationToken return list; } - private Task SkipBeforeFirstAsync(IAsyncEnumerator en) => SkipBeforeAsync(_minIndexInclusive, en); + private ValueTask SkipBeforeFirstAsync(IAsyncEnumerator en) => SkipBeforeAsync(_minIndexInclusive, en); - private static async Task SkipBeforeAsync(int index, IAsyncEnumerator en) + private static async ValueTask SkipBeforeAsync(int index, IAsyncEnumerator en) { var n = await SkipAndCountAsync(index, en).ConfigureAwait(false); return n == index; } - private static async Task SkipAndCountAsync(int index, IAsyncEnumerator en) + private static async ValueTask SkipAndCountAsync(int index, IAsyncEnumerator en) { Debug.Assert(index >= 0); return (int)await SkipAndCountAsync((uint)index, en).ConfigureAwait(false); } - private static async Task SkipAndCountAsync(uint index, IAsyncEnumerator en) + private static async ValueTask SkipAndCountAsync(uint index, IAsyncEnumerator en) { Debug.Assert(en != null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 979d778fcd..d84163f213 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -89,38 +89,38 @@ public IAsyncPartition Take(int count) } } - public Task> TryGetElementAsync(int index, CancellationToken cancellationToken) + public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) { if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < _source.Count - _minIndexInclusive) { var res = _source[_minIndexInclusive + index]; - return Task.FromResult(new Maybe(res)); + return new ValueTask>(new Maybe(res)); } - return Task.FromResult(new Maybe()); + return new ValueTask>(new Maybe()); } - public Task> TryGetFirstAsync(CancellationToken cancellationToken) + public ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { if (_source.Count > _minIndexInclusive) { var res = _source[_minIndexInclusive]; - return Task.FromResult(new Maybe(res)); + return new ValueTask>(new Maybe(res)); } - return Task.FromResult(new Maybe()); + return new ValueTask>(new Maybe()); } - public Task> TryGetLastAsync(CancellationToken cancellationToken) + public ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { var lastIndex = _source.Count - 1; if (lastIndex >= _minIndexInclusive) { var res = _source[Math.Min(lastIndex, _maxIndexInclusive)]; - return Task.FromResult(new Maybe(res)); + return new ValueTask>(new Maybe(res)); } - return Task.FromResult(new Maybe()); + return new ValueTask>(new Maybe()); } private int Count diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs index fa99b30a83..b94e80d9ab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs @@ -32,20 +32,20 @@ internal interface IAsyncPartition : IAsyncIListProvider /// The 0-based index to access. /// Token to observe for cancellation requests. /// The element if found, otherwise, the default value of . - Task> TryGetElementAsync(int index, CancellationToken cancellationToken); + ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken); /// /// Gets the first item in this sequence. /// /// Token to observe for cancellation requests. /// The element if found, otherwise, the default value of . - Task> TryGetFirstAsync(CancellationToken cancellationToken); + ValueTask> TryGetFirstAsync(CancellationToken cancellationToken); /// /// Gets the last item in this sequence. /// /// Token to observe for cancellation requests. /// The element if found, otherwise, the default value of . - Task> TryGetLastAsync(CancellationToken cancellationToken); + ValueTask> TryGetLastAsync(CancellationToken cancellationToken); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index ee045b3d66..2ff7c87a7b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -34,11 +34,11 @@ public Task ToArrayAsync(CancellationToken cancellationToken) => Task. public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); - public Task> TryGetElementAsync(int index, CancellationToken cancellationToken) => Task.FromResult(new Maybe()); + public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) => new ValueTask>(new Maybe()); - public Task> TryGetFirstAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe()); + public ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) => new ValueTask>(new Maybe()); - public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe()); + public ValueTask> TryGetLastAsync(CancellationToken cancellationToken) => new ValueTask>(new Maybe()); public ValueTask MoveNextAsync() => new ValueTask(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 48997586d1..4d082ab7c2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -87,13 +87,13 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< return first.HasValue ? first.Value : default; } - private static Task> TryGetFirst(IAsyncEnumerable source, CancellationToken cancellationToken) + private static ValueTask> TryGetFirst(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { if (list.Count > 0) { - return Task.FromResult(new Maybe(list[0])); + return new ValueTask>(new Maybe(list[0])); } } else if (source is IAsyncPartition p) @@ -104,7 +104,7 @@ private static Task> TryGetFirst(IAsyncEnumerable> Core() + async ValueTask> Core() { var e = source.GetAsyncEnumerator(cancellationToken); @@ -124,7 +124,7 @@ async Task> Core() } } - return Task.FromResult(new Maybe()); + return new ValueTask>(new Maybe()); } private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index a722d8a23b..06f8161ac2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -87,14 +87,14 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable> TryGetLast(IAsyncEnumerable source, CancellationToken cancellationToken) + private static ValueTask> TryGetLast(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) { var count = list.Count; if (count > 0) { - return Task.FromResult(new Maybe(list[count - 1])); + return new ValueTask>(new Maybe(list[count - 1])); } } else if (source is IAsyncPartition p) @@ -105,7 +105,7 @@ private static Task> TryGetLast(IAsyncEnumerable> Core() + async ValueTask> Core() { var last = default(TSource); var hasLast = false; @@ -129,7 +129,7 @@ async Task> Core() } } - return Task.FromResult(new Maybe()); + return new ValueTask>(new Maybe()); } private static async Task> TryGetLast(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 4d558ab05a..d7964a3e66 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -93,19 +93,19 @@ public Task> ToListAsync(CancellationToken cancellationToken) return Task.FromResult(res); } - public Task> TryGetElementAsync(int index, CancellationToken cancellationToken) + public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) { if ((uint)index < (uint)(_end - _start)) { - return Task.FromResult(new Maybe(_start + index)); + return new ValueTask>(new Maybe(_start + index)); } - return Task.FromResult(new Maybe()); + return new ValueTask>(new Maybe()); } - public Task> TryGetFirstAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(_start)); + public ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) => new ValueTask>(new Maybe(_start)); - public Task> TryGetLastAsync(CancellationToken cancellationToken) => Task.FromResult(new Maybe(_end - 1)); + public ValueTask> TryGetLastAsync(CancellationToken cancellationToken) => new ValueTask>(new Maybe(_end - 1)); protected override async ValueTask MoveNextCore() { From 6f9f24ef8c16f1f7a95fef9e7ce851ed926582f4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 15 Nov 2018 11:17:07 -0800 Subject: [PATCH 537/862] Simplify some code. --- Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index f1d15aeaf5..988b5c3c6c 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -141,7 +141,7 @@ public Enumerator(DisposeCounter disposeCounter) public ValueTask DisposeAsync() { _disposeCounter.DisposeCount++; - return new ValueTask(Task.FromResult(true)); + return default; } public ValueTask MoveNextAsync() From 568e78fee421e57bbff9d8e789cc7ce77ee06560 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 15 Nov 2018 11:17:20 -0800 Subject: [PATCH 538/862] Implement Average overloads with selector. --- .../Linq/Operators/Average.Generated.cs | 80 +- .../Linq/Operators/Average.Generated.tt | 8 +- .../System/Linq/Operators/Average.cs | 750 +++++++++++++++++- 3 files changed, 750 insertions(+), 88 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 82190d77cf..e388ae5d42 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -33,7 +33,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -43,7 +43,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -53,7 +53,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -63,7 +63,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -89,7 +89,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -99,7 +99,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -109,7 +109,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -119,7 +119,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -145,7 +145,7 @@ public static Task AverageAsync(this IAsyncEnumerable s if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -155,7 +155,7 @@ public static Task AverageAsync(this IAsyncEnumerable s if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -165,7 +165,7 @@ public static Task AverageAsync(this IAsyncEnumerable s if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -175,7 +175,7 @@ public static Task AverageAsync(this IAsyncEnumerable s if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -201,7 +201,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -211,7 +211,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -221,7 +221,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -231,7 +231,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -257,7 +257,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -267,7 +267,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -277,7 +277,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -287,7 +287,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -313,7 +313,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -323,7 +323,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -333,7 +333,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -343,7 +343,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -369,7 +369,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -379,7 +379,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -389,7 +389,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -399,7 +399,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -425,7 +425,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -435,7 +435,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -445,7 +445,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -455,7 +455,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -481,7 +481,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -491,7 +491,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -501,7 +501,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -511,7 +511,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source) @@ -537,7 +537,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) @@ -547,7 +547,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) @@ -557,7 +557,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -567,7 +567,7 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index b8cd9612b8..826d82e0a6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -58,7 +58,7 @@ foreach (var o in os) if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) @@ -68,7 +68,7 @@ foreach (var o in os) if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector) @@ -78,7 +78,7 @@ foreach (var o in os) if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(CancellationToken.None); + return AverageCore(source, selector, CancellationToken.None); } public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) @@ -88,7 +88,7 @@ foreach (var o in os) if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return source.Select(selector).AverageAsync(cancellationToken); + return AverageCore(source, selector, cancellationToken); } <# diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index 1a74989598..c1974d9179 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -40,6 +40,66 @@ private static async Task AverageCore(this IAsyncEnumerable source, } } + private static async Task AverageCore(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += selector(e.Current); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = await selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -51,7 +111,415 @@ private static async Task AverageCore(this IAsyncEnumerable source, var v = e.Current; if (v.HasValue) { - long sum = v.GetValueOrDefault(); + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } + + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = selector(e.Current); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } + + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } + + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += selector(e.Current); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = await selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } + + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = selector(e.Current); + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } + + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } + + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = e.Current; + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + // There is an opportunity to short-circuit here, in that if e.Current is + // ever NaN then the result will always be NaN. Assuming that this case is + // rare enough that not checking is the better approach generally. + sum += e.Current; + ++count; + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = selector(e.Current); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + // There is an opportunity to short-circuit here, in that if e.Current is + // ever NaN then the result will always be NaN. Assuming that this case is + // rare enough that not checking is the better approach generally. + sum += selector(e.Current); + ++count; + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = await selector(e.Current).ConfigureAwait(false); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + // There is an opportunity to short-circuit here, in that if e.Current is + // ever NaN then the result will always be NaN. Assuming that this case is + // rare enough that not checking is the better approach generally. + sum += await selector(e.Current).ConfigureAwait(false); + ++count; + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); long count = 1; checked { @@ -66,7 +534,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, } } - return (double)sum / count; + return sum / count; } } } @@ -78,37 +546,45 @@ private static async Task AverageCore(this IAsyncEnumerable source, return null; } - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = e.Current; - long count = 1; - checked + while (await e.MoveNextAsync().ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var v = selector(e.Current); + if (v.HasValue) { - sum += e.Current; - ++count; + var sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; } } - - return (double)sum / count; } finally { await e.DisposeAsync().ConfigureAwait(false); } + + return null; } - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -116,7 +592,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + var v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { var sum = v.GetValueOrDefault(); @@ -125,7 +601,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can { while (await e.MoveNextAsync().ConfigureAwait(false)) { - v = e.Current; + v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -134,7 +610,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can } } - return (double)sum / count; + return sum / count; } } } @@ -146,7 +622,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can return null; } - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -157,18 +633,15 @@ private static async Task AverageCore(IAsyncEnumerable source, C throw Error.NoElements(); } - var sum = e.Current; + double sum = e.Current; long count = 1; while (await e.MoveNextAsync().ConfigureAwait(false)) { - // There is an opportunity to short-circuit here, in that if e.Current is - // ever NaN then the result will always be NaN. Assuming that this case is - // rare enough that not checking is the better approach generally. sum += e.Current; ++count; } - return sum / count; + return (float)(sum / count); } finally { @@ -176,7 +649,61 @@ private static async Task AverageCore(IAsyncEnumerable source, C } } - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = selector(e.Current); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += selector(e.Current); + ++count; + } + + return (float)(sum / count); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = await selector(e.Current).ConfigureAwait(false); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current).ConfigureAwait(false); + ++count; + } + + return (float)(sum / count); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -187,7 +714,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C var v = e.Current; if (v.HasValue) { - var sum = v.GetValueOrDefault(); + double sum = v.GetValueOrDefault(); long count = 1; checked { @@ -202,7 +729,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C } } - return sum / count; + return (float)(sum / count); } } } @@ -214,34 +741,45 @@ private static async Task AverageCore(IAsyncEnumerable source, C return null; } - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - double sum = e.Current; - long count = 1; while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += e.Current; - ++count; - } + var v = selector(e.Current); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } - return (float)(sum / count); + return (float)(sum / count); + } + } } finally { await e.DisposeAsync().ConfigureAwait(false); } + + return null; } - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -249,7 +787,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + var v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { double sum = v.GetValueOrDefault(); @@ -258,7 +796,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can { while (await e.MoveNextAsync().ConfigureAwait(false)) { - v = e.Current; + v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -306,6 +844,60 @@ private static async Task AverageCore(IAsyncEnumerable source, } } + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = selector(e.Current); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += selector(e.Current); + ++count; + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = await selector(e.Current).ConfigureAwait(false); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current).ConfigureAwait(false); + ++count; + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -340,5 +932,75 @@ private static async Task AverageCore(IAsyncEnumerable source, return null; } + + private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = selector(e.Current); + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } + + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } } From d596d9f6d8532e891424b5a758aeb3765155dcc6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 16 Nov 2018 18:01:02 -0800 Subject: [PATCH 539/862] Adding "deep cancellation" API surface predicated by a NO_DEEP_CANCELLATION symbol. --- .../System/Linq/AsyncIterator.Opt.cs | 15 + .../System/Linq/IOrderedAsyncEnumerable.cs | 5 + .../System/Linq/Operators/Aggregate.cs | 112 +++++ .../System/Linq/Operators/All.cs | 34 ++ .../System/Linq/Operators/Any.cs | 34 ++ .../Linq/Operators/Average.Generated.cs | 120 +++++ .../Linq/Operators/Average.Generated.tt | 12 + .../System/Linq/Operators/Average.cs | 351 ++++++++++++++ .../System/Linq/Operators/Count.cs | 41 ++ .../System/Linq/Operators/First.cs | 22 + .../System/Linq/Operators/FirstOrDefault.cs | 47 ++ .../System/Linq/Operators/GroupBy.cs | 394 +++++++++++++++ .../System/Linq/Operators/GroupJoin.cs | 132 +++++ .../System/Linq/Operators/Join.cs | 165 +++++++ .../System/Linq/Operators/Last.cs | 21 + .../System/Linq/Operators/LastOrDefault.cs | 56 +++ .../System/Linq/Operators/LongCount.cs | 41 ++ .../System/Linq/Operators/Lookup.cs | 127 +++++ .../System/Linq/Operators/Max.Generic.cs | 67 +++ .../System/Linq/Operators/Max.Primitive.cs | 455 ++++++++++++++++++ .../System/Linq/Operators/Max.cs | 12 + .../System/Linq/Operators/Min.Generic.cs | 67 +++ .../System/Linq/Operators/Min.Primitive.cs | 393 +++++++++++++++ .../System/Linq/Operators/Min.cs | 12 + .../System/Linq/Operators/MinMax.Generated.cs | 240 +++++++++ .../System/Linq/Operators/MinMax.Generated.tt | 12 + .../System/Linq/Operators/OrderBy.cs | 102 +++- .../Linq/Operators/OrderedAsyncEnumerable.cs | 86 +++- .../System/Linq/Operators/Select.cs | 285 +++++++++++ .../System/Linq/Operators/SelectMany.cs | 453 +++++++++++++++++ .../System/Linq/Operators/Single.cs | 46 ++ .../System/Linq/Operators/SingleOrDefault.cs | 46 ++ .../System/Linq/Operators/SkipWhile.cs | 188 ++++++++ .../System/Linq/Operators/Sum.Generated.cs | 382 +++++++++++++++ .../System/Linq/Operators/Sum.Generated.tt | 53 ++ .../System/Linq/Operators/TakeWhile.cs | 163 +++++++ .../System/Linq/Operators/ToDictionary.cs | 80 +++ .../System/Linq/Operators/ToLookup.cs | 59 +++ .../System/Linq/Operators/Where.cs | 174 +++++++ .../System/Linq/Operators/Zip.cs | 88 ++++ 40 files changed, 5178 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs index e6d2ecf616..ae18f4be44 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.Opt.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -19,6 +20,13 @@ public virtual IAsyncEnumerable Select(Func(this, selector); } +#if !NO_DEEP_CANCELLATION + public virtual IAsyncEnumerable Select(Func> selector) + { + return new AsyncEnumerable.SelectEnumerableAsyncIteratorWithTaskAndCancellation(this, selector); + } +#endif + public virtual IAsyncEnumerable Where(Func predicate) { return new AsyncEnumerable.WhereEnumerableAsyncIterator(this, predicate); @@ -28,5 +36,12 @@ public virtual IAsyncEnumerable Where(Func> pr { return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTask(this, predicate); } + +#if !NO_DEEP_CANCELLATION + public virtual IAsyncEnumerable Where(Func> predicate) + { + return new AsyncEnumerable.WhereEnumerableAsyncIteratorWithTaskAndCancellation(this, predicate); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs index 706b4ef784..26d0b1ab7e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IOrderedAsyncEnumerable.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -11,5 +12,9 @@ public interface IOrderedAsyncEnumerable : IAsyncEnumerable CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending); IOrderedAsyncEnumerable CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending); + +#if !NO_DEEP_CANCELLATION + IOrderedAsyncEnumerable CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending); +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 05e2dd2927..b70c1775a6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -50,6 +50,18 @@ public static Task AggregateAsync(this IAsyncEnumerable AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + + return AggregateCore(source, accumulator, cancellationToken); + } +#endif + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) { if (source == null) @@ -90,6 +102,18 @@ public static Task AggregateAsync(this IAsync return AggregateCore(source, seed, accumulator, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + + return AggregateCore(source, seed, accumulator, cancellationToken); + } +#endif + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) { if (source == null) @@ -138,6 +162,20 @@ public static Task AggregateAsync(this I return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); + } +#endif + private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { var acc = seed; @@ -206,6 +244,29 @@ private static async Task AggregateCore(IAsyncEnumera return acc; } +#if !NO_DEEP_CANCELLATION + private static async Task AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) + { + var acc = seed; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return acc; + } +#endif + private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { var acc = seed; @@ -227,6 +288,29 @@ private static async Task AggregateCore( return await resultSelector(acc).ConfigureAwait(false); } +#if !NO_DEEP_CANCELLATION + private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + { + var acc = seed; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return await resultSelector(acc, cancellationToken).ConfigureAwait(false); + } +#endif + private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -252,5 +336,33 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var acc = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + } + + return acc; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 4629f5cfa6..cea2a2104c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -50,6 +50,18 @@ public static Task AllAsync(this IAsyncEnumerable source return AllCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return AllCore(source, predicate, cancellationToken); + } +#endif + private static async Task AllCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -89,5 +101,27 @@ private static async Task AllCore(IAsyncEnumerable sourc return true; } + +#if !NO_DEEP_CANCELLATION + private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (!await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + return false; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return true; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 2744e8864c..eecd57d415 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -66,6 +66,18 @@ public static Task AnyAsync(this IAsyncEnumerable source return AnyCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return AnyCore(source, predicate, cancellationToken); + } +#endif + private static async Task AnyCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -119,5 +131,27 @@ private static async Task AnyCore(IAsyncEnumerable sourc return false; } + +#if !NO_DEEP_CANCELLATION + private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + return true; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return false; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index e388ae5d42..7937b617c8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -66,6 +66,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -122,6 +134,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -178,6 +202,18 @@ public static Task AverageAsync(this IAsyncEnumerable s return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -234,6 +270,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -290,6 +338,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -346,6 +406,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -402,6 +474,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -458,6 +542,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -514,6 +610,18 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + public static Task AverageAsync(this IAsyncEnumerable source) { if (source == null) @@ -570,5 +678,17 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 826d82e0a6..b7ebbf824c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -91,6 +91,18 @@ foreach (var o in os) return AverageCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return AverageCore(source, selector, cancellationToken); + } +#endif + <# } #> diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index c1974d9179..76c20af694 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -100,6 +100,38 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -214,6 +246,46 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -304,6 +376,38 @@ private static async Task AverageCore(IAsyncEnumerable } } +#if !NO_DEEP_CANCELLATION + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -418,6 +522,46 @@ private static async Task AverageCore(IAsyncEnumerable return null; } +#if !NO_DEEP_CANCELLATION + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -508,6 +652,38 @@ private static async Task AverageCore(IAsyncEnumerable } } +#if !NO_DEEP_CANCELLATION + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + // There is an opportunity to short-circuit here, in that if e.Current is + // ever NaN then the result will always be NaN. Assuming that this case is + // rare enough that not checking is the better approach generally. + sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); + ++count; + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -622,6 +798,46 @@ private static async Task AverageCore(IAsyncEnumerable return null; } +#if !NO_DEEP_CANCELLATION + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -703,6 +919,35 @@ private static async Task AverageCore(IAsyncEnumerable } } +#if !NO_DEEP_CANCELLATION + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); + ++count; + } + + return (float)(sum / count); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -817,6 +1062,46 @@ private static async Task AverageCore(IAsyncEnumerable return null; } +#if !NO_DEEP_CANCELLATION + private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -898,6 +1183,35 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); + ++count; + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif + private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -1002,5 +1316,42 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + var sum = v.GetValueOrDefault(); + long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index a00ea3cff8..e9ff832864 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -67,6 +67,18 @@ public static Task CountAsync(this IAsyncEnumerable sourc return CountCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return CountCore(source, predicate, cancellationToken); + } +#endif + private static Task CountCore(IAsyncEnumerable source, CancellationToken cancellationToken) { switch (source) @@ -159,5 +171,34 @@ private static async Task CountCore(this IAsyncEnumerable return count; } + +#if !NO_DEEP_CANCELLATION + private static async Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var count = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + { + checked + { + count++; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index c8320beba3..6ca57a3175 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -66,6 +66,18 @@ public static Task FirstAsync(this IAsyncEnumerable s return FirstCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return FirstCore(source, predicate, cancellationToken); + } +#endif + private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); @@ -86,5 +98,15 @@ private static async Task FirstCore(IAsyncEnumerable return first.HasValue ? first.Value : throw Error.NoElements(); } + +#if !NO_DEEP_CANCELLATION + + private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : throw Error.NoElements(); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 4d082ab7c2..b516e800bb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -66,6 +66,18 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return FirstOrDefaultCore(source, predicate, cancellationToken); + } +#endif + private static async Task FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); @@ -87,6 +99,15 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< return first.HasValue ? first.Value : default; } +#if !NO_DEEP_CANCELLATION + private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : default; + } +#endif + private static ValueTask> TryGetFirst(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) @@ -174,5 +195,31 @@ private static async Task> TryGetFirst(IAsyncEnumerable< return new Maybe(); } + +#if !NO_DEEP_CANCELLATION + private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = e.Current; + + if (await predicate(value, cancellationToken).ConfigureAwait(false)) + { + return new Maybe(value); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return new Maybe(); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index ea37b78e0a..58c405c4e5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -41,6 +41,18 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, comparer: null); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); + } +#endif + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) @@ -51,6 +63,18 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer); + } +#endif + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) @@ -87,6 +111,20 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, comparer: null); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + + return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); + } +#endif + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { if (source == null) @@ -99,6 +137,20 @@ public static IAsyncEnumerable> GroupBy(source, keySelector, elementSelector, comparer); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + + return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer); + } +#endif + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) { if (source == null) @@ -135,6 +187,20 @@ public static IAsyncEnumerable GroupBy(this IAs return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); + } +#endif + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -147,6 +213,20 @@ public static IAsyncEnumerable GroupBy(this IAs return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer); + } +#endif + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) { if (source == null) @@ -189,6 +269,22 @@ public static IAsyncEnumerable GroupBy(keySelector, elementSelector, comparer: null).Select(g => resultSelector(g.Key, g)); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return source.GroupBy(keySelector, elementSelector, comparer: null).Select((g, ct) => resultSelector(g.Key, g, ct)); + } +#endif + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -203,6 +299,22 @@ public static IAsyncEnumerable GroupBy resultSelector(g.Key, g)); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return source.GroupBy(keySelector, elementSelector, comparer).Select((g, ct) => resultSelector(g.Key, g, ct)); + } +#endif + internal sealed class GroupedResultAsyncEnumerable : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable _source; @@ -389,6 +501,101 @@ async Task Core() } } +#if !NO_DEEP_CANCELLATION + internal sealed class GroupedResultAsyncEnumerableWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider + { + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly Func, CancellationToken, ValueTask> _resultSelector; + private readonly IEqualityComparer _comparer; + + private Internal.LookupWithTask _lookup; + private IAsyncEnumerator _enumerator; + + public GroupedResultAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(resultSelector != null); + + _source = source; + _keySelector = keySelector; + _resultSelector = resultSelector; + _comparer = comparer; + } + + public override AsyncIteratorBase Clone() + { + return new GroupedResultAsyncEnumerableWithTaskAndCancellation(_source, _keySelector, _resultSelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); + _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArray(_resultSelector, cancellationToken).ConfigureAwait(false); + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToList(_resultSelector, cancellationToken).ConfigureAwait(false); + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return TaskExt.MinusOne; + } + + return Core(); + + async Task Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + } +#endif + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; @@ -575,6 +782,101 @@ async Task Core() } } +#if !NO_DEEP_CANCELLATION + internal sealed class GroupedAsyncEnumerableWithTaskAndCancellation : AsyncIterator>, IAsyncIListProvider> + { + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly Func> _elementSelector; + private readonly IEqualityComparer _comparer; + + private Internal.LookupWithTask _lookup; + private IEnumerator> _enumerator; + + public GroupedAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(elementSelector != null); + + _source = source; + _keySelector = keySelector; + _elementSelector = elementSelector; + _comparer = comparer; + } + + public override AsyncIteratorBase> Clone() + { + return new GroupedAsyncEnumerableWithTaskAndCancellation(_source, _keySelector, _elementSelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); + _enumerator = _lookup.GetEnumerator(); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (_enumerator.MoveNext()) + { + _current = (IAsyncGrouping)_enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + { + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task>> ToListAsync(CancellationToken cancellationToken) + { + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToListAsync(cancellationToken).ConfigureAwait(false); + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return TaskExt.MinusOne; + } + + return Core(); + + async Task Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + } +#endif + internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; @@ -754,5 +1056,97 @@ async Task Core() } } } + +#if !NO_DEEP_CANCELLATION + internal sealed class GroupedAsyncEnumerableWithTaskAndCancellation : AsyncIterator>, IAsyncIListProvider> + { + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly IEqualityComparer _comparer; + + private Internal.LookupWithTask _lookup; + private IEnumerator> _enumerator; + + public GroupedAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + + _source = source; + _keySelector = keySelector; + _comparer = comparer; + } + + public override AsyncIteratorBase> Clone() + { + return new GroupedAsyncEnumerableWithTaskAndCancellation(_source, _keySelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); + _enumerator = _lookup.GetEnumerator(); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (_enumerator.MoveNext()) + { + _current = (IAsyncGrouping)_enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + { + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); + } + + public async Task>> ToListAsync(CancellationToken cancellationToken) + { + IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToListAsync(cancellationToken).ConfigureAwait(false); + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return TaskExt.MinusOne; + } + + return Core(); + + async Task Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 9ab3b4b9f6..e3b1abf75e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -58,6 +58,24 @@ public static IAsyncEnumerable GroupJoin return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) + { + if (outer == null) + throw Error.ArgumentNull(nameof(outer)); + if (inner == null) + throw Error.ArgumentNull(nameof(inner)); + if (outerKeySelector == null) + throw Error.ArgumentNull(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw Error.ArgumentNull(nameof(innerKeySelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new GroupJoinAsyncEnumerableWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + } +#endif + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -74,6 +92,24 @@ public static IAsyncEnumerable GroupJoin return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw Error.ArgumentNull(nameof(outer)); + if (inner == null) + throw Error.ArgumentNull(nameof(inner)); + if (outerKeySelector == null) + throw Error.ArgumentNull(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw Error.ArgumentNull(nameof(innerKeySelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new GroupJoinAsyncEnumerableWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + } +#endif + private sealed class GroupJoinAsyncEnumerable : IAsyncEnumerable { private readonly IEqualityComparer _comparer; @@ -261,5 +297,101 @@ public async ValueTask MoveNextAsync() public ValueTask DisposeAsync() => _outer.DisposeAsync(); } } + +#if !NO_DEEP_CANCELLATION + private sealed class GroupJoinAsyncEnumerableWithTaskAndCancellation : IAsyncEnumerable + { + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _inner; + private readonly Func> _innerKeySelector; + private readonly IAsyncEnumerable _outer; + private readonly Func> _outerKeySelector; + private readonly Func, CancellationToken, ValueTask> _resultSelector; + + public GroupJoinAsyncEnumerableWithTaskAndCancellation( + IAsyncEnumerable outer, + IAsyncEnumerable inner, + Func> outerKeySelector, + Func> innerKeySelector, + Func, CancellationToken, ValueTask> resultSelector, + IEqualityComparer comparer) + { + _outer = outer; + _inner = inner; + _outerKeySelector = outerKeySelector; + _innerKeySelector = innerKeySelector; + _resultSelector = resultSelector; + _comparer = comparer; + } + + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) + => new GroupJoinAsyncEnumeratorWithTask( + _outer.GetAsyncEnumerator(cancellationToken), + _inner, + _outerKeySelector, + _innerKeySelector, + _resultSelector, + _comparer, + cancellationToken); + + private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator + { + private readonly IEqualityComparer _comparer; + private readonly IAsyncEnumerable _inner; + private readonly Func> _innerKeySelector; + private readonly IAsyncEnumerator _outer; + private readonly Func> _outerKeySelector; + private readonly Func, CancellationToken, ValueTask> _resultSelector; + private readonly CancellationToken _cancellationToken; + + private Internal.LookupWithTask _lookup; + + public GroupJoinAsyncEnumeratorWithTask( + IAsyncEnumerator outer, + IAsyncEnumerable inner, + Func> outerKeySelector, + Func> innerKeySelector, + Func, CancellationToken, ValueTask> resultSelector, + IEqualityComparer comparer, + CancellationToken cancellationToken) + { + _outer = outer; + _inner = inner; + _outerKeySelector = outerKeySelector; + _innerKeySelector = innerKeySelector; + _resultSelector = resultSelector; + _comparer = comparer; + _cancellationToken = cancellationToken; + } + + public async ValueTask MoveNextAsync() + { + // nothing to do + if (!await _outer.MoveNextAsync().ConfigureAwait(false)) + { + return false; + } + + if (_lookup == null) + { + _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); + } + + var item = _outer.Current; + + var outerKey = await _outerKeySelector(item, _cancellationToken).ConfigureAwait(false); + var inner = _lookup[outerKey].ToAsyncEnumerable(); + + Current = await _resultSelector(item, inner, _cancellationToken).ConfigureAwait(false); + + return true; + } + + public TResult Current { get; private set; } + + public ValueTask DisposeAsync() => _outer.DisposeAsync(); + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 6918f7cb0d..fd2466d2da 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -59,6 +59,24 @@ public static IAsyncEnumerable Join(this return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) + { + if (outer == null) + throw Error.ArgumentNull(nameof(outer)); + if (inner == null) + throw Error.ArgumentNull(nameof(inner)); + if (outerKeySelector == null) + throw Error.ArgumentNull(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw Error.ArgumentNull(nameof(innerKeySelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new JoinAsyncIteratorWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + } +#endif + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -75,6 +93,24 @@ public static IAsyncEnumerable Join(this return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw Error.ArgumentNull(nameof(outer)); + if (inner == null) + throw Error.ArgumentNull(nameof(inner)); + if (outerKeySelector == null) + throw Error.ArgumentNull(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw Error.ArgumentNull(nameof(innerKeySelector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new JoinAsyncIteratorWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + } +#endif + internal sealed class JoinAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _outer; @@ -328,5 +364,134 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + internal sealed class JoinAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly IAsyncEnumerable _outer; + private readonly IAsyncEnumerable _inner; + private readonly Func> _outerKeySelector; + private readonly Func> _innerKeySelector; + private readonly Func> _resultSelector; + private readonly IEqualityComparer _comparer; + + private IAsyncEnumerator _outerEnumerator; + + public JoinAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + { + Debug.Assert(outer != null); + Debug.Assert(inner != null); + Debug.Assert(outerKeySelector != null); + Debug.Assert(innerKeySelector != null); + Debug.Assert(resultSelector != null); + + _outer = outer; + _inner = inner; + _outerKeySelector = outerKeySelector; + _innerKeySelector = innerKeySelector; + _resultSelector = resultSelector; + _comparer = comparer; + } + + public override AsyncIteratorBase Clone() + { + return new JoinAsyncIteratorWithTaskAndCancellation(_outer, _inner, _outerKeySelector, _innerKeySelector, _resultSelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_outerEnumerator != null) + { + await _outerEnumerator.DisposeAsync().ConfigureAwait(false); + _outerEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + // State machine vars + private Internal.LookupWithTask _lookup; + private int _count; + private TInner[] _elements; + private int _index; + private TOuter _item; + private int _mode; + + private const int State_If = 1; + private const int State_DoLoop = 2; + private const int State_For = 3; + private const int State_While = 4; + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _outerEnumerator = _outer.GetAsyncEnumerator(_cancellationToken); + _mode = State_If; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (_mode) + { + case State_If: + if (await _outerEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); + + if (_lookup.Count != 0) + { + _mode = State_DoLoop; + goto case State_DoLoop; + } + } + + break; + + case State_DoLoop: + _item = _outerEnumerator.Current; + var g = _lookup.GetGrouping(await _outerKeySelector(_item, _cancellationToken).ConfigureAwait(false), create: false); + if (g != null) + { + _count = g._count; + _elements = g._elements; + _index = 0; + _mode = State_For; + goto case State_For; + } + + // advance to while + _mode = State_While; + goto case State_While; + + case State_For: + _current = await _resultSelector(_item, _elements[_index], _cancellationToken).ConfigureAwait(false); + _index++; + if (_index == _count) + { + _mode = State_While; + } + + return true; + + case State_While: + var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); + if (hasNext) + { + goto case State_DoLoop; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 21b16a1980..aa56a914f7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -66,6 +66,18 @@ public static Task LastAsync(this IAsyncEnumerable so return LastCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return LastCore(source, predicate, cancellationToken); + } +#endif + private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); @@ -86,5 +98,14 @@ private static async Task LastCore(IAsyncEnumerable s return last.HasValue ? last.Value : throw Error.NoElements(); } + +#if !NO_DEEP_CANCELLATION + private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : throw Error.NoElements(); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 06f8161ac2..93ac785c87 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -66,6 +66,18 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return LastOrDefaultCore(source, predicate, cancellationToken); + } +#endif + private static async Task LastOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); @@ -87,6 +99,15 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : default; + } +#endif + private static ValueTask> TryGetLast(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) @@ -197,5 +218,40 @@ private static async Task> TryGetLast(IAsyncEnumerable(); } + +#if !NO_DEEP_CANCELLATION + private static async Task> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var last = default(TSource); + var hasLast = false; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = e.Current; + + if (await predicate(value, cancellationToken).ConfigureAwait(false)) + { + hasLast = true; + last = value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + if (hasLast) + { + return new Maybe(last); + } + + return new Maybe(); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index e09d3509e0..8af207fe35 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -66,6 +66,18 @@ public static Task LongCountAsync(this IAsyncEnumerable return LongCountCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return LongCountCore(source, predicate, cancellationToken); + } +#endif + private static async Task LongCountCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var count = 0L; @@ -143,5 +155,34 @@ private static async Task LongCountCore(IAsyncEnumerable return count; } + +#if !NO_DEEP_CANCELLATION + private static async Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var count = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + { + checked + { + count++; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return count; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index cac5b05abe..ec11234db2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -398,6 +398,37 @@ internal static async Task> CreateAsync( return lookup; } +#if !NO_DEEP_CANCELLATION + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + Debug.Assert(elementSelector != null); + + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + var group = lookup.GetGrouping(key, create: true); + + var element = await elementSelector(enu.Current, cancellationToken).ConfigureAwait(false); + group.Add(element); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } +#endif + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { Debug.Assert(source != null); @@ -423,6 +454,33 @@ internal static async Task> CreateAsync(IAsyncEnu return lookup; } +#if !NO_DEEP_CANCELLATION + internal static async Task> CreateAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } +#endif + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { var lookup = new LookupWithTask(comparer); @@ -448,6 +506,33 @@ internal static async Task> CreateForJoinAsync(IA return lookup; } +#if !NO_DEEP_CANCELLATION + internal static async Task> CreateForJoinAsync(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var lookup = new LookupWithTask(comparer); + + var enu = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + if (key != null) + { + lookup.GetGrouping(key, create: true).Add(enu.Current); + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return lookup; + } +#endif + internal Grouping GetGrouping(TKey key, bool create) { var hashCode = InternalGetHashCode(key); @@ -518,6 +603,27 @@ internal async Task ToArray(Func ToArray(Func, CancellationToken, ValueTask> resultSelector, CancellationToken cancellationToken) + { + var array = new TResult[Count]; + var index = 0; + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable(), cancellationToken).ConfigureAwait(false); + ++index; + } while (g != _lastGrouping); + } + + return array; + } +#endif + internal async Task> ToList(Func, ValueTask> resultSelector) { var list = new List(Count); @@ -537,6 +643,27 @@ internal async Task> ToList(Func> ToList(Func, CancellationToken, ValueTask> resultSelector, CancellationToken cancellationToken) + { + var list = new List(Count); + var g = _lastGrouping; + if (g != null) + { + do + { + g = g._next; + g.Trim(); + + var result = await resultSelector(g._key, g._elements.ToAsyncEnumerable(), cancellationToken).ConfigureAwait(false); + list.Add(result); + } while (g != _lastGrouping); + } + + return list; + } +#endif + private void Resize() { var newSize = checked((Count * 2) + 1); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs index 73541c5e00..2682b9f608 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs @@ -204,5 +204,72 @@ private static async Task MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TResult); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs index 048152a33d..cce4651d80 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs @@ -1368,5 +1368,460 @@ private static async Task MaxCore(IAsyncEnumerable so return value; } + +#if !NO_DEEP_CANCELLATION + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive + // or mostly-positive integer values are quite common in real-world + // uses, it's only been done in this direction for int? and long?. + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + // As described in a comment on Min(IAsyncEnumerable) NaN is ordered + // less than all other values. We need to do explicit checks to ensure this, but + // once we've found a value that is not NaN we need no longer worry about it, + // so first loop until such a value is found (or not, as the case may be). + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index d026b2d4b5..7d661d503c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -65,5 +65,17 @@ public static Task MaxAsync(this IAsyncEnumerable MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs index 8279a6c379..e7bf900793 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs @@ -204,5 +204,72 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var comparer = Comparer.Default; + var value = default(TResult); + if (value == null) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + else + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + return value; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs index ac848e7de1..bf21c3aca0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs @@ -1182,5 +1182,398 @@ private static async Task MinCore(IAsyncEnumerable so return value; } + +#if !NO_DEEP_CANCELLATION + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + int? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + long? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + else if (float.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + float? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (float.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else if (double.IsNaN(x)) + { + return x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + double? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else if (double.IsNaN(x)) + { + return cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal value; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + + private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + decimal? value = null; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 47a241d29a..f30f106df3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -65,5 +65,17 @@ public static Task MinAsync(this IAsyncEnumerable MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 58009b2d3a..851430cdf3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -66,6 +66,18 @@ public static Task MaxAsync(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -122,6 +134,18 @@ public static Task MaxAsync(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -178,6 +202,18 @@ public static Task MaxAsync(this IAsyncEnumerable source return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -234,6 +270,18 @@ public static Task MaxAsync(this IAsyncEnumerable source return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -290,6 +338,18 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -346,6 +406,18 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -402,6 +474,18 @@ public static Task MaxAsync(this IAsyncEnumerable sour return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -458,6 +542,18 @@ public static Task MaxAsync(this IAsyncEnumerable sour return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -514,6 +610,18 @@ public static Task MaxAsync(this IAsyncEnumerable sou return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MaxAsync(this IAsyncEnumerable source) { if (source == null) @@ -570,6 +678,18 @@ public static Task MaxAsync(this IAsyncEnumerable sou return MaxCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MaxCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -626,6 +746,18 @@ public static Task MinAsync(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -682,6 +814,18 @@ public static Task MinAsync(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -738,6 +882,18 @@ public static Task MinAsync(this IAsyncEnumerable source return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -794,6 +950,18 @@ public static Task MinAsync(this IAsyncEnumerable source return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -850,6 +1018,18 @@ public static Task MinAsync(this IAsyncEnumerable sourc return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -906,6 +1086,18 @@ public static Task MinAsync(this IAsyncEnumerable sourc return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -962,6 +1154,18 @@ public static Task MinAsync(this IAsyncEnumerable sour return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -1018,6 +1222,18 @@ public static Task MinAsync(this IAsyncEnumerable sour return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -1074,6 +1290,18 @@ public static Task MinAsync(this IAsyncEnumerable sou return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + public static Task MinAsync(this IAsyncEnumerable source) { if (source == null) @@ -1130,5 +1358,17 @@ public static Task MinAsync(this IAsyncEnumerable sou return MinCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return MinCore(source, selector, cancellationToken); + } +#endif + } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index e07c216a8d..1361103dde 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -78,6 +78,18 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return <#=m#>Core(source, selector, cancellationToken); + } +#endif + <# } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index e41dc7e9e6..436830b415 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -16,7 +17,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return OrderBy(source, keySelector, comparer: null); + return new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: false, parent: null); } public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) @@ -26,7 +27,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return OrderBy(source, keySelector, comparer: null); + return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: false, parent: null); } public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) @@ -38,6 +39,7 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) @@ -48,6 +50,18 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); } +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: false, parent: null); + } +#endif + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) { if (source == null) @@ -55,7 +69,7 @@ public static IOrderedAsyncEnumerable OrderByDescending( if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.OrderByDescending(keySelector, comparer: null); + return new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: true, parent: null); } public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) @@ -65,8 +79,20 @@ public static IOrderedAsyncEnumerable OrderByDescending( if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.OrderByDescending(keySelector, comparer: null); + return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: true, parent: null); + } + +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: true, parent: null); } +#endif public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { @@ -88,6 +114,18 @@ public static IOrderedAsyncEnumerable OrderByDescending( return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); } +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: true, parent: null); + } +#endif + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector) { if (source == null) @@ -95,7 +133,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.ThenBy(keySelector, Comparer.Default); + return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: false); } public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) @@ -105,9 +143,21 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.ThenBy(keySelector, Comparer.Default); + return source.CreateOrderedEnumerable(keySelector, comparer: default(IComparer), descending: false); } +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: false); + } +#endif + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) @@ -128,6 +178,18 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); + } +#endif + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector) { if (source == null) @@ -135,7 +197,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.CreateOrderedEnumerable(keySelector, Comparer.Default, descending: true); + return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: true); } public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) @@ -145,9 +207,21 @@ public static IOrderedAsyncEnumerable ThenByDescending(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return source.CreateOrderedEnumerable(keySelector, Comparer.Default, descending: true); + return source.CreateOrderedEnumerable(keySelector, comparer: default(IComparer), descending: true); } +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: true); + } +#endif + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) @@ -167,5 +241,17 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } + +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 4a744d9df7..0b18381a44 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -28,6 +28,11 @@ IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrdere return new OrderedAsyncEnumerableWithTask(_source, keySelector, comparer, descending, this); } + IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func> keySelector, IComparer comparer, bool descending) + { + return new OrderedAsyncEnumerableWithTaskAndCancellation(_source, keySelector, comparer, descending, this); + } + protected override async ValueTask MoveNextCore() { switch (_state) @@ -37,7 +42,7 @@ protected override async ValueTask MoveNextCore() // REVIEW: If we add selectors with CancellationToken support, we should feed the token to Sort. - var sorter = GetAsyncEnumerableSorter(next: null); + var sorter = GetAsyncEnumerableSorter(next: null, _cancellationToken); _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); _index = 0; @@ -66,7 +71,7 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - internal abstract AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next); + internal abstract AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next, CancellationToken cancellationToken); } internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnumerable @@ -93,13 +98,13 @@ public override AsyncIteratorBase Clone() return new OrderedAsyncEnumerable(_source, _keySelector, _comparer, _descending, _parent); } - internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next) + internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next, CancellationToken cancellationToken) { var sorter = new SyncKeySelectorAsyncEnumerableSorter(_keySelector, _comparer, _descending, next); if (_parent != null) { - return _parent.GetAsyncEnumerableSorter(sorter); + return _parent.GetAsyncEnumerableSorter(sorter, cancellationToken); } return sorter; @@ -130,19 +135,58 @@ public override AsyncIteratorBase Clone() return new OrderedAsyncEnumerableWithTask(_source, _keySelector, _comparer, _descending, _parent); } - internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next) + internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next, CancellationToken cancellationToken) { var sorter = new AsyncKeySelectorAsyncEnumerableSorter(_keySelector, _comparer, _descending, next); if (_parent != null) { - return _parent.GetAsyncEnumerableSorter(sorter); + return _parent.GetAsyncEnumerableSorter(sorter, cancellationToken); } return sorter; } } +#if !NO_DEEP_CANCELLATION + internal sealed class OrderedAsyncEnumerableWithTaskAndCancellation : OrderedAsyncEnumerable + { + private readonly IComparer _comparer; + private readonly bool _descending; + private readonly Func> _keySelector; + private readonly OrderedAsyncEnumerable _parent; + + public OrderedAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + + _source = source; + _keySelector = keySelector; + _comparer = comparer; + _descending = descending; + _parent = parent; + } + + public override AsyncIteratorBase Clone() + { + return new OrderedAsyncEnumerableWithTaskAndCancellation(_source, _keySelector, _comparer, _descending, _parent); + } + + internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next, CancellationToken cancellationToken) + { + var sorter = new AsyncKeySelectorAsyncEnumerableSorterWithCancellation(_keySelector, _comparer, _descending, next, cancellationToken); + + if (_parent != null) + { + return _parent.GetAsyncEnumerableSorter(sorter, cancellationToken); + } + + return sorter; + } + } +#endif + internal abstract class AsyncEnumerableSorter { internal abstract ValueTask ComputeKeys(TElement[] elements, int count); @@ -305,4 +349,34 @@ internal override async ValueTask ComputeKeys(TElement[] elements, int count) } } } + +#if !NO_DEEP_CANCELLATION + internal sealed class AsyncKeySelectorAsyncEnumerableSorterWithCancellation : AsyncEnumerableSorterBase + { + private readonly Func> _keySelector; + private readonly CancellationToken _cancellationToken; + + public AsyncKeySelectorAsyncEnumerableSorterWithCancellation(Func> keySelector, IComparer comparer, bool descending, AsyncEnumerableSorter next, CancellationToken cancellationToken) + : base(comparer, descending, next) + { + _keySelector = keySelector; + _cancellationToken = cancellationToken; + } + + internal override async ValueTask ComputeKeys(TElement[] elements, int count) + { + _keys = new TKey[count]; + + for (var i = 0; i < count; i++) + { + _keys[i] = await _keySelector(elements[i], _cancellationToken).ConfigureAwait(false); + } + + if (_next != null) + { + await _next.ComputeKeys(elements, count).ConfigureAwait(false); + } + } + } +#endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index ddd4a0cc9a..468d77f83e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -57,6 +57,26 @@ public static IAsyncEnumerable Select(this IAsyncEnum return new SelectEnumerableAsyncIteratorWithTask(source, selector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + switch (source) + { + case AsyncIterator iterator: + return iterator.Select(selector); + case IList list: + return new SelectIListIteratorWithTaskAndCancellation(list, selector); + } + + return new SelectEnumerableAsyncIteratorWithTaskAndCancellation(source, selector); + } +#endif + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) { if (source == null) @@ -67,6 +87,18 @@ public static IAsyncEnumerable Select(this IAsyncEnum return new SelectEnumerableWithIndexAsyncIteratorWithTask(source, selector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return new SelectEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(source, selector); + } +#endif + private static Func CombineSelectors(Func selector1, Func selector2) { return x => selector2(selector1(x)); @@ -77,6 +109,13 @@ private static Func> CombineSelectors await selector2(await selector1(x).ConfigureAwait(false)).ConfigureAwait(false); } +#if !NO_DEEP_CANCELLATION + private static Func> CombineSelectors(Func> selector1, Func> selector2) + { + return async (x, ct) => await selector2(await selector1(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false); + } +#endif + internal sealed class SelectEnumerableAsyncIterator : AsyncIterator { private readonly Func _selector; @@ -373,6 +412,69 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + internal sealed class SelectEnumerableAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _selector; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + + public SelectEnumerableAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + _source = source; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new SelectEnumerableAsyncIteratorWithTaskAndCancellation(_source, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + public override IAsyncEnumerable Select(Func> selector) + { + return new SelectEnumerableAsyncIteratorWithTaskAndCancellation(_source, CombineSelectors(_selector, selector)); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = await _selector(_enumerator.Current, _cancellationToken).ConfigureAwait(false); + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + internal sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _selector; @@ -437,6 +539,72 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + internal sealed class SelectEnumerableWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _selector; + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; + private int _index; + + public SelectEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + _source = source; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new SelectEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(_source, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _index = -1; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + + checked + { + _index++; + } + + _current = await _selector(item, _index, _cancellationToken).ConfigureAwait(false); + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + // NB: LINQ to Objects implements IPartition for this. However, it seems incorrect to do so in a trivial // manner where e.g. TryGetLast simply indexes into the list without running the selector for the first n - 1 // elements in order to ensure side-effects. We should consider whether we want to follow this implementation @@ -556,5 +724,122 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + internal sealed class SelectIListIteratorWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider + { + private readonly Func> _selector; + private readonly IList _source; + private IEnumerator _enumerator; + + public SelectIListIteratorWithTaskAndCancellation(IList source, Func> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + _source = source; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new SelectIListIteratorWithTaskAndCancellation(_source, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + _enumerator.Dispose(); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return TaskExt.MinusOne; + } + + return Core(); + + async Task Core() + { + var count = 0; + + foreach (var item in _source) + { + await _selector(item, cancellationToken).ConfigureAwait(false); + + checked + { + count++; + } + } + + return count; + } + } + + public override IAsyncEnumerable Select(Func> selector) + { + return new SelectIListIteratorWithTaskAndCancellation(_source, CombineSelectors(_selector, selector)); + } + + public async Task ToArrayAsync(CancellationToken cancellationToken) + { + var n = _source.Count; + + var res = new TResult[n]; + + for (var i = 0; i < n; i++) + { + res[i] = await _selector(_source[i], cancellationToken).ConfigureAwait(false); + } + + return res; + } + + public async Task> ToListAsync(CancellationToken cancellationToken) + { + var n = _source.Count; + + var res = new List(n); + + for (var i = 0; i < n; i++) + { + res.Add(await _selector(_source[i], cancellationToken).ConfigureAwait(false)); + } + + return res; + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetEnumerator(); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (_enumerator.MoveNext()) + { + _current = await _selector(_enumerator.Current, _cancellationToken).ConfigureAwait(false); + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index b881898a8a..d7d14031f1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -31,6 +31,18 @@ public static IAsyncEnumerable SelectMany(this IAsync return new SelectManyAsyncIteratorWithTask(source, selector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return new SelectManyAsyncIteratorWithTaskAndCancellation(source, selector); + } +#endif + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector) { if (source == null) @@ -51,6 +63,18 @@ public static IAsyncEnumerable SelectMany(this IAsync return new SelectManyWithIndexAsyncIteratorWithTask(source, selector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(source, selector); + } +#endif + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) { if (source == null) @@ -75,6 +99,20 @@ public static IAsyncEnumerable SelectMany(source, selector, resultSelector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new SelectManyAsyncIteratorWithTaskAndCancellation(source, selector, resultSelector); + } +#endif + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) { if (source == null) @@ -99,6 +137,20 @@ public static IAsyncEnumerable SelectMany(source, selector, resultSelector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(source, selector, resultSelector); + } +#endif + private sealed class SelectManyAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -281,6 +333,99 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class SelectManyAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> _selector; + private readonly IAsyncEnumerable _source; + + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; + + public SelectManyAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + _source = source; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new SelectManyAsyncIteratorWithTaskAndCancellation(_source, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; + } + + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); + _mode = State_Source; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (_mode) + { + case State_Source: + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + var inner = await _selector(_sourceEnumerator.Current, _cancellationToken).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); + + _mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _resultEnumerator.Current; + return true; + } + + _mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class SelectManyAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -477,6 +622,106 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class SelectManyAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> _collectionSelector; + private readonly Func> _resultSelector; + private readonly IAsyncEnumerable _source; + + private TSource _currentSource; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; + + public SelectManyAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + { + Debug.Assert(source != null); + Debug.Assert(collectionSelector != null); + Debug.Assert(resultSelector != null); + + _source = source; + _collectionSelector = collectionSelector; + _resultSelector = resultSelector; + } + + public override AsyncIteratorBase Clone() + { + return new SelectManyAsyncIteratorWithTaskAndCancellation(_source, _collectionSelector, _resultSelector); + } + + public override async ValueTask DisposeAsync() + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; + } + + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + + _currentSource = default; + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); + _mode = State_Source; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (_mode) + { + case State_Source: + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + _currentSource = _sourceEnumerator.Current; + var inner = await _collectionSelector(_currentSource, _cancellationToken).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); + + _mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = await _resultSelector(_currentSource, _resultEnumerator.Current, _cancellationToken).ConfigureAwait(false); + return true; + } + + _mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class SelectManyWithIndexAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -689,6 +934,114 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class SelectManyWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> _collectionSelector; + private readonly Func> _resultSelector; + private readonly IAsyncEnumerable _source; + + private TSource _currentSource; + private int _index; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; + + public SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + { + Debug.Assert(source != null); + Debug.Assert(collectionSelector != null); + Debug.Assert(resultSelector != null); + + _source = source; + _collectionSelector = collectionSelector; + _resultSelector = resultSelector; + } + + public override AsyncIteratorBase Clone() + { + return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(_source, _collectionSelector, _resultSelector); + } + + public override async ValueTask DisposeAsync() + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; + } + + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + + _currentSource = default; + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); + _index = -1; + _mode = State_Source; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (_mode) + { + case State_Source: + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + _currentSource = _sourceEnumerator.Current; + + checked + { + _index++; + } + + var inner = await _collectionSelector(_currentSource, _index, _cancellationToken).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); + + _mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = await _resultSelector(_currentSource, _resultEnumerator.Current, _cancellationToken).ConfigureAwait(false); + return true; + } + + _mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class SelectManyWithIndexAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -884,5 +1237,105 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class SelectManyWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private const int State_Source = 1; + private const int State_Result = 2; + + private readonly Func>> _selector; + private readonly IAsyncEnumerable _source; + + private int _index; + private int _mode; + private IAsyncEnumerator _resultEnumerator; + private IAsyncEnumerator _sourceEnumerator; + + public SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + _source = source; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(_source, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + _resultEnumerator = null; + } + + if (_sourceEnumerator != null) + { + await _sourceEnumerator.DisposeAsync().ConfigureAwait(false); + _sourceEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _sourceEnumerator = _source.GetAsyncEnumerator(_cancellationToken); + _index = -1; + _mode = State_Source; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + switch (_mode) + { + case State_Source: + if (await _sourceEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + if (_resultEnumerator != null) + { + await _resultEnumerator.DisposeAsync().ConfigureAwait(false); + } + + checked + { + _index++; + } + + var inner = await _selector(_sourceEnumerator.Current, _index, _cancellationToken).ConfigureAwait(false); + _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); + + _mode = State_Result; + goto case State_Result; + } + break; + + case State_Result: + if (await _resultEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _resultEnumerator.Current; + return true; + } + + _mode = State_Source; + goto case State_Source; // loop + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 090dd2cd7b..3140d3a6a4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -66,6 +66,18 @@ public static Task SingleAsync(this IAsyncEnumerable return SingleCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return SingleCore(source, predicate, cancellationToken); + } +#endif + private static async Task SingleCore(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) @@ -165,5 +177,39 @@ private static async Task SingleCore(IAsyncEnumerable await e.DisposeAsync().ConfigureAwait(false); } } + +#if !NO_DEEP_CANCELLATION + private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var result = e.Current; + + if (await predicate(result, cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + + throw Error.NoElements(); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 102d64f08e..de507c35f6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -66,6 +66,18 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< return SingleOrDefaultCore(source, predicate, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return SingleOrDefaultCore(source, predicate, cancellationToken); + } +#endif + private static async Task SingleOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IList list) @@ -166,5 +178,39 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable await e.DisposeAsync().ConfigureAwait(false); } } + +#if !NO_DEEP_CANCELLATION + private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var result = e.Current; + + if (await predicate(result, cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + + return default; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index bef6799482..51d2eeb081 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -41,6 +41,18 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable return new SkipWhileAsyncIteratorWithTask(source, predicate); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return new SkipWhileAsyncIteratorWithTaskAndCancellation(source, predicate); + } +#endif + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) @@ -51,6 +63,18 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return new SkipWhileWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); + } +#endif + private sealed class SkipWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -287,6 +311,84 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class SkipWhileAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; + + private bool _doMoveNext; + private IAsyncEnumerator _enumerator; + + public SkipWhileAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + _source = source; + _predicate = predicate; + } + + public override AsyncIteratorBase Clone() + { + return new SkipWhileAsyncIteratorWithTaskAndCancellation(_source, _predicate); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + + // skip elements as requested + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var element = _enumerator.Current; + if (!await _predicate(element, _cancellationToken).ConfigureAwait(false)) + { + _doMoveNext = false; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + + break; + + case AsyncIteratorState.Iterating: + if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + if (!_doMoveNext) + { + _current = _enumerator.Current; + _doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class SkipWhileWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; @@ -370,5 +472,91 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class SkipWhileWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; + + private bool _doMoveNext; + private IAsyncEnumerator _enumerator; + private int _index; + + public SkipWhileWithIndexAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + _source = source; + _predicate = predicate; + } + + public override AsyncIteratorBase Clone() + { + return new SkipWhileWithIndexAsyncIteratorWithTaskAndCancellation(_source, _predicate); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _index = -1; + + // skip elements as requested + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var element = _enumerator.Current; + + checked + { + _index++; + } + + if (!await _predicate(element, _index, _cancellationToken).ConfigureAwait(false)) + { + _doMoveNext = false; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + } + + break; + + case AsyncIteratorState.Iterating: + if (_doMoveNext && await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + if (!_doMoveNext) + { + _current = _enumerator.Current; + _doMoveNext = true; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 05680c8866..22eb5968c5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -66,6 +66,18 @@ public static Task SumAsync(this IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0; @@ -142,6 +154,34 @@ private static async Task SumCore(IAsyncEnumerable source return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -198,6 +238,18 @@ public static Task SumAsync(this IAsyncEnumerable source return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0L; @@ -274,6 +326,34 @@ private static async Task SumCore(IAsyncEnumerable sourc return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -330,6 +410,18 @@ public static Task SumAsync(this IAsyncEnumerable sourc return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0.0f; @@ -397,6 +489,31 @@ private static async Task SumCore(IAsyncEnumerable sour return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -453,6 +570,18 @@ public static Task SumAsync(this IAsyncEnumerable sour return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0.0; @@ -520,6 +649,31 @@ private static async Task SumCore(IAsyncEnumerable sou return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -576,6 +730,18 @@ public static Task SumAsync(this IAsyncEnumerable sou return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0m; @@ -643,6 +809,31 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -699,6 +890,18 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0; @@ -775,6 +978,34 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -831,6 +1062,18 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0L; @@ -907,6 +1150,34 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -963,6 +1234,18 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0.0f; @@ -1030,6 +1313,31 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -1086,6 +1394,18 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0.0; @@ -1153,6 +1473,31 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + public static Task SumAsync(this IAsyncEnumerable source) { if (source == null) @@ -1209,6 +1554,18 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var sum = 0m; @@ -1276,5 +1633,30 @@ private static async Task SumCore(IAsyncEnumerable so return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + { + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 71fe878c05..70af0128bb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -91,6 +91,18 @@ foreach (var o in os) return SumCore(source, selector, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return SumCore(source, selector, cancellationToken); + } +#endif + private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { var sum = <#=o.zero#>; @@ -206,6 +218,47 @@ else return sum; } +#if !NO_DEEP_CANCELLATION + private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + { + var sum = <#=o.zero#>; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + +<# +if (o.@checked) +{ +#> + checked + { + sum += value<#=n#>; + } +<# +} +else +{ +#> + sum += value<#=n#>; +<# +} +#> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } +#endif + <# } #> diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 6e275ef72c..5df1a3346f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -41,6 +41,18 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable return new TakeWhileAsyncIteratorWithTask(source, predicate); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return new TakeWhileAsyncIteratorWithTaskAndCancellation(source, predicate); + } +#endif + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) { if (source == null) @@ -51,6 +63,18 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return new TakeWhileWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); + } +#endif + private sealed class TakeWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -250,6 +274,72 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class TakeWhileAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + + public TakeWhileAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + _source = source; + _predicate = predicate; + } + + public override AsyncIteratorBase Clone() + { + return new TakeWhileAsyncIteratorWithTaskAndCancellation(_source, _predicate); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + if (!await _predicate(item, _cancellationToken).ConfigureAwait(false)) + { + break; + } + + _current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class TakeWhileWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; @@ -320,5 +410,78 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class TakeWhileWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + private int _index; + + public TakeWhileWithIndexAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(predicate != null); + Debug.Assert(source != null); + + _source = source; + _predicate = predicate; + } + + public override AsyncIteratorBase Clone() + { + return new TakeWhileWithIndexAsyncIteratorWithTaskAndCancellation(_source, _predicate); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _index = -1; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + + checked + { + _index++; + } + + if (!await _predicate(item, _index, _cancellationToken).ConfigureAwait(false)) + { + break; + } + + _current = item; + return true; + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index a7859cf902..822161b94e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -50,6 +50,18 @@ public static Task> ToDictionaryAsync(t return ToDictionaryCore(source, keySelector, x => new ValueTask(x), EqualityComparer.Default, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return ToDictionaryCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), EqualityComparer.Default, cancellationToken); + } +#endif + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) @@ -90,6 +102,18 @@ public static Task> ToDictionaryAsync(t return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return ToDictionaryCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer, cancellationToken); + } +#endif + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) @@ -138,6 +162,20 @@ public static Task> ToDictionaryAsync.Default, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + + return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, cancellationToken); + } +#endif + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) @@ -186,6 +224,20 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + + return ToDictionaryCore(source, keySelector, elementSelector, comparer, cancellationToken); + } +#endif + private static async Task> ToDictionaryCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); @@ -237,5 +289,33 @@ private static async Task> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + var d = new Dictionary(comparer); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + + var key = await keySelector(x, cancellationToken).ConfigureAwait(false); + var value = await elementSelector(x, cancellationToken).ConfigureAwait(false); + + d.Add(key, value); + } + + return d; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 7cc12bb300..a871595572 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -50,6 +50,18 @@ public static Task> ToLookupAsync(this IAs return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer: null, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return ToLookupCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer: null, cancellationToken); + } +#endif + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { if (source == null) @@ -90,6 +102,18 @@ public static Task> ToLookupAsync(this IAs return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return ToLookupCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer, cancellationToken); + } +#endif + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector) { if (source == null) @@ -138,6 +162,20 @@ public static Task> ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + + return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); + } +#endif + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { if (source == null) @@ -186,6 +224,20 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (elementSelector == null) + throw Error.ArgumentNull(nameof(elementSelector)); + + return ToLookupCore(source, keySelector, elementSelector, comparer, cancellationToken); + } +#endif + private static async Task> ToLookupCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { return await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); @@ -195,5 +247,12 @@ private static async Task> ToLookupCore.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); } + +#if !NO_DEEP_CANCELLATION + private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 5a70885a45..9c4d1e30d6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -52,6 +53,24 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable(source, predicate); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + if (source is AsyncIteratorBase iterator) + { + return iterator.Where(predicate); + } + + // TODO: Can we add array/list optimizations here, does it make sense? + return new WhereEnumerableAsyncIteratorWithTaskAndCancellation(source, predicate); + } +#endif + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) { if (source == null) @@ -62,6 +81,18 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable(source, predicate); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return new WhereEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); + } +#endif + private static Func CombinePredicates(Func predicate1, Func predicate2) { return x => predicate1(x) && predicate2(x); @@ -72,6 +103,13 @@ private static Func> CombinePredicates(Func await predicate1(x).ConfigureAwait(false) && await predicate2(x).ConfigureAwait(false); } +#if !NO_DEEP_CANCELLATION + private static Func> CombinePredicates(Func> predicate1, Func> predicate2) + { + return async (x, ct) => await predicate1(x, ct).ConfigureAwait(false) && await predicate2(x, ct).ConfigureAwait(false); + } +#endif + internal sealed class WhereEnumerableAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -273,6 +311,72 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + internal sealed class WhereEnumerableAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; + private IAsyncEnumerator _enumerator; + + public WhereEnumerableAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(source != null); + Debug.Assert(predicate != null); + + _source = source; + _predicate = predicate; + } + + public override AsyncIteratorBase Clone() + { + return new WhereEnumerableAsyncIteratorWithTaskAndCancellation(_source, _predicate); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + public override IAsyncEnumerable Where(Func> predicate) + { + return new WhereEnumerableAsyncIteratorWithTaskAndCancellation(_source, CombinePredicates(_predicate, predicate)); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) + { + _current = item; + return true; + } + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif + internal sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; @@ -341,6 +445,76 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + internal sealed class WhereEnumerableWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _predicate; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + private int _index; + + public WhereEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> predicate) + { + Debug.Assert(source != null); + Debug.Assert(predicate != null); + + _source = source; + _predicate = predicate; + } + + public override AsyncIteratorBase Clone() + { + return new WhereEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(_source, _predicate); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _index = -1; + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + + checked + { + _index++; + } + + if (await _predicate(item, _index, _cancellationToken).ConfigureAwait(false)) + { + _current = item; + return true; + } + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif + internal sealed class WhereSelectEnumerableAsyncIterator : AsyncIterator { private readonly Func _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 89cb49fb67..51bcf94c69 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -35,6 +35,20 @@ public static IAsyncEnumerable Zip(this IAsyn return new ZipAsyncIteratorWithTask(first, second, selector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + { + if (first == null) + throw Error.ArgumentNull(nameof(first)); + if (second == null) + throw Error.ArgumentNull(nameof(second)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return new ZipAsyncIteratorWithTaskAndCancellation(first, second, selector); + } +#endif + private sealed class ZipAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _first; @@ -178,5 +192,79 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class ZipAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly IAsyncEnumerable _first; + private readonly IAsyncEnumerable _second; + private readonly Func> _selector; + + private IAsyncEnumerator _firstEnumerator; + private IAsyncEnumerator _secondEnumerator; + + public ZipAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + { + Debug.Assert(first != null); + Debug.Assert(second != null); + Debug.Assert(selector != null); + + _first = first; + _second = second; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new ZipAsyncIteratorWithTaskAndCancellation(_first, _second, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_secondEnumerator != null) + { + await _secondEnumerator.DisposeAsync().ConfigureAwait(false); + _secondEnumerator = null; + } + + if (_firstEnumerator != null) + { + await _firstEnumerator.DisposeAsync().ConfigureAwait(false); + _firstEnumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + // REVIEW: Earlier versions of this operator performed concurrent MoveNextAsync calls, which isn't a great default and + // results in an unexpected source of concurrency. However, a concurrent Zip may be a worthy addition to the + // API or System.Interactive.Async as a complementary implementation besides the conservative default. + + switch (_state) + { + case AsyncIteratorState.Allocated: + _firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); + _secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _firstEnumerator.MoveNextAsync().ConfigureAwait(false) && await _secondEnumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = await _selector(_firstEnumerator.Current, _secondEnumerator.Current, _cancellationToken).ConfigureAwait(false); + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif } } From f17f829fbb7984d6e0c0ec850213c403b4e8c54c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 16 Nov 2018 18:10:18 -0800 Subject: [PATCH 540/862] Adding deep cancellation API surface on AsyncQueryable. --- .../System/Linq/AsyncQueryable.Generated.cs | 1662 +++++++++++++++-- 1 file changed, 1538 insertions(+), 124 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index d6528a1639..725c3b98d9 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -40,6 +40,20 @@ public static Task AggregateAsync(this IAsyncQueryable AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) @@ -96,6 +110,20 @@ public static Task AggregateAsync(this IAsync #endif } + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken) { if (source == null) @@ -156,6 +184,22 @@ public static Task AggregateAsync(this I #endif } + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken) { if (source == null) @@ -230,6 +274,20 @@ public static Task AllAsync(this IAsyncQueryable source, #endif } + public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -310,6 +368,20 @@ public static Task AnyAsync(this IAsyncQueryable source, #endif } + public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -856,6 +928,146 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) @@ -1280,6 +1492,20 @@ public static Task CountAsync(this IAsyncQueryable source #endif } + public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -1488,6 +1714,20 @@ public static Task FirstAsync(this IAsyncQueryable so #endif } + public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -1568,6 +1808,20 @@ public static Task FirstOrDefaultAsync(this IAsyncQueryable FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -1582,6 +1836,20 @@ public static Task FirstOrDefaultAsync(this IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -1610,6 +1878,22 @@ public static IAsyncQueryable> GroupBy> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) @@ -1642,7 +1926,7 @@ public static IAsyncQueryable> GroupBy GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1652,13 +1936,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1668,13 +1952,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1684,13 +1968,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1700,12 +1984,80 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); +#endif + } + + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); +#endif + } + + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1778,6 +2130,24 @@ public static IAsyncQueryable> GroupBy GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); +#endif + } + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) { if (source == null) @@ -1814,6 +2184,26 @@ public static IAsyncQueryable GroupBy #endif } + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1854,6 +2244,26 @@ public static IAsyncQueryable GroupBy #endif } + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + +#if CRIPPLED_REFLECTION + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); +#else + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); +#endif + } + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { if (outer == null) @@ -1894,6 +2304,28 @@ public static IAsyncQueryable GroupJoin( #endif } + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -1968,6 +2400,26 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + +#if CRIPPLED_REFLECTION + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); +#else + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); +#endif + } + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { if (outer == null) @@ -2008,6 +2460,28 @@ public static IAsyncQueryable Join(this #endif } + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) + { + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -2118,6 +2592,20 @@ public static Task LastAsync(this IAsyncQueryable sou #endif } + public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -2198,6 +2686,20 @@ public static Task LastOrDefaultAsync(this IAsyncQueryable LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -2278,6 +2780,20 @@ public static Task LongCountAsync(this IAsyncQueryable s #endif } + public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -2836,7 +3352,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2844,13 +3360,13 @@ public static Task MaxAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2858,13 +3374,13 @@ public static Task MaxAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2872,13 +3388,13 @@ public static Task MaxAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2886,13 +3402,13 @@ public static Task MaxAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2900,13 +3416,13 @@ public static Task MaxAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2914,13 +3430,13 @@ public static Task MaxAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2928,13 +3444,13 @@ public static Task MaxAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2942,13 +3458,13 @@ public static Task MaxAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2956,13 +3472,13 @@ public static Task MaxAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2970,13 +3486,13 @@ public static Task MaxAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2984,13 +3500,13 @@ public static Task MaxAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2998,13 +3514,13 @@ public static Task MaxAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3012,13 +3528,13 @@ public static Task MaxAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3026,13 +3542,13 @@ public static Task MaxAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3040,13 +3556,13 @@ public static Task MaxAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3054,13 +3570,153 @@ public static Task MaxAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3144,6 +3800,20 @@ public static Task MaxAsync(this IAsyncQueryable MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) @@ -3716,7 +4386,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3724,13 +4394,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3738,13 +4408,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3752,13 +4422,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3766,13 +4436,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3780,13 +4450,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3794,13 +4464,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3808,13 +4478,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3822,13 +4492,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3836,13 +4506,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3850,13 +4520,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3864,13 +4534,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3878,13 +4548,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3892,13 +4562,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3906,13 +4576,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3920,13 +4590,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3934,13 +4604,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3948,13 +4618,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3962,13 +4632,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3976,13 +4646,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3990,13 +4660,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4004,13 +4674,13 @@ public static Task MinAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4018,13 +4688,13 @@ public static Task MinAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4032,13 +4702,13 @@ public static Task MinAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4046,39 +4716,193 @@ public static Task MinAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable OfType(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static IAsyncQueryable OfType(this IAsyncQueryable source) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); +#endif + } + + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4092,6 +4916,22 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync #endif } + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -4124,6 +4964,20 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync #endif } + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -4152,6 +5006,22 @@ public static IOrderedAsyncQueryable OrderByDescending(t #endif } + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -4208,6 +5078,34 @@ public static IAsyncQueryable Reverse(this IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -4264,6 +5162,20 @@ public static IAsyncQueryable Select(this IAsyncQuery #endif } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -4278,6 +5190,20 @@ public static IAsyncQueryable SelectMany(this IAsyncQ #endif } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); +#endif + } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -4320,6 +5246,22 @@ public static IAsyncQueryable SelectMany(this IAsyncQ #endif } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); +#endif + } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) { if (source == null) @@ -4336,6 +5278,22 @@ public static IAsyncQueryable SelectMany #endif } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); +#endif + } + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) { if (source == null) @@ -4510,6 +5468,20 @@ public static Task SingleAsync(this IAsyncQueryable s #endif } + public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -4590,6 +5562,20 @@ public static Task SingleOrDefaultAsync(this IAsyncQueryable SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) { if (source == null) @@ -4642,6 +5628,20 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -4656,6 +5656,20 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -5102,11 +6116,151 @@ public static Task SumAsync(this IAsyncQueryable sour #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5114,13 +6268,13 @@ public static Task SumAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5128,13 +6282,13 @@ public static Task SumAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5142,13 +6296,13 @@ public static Task SumAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5156,13 +6310,13 @@ public static Task SumAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5170,13 +6324,13 @@ public static Task SumAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5184,13 +6338,13 @@ public static Task SumAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5198,9 +6352,9 @@ public static Task SumAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } @@ -5522,6 +6676,20 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -5536,6 +6704,20 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -5564,6 +6746,20 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -5592,6 +6788,22 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere #endif } + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -5624,6 +6836,20 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere #endif } + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -5652,6 +6878,22 @@ public static IOrderedAsyncQueryable ThenByDescending(th #endif } + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#else + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); +#endif + } + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -5736,6 +6978,20 @@ public static Task> ToDictionaryAsync(t #endif } + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) @@ -5796,6 +7052,22 @@ public static Task> ToDictionaryAsync(t #endif } + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -5860,6 +7132,22 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) @@ -5928,6 +7216,24 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -6068,6 +7374,20 @@ public static Task> ToLookupAsync(this IAs #endif } + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) @@ -6128,6 +7448,22 @@ public static Task> ToLookupAsync(this IAs #endif } + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -6192,6 +7528,22 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) { if (source == null) @@ -6260,6 +7612,24 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -6340,6 +7710,20 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -6354,6 +7738,20 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); +#endif + } + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -6382,6 +7780,22 @@ public static IAsyncQueryable Where(this IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); +#else + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); +#endif + } + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) { if (first == null) From 252fa39ed994a224d02b867d71d09471e63cbbe5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 17 Nov 2018 17:21:45 -0800 Subject: [PATCH 541/862] Adding "deep cancellation" support in Ix.Async. --- .../System/Linq/AsyncQueryableEx.Generated.cs | 210 ++++++++++++++++++ .../System/Linq/Operators/Catch.cs | 108 +++++++++ .../System/Linq/Operators/Defer.cs | 69 +++++- .../System/Linq/Operators/Distinct.cs | 6 + .../Linq/Operators/DistinctUntilChanged.cs | 106 +++++++++ .../System/Linq/Operators/Do.cs | 140 ++++++++++++ .../System/Linq/Operators/Expand.cs | 104 +++++++++ .../System/Linq/Operators/Finally.cs | 3 +- .../System/Linq/Operators/Generate.cs | 2 + .../System/Linq/Operators/MaxBy.cs | 36 +++ .../System/Linq/Operators/MinBy.cs | 78 +++++++ .../System/Linq/Operators/Scan.cs | 167 ++++++++++++++ .../System/Linq/Operators/Using.cs | 83 +++++++ 13 files changed, 1110 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index a1b5387f94..31be24b08b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -64,6 +64,20 @@ public static IAsyncQueryable Catch(this IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (handler == null) + throw new ArgumentNullException(nameof(handler)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); +#endif + } + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) { if (source == null) @@ -190,6 +204,20 @@ public static IAsyncQueryable DistinctUntilChanged(this IAsync #endif } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -218,6 +246,22 @@ public static IAsyncQueryable DistinctUntilChanged(this #endif } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) @@ -264,6 +308,20 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); +#endif + } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) @@ -324,6 +382,38 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); +#endif + } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) @@ -374,6 +464,24 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); +#endif + } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) { if (source == null) @@ -392,6 +500,20 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); +#endif + } + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -540,6 +662,20 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) @@ -600,6 +736,22 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -700,6 +852,20 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) @@ -760,6 +926,22 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -854,6 +1036,20 @@ public static IAsyncQueryable Retry(this IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); +#endif + } + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) { if (source == null) @@ -882,6 +1078,20 @@ public static IAsyncQueryable Scan(this IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#endif + } + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) { if (source == null) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 815ea16df1..f158be885d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -34,6 +34,19 @@ public static IAsyncEnumerable Catch(this IAsyncEn return new CatchAsyncIteratorWithTask(source, handler); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func>> handler) + where TException : Exception + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (handler == null) + throw Error.ArgumentNull(nameof(handler)); + + return new CatchAsyncIteratorWithTaskAndCancellation(source, handler); + } +#endif + public static IAsyncEnumerable Catch(this IEnumerable> sources) { if (sources == null) @@ -251,6 +264,101 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class CatchAsyncIteratorWithTaskAndCancellation : AsyncIterator where TException : Exception + { + private readonly Func>> _handler; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + private bool _isDone; + + public CatchAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> handler) + { + Debug.Assert(source != null); + Debug.Assert(handler != null); + + _source = source; + _handler = handler; + } + + public override AsyncIteratorBase Clone() + { + return new CatchAsyncIteratorWithTaskAndCancellation(_source, _handler); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _isDone = false; + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (true) + { + if (!_isDone) + { + try + { + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + } + catch (TException ex) + { + // Note: Ideally we'd dipose of the previous enumerator before + // invoking the handler, but we use this order to preserve + // current behavior + var inner = await _handler(ex, _cancellationToken).ConfigureAwait(false); + var err = inner.GetAsyncEnumerator(_cancellationToken); + + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + } + + _enumerator = err; + _isDone = true; + continue; // loop so we hit the catch state + } + } + + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + break; // while + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class CatchAsyncIterator : AsyncIterator { private readonly IEnumerable> _sources; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index f8c76bdeae..fb3784acaa 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using static System.Linq.AsyncEnumerable; namespace System.Linq { @@ -28,6 +27,16 @@ public static IAsyncEnumerable Defer(Func(factory); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Defer(Func>> factory) + { + if (factory == null) + throw Error.ArgumentNull(nameof(factory)); + + return new AsyncDeferIteratorWithCancellation(factory); + } +#endif + private sealed class DeferIterator : AsyncIteratorBase { private readonly Func> _factory; @@ -141,5 +150,63 @@ private async ValueTask InitializeAndMoveNextAsync() return await _enumerator.MoveNextAsync().ConfigureAwait(false); } } + +#if !NO_DEEP_CANCELLATION + private sealed class AsyncDeferIteratorWithCancellation : AsyncIteratorBase + { + private readonly Func>> _factory; + private IAsyncEnumerator _enumerator; + + public AsyncDeferIteratorWithCancellation(Func>> factory) + { + Debug.Assert(factory != null); + + _factory = factory; + } + + public override T Current => _enumerator == null ? default : _enumerator.Current; + + public override AsyncIteratorBase Clone() + { + return new AsyncDeferIteratorWithCancellation(_factory); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override ValueTask MoveNextCore() + { + if (_enumerator == null) + { + return InitializeAndMoveNextAsync(); + } + + return _enumerator.MoveNextAsync(); + } + + private async ValueTask InitializeAndMoveNextAsync() + { + try + { + _enumerator = (await _factory(_cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); + } + catch (Exception ex) + { + _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); + throw; + } + + return await _enumerator.MoveNextAsync().ConfigureAwait(false); + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 895ae029ac..edb29734fe 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -41,6 +41,9 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer: null); } +#if !NO_DEEP_CANCELLATION // TODO +#endif + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) @@ -53,6 +56,9 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION // TODO +#endif + private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { return new DistinctAsyncIterator(source, keySelector, comparer); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 49e511f5a4..398edc8518 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -57,6 +57,18 @@ public static IAsyncEnumerable DistinctUntilChanged(this return DistinctUntilChangedCore(source, keySelector, comparer: null); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return DistinctUntilChangedCore(source, keySelector, comparer: null); + } +#endif + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) @@ -69,6 +81,20 @@ public static IAsyncEnumerable DistinctUntilChanged(this return DistinctUntilChangedCore(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (comparer == null) + throw Error.ArgumentNull(nameof(comparer)); + + return DistinctUntilChangedCore(source, keySelector, comparer); + } +#endif + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, IEqualityComparer comparer) { return new DistinctUntilChangedAsyncIterator(source, comparer); @@ -84,6 +110,13 @@ private static IAsyncEnumerable DistinctUntilChangedCore return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + return new DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(source, keySelector, comparer); + } +#endif + private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; @@ -296,5 +329,78 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class DistinctUntilChangedAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly IEqualityComparer _comparer; + private readonly Func> _keySelector; + private readonly IAsyncEnumerable _source; + private TKey _currentKeyValue; + + private IAsyncEnumerator _enumerator; + private bool _hasCurrentKey; + + public DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + _source = source; + _keySelector = keySelector; + _comparer = comparer ?? EqualityComparer.Default; + } + + public override AsyncIteratorBase Clone() + { + return new DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(_source, _keySelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _currentKeyValue = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + var comparerEquals = false; + + if (_hasCurrentKey) + { + comparerEquals = _comparer.Equals(_currentKeyValue, key); + } + if (!_hasCurrentKey || !comparerEquals) + { + _hasCurrentKey = true; + _currentKeyValue = key; + _current = item; + return true; + } + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index 06628ac7f1..a566512024 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -11,6 +11,8 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + // REVIEW: Should we convert Task-based overloads to ValueTask? + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext) { if (source == null) @@ -107,6 +109,56 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + + return DoCore(source, onNext: onNext, onError: null, onCompleted: null); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onCompleted) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + if (onCompleted == null) + throw Error.ArgumentNull(nameof(onCompleted)); + + return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + if (onError == null) + throw Error.ArgumentNull(nameof(onError)); + + return DoCore(source, onNext: onNext, onError: onError, onCompleted: null); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + if (onError == null) + throw Error.ArgumentNull(nameof(onError)); + if (onCompleted == null) + throw Error.ArgumentNull(nameof(onCompleted)); + + return DoCore(source, onNext, onError, onCompleted); + } +#endif + public static IAsyncEnumerable Do(this IAsyncEnumerable source, IObserver observer) { if (source == null) @@ -127,6 +179,13 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable(source, onNext, onError, onCompleted); } +#if !NO_DEEP_CANCELLATION + private static IAsyncEnumerable DoCore(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + return new DoAsyncIteratorWithTaskAndCancellation(source, onNext, onError, onCompleted); + } +#endif + private sealed class DoAsyncIterator : AsyncIterator { private readonly Action _onCompleted; @@ -281,5 +340,86 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class DoAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func _onCompleted; + private readonly Func _onError; + private readonly Func _onNext; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + + public DoAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + Debug.Assert(source != null); + Debug.Assert(onNext != null); + + _source = source; + _onNext = onNext; + _onError = onError; + _onCompleted = onCompleted; + } + + public override AsyncIteratorBase Clone() + { + return new DoAsyncIteratorWithTaskAndCancellation(_source, _onNext, _onError, _onCompleted); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + try + { + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + await _onNext(_current, _cancellationToken).ConfigureAwait(false); + + return true; + } + } + catch (OperationCanceledException) + { + throw; + } + catch (Exception ex) when (_onError != null) + { + await _onError(ex, _cancellationToken).ConfigureAwait(false); + throw; + } + + if (_onCompleted != null) + { + await _onCompleted(_cancellationToken).ConfigureAwait(false); + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 82ee0ff921..bb7aeda337 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -31,6 +31,18 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable(source, selector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return new ExpandAsyncIteratorWithTaskAndCancellation(source, selector); + } +#endif + private sealed class ExpandAsyncIterator : AsyncIterator { private readonly Func> _selector; @@ -210,5 +222,97 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class ExpandAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func>> _selector; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + + private Queue> _queue; + + public ExpandAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + _source = source; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new ExpandAsyncIteratorWithTaskAndCancellation(_source, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + _queue = null; + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _queue = new Queue>(); + _queue.Enqueue(_source); + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (true) + { + if (_enumerator == null) + { + if (_queue.Count > 0) + { + var src = _queue.Dequeue(); + + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + } + + _enumerator = src.GetAsyncEnumerator(_cancellationToken); + + continue; // loop + } + + break; // while + } + + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + var next = await _selector(item, _cancellationToken).ConfigureAwait(false); + _queue.Enqueue(next); + _current = item; + return true; + } + + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 52bc64d620..bbf2c89cc6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -31,6 +30,8 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable(source, finallyAction); } + // REVIEW: No cancellation support for finally action. + private sealed class FinallyAsyncIterator : AsyncIterator { private readonly Action _finallyAction; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 897325aa93..97a8988a58 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -23,6 +23,8 @@ public static IAsyncEnumerable Generate(TState initial return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); } + // REVIEW: Add async variant? + private sealed class GenerateAsyncIterator : AsyncIterator { private readonly Func _condition; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index a4b988cfe7..b351242334 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -70,6 +70,18 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer: null, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MaxByCore(source, keySelector, comparer: null, cancellationToken); + } +#endif + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) @@ -90,6 +102,18 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MaxByCore(source, keySelector, comparer, cancellationToken); + } +#endif + private static Task> MaxByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) @@ -109,5 +133,17 @@ private static Task> MaxByCore(IAsyncEnumerable comparer.Compare(key, minValue), cancellationToken); } + +#if !NO_DEEP_CANCELLATION + private static Task> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (comparer == null) + { + comparer = Comparer.Default; + } + + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 42deacd924..892af69474 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -70,6 +70,18 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer: null, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MinByCore(source, keySelector, comparer: null, cancellationToken); + } +#endif + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) @@ -90,6 +102,18 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MinByCore(source, keySelector, comparer, cancellationToken); + } +#endif + private static Task> MinByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) @@ -110,6 +134,18 @@ private static Task> MinByCore(IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); } +#if !NO_DEEP_CANCELLATION + private static Task> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (comparer == null) + { + comparer = Comparer.Default; + } + + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); + } +#endif + private static async Task> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) { var result = new List(); @@ -189,5 +225,47 @@ private static async Task> ExtremaBy(IAsyncEnumera return result; } + +#if !NO_DEEP_CANCELLATION + private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) + { + var result = new List(); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); + + var current = e.Current; + var resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); + result.Add(current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var key = await keySelector(cur, cancellationToken).ConfigureAwait(false); + + var cmp = compare(key, resKey); + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return result; + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 6be9e4c501..82cb3e838a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -41,6 +41,18 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable(source, accumulator); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func> accumulator) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + + return new ScanAsyncEnumerableWithTaskAndCancellation(source, accumulator); + } +#endif + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { if (source == null) @@ -51,6 +63,18 @@ public static IAsyncEnumerable Scan(this IAsy return new ScanAsyncEnumerableWithTask(source, seed, accumulator); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + + return new ScanAsyncEnumerableWithTaskAndCancellation(source, seed, accumulator); + } +#endif + private sealed class ScanAsyncEnumerable : AsyncIterator { private readonly Func _accumulator; @@ -263,6 +287,82 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class ScanAsyncEnumerableWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _accumulator; + private readonly IAsyncEnumerable _source; + + private TSource _accumulated; + private IAsyncEnumerator _enumerator; + + private bool _hasSeed; + + public ScanAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> accumulator) + { + Debug.Assert(source != null); + Debug.Assert(accumulator != null); + + _source = source; + _accumulator = accumulator; + } + + public override AsyncIteratorBase Clone() + { + return new ScanAsyncEnumerableWithTaskAndCancellation(_source, _accumulator); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _hasSeed = false; + _accumulated = default; + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + if (!_hasSeed) + { + _hasSeed = true; + _accumulated = item; + continue; // loop + } + + _accumulated = await _accumulator(_accumulated, item, _cancellationToken).ConfigureAwait(false); + _current = _accumulated; + return true; + } + + break; // case + + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class ScanAsyncEnumerableWithTask : AsyncIterator { private readonly Func> _accumulator; @@ -327,5 +427,72 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class ScanAsyncEnumerableWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _accumulator; + private readonly TAccumulate _seed; + private readonly IAsyncEnumerable _source; + + private TAccumulate _accumulated; + private IAsyncEnumerator _enumerator; + + public ScanAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + { + Debug.Assert(source != null); + Debug.Assert(accumulator != null); + + _source = source; + _seed = seed; + _accumulator = accumulator; + } + + public override AsyncIteratorBase Clone() + { + return new ScanAsyncEnumerableWithTaskAndCancellation(_source, _seed, _accumulator); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _accumulated = _seed; + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + _accumulated = await _accumulator(_accumulated, item, _cancellationToken).ConfigureAwait(false); + _current = _accumulated; + return true; + } + + break; + + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 0641fff7d2..2e459a2109 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -11,6 +11,8 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + // REVIEW: Add support for IAsyncDisposable resources. + public static IAsyncEnumerable Using(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable { if (resourceFactory == null) @@ -31,6 +33,18 @@ public static IAsyncEnumerable Using(Func(resourceFactory, enumerableFactory); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Using(Func> resourceFactory, Func>> enumerableFactory) where TResource : IDisposable + { + if (resourceFactory == null) + throw Error.ArgumentNull(nameof(resourceFactory)); + if (enumerableFactory == null) + throw Error.ArgumentNull(nameof(enumerableFactory)); + + return new UsingAsyncIteratorWithTaskAndCancellation(resourceFactory, enumerableFactory); + } +#endif + private sealed class UsingAsyncIterator : AsyncIterator where TResource : IDisposable { private readonly Func> _enumerableFactory; @@ -165,5 +179,74 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class UsingAsyncIteratorWithTaskAndCancellation : AsyncIterator where TResource : IDisposable + { + private readonly Func>> _enumerableFactory; + private readonly Func> _resourceFactory; + + private IAsyncEnumerable _enumerable; + private IAsyncEnumerator _enumerator; + private TResource _resource; + + public UsingAsyncIteratorWithTaskAndCancellation(Func> resourceFactory, Func>> enumerableFactory) + { + Debug.Assert(resourceFactory != null); + Debug.Assert(enumerableFactory != null); + + _resourceFactory = resourceFactory; + _enumerableFactory = enumerableFactory; + } + + public override AsyncIteratorBase Clone() + { + return new UsingAsyncIteratorWithTaskAndCancellation(_resourceFactory, _enumerableFactory); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + if (_resource != null) + { + _resource.Dispose(); + _resource = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _resource = await _resourceFactory(_cancellationToken).ConfigureAwait(false); + _enumerable = await _enumerableFactory(_resource, _cancellationToken).ConfigureAwait(false); + + _enumerator = _enumerable.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif } } From c56e02c33ac89463ded3006d1c3a0435f017661d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 17 Nov 2018 17:21:45 -0800 Subject: [PATCH 542/862] Adding ref assemblies --- .../System/Linq/AsyncQueryableEx.Generated.cs | 210 ++++++++++++++++++ .../System.Interactive.Async.csproj | 2 +- .../System/Linq/Operators/Catch.cs | 108 +++++++++ .../System/Linq/Operators/Defer.cs | 69 +++++- .../System/Linq/Operators/Distinct.cs | 6 + .../Linq/Operators/DistinctUntilChanged.cs | 106 +++++++++ .../System/Linq/Operators/Do.cs | 140 ++++++++++++ .../System/Linq/Operators/Expand.cs | 104 +++++++++ .../System/Linq/Operators/Finally.cs | 3 +- .../System/Linq/Operators/Generate.cs | 2 + .../System/Linq/Operators/MaxBy.cs | 36 +++ .../System/Linq/Operators/MinBy.cs | 78 +++++++ .../System/Linq/Operators/Scan.cs | 167 ++++++++++++++ .../System/Linq/Operators/Using.cs | 83 +++++++ Ix.NET/Source/refs/Directory.build.props | 1 - ...tem.Interactive.Async.Providers.Ref.csproj | 19 ++ .../System.Interactive.Async.Ref.csproj | 23 ++ .../System.Linq.Async.Queryable.Ref.csproj | 23 ++ .../System.Linq.Async.Ref.csproj | 19 ++ 19 files changed, 1195 insertions(+), 4 deletions(-) create mode 100644 Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index a1b5387f94..31be24b08b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -64,6 +64,20 @@ public static IAsyncQueryable Catch(this IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (handler == null) + throw new ArgumentNullException(nameof(handler)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); +#endif + } + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) { if (source == null) @@ -190,6 +204,20 @@ public static IAsyncQueryable DistinctUntilChanged(this IAsync #endif } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -218,6 +246,22 @@ public static IAsyncQueryable DistinctUntilChanged(this #endif } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) @@ -264,6 +308,20 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); +#endif + } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) @@ -324,6 +382,38 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); +#endif + } + + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); +#endif + } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) @@ -374,6 +464,24 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (onNext == null) + throw new ArgumentNullException(nameof(onNext)); + if (onError == null) + throw new ArgumentNullException(nameof(onError)); + if (onCompleted == null) + throw new ArgumentNullException(nameof(onCompleted)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); +#endif + } + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) { if (source == null) @@ -392,6 +500,20 @@ public static IAsyncQueryable Do(this IAsyncQueryable #endif } + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); +#endif + } + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -540,6 +662,20 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) @@ -600,6 +736,22 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -700,6 +852,20 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) { if (source == null) @@ -760,6 +926,22 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (source == null) @@ -854,6 +1036,20 @@ public static IAsyncQueryable Retry(this IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); +#endif + } + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) { if (source == null) @@ -882,6 +1078,20 @@ public static IAsyncQueryable Scan(this IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (accumulator == null) + throw new ArgumentNullException(nameof(accumulator)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); +#endif + } + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) { if (source == null) diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 190f22600c..8d9ff6de02 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -2,7 +2,7 @@ Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. - Interactive Extensions - Async Library + Interactive Extensions - Async Library net45;net46;netstandard1.4;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 815ea16df1..f158be885d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -34,6 +34,19 @@ public static IAsyncEnumerable Catch(this IAsyncEn return new CatchAsyncIteratorWithTask(source, handler); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func>> handler) + where TException : Exception + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (handler == null) + throw Error.ArgumentNull(nameof(handler)); + + return new CatchAsyncIteratorWithTaskAndCancellation(source, handler); + } +#endif + public static IAsyncEnumerable Catch(this IEnumerable> sources) { if (sources == null) @@ -251,6 +264,101 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class CatchAsyncIteratorWithTaskAndCancellation : AsyncIterator where TException : Exception + { + private readonly Func>> _handler; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + private bool _isDone; + + public CatchAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> handler) + { + Debug.Assert(source != null); + Debug.Assert(handler != null); + + _source = source; + _handler = handler; + } + + public override AsyncIteratorBase Clone() + { + return new CatchAsyncIteratorWithTaskAndCancellation(_source, _handler); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _isDone = false; + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (true) + { + if (!_isDone) + { + try + { + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + } + catch (TException ex) + { + // Note: Ideally we'd dipose of the previous enumerator before + // invoking the handler, but we use this order to preserve + // current behavior + var inner = await _handler(ex, _cancellationToken).ConfigureAwait(false); + var err = inner.GetAsyncEnumerator(_cancellationToken); + + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + } + + _enumerator = err; + _isDone = true; + continue; // loop so we hit the catch state + } + } + + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + break; // while + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class CatchAsyncIterator : AsyncIterator { private readonly IEnumerable> _sources; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index f8c76bdeae..fb3784acaa 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using static System.Linq.AsyncEnumerable; namespace System.Linq { @@ -28,6 +27,16 @@ public static IAsyncEnumerable Defer(Func(factory); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Defer(Func>> factory) + { + if (factory == null) + throw Error.ArgumentNull(nameof(factory)); + + return new AsyncDeferIteratorWithCancellation(factory); + } +#endif + private sealed class DeferIterator : AsyncIteratorBase { private readonly Func> _factory; @@ -141,5 +150,63 @@ private async ValueTask InitializeAndMoveNextAsync() return await _enumerator.MoveNextAsync().ConfigureAwait(false); } } + +#if !NO_DEEP_CANCELLATION + private sealed class AsyncDeferIteratorWithCancellation : AsyncIteratorBase + { + private readonly Func>> _factory; + private IAsyncEnumerator _enumerator; + + public AsyncDeferIteratorWithCancellation(Func>> factory) + { + Debug.Assert(factory != null); + + _factory = factory; + } + + public override T Current => _enumerator == null ? default : _enumerator.Current; + + public override AsyncIteratorBase Clone() + { + return new AsyncDeferIteratorWithCancellation(_factory); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override ValueTask MoveNextCore() + { + if (_enumerator == null) + { + return InitializeAndMoveNextAsync(); + } + + return _enumerator.MoveNextAsync(); + } + + private async ValueTask InitializeAndMoveNextAsync() + { + try + { + _enumerator = (await _factory(_cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); + } + catch (Exception ex) + { + _enumerator = Throw(ex).GetAsyncEnumerator(_cancellationToken); + throw; + } + + return await _enumerator.MoveNextAsync().ConfigureAwait(false); + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 895ae029ac..edb29734fe 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -41,6 +41,9 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer: null); } +#if !NO_DEEP_CANCELLATION // TODO +#endif + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) @@ -53,6 +56,9 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION // TODO +#endif + private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { return new DistinctAsyncIterator(source, keySelector, comparer); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 49e511f5a4..398edc8518 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -57,6 +57,18 @@ public static IAsyncEnumerable DistinctUntilChanged(this return DistinctUntilChangedCore(source, keySelector, comparer: null); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return DistinctUntilChangedCore(source, keySelector, comparer: null); + } +#endif + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { if (source == null) @@ -69,6 +81,20 @@ public static IAsyncEnumerable DistinctUntilChanged(this return DistinctUntilChangedCore(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable DistinctUntilChanged(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + if (comparer == null) + throw Error.ArgumentNull(nameof(comparer)); + + return DistinctUntilChangedCore(source, keySelector, comparer); + } +#endif + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, IEqualityComparer comparer) { return new DistinctUntilChangedAsyncIterator(source, comparer); @@ -84,6 +110,13 @@ private static IAsyncEnumerable DistinctUntilChangedCore return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION + private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + return new DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(source, keySelector, comparer); + } +#endif + private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; @@ -296,5 +329,78 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class DistinctUntilChangedAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly IEqualityComparer _comparer; + private readonly Func> _keySelector; + private readonly IAsyncEnumerable _source; + private TKey _currentKeyValue; + + private IAsyncEnumerator _enumerator; + private bool _hasCurrentKey; + + public DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + _source = source; + _keySelector = keySelector; + _comparer = comparer ?? EqualityComparer.Default; + } + + public override AsyncIteratorBase Clone() + { + return new DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(_source, _keySelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _currentKeyValue = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + var comparerEquals = false; + + if (_hasCurrentKey) + { + comparerEquals = _comparer.Equals(_currentKeyValue, key); + } + if (!_hasCurrentKey || !comparerEquals) + { + _hasCurrentKey = true; + _currentKeyValue = key; + _current = item; + return true; + } + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index 06628ac7f1..a566512024 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -11,6 +11,8 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + // REVIEW: Should we convert Task-based overloads to ValueTask? + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Action onNext) { if (source == null) @@ -107,6 +109,56 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + + return DoCore(source, onNext: onNext, onError: null, onCompleted: null); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onCompleted) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + if (onCompleted == null) + throw Error.ArgumentNull(nameof(onCompleted)); + + return DoCore(source, onNext: onNext, onError: null, onCompleted: onCompleted); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + if (onError == null) + throw Error.ArgumentNull(nameof(onError)); + + return DoCore(source, onNext: onNext, onError: onError, onCompleted: null); + } + + public static IAsyncEnumerable Do(this IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (onNext == null) + throw Error.ArgumentNull(nameof(onNext)); + if (onError == null) + throw Error.ArgumentNull(nameof(onError)); + if (onCompleted == null) + throw Error.ArgumentNull(nameof(onCompleted)); + + return DoCore(source, onNext, onError, onCompleted); + } +#endif + public static IAsyncEnumerable Do(this IAsyncEnumerable source, IObserver observer) { if (source == null) @@ -127,6 +179,13 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable(source, onNext, onError, onCompleted); } +#if !NO_DEEP_CANCELLATION + private static IAsyncEnumerable DoCore(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + return new DoAsyncIteratorWithTaskAndCancellation(source, onNext, onError, onCompleted); + } +#endif + private sealed class DoAsyncIterator : AsyncIterator { private readonly Action _onCompleted; @@ -281,5 +340,86 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class DoAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func _onCompleted; + private readonly Func _onError; + private readonly Func _onNext; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + + public DoAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) + { + Debug.Assert(source != null); + Debug.Assert(onNext != null); + + _source = source; + _onNext = onNext; + _onError = onError; + _onCompleted = onCompleted; + } + + public override AsyncIteratorBase Clone() + { + return new DoAsyncIteratorWithTaskAndCancellation(_source, _onNext, _onError, _onCompleted); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + try + { + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + await _onNext(_current, _cancellationToken).ConfigureAwait(false); + + return true; + } + } + catch (OperationCanceledException) + { + throw; + } + catch (Exception ex) when (_onError != null) + { + await _onError(ex, _cancellationToken).ConfigureAwait(false); + throw; + } + + if (_onCompleted != null) + { + await _onCompleted(_cancellationToken).ConfigureAwait(false); + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index 82ee0ff921..bb7aeda337 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -31,6 +31,18 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable(source, selector); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func>> selector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return new ExpandAsyncIteratorWithTaskAndCancellation(source, selector); + } +#endif + private sealed class ExpandAsyncIterator : AsyncIterator { private readonly Func> _selector; @@ -210,5 +222,97 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class ExpandAsyncIteratorWithTaskAndCancellation : AsyncIterator + { + private readonly Func>> _selector; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + + private Queue> _queue; + + public ExpandAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func>> selector) + { + Debug.Assert(source != null); + Debug.Assert(selector != null); + + _source = source; + _selector = selector; + } + + public override AsyncIteratorBase Clone() + { + return new ExpandAsyncIteratorWithTaskAndCancellation(_source, _selector); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + _queue = null; + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _queue = new Queue>(); + _queue.Enqueue(_source); + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (true) + { + if (_enumerator == null) + { + if (_queue.Count > 0) + { + var src = _queue.Dequeue(); + + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + } + + _enumerator = src.GetAsyncEnumerator(_cancellationToken); + + continue; // loop + } + + break; // while + } + + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + var next = await _selector(item, _cancellationToken).ConfigureAwait(false); + _queue.Enqueue(next); + _current = item; + return true; + } + + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + break; // case + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 52bc64d620..bbf2c89cc6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -31,6 +30,8 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable(source, finallyAction); } + // REVIEW: No cancellation support for finally action. + private sealed class FinallyAsyncIterator : AsyncIterator { private readonly Action _finallyAction; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 897325aa93..97a8988a58 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -23,6 +23,8 @@ public static IAsyncEnumerable Generate(TState initial return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); } + // REVIEW: Add async variant? + private sealed class GenerateAsyncIterator : AsyncIterator { private readonly Func _condition; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index a4b988cfe7..b351242334 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -70,6 +70,18 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer: null, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MaxByCore(source, keySelector, comparer: null, cancellationToken); + } +#endif + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) @@ -90,6 +102,18 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MaxByCore(source, keySelector, comparer, cancellationToken); + } +#endif + private static Task> MaxByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) @@ -109,5 +133,17 @@ private static Task> MaxByCore(IAsyncEnumerable comparer.Compare(key, minValue), cancellationToken); } + +#if !NO_DEEP_CANCELLATION + private static Task> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (comparer == null) + { + comparer = Comparer.Default; + } + + return ExtremaBy(source, keySelector, (key, minValue) => comparer.Compare(key, minValue), cancellationToken); + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 42deacd924..892af69474 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -70,6 +70,18 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer: null, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MinByCore(source, keySelector, comparer: null, cancellationToken); + } +#endif + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) @@ -90,6 +102,18 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer, cancellationToken); } +#if !NO_DEEP_CANCELLATION + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return MinByCore(source, keySelector, comparer, cancellationToken); + } +#endif + private static Task> MinByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) @@ -110,6 +134,18 @@ private static Task> MinByCore(IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); } +#if !NO_DEEP_CANCELLATION + private static Task> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + { + if (comparer == null) + { + comparer = Comparer.Default; + } + + return ExtremaBy(source, keySelector, (key, minValue) => -comparer.Compare(key, minValue), cancellationToken); + } +#endif + private static async Task> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) { var result = new List(); @@ -189,5 +225,47 @@ private static async Task> ExtremaBy(IAsyncEnumera return result; } + +#if !NO_DEEP_CANCELLATION + private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) + { + var result = new List(); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); + + var current = e.Current; + var resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); + result.Add(current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var key = await keySelector(cur, cancellationToken).ConfigureAwait(false); + + var cmp = compare(key, resKey); + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return result; + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 6be9e4c501..82cb3e838a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -41,6 +41,18 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable(source, accumulator); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func> accumulator) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + + return new ScanAsyncEnumerableWithTaskAndCancellation(source, accumulator); + } +#endif + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) { if (source == null) @@ -51,6 +63,18 @@ public static IAsyncEnumerable Scan(this IAsy return new ScanAsyncEnumerableWithTask(source, seed, accumulator); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + + return new ScanAsyncEnumerableWithTaskAndCancellation(source, seed, accumulator); + } +#endif + private sealed class ScanAsyncEnumerable : AsyncIterator { private readonly Func _accumulator; @@ -263,6 +287,82 @@ protected override async ValueTask MoveNextCore() } } +#if !NO_DEEP_CANCELLATION + private sealed class ScanAsyncEnumerableWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _accumulator; + private readonly IAsyncEnumerable _source; + + private TSource _accumulated; + private IAsyncEnumerator _enumerator; + + private bool _hasSeed; + + public ScanAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> accumulator) + { + Debug.Assert(source != null); + Debug.Assert(accumulator != null); + + _source = source; + _accumulator = accumulator; + } + + public override AsyncIteratorBase Clone() + { + return new ScanAsyncEnumerableWithTaskAndCancellation(_source, _accumulator); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _hasSeed = false; + _accumulated = default; + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + if (!_hasSeed) + { + _hasSeed = true; + _accumulated = item; + continue; // loop + } + + _accumulated = await _accumulator(_accumulated, item, _cancellationToken).ConfigureAwait(false); + _current = _accumulated; + return true; + } + + break; // case + + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif + private sealed class ScanAsyncEnumerableWithTask : AsyncIterator { private readonly Func> _accumulator; @@ -327,5 +427,72 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class ScanAsyncEnumerableWithTaskAndCancellation : AsyncIterator + { + private readonly Func> _accumulator; + private readonly TAccumulate _seed; + private readonly IAsyncEnumerable _source; + + private TAccumulate _accumulated; + private IAsyncEnumerator _enumerator; + + public ScanAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, TAccumulate seed, Func> accumulator) + { + Debug.Assert(source != null); + Debug.Assert(accumulator != null); + + _source = source; + _seed = seed; + _accumulator = accumulator; + } + + public override AsyncIteratorBase Clone() + { + return new ScanAsyncEnumerableWithTaskAndCancellation(_source, _seed, _accumulator); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _accumulated = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + _accumulated = _seed; + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + var item = _enumerator.Current; + _accumulated = await _accumulator(_accumulated, item, _cancellationToken).ConfigureAwait(false); + _current = _accumulated; + return true; + } + + break; + + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 0641fff7d2..2e459a2109 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -11,6 +11,8 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + // REVIEW: Add support for IAsyncDisposable resources. + public static IAsyncEnumerable Using(Func resourceFactory, Func> enumerableFactory) where TResource : IDisposable { if (resourceFactory == null) @@ -31,6 +33,18 @@ public static IAsyncEnumerable Using(Func(resourceFactory, enumerableFactory); } +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Using(Func> resourceFactory, Func>> enumerableFactory) where TResource : IDisposable + { + if (resourceFactory == null) + throw Error.ArgumentNull(nameof(resourceFactory)); + if (enumerableFactory == null) + throw Error.ArgumentNull(nameof(enumerableFactory)); + + return new UsingAsyncIteratorWithTaskAndCancellation(resourceFactory, enumerableFactory); + } +#endif + private sealed class UsingAsyncIterator : AsyncIterator where TResource : IDisposable { private readonly Func> _enumerableFactory; @@ -165,5 +179,74 @@ protected override async ValueTask MoveNextCore() return false; } } + +#if !NO_DEEP_CANCELLATION + private sealed class UsingAsyncIteratorWithTaskAndCancellation : AsyncIterator where TResource : IDisposable + { + private readonly Func>> _enumerableFactory; + private readonly Func> _resourceFactory; + + private IAsyncEnumerable _enumerable; + private IAsyncEnumerator _enumerator; + private TResource _resource; + + public UsingAsyncIteratorWithTaskAndCancellation(Func> resourceFactory, Func>> enumerableFactory) + { + Debug.Assert(resourceFactory != null); + Debug.Assert(enumerableFactory != null); + + _resourceFactory = resourceFactory; + _enumerableFactory = enumerableFactory; + } + + public override AsyncIteratorBase Clone() + { + return new UsingAsyncIteratorWithTaskAndCancellation(_resourceFactory, _enumerableFactory); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + } + + if (_resource != null) + { + _resource.Dispose(); + _resource = default; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _resource = await _resourceFactory(_cancellationToken).ConfigureAwait(false); + _enumerable = await _enumerableFactory(_resource, _cancellationToken).ConfigureAwait(false); + + _enumerator = _enumerable.GetAsyncEnumerator(_cancellationToken); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + } +#endif } } diff --git a/Ix.NET/Source/refs/Directory.build.props b/Ix.NET/Source/refs/Directory.build.props index 8441a3178b..613a4047db 100644 --- a/Ix.NET/Source/refs/Directory.build.props +++ b/Ix.NET/Source/refs/Directory.build.props @@ -5,7 +5,6 @@ 2.1 - $(DefineConstants);REFERENCE_ASSEMBLY diff --git a/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj new file mode 100644 index 0000000000..fac0fd0748 --- /dev/null +++ b/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj @@ -0,0 +1,19 @@ + + + + Interactive Extensions Async Providers Library used to build query providers and express queries over enumerable sequences. + Interactive Extensions - Async Providers Library + netcoreapp2.0;netstandard2.1 + Ix;Interactive;Extensions;Enumerable;Asynchronous + + + + + + + + + + + + diff --git a/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj new file mode 100644 index 0000000000..f064a205ae --- /dev/null +++ b/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj @@ -0,0 +1,23 @@ + + + + Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. + Interactive Extensions - Async Library + Microsoft + netcoreapp2.0;netstandard2.1 + Ix;Interactive;Extensions;Enumerable;Asynchronous + + + + + + + + + + + + + + + diff --git a/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj new file mode 100644 index 0000000000..01fa4992ec --- /dev/null +++ b/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj @@ -0,0 +1,23 @@ + + + + LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. + System.Linq.Async.Queryable + Microsoft + netstandard1.0;netcoreapp2.0;netstandard2.1 + Enumerable;Asynchronous;LINQ + + + + + + + + + + + + + + + diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj new file mode 100644 index 0000000000..889887cddb --- /dev/null +++ b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj @@ -0,0 +1,19 @@ + + + + LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. + System.Linq.Async + Microsoft + netstandard1.0;netcoreapp2.0;netstandard2.1 + Enumerable;Asynchronous;LINQ + + + + + + + + + + + From b584036ab38579034969e5292682a157d4433257 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 10:15:59 -0800 Subject: [PATCH 543/862] Add interface implementation for ConfigureAwait. --- .../Threading/Tasks/AsyncEnumerableExtensions.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index 81f11a8432..d3b5dd4294 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -19,7 +19,10 @@ public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerab return new ConfiguredAsyncEnumerable(enumerable, continueOnCapturedContext); } - public struct ConfiguredAsyncEnumerable + // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation. + // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. + + public struct ConfiguredAsyncEnumerable : IAsyncEnumerable { private readonly IAsyncEnumerable _enumerable; private readonly bool _continueOnCapturedContext; @@ -33,7 +36,10 @@ internal ConfiguredAsyncEnumerable(IAsyncEnumerable enumerable, bool continue public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); - public struct ConfiguredAsyncEnumerator + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => + GetAsyncEnumerator(cancellationToken); + + public struct ConfiguredAsyncEnumerator : IAsyncEnumerator { private readonly IAsyncEnumerator _enumerator; private readonly bool _continueOnCapturedContext; @@ -51,6 +57,12 @@ public ConfiguredValueTaskAwaitable MoveNextAsync() => public ConfiguredValueTaskAwaitable DisposeAsync() => _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); + + async ValueTask IAsyncEnumerator.MoveNextAsync() => + await _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); + + async ValueTask IAsyncDisposable.DisposeAsync() => + await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); } } } From 7499e2a070077d4ac2e674a6b7f070d643db30d6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 10:16:06 -0800 Subject: [PATCH 544/862] Add WithCancellation operator. --- .../System/Linq/AsyncEnumerable.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index f9921a85b4..09db9a7f7c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; +using System.Threading.Tasks; namespace System.Linq { @@ -18,6 +19,14 @@ public static IAsyncEnumerable CreateEnumerable(Func(getEnumerator); } + public static IAsyncEnumerable WithCancellation(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return new WithCancellationAsyncEnumerable(source, cancellationToken); + } + private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable { private readonly Func> _getEnumerator; @@ -31,5 +40,44 @@ public AnonymousAsyncEnumerable(Func> get public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => _getEnumerator(cancellationToken); } + + // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. + // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. + + public struct WithCancellationAsyncEnumerable : IAsyncEnumerable + { + private readonly IAsyncEnumerable _source; + private readonly CancellationToken _cancellationToken; + + public WithCancellationAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) + { + _source = source; + _cancellationToken = cancellationToken; + } + + // REVIEW: Should we simply ignore the second cancellation token or should we link the two? + + public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) + => new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(_cancellationToken)); + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + => GetAsyncEnumerator(cancellationToken); + + public struct WithCancellationAsyncEnumerator : IAsyncEnumerator + { + private readonly IAsyncEnumerator _enumerator; + + public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) + { + _enumerator = enumerator; + } + + public T Current => _enumerator.Current; + + public ValueTask DisposeAsync() => _enumerator.DisposeAsync(); + + public ValueTask MoveNextAsync() => _enumerator.MoveNextAsync(); + } + } } } From 1fe1409a43852cd2a95ce4a3a44554a118db0273 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:22:25 -0800 Subject: [PATCH 545/862] Cosmetics. --- .../System.Linq.Async/System/Linq/Operators/TakeWhile.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 5df1a3346f..6e2c81005e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -117,7 +117,6 @@ protected override async ValueTask MoveNextCore() _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; - case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -182,7 +181,6 @@ protected override async ValueTask MoveNextCore() _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; - case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -252,7 +250,6 @@ protected override async ValueTask MoveNextCore() _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; - case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -383,7 +380,6 @@ protected override async ValueTask MoveNextCore() _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; - case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -455,7 +451,6 @@ protected override async ValueTask MoveNextCore() _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; - case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { From 8d11e5c8f439d1f849bb586b963a293aad3aab5d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:23:07 -0800 Subject: [PATCH 546/862] Mark some structs as readonly. --- .../Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs | 6 +++--- Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs | 2 +- .../System/Threading/Tasks/AsyncEnumerableExtensions.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 09db9a7f7c..63e5e308fd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -19,7 +19,7 @@ public static IAsyncEnumerable CreateEnumerable(Func(getEnumerator); } - public static IAsyncEnumerable WithCancellation(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static WithCancellationAsyncEnumerable WithCancellation(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -44,7 +44,7 @@ public AnonymousAsyncEnumerable(Func> get // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. - public struct WithCancellationAsyncEnumerable : IAsyncEnumerable + public readonly struct WithCancellationAsyncEnumerable : IAsyncEnumerable { private readonly IAsyncEnumerable _source; private readonly CancellationToken _cancellationToken; @@ -63,7 +63,7 @@ public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken canc IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => GetAsyncEnumerator(cancellationToken); - public struct WithCancellationAsyncEnumerator : IAsyncEnumerator + public readonly struct WithCancellationAsyncEnumerator : IAsyncEnumerator { private readonly IAsyncEnumerator _enumerator; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs index 8044a37d18..e7d923b5c6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs @@ -6,7 +6,7 @@ namespace System.Linq { - internal struct Maybe : IEquatable> + internal readonly struct Maybe : IEquatable> { public Maybe(T value) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index d3b5dd4294..da85697f1b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -22,7 +22,7 @@ public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerab // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation. // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. - public struct ConfiguredAsyncEnumerable : IAsyncEnumerable + public readonly struct ConfiguredAsyncEnumerable : IAsyncEnumerable { private readonly IAsyncEnumerable _enumerable; private readonly bool _continueOnCapturedContext; @@ -39,7 +39,7 @@ public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => GetAsyncEnumerator(cancellationToken); - public struct ConfiguredAsyncEnumerator : IAsyncEnumerator + public readonly struct ConfiguredAsyncEnumerator : IAsyncEnumerator { private readonly IAsyncEnumerator _enumerator; private readonly bool _continueOnCapturedContext; From 4e73c9a0320c380c7368d6191549bc80ece63412 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:23:38 -0800 Subject: [PATCH 547/862] Save some state machine allocations. --- .../System/Linq/AsyncListPartition.cs | 13 +++++++++---- .../System/Linq/Operators/Range.cs | 15 ++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index d84163f213..a4ec5eeafe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -38,17 +38,22 @@ public override AsyncIteratorBase Clone() return new AsyncListPartition(_source, _minIndexInclusive, _maxIndexInclusive); } - protected override async ValueTask MoveNextCore() + protected override ValueTask MoveNextCore() { if ((uint)_index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && _index < _source.Count - _minIndexInclusive) { _current = _source[_minIndexInclusive + _index]; ++_index; - return true; + return new ValueTask(true); } - await DisposeAsync().ConfigureAwait(false); - return false; + return Core(); + + async ValueTask Core() + { + await DisposeAsync().ConfigureAwait(false); + return false; + } } #if NOT_YET diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index d7964a3e66..e321190950 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -107,7 +107,7 @@ public ValueTask> TryGetElementAsync(int index, CancellationToken can public ValueTask> TryGetLastAsync(CancellationToken cancellationToken) => new ValueTask>(new Maybe(_end - 1)); - protected override async ValueTask MoveNextCore() + protected override ValueTask MoveNextCore() { switch (_state) { @@ -115,21 +115,26 @@ protected override async ValueTask MoveNextCore() _current = _start; _state = AsyncIteratorState.Iterating; - return true; + return new ValueTask(true); case AsyncIteratorState.Iterating: _current++; if (_current != _end) { - return true; + return new ValueTask(true); } break; } - await DisposeAsync().ConfigureAwait(false); - return false; + return Core(); + + async ValueTask Core() + { + await DisposeAsync().ConfigureAwait(false); + return false; + } } } } From 1e2096aadd803e5fd0c689bc5d238b12dc106015 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:23:48 -0800 Subject: [PATCH 548/862] Mark a few methods as static. --- .../System/Linq/AsyncEnumerableRewriter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs index a1758a9884..fa691301b6 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs @@ -250,7 +250,7 @@ private static bool ArgsMatch(MethodInfo method, ReadOnlyCollection return true; } - private ReadOnlyCollection FixupQuotedArgs(MethodInfo method, ReadOnlyCollection argList) + private static ReadOnlyCollection FixupQuotedArgs(MethodInfo method, ReadOnlyCollection argList) { // // Get all of the method parameters. No fix-up needed if empty. @@ -303,7 +303,7 @@ private ReadOnlyCollection FixupQuotedArgs(MethodInfo method, ReadOn return argList; } - private Expression FixupQuotedExpression(Type type, Expression expression) + private static Expression FixupQuotedExpression(Type type, Expression expression) { var res = expression; From 3504fe8bf65675a58c65f2545e5701f626d46fd2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:24:04 -0800 Subject: [PATCH 549/862] Move Task conversion to separate file. --- .../Linq/Operators/ToAsyncEnumerable.Task.cs | 42 +++++++++++++++++++ .../Linq/Operators/ToAsyncEnumerable.cs | 38 ++++------------- 2 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs new file mode 100644 index 0000000000..eeece1f6f5 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable ToAsyncEnumerable(this Task task) + { + if (task == null) + throw Error.ArgumentNull(nameof(task)); + + return new TaskToAsyncEnumerable(task); + } + + private sealed class TaskToAsyncEnumerable : AsyncIterator + { + private readonly Task _task; + private int _called; + + public TaskToAsyncEnumerable(Task task) => _task = task; + + public override AsyncIteratorBase Clone() => new TaskToAsyncEnumerable(_task); + + protected override async ValueTask MoveNextCore() + { + if (Interlocked.CompareExchange(ref _called, 1, 0) == 0) + { + _current = await _task.ConfigureAwait(false); + return true; + } + + return false; + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index f71bde926c..98d47324ba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -18,41 +18,17 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IEnumera throw Error.ArgumentNull(nameof(source)); // optimize these adapters for lists and collections - if (source is IList list) - return new AsyncIListEnumerableAdapter(list); - - if (source is ICollection collection) - return new AsyncICollectionEnumerableAdapter(collection); + switch (source) + { + case IList list: + return new AsyncIListEnumerableAdapter(list); + case ICollection collection: + return new AsyncICollectionEnumerableAdapter(collection); + } return new AsyncEnumerableAdapter(source); } - public static IAsyncEnumerable ToAsyncEnumerable(this Task task) - { - if (task == null) - throw Error.ArgumentNull(nameof(task)); - - return CreateEnumerable( - _ => - { - var called = 0; - - var value = default(TSource); - return AsyncEnumerator.Create( - async () => - { - if (Interlocked.CompareExchange(ref called, 1, 0) == 0) - { - value = await task.ConfigureAwait(false); - return true; - } - return false; - }, - () => value, - () => default); - }); - } - public static IAsyncEnumerable ToAsyncEnumerable(this IObservable source) { if (source == null) From 640aa0f7d50b87b3ce070cf073bdc18e0699b401 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:28:20 -0800 Subject: [PATCH 550/862] Marking a few classes as private instead of internal. --- .../System/Linq/Operators/ToAsyncEnumerable.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 98d47324ba..3f4675cc78 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -99,7 +99,7 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva }); } - internal sealed class AsyncEnumerableAdapter : AsyncIterator, IAsyncIListProvider + private sealed class AsyncEnumerableAdapter : AsyncIterator, IAsyncIListProvider { private readonly IEnumerable _source; @@ -169,7 +169,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT } } - internal sealed class AsyncIListEnumerableAdapter : AsyncIterator, IAsyncIListProvider, IList + private sealed class AsyncIListEnumerableAdapter : AsyncIterator, IAsyncIListProvider, IList { private readonly IList _source; private IEnumerator _enumerator; @@ -273,7 +273,7 @@ T IList.this[int index] } } - internal sealed class AsyncICollectionEnumerableAdapter : AsyncIterator, IAsyncIListProvider, ICollection + private sealed class AsyncICollectionEnumerableAdapter : AsyncIterator, IAsyncIListProvider, ICollection { private readonly ICollection _source; private IEnumerator _enumerator; From f08c7f063ed1f5324c6f5fa14bd422f23038d779 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:30:16 -0800 Subject: [PATCH 551/862] Remove IObservable conversion to its own file. --- .../Operators/ToAsyncEnumerable.Observable.cs | 160 ++++++++++++++++++ .../Linq/Operators/ToAsyncEnumerable.cs | 148 ---------------- 2 files changed, 160 insertions(+), 148 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs new file mode 100644 index 0000000000..41710acfc0 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs @@ -0,0 +1,160 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + public static IAsyncEnumerable ToAsyncEnumerable(this IObservable source) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return CreateEnumerable( + ct => + { + var observer = new ToAsyncEnumerableObserver(); + + var subscription = source.Subscribe(observer); + + // REVIEW: Review possible concurrency issues with Dispose calls. + + var ctr = ct.Register(subscription.Dispose); + + return AsyncEnumerator.Create( + tcs => + { + var hasValue = false; + var hasCompleted = false; + var error = default(Exception); + + lock (observer.SyncRoot) + { + if (observer.Values.Count > 0) + { + hasValue = true; + observer.Current = observer.Values.Dequeue(); + } + else if (observer.HasCompleted) + { + hasCompleted = true; + } + else if (observer.Error != null) + { + error = observer.Error; + } + else + { + observer.TaskCompletionSource = tcs; + } + } + + if (hasValue) + { + tcs.TrySetResult(true); + } + else if (hasCompleted) + { + tcs.TrySetResult(false); + } + else if (error != null) + { + tcs.TrySetException(error); + } + + return new ValueTask(tcs.Task); + }, + () => observer.Current, + () => + { + ctr.Dispose(); + subscription.Dispose(); + // Should we cancel in-flight operations somehow? + return default; + }); + }); + } + + private sealed class ToAsyncEnumerableObserver : IObserver + { + public readonly Queue Values; + + public T Current; + public Exception Error; + public bool HasCompleted; + public TaskCompletionSource TaskCompletionSource; + + public ToAsyncEnumerableObserver() + { + Values = new Queue(); + } + + public object SyncRoot + { + get { return Values; } + } + + public void OnCompleted() + { + var tcs = default(TaskCompletionSource); + + lock (SyncRoot) + { + HasCompleted = true; + + if (TaskCompletionSource != null) + { + tcs = TaskCompletionSource; + TaskCompletionSource = null; + } + } + + tcs?.TrySetResult(false); + } + + public void OnError(Exception error) + { + var tcs = default(TaskCompletionSource); + + lock (SyncRoot) + { + Error = error; + + if (TaskCompletionSource != null) + { + tcs = TaskCompletionSource; + TaskCompletionSource = null; + } + } + + tcs?.TrySetException(error); + } + + public void OnNext(T value) + { + var tcs = default(TaskCompletionSource); + + lock (SyncRoot) + { + if (TaskCompletionSource == null) + { + Values.Enqueue(value); + } + else + { + Current = value; + + tcs = TaskCompletionSource; + TaskCompletionSource = null; + } + } + + tcs?.TrySetResult(true); + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 3f4675cc78..cfc4004984 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -29,76 +29,6 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IEnumera return new AsyncEnumerableAdapter(source); } - public static IAsyncEnumerable ToAsyncEnumerable(this IObservable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return CreateEnumerable( - ct => - { - var observer = new ToAsyncEnumerableObserver(); - - var subscription = source.Subscribe(observer); - - // REVIEW: Review possible concurrency issues with Dispose calls. - - var ctr = ct.Register(subscription.Dispose); - - return AsyncEnumerator.Create( - tcs => - { - var hasValue = false; - var hasCompleted = false; - var error = default(Exception); - - lock (observer.SyncRoot) - { - if (observer.Values.Count > 0) - { - hasValue = true; - observer.Current = observer.Values.Dequeue(); - } - else if (observer.HasCompleted) - { - hasCompleted = true; - } - else if (observer.Error != null) - { - error = observer.Error; - } - else - { - observer.TaskCompletionSource = tcs; - } - } - - if (hasValue) - { - tcs.TrySetResult(true); - } - else if (hasCompleted) - { - tcs.TrySetResult(false); - } - else if (error != null) - { - tcs.TrySetException(error); - } - - return new ValueTask(tcs.Task); - }, - () => observer.Current, - () => - { - ctr.Dispose(); - subscription.Dispose(); - // Should we cancel in-flight operations somehow? - return default; - }); - }); - } - private sealed class AsyncEnumerableAdapter : AsyncIterator, IAsyncIListProvider { private readonly IEnumerable _source; @@ -359,83 +289,5 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT bool ICollection.IsReadOnly => _source.IsReadOnly; } - - private sealed class ToAsyncEnumerableObserver : IObserver - { - public readonly Queue Values; - - public T Current; - public Exception Error; - public bool HasCompleted; - public TaskCompletionSource TaskCompletionSource; - - public ToAsyncEnumerableObserver() - { - Values = new Queue(); - } - - public object SyncRoot - { - get { return Values; } - } - - public void OnCompleted() - { - var tcs = default(TaskCompletionSource); - - lock (SyncRoot) - { - HasCompleted = true; - - if (TaskCompletionSource != null) - { - tcs = TaskCompletionSource; - TaskCompletionSource = null; - } - } - - tcs?.TrySetResult(false); - } - - public void OnError(Exception error) - { - var tcs = default(TaskCompletionSource); - - lock (SyncRoot) - { - Error = error; - - if (TaskCompletionSource != null) - { - tcs = TaskCompletionSource; - TaskCompletionSource = null; - } - } - - tcs?.TrySetException(error); - } - - public void OnNext(T value) - { - var tcs = default(TaskCompletionSource); - - lock (SyncRoot) - { - if (TaskCompletionSource == null) - { - Values.Enqueue(value); - } - else - { - Current = value; - - tcs = TaskCompletionSource; - TaskCompletionSource = null; - } - } - - tcs?.TrySetResult(true); - } - } } } From 3632d7ed7c58772ffa0f9fa471deafe4dce0bcde Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 20 Nov 2018 13:33:00 -0800 Subject: [PATCH 552/862] Clean up some code. --- .../Linq/Operators/ToAsyncEnumerable.cs | 69 ++++--------------- 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index cfc4004984..c84d12d3dd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -42,10 +42,7 @@ public AsyncEnumerableAdapter(IEnumerable source) _source = source; } - public override AsyncIteratorBase Clone() - { - return new AsyncEnumerableAdapter(_source); - } + public override AsyncIteratorBase Clone() => new AsyncEnumerableAdapter(_source); public override async ValueTask DisposeAsync() { @@ -83,20 +80,11 @@ protected override async ValueTask MoveNextCore() // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize // and short circuit as appropriate - public Task ToArrayAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_source.ToArray()); - } + public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToArray()); - public Task> ToListAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_source.ToList()); - } + public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToList()); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - return Task.FromResult(_source.Count()); - } + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_source.Count()); } private sealed class AsyncIListEnumerableAdapter : AsyncIterator, IAsyncIListProvider, IList @@ -111,10 +99,7 @@ public AsyncIListEnumerableAdapter(IList source) _source = source; } - public override AsyncIteratorBase Clone() - { - return new AsyncIListEnumerableAdapter(_source); - } + public override AsyncIteratorBase Clone() => new AsyncIListEnumerableAdapter(_source); public override async ValueTask DisposeAsync() { @@ -150,27 +135,15 @@ protected override async ValueTask MoveNextCore() return false; } - public override IAsyncEnumerable Select(Func selector) - { - return new SelectIListIterator(_source, selector); - } + public override IAsyncEnumerable Select(Func selector) => new SelectIListIterator(_source, selector); // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize // and short circuit as appropriate - public Task ToArrayAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_source.ToArray()); - } + public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToArray()); - public Task> ToListAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_source.ToList()); - } + public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToList()); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - return Task.FromResult(_source.Count); - } + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_source.Count); IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); @@ -198,8 +171,8 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT T IList.this[int index] { - get { return _source[index]; } - set { _source[index] = value; } + get => _source[index]; + set => _source[index] = value; } } @@ -215,10 +188,7 @@ public AsyncICollectionEnumerableAdapter(ICollection source) _source = source; } - public override AsyncIteratorBase Clone() - { - return new AsyncICollectionEnumerableAdapter(_source); - } + public override AsyncIteratorBase Clone() => new AsyncICollectionEnumerableAdapter(_source); public override async ValueTask DisposeAsync() { @@ -256,20 +226,11 @@ protected override async ValueTask MoveNextCore() // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize // and short circuit as appropriate - public Task ToArrayAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_source.ToArray()); - } + public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToArray()); - public Task> ToListAsync(CancellationToken cancellationToken) - { - return Task.FromResult(_source.ToList()); - } + public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToList()); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - return Task.FromResult(_source.Count); - } + public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_source.Count); IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); From 8b7d90e758b802ec9b122cfa54ebde0262996d7c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 29 Nov 2018 15:20:00 -0800 Subject: [PATCH 553/862] Embrace LDM-2018-11-28 decision to check for cancellation in GetAsyncEnumerator. --- .../System/Linq/Operators/Never.cs | 2 ++ .../System/Linq/Operators/Return.cs | 2 ++ .../System/Linq/Operators/Throw.cs | 2 ++ .../System/Linq/AsyncEnumerableQuery.cs | 2 ++ .../System/Linq/AsyncEnumerable.cs | 8 +++++++- .../System/Linq/AsyncIterator.cs | 2 ++ .../System/Linq/Operators/Empty.cs | 7 ++++++- .../System/Linq/Operators/GroupJoin.cs | 18 +++++++++++++++--- .../System/Linq/Operators/Grouping.cs | 7 ++++++- .../System/Linq/Operators/Lookup.cs | 4 ++++ .../Tasks/AsyncEnumerableExtensions.cs | 8 ++++++-- 11 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index 541f1ceb3c..c72758369e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -21,6 +21,8 @@ private sealed class NeverAsyncEnumerable : IAsyncEnumerable public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + return new NeverAsyncEnumerator(cancellationToken); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs index abf2571112..779d4c873a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -28,6 +28,8 @@ public ReturnEnumerable(TValue value) public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + return new ReturnEnumerator(_value); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index 6abca00a40..aecc4352da 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -37,6 +37,8 @@ public ThrowEnumerable(ValueTask moveNextThrows) public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + return new ThrowEnumerator(_moveNextThrows); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs index c3d4317c49..74128d64b4 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs @@ -118,6 +118,8 @@ Task IAsyncQueryProvider.ExecuteAsync(Expression expression, C /// A new enumerator instance used to enumerate the elements in the sequence. public IAsyncEnumerator GetAsyncEnumerator(CancellationToken token) { + token.ThrowIfCancellationRequested(); + if (_enumerable == null) { var expression = Expression.Lambda>>(new AsyncEnumerableRewriter().Visit(_expression), null); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 63e5e308fd..e62580458e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -38,7 +38,12 @@ public AnonymousAsyncEnumerable(Func> get _getEnumerator = getEnumerator; } - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => _getEnumerator(cancellationToken); + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + + return _getEnumerator(cancellationToken); + } } // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. @@ -56,6 +61,7 @@ public WithCancellationAsyncEnumerable(IAsyncEnumerable source, CancellationT } // REVIEW: Should we simply ignore the second cancellation token or should we link the two? + // REVIEW: [LDM-2018-11-28] Should we have eager cancellation here too? public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(_cancellationToken)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 804ba8ca65..21720b8a70 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -30,6 +30,8 @@ protected AsyncIteratorBase() public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + var enumerator = _state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 2ff7c87a7b..b1dcb03757 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -42,7 +42,12 @@ public Task ToArrayAsync(CancellationToken cancellationToken) => Task. public ValueTask MoveNextAsync() => new ValueTask(false); - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => this; + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + + return this; + } public ValueTask DisposeAsync() => default; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index e3b1abf75e..6d8ee96a12 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -136,7 +136,10 @@ public GroupJoinAsyncEnumerable( } public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - => new GroupJoinAsyncEnumerator( + { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + + return new GroupJoinAsyncEnumerator( _outer.GetAsyncEnumerator(cancellationToken), _inner, _outerKeySelector, @@ -144,6 +147,7 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati _resultSelector, _comparer, cancellationToken); + } private sealed class GroupJoinAsyncEnumerator : IAsyncEnumerator { @@ -230,7 +234,10 @@ public GroupJoinAsyncEnumerableWithTask( } public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - => new GroupJoinAsyncEnumeratorWithTask( + { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + + return new GroupJoinAsyncEnumeratorWithTask( _outer.GetAsyncEnumerator(cancellationToken), _inner, _outerKeySelector, @@ -238,6 +245,7 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati _resultSelector, _comparer, cancellationToken); + } private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator { @@ -325,7 +333,10 @@ public GroupJoinAsyncEnumerableWithTaskAndCancellation( } public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - => new GroupJoinAsyncEnumeratorWithTask( + { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + + return new GroupJoinAsyncEnumeratorWithTask( _outer.GetAsyncEnumerator(cancellationToken), _inner, _outerKeySelector, @@ -333,6 +344,7 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati _resultSelector, _comparer, cancellationToken); + } private sealed class GroupJoinAsyncEnumeratorWithTask : IAsyncEnumerator { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs index be714fece9..8638b34218 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs @@ -89,6 +89,11 @@ internal void Trim() } } - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => this.ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + + return this.ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index ec11234db2..d51983bbdf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -274,6 +274,8 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); } @@ -687,6 +689,8 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + return Enumerable.Cast>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index da85697f1b..e65737d5da 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -33,8 +33,12 @@ internal ConfiguredAsyncEnumerable(IAsyncEnumerable enumerable, bool continue _continueOnCapturedContext = continueOnCapturedContext; } - public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) => - new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); + public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. + + return new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); + } IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => GetAsyncEnumerator(cancellationToken); From 80b4afa2c05377c7a52d1724912b7b315ebca5ce Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 29 Nov 2018 15:20:47 -0800 Subject: [PATCH 554/862] Small tweak to Task conversion code. --- .../System/Linq/Operators/ToAsyncEnumerable.Task.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs index eeece1f6f5..244d06efe3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Task.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -21,7 +20,6 @@ public static IAsyncEnumerable ToAsyncEnumerable(this Task : AsyncIterator { private readonly Task _task; - private int _called; public TaskToAsyncEnumerable(Task task) => _task = task; @@ -29,8 +27,9 @@ private sealed class TaskToAsyncEnumerable : AsyncIterator protected override async ValueTask MoveNextCore() { - if (Interlocked.CompareExchange(ref _called, 1, 0) == 0) + if (_state == AsyncIteratorState.Allocated) { + _state = AsyncIteratorState.Iterating; _current = await _task.ConfigureAwait(false); return true; } From 36167b3d0639b435ec74a4b409e6203c2ff6b4f2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 29 Nov 2018 15:42:12 -0800 Subject: [PATCH 555/862] Small name change for WithCancellationToken. --- .../System.Linq.Async/System/Linq/AsyncEnumerable.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index e62580458e..8d4841cc69 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -19,12 +19,14 @@ public static IAsyncEnumerable CreateEnumerable(Func(getEnumerator); } - public static WithCancellationAsyncEnumerable WithCancellation(this IAsyncEnumerable source, CancellationToken cancellationToken) + // REVIEW: [LDM-2018-11-28] Should return type be a struct or just the interface type? + + public static WithCancellationTokenAsyncEnumerable WithCancellationToken(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return new WithCancellationAsyncEnumerable(source, cancellationToken); + return new WithCancellationTokenAsyncEnumerable(source, cancellationToken); } private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable @@ -49,12 +51,12 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToke // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. - public readonly struct WithCancellationAsyncEnumerable : IAsyncEnumerable + public readonly struct WithCancellationTokenAsyncEnumerable : IAsyncEnumerable { private readonly IAsyncEnumerable _source; private readonly CancellationToken _cancellationToken; - public WithCancellationAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) + public WithCancellationTokenAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) { _source = source; _cancellationToken = cancellationToken; From 780545179056a94cd95fadbcf769165c098d86d2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 29 Nov 2018 18:40:53 -0800 Subject: [PATCH 556/862] Fix a namespace fluke. --- .../Tasks/AsyncEnumerableExtensions.cs | 83 +++++++++---------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index e65737d5da..e5a0c7f41d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -7,67 +7,64 @@ namespace System.Threading.Tasks { - namespace System.Threading.Tasks + public static class AsyncEnumerableExtensions { - public static class AsyncEnumerableExtensions + public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerable enumerable, bool continueOnCapturedContext) { - public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerable enumerable, bool continueOnCapturedContext) + if (enumerable == null) + throw Error.ArgumentNull(nameof(enumerable)); + + return new ConfiguredAsyncEnumerable(enumerable, continueOnCapturedContext); + } + + // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation. + // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. + + public readonly struct ConfiguredAsyncEnumerable : IAsyncEnumerable + { + private readonly IAsyncEnumerable _enumerable; + private readonly bool _continueOnCapturedContext; + + internal ConfiguredAsyncEnumerable(IAsyncEnumerable enumerable, bool continueOnCapturedContext) + { + _enumerable = enumerable; + _continueOnCapturedContext = continueOnCapturedContext; + } + + public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { - if (enumerable == null) - throw Error.ArgumentNull(nameof(enumerable)); + cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. - return new ConfiguredAsyncEnumerable(enumerable, continueOnCapturedContext); + return new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); } - // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation. - // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => + GetAsyncEnumerator(cancellationToken); - public readonly struct ConfiguredAsyncEnumerable : IAsyncEnumerable + public readonly struct ConfiguredAsyncEnumerator : IAsyncEnumerator { - private readonly IAsyncEnumerable _enumerable; + private readonly IAsyncEnumerator _enumerator; private readonly bool _continueOnCapturedContext; - internal ConfiguredAsyncEnumerable(IAsyncEnumerable enumerable, bool continueOnCapturedContext) + internal ConfiguredAsyncEnumerator(IAsyncEnumerator enumerator, bool continueOnCapturedContext) { - _enumerable = enumerable; + _enumerator = enumerator; _continueOnCapturedContext = continueOnCapturedContext; } - public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. - - return new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); - } + public ConfiguredValueTaskAwaitable MoveNextAsync() => + _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => - GetAsyncEnumerator(cancellationToken); - - public readonly struct ConfiguredAsyncEnumerator : IAsyncEnumerator - { - private readonly IAsyncEnumerator _enumerator; - private readonly bool _continueOnCapturedContext; + public T Current => _enumerator.Current; - internal ConfiguredAsyncEnumerator(IAsyncEnumerator enumerator, bool continueOnCapturedContext) - { - _enumerator = enumerator; - _continueOnCapturedContext = continueOnCapturedContext; - } + public ConfiguredValueTaskAwaitable DisposeAsync() => + _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - public ConfiguredValueTaskAwaitable MoveNextAsync() => - _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); + async ValueTask IAsyncEnumerator.MoveNextAsync() => + await _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); - public T Current => _enumerator.Current; - - public ConfiguredValueTaskAwaitable DisposeAsync() => - _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - - async ValueTask IAsyncEnumerator.MoveNextAsync() => - await _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); - - async ValueTask IAsyncDisposable.DisposeAsync() => - await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - } + async ValueTask IAsyncDisposable.DisposeAsync() => + await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); } } } From 0d6699be638f0f471d9f2b407cea0fe7280b83e0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 3 Dec 2018 10:11:56 -0800 Subject: [PATCH 557/862] Refactor WithCancellationToken to separate file. --- .../AsyncEnumerable.WithCancellationToken.cs | 63 +++++++++++++++++++ .../System/Linq/AsyncEnumerable.cs | 50 --------------- 2 files changed, 63 insertions(+), 50 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellationToken.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellationToken.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellationToken.cs new file mode 100644 index 0000000000..025d65fd57 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellationToken.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + // REVIEW: [LDM-2018-11-28] Should return type be a struct or just the interface type? Should this live in the System.Linq namespace or in System.Collections.Generic? + + public static WithCancellationTokenAsyncEnumerable WithCancellationToken(this IAsyncEnumerable source, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return new WithCancellationTokenAsyncEnumerable(source, cancellationToken); + } + + // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. + // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. + + public readonly struct WithCancellationTokenAsyncEnumerable : IAsyncEnumerable + { + private readonly IAsyncEnumerable _source; + private readonly CancellationToken _cancellationToken; + + public WithCancellationTokenAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) + { + _source = source; + _cancellationToken = cancellationToken; + } + + // REVIEW: Should we simply ignore the second cancellation token or should we link the two? + // REVIEW: [LDM-2018-11-28] Should we have eager cancellation here too? + + public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) + => new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(_cancellationToken)); + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + => GetAsyncEnumerator(cancellationToken); + + public readonly struct WithCancellationAsyncEnumerator : IAsyncEnumerator + { + private readonly IAsyncEnumerator _enumerator; + + public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) + { + _enumerator = enumerator; + } + + public T Current => _enumerator.Current; + + public ValueTask DisposeAsync() => _enumerator.DisposeAsync(); + + public ValueTask MoveNextAsync() => _enumerator.MoveNextAsync(); + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 8d4841cc69..595ff4a646 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -19,16 +19,6 @@ public static IAsyncEnumerable CreateEnumerable(Func(getEnumerator); } - // REVIEW: [LDM-2018-11-28] Should return type be a struct or just the interface type? - - public static WithCancellationTokenAsyncEnumerable WithCancellationToken(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return new WithCancellationTokenAsyncEnumerable(source, cancellationToken); - } - private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable { private readonly Func> _getEnumerator; @@ -47,45 +37,5 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToke return _getEnumerator(cancellationToken); } } - - // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. - // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. - - public readonly struct WithCancellationTokenAsyncEnumerable : IAsyncEnumerable - { - private readonly IAsyncEnumerable _source; - private readonly CancellationToken _cancellationToken; - - public WithCancellationTokenAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) - { - _source = source; - _cancellationToken = cancellationToken; - } - - // REVIEW: Should we simply ignore the second cancellation token or should we link the two? - // REVIEW: [LDM-2018-11-28] Should we have eager cancellation here too? - - public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - => new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(_cancellationToken)); - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - => GetAsyncEnumerator(cancellationToken); - - public readonly struct WithCancellationAsyncEnumerator : IAsyncEnumerator - { - private readonly IAsyncEnumerator _enumerator; - - public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) - { - _enumerator = enumerator; - } - - public T Current => _enumerator.Current; - - public ValueTask DisposeAsync() => _enumerator.DisposeAsync(); - - public ValueTask MoveNextAsync() => _enumerator.MoveNextAsync(); - } - } } } From 52373c9f1070f3273a0480dbf9b6025061d999c8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 3 Dec 2018 10:12:27 -0800 Subject: [PATCH 558/862] Clean up namespace. --- Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 595ff4a646..1e4b0a362b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; -using System.Threading.Tasks; namespace System.Linq { From 1e0626b06619284b214d420c7816a82ab5ee402f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 3 Dec 2018 10:15:49 -0800 Subject: [PATCH 559/862] Add ConfigureAwait for IAsyncEnumerator. --- .../System/Threading/Tasks/AsyncEnumerableExtensions.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index e5a0c7f41d..67b53355c9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -17,6 +17,14 @@ public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerab return new ConfiguredAsyncEnumerable(enumerable, continueOnCapturedContext); } + public static ConfiguredAsyncEnumerable.ConfiguredAsyncEnumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) + { + if (enumerator == null) + throw Error.ArgumentNull(nameof(enumerator)); + + return new ConfiguredAsyncEnumerable.ConfiguredAsyncEnumerator(enumerator, continueOnCapturedContext); + } + // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation. // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. From a6a0768b8784bd269ef6b00fadc5422b18802502 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 16:51:39 -0800 Subject: [PATCH 560/862] Simplify building ref assemblies. --- Ix.NET/Source/Directory.build.props | 2 ++ .../System.Interactive.Providers.csproj | 3 +-- .../System.Interactive.csproj | 5 +--- Ix.NET/Source/global.json | 5 ---- Ix.NET/Source/refs/Directory.build.props | 11 --------- ...tem.Interactive.Async.Providers.Ref.csproj | 19 --------------- .../System.Interactive.Async.Ref.csproj | 23 ------------------- .../System.Interactive.Providers.Ref.csproj | 23 ------------------- .../System.Interactive.Ref.csproj | 15 ------------ .../System.Linq.Async.Queryable.Ref.csproj | 23 ------------------- .../System.Linq.Async.Ref.csproj | 19 --------------- 11 files changed, 4 insertions(+), 144 deletions(-) delete mode 100644 Ix.NET/Source/global.json delete mode 100644 Ix.NET/Source/refs/Directory.build.props delete mode 100644 Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj delete mode 100644 Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj delete mode 100644 Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj delete mode 100644 Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj delete mode 100644 Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj delete mode 100644 Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index b21774a268..8082df8e71 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -17,6 +17,8 @@ true true latest + true + true diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index 1dc90c1d94..661c784e84 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -1,4 +1,4 @@ - + Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. @@ -13,7 +13,6 @@ - diff --git a/Ix.NET/Source/System.Interactive/System.Interactive.csproj b/Ix.NET/Source/System.Interactive/System.Interactive.csproj index 2fe04e7d54..472999194c 100644 --- a/Ix.NET/Source/System.Interactive/System.Interactive.csproj +++ b/Ix.NET/Source/System.Interactive/System.Interactive.csproj @@ -1,4 +1,4 @@ - + Interactive Extensions Main Library used to express queries over enumerable sequences. @@ -10,9 +10,6 @@ - - - diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json deleted file mode 100644 index eca09e09aa..0000000000 --- a/Ix.NET/Source/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "msbuild-sdks": { - "MSBuild.Sdk.Extras": "1.6.55" - } -} \ No newline at end of file diff --git a/Ix.NET/Source/refs/Directory.build.props b/Ix.NET/Source/refs/Directory.build.props deleted file mode 100644 index 613a4047db..0000000000 --- a/Ix.NET/Source/refs/Directory.build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - 2.1 - $(DefineConstants);REFERENCE_ASSEMBLY - - - diff --git a/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj deleted file mode 100644 index fac0fd0748..0000000000 --- a/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - Interactive Extensions Async Providers Library used to build query providers and express queries over enumerable sequences. - Interactive Extensions - Async Providers Library - netcoreapp2.0;netstandard2.1 - Ix;Interactive;Extensions;Enumerable;Asynchronous - - - - - - - - - - - - diff --git a/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj deleted file mode 100644 index f064a205ae..0000000000 --- a/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. - Interactive Extensions - Async Library - Microsoft - netcoreapp2.0;netstandard2.1 - Ix;Interactive;Extensions;Enumerable;Asynchronous - - - - - - - - - - - - - - - diff --git a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj deleted file mode 100644 index d9eb1a846a..0000000000 --- a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. - Interactive Extensions - Providers Library - netstandard1.0;netcoreapp2.0;netstandard2.1 - Ix;Interactive;Extensions;Enumerable - - - - - - - - - - - - - - - - diff --git a/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj deleted file mode 100644 index 7237c5a159..0000000000 --- a/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Interactive Extensions Main Library used to express queries over enumerable sequences. - Interactive Extensions - Main Library - Microsoft - netstandard1.0;netcoreapp2.0;netstandard2.1 - Ix;Interactive;Extensions;Enumerable - - - - - - - diff --git a/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj deleted file mode 100644 index 01fa4992ec..0000000000 --- a/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. - System.Linq.Async.Queryable - Microsoft - netstandard1.0;netcoreapp2.0;netstandard2.1 - Enumerable;Asynchronous;LINQ - - - - - - - - - - - - - - - diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj deleted file mode 100644 index 889887cddb..0000000000 --- a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. - System.Linq.Async - Microsoft - netstandard1.0;netcoreapp2.0;netstandard2.1 - Enumerable;Asynchronous;LINQ - - - - - - - - - - - From 6a65f1e1ccbc7b01ae130841befb141ca39a3aa5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 16:51:51 -0800 Subject: [PATCH 561/862] Fix await warning in Playground. --- Ix.NET/Source/Playground/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Ix.NET/Source/Playground/Program.cs b/Ix.NET/Source/Playground/Program.cs index 66ca95dd94..4c5b0bd3a8 100644 --- a/Ix.NET/Source/Playground/Program.cs +++ b/Ix.NET/Source/Playground/Program.cs @@ -21,6 +21,7 @@ static void Main() static async Task Experiment() { // Add test code here + await Task.Yield(); // Suppress CS1998 } [Demo(11, "LINQ to Objects for IEnumerable")] From f85d3b33b3ddd8788f4ea4d0ae62096e233647af Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 17:21:32 -0800 Subject: [PATCH 562/862] Adding initial VS Code support. --- Ix.NET/Source/.vscode/launch.json | 35 +++++++++++++++++++++++++++++++ Ix.NET/Source/.vscode/tasks.json | 35 +++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 Ix.NET/Source/.vscode/launch.json create mode 100644 Ix.NET/Source/.vscode/tasks.json diff --git a/Ix.NET/Source/.vscode/launch.json b/Ix.NET/Source/.vscode/launch.json new file mode 100644 index 0000000000..7ec18c6860 --- /dev/null +++ b/Ix.NET/Source/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console) - Ix.NET.sln", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build - Ix.NET.sln", + "program": "${workspaceFolder}/Playground/bin/Debug/netcoreapp2.1/Playground.dll", + "args": [], + "cwd": "${workspaceFolder}/Playground", + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Launch (console) - Ix.Async.NET.sln", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build - Ix.Async.NET.sln", + "program": "${workspaceFolder}/Playground/bin/Debug/netcoreapp2.1/Playground.dll", + "args": [], + "cwd": "${workspaceFolder}/Playground", + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/Ix.NET/Source/.vscode/tasks.json b/Ix.NET/Source/.vscode/tasks.json new file mode 100644 index 0000000000..9e991038db --- /dev/null +++ b/Ix.NET/Source/.vscode/tasks.json @@ -0,0 +1,35 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build - Ix.NET.sln", + "command": "dotnet", + "args": [ + "build", + "${workspaceFolder}/Ix.NET.sln", + "/property:GenerateFullPaths=true" + ], + "type": "shell", + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "build - Ix.Async.NET.sln", + "command": "dotnet", + "args": [ + "build", + "${workspaceFolder}/Ix.NET.sln", + "/property:GenerateFullPaths=true" + ], + "type": "shell", + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file From f687ae1ec6456adba34d7a3603b2b01101d53028 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 17:39:18 -0800 Subject: [PATCH 563/862] Remove REFERENCE_ASSEMBLY. --- .../System/Linq/QueryableEx.Generated.cs | 8 -------- .../System.Interactive/System/Linq/Operators/SkipLast.cs | 4 ++-- .../System.Interactive/System/Linq/Operators/TakeLast.cs | 4 ++-- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs index b5cbac93ea..aa2a046c0c 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs @@ -2152,11 +2152,7 @@ public static IQueryable TakeLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable TakeLast(IEnumerable source, int count) { -#if REFERENCE_ASSEMBLY - return null; -#else return EnumerableEx.TakeLast(source, count); -#endif } #pragma warning restore 1591 @@ -2190,11 +2186,7 @@ public static IQueryable SkipLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable SkipLast(IEnumerable source, int count) { -#if REFERENCE_ASSEMBLY - return null; -#else return EnumerableEx.SkipLast(source, count); -#endif } #pragma warning restore 1591 diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs index 8cdb1f3180..cbd3f553c1 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs @@ -8,7 +8,7 @@ namespace System.Linq { public static partial class EnumerableEx { -#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0 || NETSTANDARD2_1)) +#if !(NETCOREAPP2_0 || NETSTANDARD2_1) /// /// Bypasses a specified number of contiguous elements from the end of the sequence and returns the remaining elements. /// @@ -33,7 +33,6 @@ public static IEnumerable SkipLast(this IEnumerable s return SkipLastCore(source, count); } -#endif private static IEnumerable SkipLastCore(this IEnumerable source, int count) { @@ -49,5 +48,6 @@ private static IEnumerable SkipLastCore(this IEnumerable /// Returns a specified number of contiguous elements from the end of the sequence. /// @@ -30,7 +30,6 @@ public static IEnumerable TakeLast(this IEnumerable s return TakeLastCore(source, count); } -#endif private static IEnumerable TakeLastCore(IEnumerable source, int count) { @@ -56,5 +55,6 @@ private static IEnumerable TakeLastCore(IEnumerable s yield return q.Dequeue(); } } +#endif } } From f7b1cf96eaece480710edc7c319d69a1fa1cca0d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 17:49:27 -0800 Subject: [PATCH 564/862] Remove unused using. --- Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index d8b8912bdb..77bd9768de 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -7,8 +7,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Threading; -using System.Threading.Tasks; namespace System.Linq { From 4054bcec72f4d143994966958fab2f7f00016be7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 17:52:10 -0800 Subject: [PATCH 565/862] Adding C# 8.0 build flavors to prototype with new language features. --- Ix.NET/Source/Directory.build.targets | 3 ++ Ix.NET/Source/Ix.Async.NET.sln | 38 ++++++++++++++++++- ...m.Interactive.Async.Providers.Tests.csproj | 1 + .../System.Interactive.Async.Providers.csproj | 1 + .../System.Interactive.Async.Tests.csproj | 1 + .../System.Interactive.Async.csproj | 1 + .../System.Linq.Async.Queryable.Tests.csproj | 1 + .../System.Linq.Async.Queryable.csproj | 1 + .../System.Linq.Async.Tests.csproj | 1 + .../System.Linq.Async.csproj | 1 + 10 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index e43257ab08..8aab913fe3 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -10,6 +10,9 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION + + $(DefineConstants);CSHARP8 + $(AssemblyName) ($(TargetFramework)) diff --git a/Ix.NET/Source/Ix.Async.NET.sln b/Ix.NET/Source/Ix.Async.NET.sln index 3cf8c2088d..ca258f2735 100644 --- a/Ix.NET/Source/Ix.Async.NET.sln +++ b/Ix.NET/Source/Ix.Async.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26730.3 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28407.52 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}" EndProject @@ -37,40 +37,74 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Pr EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_CSharp8|Any CPU = Debug_CSharp8|Any CPU Debug|Any CPU = Debug|Any CPU + Release_CSharp8|Any CPU = Release_CSharp8|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release|Any CPU.ActiveCfg = Release|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release|Any CPU.Build.0 = Release|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug|Any CPU.Build.0 = Debug|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release|Any CPU.ActiveCfg = Release|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release|Any CPU.Build.0 = Release|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.Build.0 = Release|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.Build.0 = Release|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.ActiveCfg = Release|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.Build.0 = Release|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.Build.0 = Release|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {134E9066-6217-4AF0-B408-47D92AB595BD}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.Build.0 = Release|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU + {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj index 2bfd2ccfa1..6cdbe5f13d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj @@ -3,6 +3,7 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 + Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index c716f03892..4411fce272 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -5,6 +5,7 @@ Interactive Extensions - Async Providers Library net45;net46;netstandard1.4;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous + Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index c3405f7184..eb09eff87d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -3,6 +3,7 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 + Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 8d9ff6de02..ee2ef3e03b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -5,6 +5,7 @@ Interactive Extensions - Async Library net45;net46;netstandard1.4;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous + Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj index e1c1ca58e1..1284677956 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -3,6 +3,7 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 + Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index 69dc5f50b2..bbb69adbca 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -2,6 +2,7 @@ net45;net46;netstandard1.4;netstandard2.0 + Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index f5119dfb4d..e9ec63c71f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -3,6 +3,7 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 + Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 72ae7239e9..4d86a70f97 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -2,6 +2,7 @@ net45;net46;netstandard1.4;netstandard2.0 + Debug;Release;Debug_CSharp8;Release_CSharp8 From 3e86916fdc1aa9efb53db5982e50d1d558026e2c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 17:57:58 -0800 Subject: [PATCH 566/862] Making a struct private. --- Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index 77bd9768de..aa3286f005 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -143,7 +143,7 @@ private void Resize() _slots = newSlots; } - internal struct Slot + private struct Slot { internal int _hashCode; internal int _next; From cc20070d20e8fd2086a1ac69dde1dda0c4a9de36 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 18:08:27 -0800 Subject: [PATCH 567/862] Move WithCancellation to separate file and reimplement. --- .../Linq/AsyncEnumerator.WithCancellation.cs | 54 +++++++++++++++++++ .../System/Linq/AsyncEnumerator.cs | 26 +-------- 2 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.WithCancellation.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.WithCancellation.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.WithCancellation.cs new file mode 100644 index 0000000000..e97b08cb6c --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.WithCancellation.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using System.Threading.Tasks; + +namespace System.Collections.Generic +{ + public static partial class AsyncEnumerator + { + /// + /// Wraps the specified enumerator with an enumerator that checks for cancellation upon every invocation + /// of the method. + /// + /// The type of the elements returned by the enumerator. + /// The enumerator to augment with cancellation support. + /// The cancellation token to observe. + /// An enumerator that honors cancellation requests. + public static IAsyncEnumerator WithCancellation(this IAsyncEnumerator source, CancellationToken cancellationToken) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + if (cancellationToken == default) + return source; + + return new WithCancellationAsyncEnumerator(source, cancellationToken); + } + + private sealed class WithCancellationAsyncEnumerator : IAsyncEnumerator + { + private readonly IAsyncEnumerator _source; + private readonly CancellationToken _cancellationToken; + + public WithCancellationAsyncEnumerator(IAsyncEnumerator source, CancellationToken cancellationToken) + { + _source = source; + _cancellationToken = cancellationToken; + } + + public T Current => _source.Current; + + public ValueTask DisposeAsync() => _source.DisposeAsync(); + + public ValueTask MoveNextAsync() + { + _cancellationToken.ThrowIfCancellationRequested(); + + return _source.MoveNextAsync(); // REVIEW: Signal cancellation through task or synchronously? + } + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 401dc08e69..2cb46efd6f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -12,7 +12,7 @@ namespace System.Collections.Generic /// /// Provides a set of extension methods for . /// - public static class AsyncEnumerator + public static partial class AsyncEnumerator { /// /// Creates a new enumerator using the specified delegates implementing the members of . @@ -52,30 +52,6 @@ public static ValueTask MoveNextAsync(this IAsyncEnumerator source, return source.MoveNextAsync(); } - /// - /// Wraps the specified enumerator with an enumerator that checks for cancellation upon every invocation - /// of the method. - /// - /// The type of the elements returned by the enumerator. - /// The enumerator to augment with cancellation support. - /// The cancellation token to observe. - /// An enumerator that honors cancellation requests. - public static IAsyncEnumerator WithCancellation(this IAsyncEnumerator source, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return new AnonymousAsyncIterator( - moveNext: () => - { - cancellationToken.ThrowIfCancellationRequested(); - return source.MoveNextAsync(); - }, - currentFunc: () => source.Current, - dispose: source.DisposeAsync - ); - } - internal static IAsyncEnumerator Create(Func, ValueTask> moveNext, Func current, Func dispose) { return new AnonymousAsyncIterator( From e410e00353bbf6452d437b4bcd724906a55feb25 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 20 Dec 2018 18:09:55 -0800 Subject: [PATCH 568/862] Rename to WithCancellation. --- .../System/Linq/AsyncEnumerable.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 8d4841cc69..2d778b8d68 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -21,12 +21,12 @@ public static IAsyncEnumerable CreateEnumerable(Func WithCancellationToken(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static WithCancellationAsyncEnumerable WithCancellation(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return new WithCancellationTokenAsyncEnumerable(source, cancellationToken); + return new WithCancellationAsyncEnumerable(source, cancellationToken); } private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable @@ -51,12 +51,12 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToke // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. - public readonly struct WithCancellationTokenAsyncEnumerable : IAsyncEnumerable + public readonly struct WithCancellationAsyncEnumerable : IAsyncEnumerable { private readonly IAsyncEnumerable _source; private readonly CancellationToken _cancellationToken; - public WithCancellationTokenAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) + public WithCancellationAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) { _source = source; _cancellationToken = cancellationToken; @@ -75,10 +75,7 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken can { private readonly IAsyncEnumerator _enumerator; - public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) - { - _enumerator = enumerator; - } + public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) => _enumerator = enumerator; public T Current => _enumerator.Current; From d9eb47844dace4af161a70690c349707052836e7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 21 Dec 2018 09:18:32 -0800 Subject: [PATCH 569/862] Linking cancellation tokens. --- .../System/Linq/AsyncEnumerable.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 2d778b8d68..6e82d89143 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -66,7 +66,24 @@ public WithCancellationAsyncEnumerable(IAsyncEnumerable source, CancellationT // REVIEW: [LDM-2018-11-28] Should we have eager cancellation here too? public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - => new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(_cancellationToken)); + { + CancellationToken token = default; + + if (cancellationToken == default) + { + token = _cancellationToken; + } + else if (_cancellationToken == default) + { + token = cancellationToken; + } + else + { + token = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken, cancellationToken).Token; + } + + return new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(token)); + } IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => GetAsyncEnumerator(cancellationToken); From 724e6752ee102fff5d29e296824e203863652a71 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 11:41:04 -0800 Subject: [PATCH 570/862] Rename file. --- ...llationToken.cs => AsyncEnumerable.WithCancellation.cs} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename Ix.NET/Source/System.Linq.Async/System/Linq/{AsyncEnumerable.WithCancellationToken.cs => AsyncEnumerable.WithCancellation.cs} (92%) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellationToken.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs similarity index 92% rename from Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellationToken.cs rename to Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs index 025d65fd57..ab1bee9ccb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellationToken.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs @@ -12,7 +12,7 @@ public static partial class AsyncEnumerable { // REVIEW: [LDM-2018-11-28] Should return type be a struct or just the interface type? Should this live in the System.Linq namespace or in System.Collections.Generic? - public static WithCancellationTokenAsyncEnumerable WithCancellationToken(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static WithCancellationTokenAsyncEnumerable WithCancellation(this IAsyncEnumerable source, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -47,10 +47,7 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken can { private readonly IAsyncEnumerator _enumerator; - public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) - { - _enumerator = enumerator; - } + public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) => _enumerator = enumerator; public T Current => _enumerator.Current; From ce1cc00303d304cd5f251f683e235ae2c1a34cc1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 12:15:34 -0800 Subject: [PATCH 571/862] Use ValueTask in a few more places. --- .../System/Linq/Operators/Distinct.cs | 14 +-- .../System/Linq/Operators/Return.cs | 6 +- .../System/Linq/AsyncEnumerableHelpers.cs | 4 +- .../System/Linq/AsyncEnumerablePartition.cs | 10 +-- .../System/Linq/AsyncListPartition.cs | 16 ++-- .../System/Linq/IAsyncIListProvider.cs | 6 +- .../System/Linq/Operators/AppendPrepend.cs | 18 ++-- .../System/Linq/Operators/Concat.cs | 10 +-- .../System/Linq/Operators/Count.cs | 2 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 6 +- .../System/Linq/Operators/Distinct.cs | 10 +-- .../System/Linq/Operators/Empty.cs | 6 +- .../System/Linq/Operators/GroupBy.cs | 90 +++++++++---------- .../System/Linq/Operators/Lookup.cs | 24 ++--- .../System/Linq/Operators/Range.cs | 10 +-- .../System/Linq/Operators/Repeat.cs | 10 +-- .../System/Linq/Operators/Reverse.cs | 10 +-- .../System/Linq/Operators/Select.cs | 34 +++---- .../System/Linq/Operators/ToArray.cs | 4 +- .../Linq/Operators/ToAsyncEnumerable.cs | 18 ++-- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/Union.cs | 30 ++++++- 22 files changed, 181 insertions(+), 159 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index edb29734fe..be94bfaa69 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -88,19 +88,19 @@ public DistinctAsyncIterator(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { @@ -233,19 +233,19 @@ public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { @@ -332,7 +332,7 @@ protected override async ValueTask MoveNextCore() return false; } - private async Task> FillSetAsync(CancellationToken cancellationToken) + private async ValueTask> FillSetAsync(CancellationToken cancellationToken) { var s = new Set(_comparer); var r = new List(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs index 779d4c873a..5e4e76b6af 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -33,11 +33,11 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellatio return new ReturnEnumerator(_value); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(1); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(1); - public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(new[] { _value }); + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(new[] { _value }); - public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List(1) { _value }); + public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(new List(1) { _value }); private sealed class ReturnEnumerator : IAsyncEnumerator { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 170f0a2a9b..8e7d6f9314 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -11,14 +11,14 @@ namespace System.Collections.Generic // Based on https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/Common/src/System/Collections/Generic/EnumerableHelpers.cs internal static class AsyncEnumerableHelpers { - internal static async Task ToArray(IAsyncEnumerable source, CancellationToken cancellationToken) + internal static async ValueTask ToArray(IAsyncEnumerable source, CancellationToken cancellationToken) { var result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false); Array.Resize(ref result.Array, result.Length); return result.Array; } - internal static async Task> ToArrayWithLength(IAsyncEnumerable source, CancellationToken cancellationToken) + internal static async ValueTask> ToArrayWithLength(IAsyncEnumerable source, CancellationToken cancellationToken) { var result = new ArrayWithLength(); // Check for short circuit optimizations. This one is very unlikely diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index b9b9407189..bfca968637 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -62,16 +62,16 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { if (!HasLimit) { @@ -291,7 +291,7 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancell return new Maybe(); } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var en = _source.GetAsyncEnumerator(cancellationToken); @@ -327,7 +327,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) #endif } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var list = new List(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index a4ec5eeafe..4d0fdd24a2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -142,12 +142,12 @@ private int Count } } - public Task ToArrayAsync(CancellationToken cancellationToken) + public ValueTask ToArrayAsync(CancellationToken cancellationToken) { var count = Count; if (count == 0) { - return Task.FromResult( + return new ValueTask( #if NO_ARRAY_EMPTY EmptyArray.Value #else @@ -162,15 +162,15 @@ public Task ToArrayAsync(CancellationToken cancellationToken) array[i] = _source[curIdx]; } - return Task.FromResult(array); + return new ValueTask(array); } - public Task> ToListAsync(CancellationToken cancellationToken) + public ValueTask> ToListAsync(CancellationToken cancellationToken) { var count = Count; if (count == 0) { - return Task.FromResult(new List()); + return new ValueTask>(new List()); } var list = new List(count); @@ -180,12 +180,12 @@ public Task> ToListAsync(CancellationToken cancellationToken) list.Add(_source[i]); } - return Task.FromResult(list); + return new ValueTask>(list); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return Task.FromResult(Count); + return new ValueTask(Count); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncIListProvider.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncIListProvider.cs index a7e77767db..8347ce1edf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncIListProvider.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncIListProvider.cs @@ -18,14 +18,14 @@ public interface IAsyncIListProvider : IAsyncEnumerable /// /// /// The array. - Task ToArrayAsync(CancellationToken cancellationToken); + ValueTask ToArrayAsync(CancellationToken cancellationToken); /// /// Produce a of the sequence through an optimized path. /// /// /// The . - Task> ToListAsync(CancellationToken cancellationToken); + ValueTask> ToListAsync(CancellationToken cancellationToken); /// /// Returns the count of elements in the sequence. @@ -34,6 +34,6 @@ public interface IAsyncIListProvider : IAsyncEnumerable /// so is quick (sure or likely to be constant time), otherwise -1 should be returned. /// /// The number of elements. - Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken); + ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index dc3ef3f851..bcf09f5fc7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -86,9 +86,9 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public abstract Task ToArrayAsync(CancellationToken cancellationToken); - public abstract Task> ToListAsync(CancellationToken cancellationToken); - public abstract Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken); + public abstract ValueTask ToArrayAsync(CancellationToken cancellationToken); + public abstract ValueTask> ToListAsync(CancellationToken cancellationToken); + public abstract ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken); } private sealed class AppendPrepend1AsyncIterator : AppendPrependAsyncIterator @@ -177,7 +177,7 @@ public override AppendPrependAsyncIterator Prepend(TSource element) } } - public override async Task ToArrayAsync(CancellationToken cancellationToken) + public override async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); if (count == -1) @@ -227,7 +227,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio return array; } - public override async Task> ToListAsync(CancellationToken cancellationToken) + public override async ValueTask> ToListAsync(CancellationToken cancellationToken) { var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); var list = count == -1 ? new List() : new List(count); @@ -260,7 +260,7 @@ public override async Task> ToListAsync(CancellationToken cancella return list; } - public override async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public override async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (_source is IAsyncIListProvider listProv) { @@ -386,7 +386,7 @@ public override AppendPrependAsyncIterator Prepend(TSource item) return new AppendPrependNAsyncIterator(_source, res, _appended, _prependCount + 1, _appendCount); } - public override async Task ToArrayAsync(CancellationToken cancellationToken) + public override async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); if (count == -1) @@ -434,7 +434,7 @@ public override async Task ToArrayAsync(CancellationToken cancellatio return array; } - public override async Task> ToListAsync(CancellationToken cancellationToken) + public override async ValueTask> ToListAsync(CancellationToken cancellationToken) { var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); var list = count == -1 ? new List() : new List(count); @@ -471,7 +471,7 @@ public override async Task> ToListAsync(CancellationToken cancella return list; } - public override async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public override async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (_source is IAsyncIListProvider listProv) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 612670b63f..4951ef215d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -66,12 +66,12 @@ private abstract class ConcatAsyncIterator : AsyncIterator, IA private int _counter; private IAsyncEnumerator _enumerator; - public Task ToArrayAsync(CancellationToken cancellationToken) + public ValueTask ToArrayAsync(CancellationToken cancellationToken) { return AsyncEnumerableHelpers.ToArray(this, cancellationToken); } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var list = new List(); for (var i = 0; ; i++) @@ -100,16 +100,16 @@ public async Task> ToListAsync(CancellationToken cancellationToken return list; } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var count = 0; for (var i = 0; ; i++) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index e9ff832864..e8c020054a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -86,7 +86,7 @@ private static Task CountCore(IAsyncEnumerable source, Ca case ICollection collection: return Task.FromResult(collection.Count); case IAsyncIListProvider listProv: - return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken); + return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken).AsTask(); case ICollection collection: return Task.FromResult(collection.Count); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 59e8cade39..aaae2fab2b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -93,13 +93,13 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); return array.Length == 0 ? new[] { _defaultValue } : array; } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); if (list.Count == 0) @@ -110,7 +110,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken return list; } - public async Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { int count; if (!onlyIfCheap || _source is ICollection || _source is ICollection) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index e4e00ce2b8..fb201adb70 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -43,28 +43,28 @@ public DistinctAsyncIterator(IAsyncEnumerable source, IEqualityComparer _comparer = comparer; } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToList(); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.Count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index b1dcb03757..3f8a50a221 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -18,13 +18,13 @@ internal sealed class EmptyAsyncIterator : IAsyncPartition, IAsy public TValue Current => default; - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(0); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(0); public IAsyncPartition Skip(int count) => this; public IAsyncPartition Take(int count) => this; - public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult( + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask( #if NO_ARRAY_EMPTY EmptyArray.Value #else @@ -32,7 +32,7 @@ public Task ToArrayAsync(CancellationToken cancellationToken) => Task. #endif ); - public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(new List()); + public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(new List()); public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) => new ValueTask>(new Maybe()); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 58c405c4e5..0cc6b988a4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -378,28 +378,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.ToArray(_resultSelector); } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.ToList(_resultSelector); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -471,28 +471,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArray(_resultSelector).ConfigureAwait(false); } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToList(_resultSelector).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -565,28 +565,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArray(_resultSelector, cancellationToken).ConfigureAwait(false); } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToList(_resultSelector, cancellationToken).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -659,28 +659,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask[]> ToArrayAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } - public async Task>> ToListAsync(CancellationToken cancellationToken) + public async ValueTask>> ToListAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -752,28 +752,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask[]> ToArrayAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } - public async Task>> ToListAsync(CancellationToken cancellationToken) + public async ValueTask>> ToListAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -846,28 +846,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask[]> ToArrayAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } - public async Task>> ToListAsync(CancellationToken cancellationToken) + public async ValueTask>> ToListAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -937,28 +937,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask[]> ToArrayAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } - public async Task>> ToListAsync(CancellationToken cancellationToken) + public async ValueTask>> ToListAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -1027,28 +1027,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask[]> ToArrayAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } - public async Task>> ToListAsync(CancellationToken cancellationToken) + public async ValueTask>> ToListAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); @@ -1118,28 +1118,28 @@ protected override async ValueTask MoveNextCore() return false; } - public async Task[]> ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask[]> ToArrayAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArrayAsync(cancellationToken).ConfigureAwait(false); } - public async Task>> ToListAsync(CancellationToken cancellationToken) + public async ValueTask>> ToListAsync(CancellationToken cancellationToken) { IAsyncIListProvider> l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToListAsync(cancellationToken).ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index d51983bbdf..e6899c917e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -267,9 +267,9 @@ private void Resize() _groupings = newGroupings; } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return Task.FromResult(Count); + return new ValueTask(Count); } IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) @@ -279,7 +279,7 @@ IAsyncEnumerator> IAsyncEnumerable>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); } - Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) + ValueTask>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) { var list = new List>(Count); var g = _lastGrouping; @@ -293,10 +293,10 @@ Task>> IAsyncIListProvider>>(list); } - Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) + ValueTask[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) { var array = new IAsyncGrouping[Count]; var index = 0; @@ -312,7 +312,7 @@ Task[]> IAsyncIListProvider[]>(array); } } @@ -682,9 +682,9 @@ private void Resize() _groupings = newGroupings; } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { - return Task.FromResult(Count); + return new ValueTask(Count); } IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) @@ -694,7 +694,7 @@ IAsyncEnumerator> IAsyncEnumerable>(this).ToAsyncEnumerable().GetAsyncEnumerator(cancellationToken); } - Task>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) + ValueTask>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) { var list = new List>(Count); var g = _lastGrouping; @@ -708,10 +708,10 @@ Task>> IAsyncIListProvider>>(list); } - Task[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) + ValueTask[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) { var array = new IAsyncGrouping[Count]; var index = 0; @@ -727,7 +727,7 @@ Task[]> IAsyncIListProvider[]>(array); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index e321190950..be401c8e90 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -41,7 +41,7 @@ public RangeAsyncIterator(int start, int count) public override AsyncIteratorBase Clone() => new RangeAsyncIterator(_start, _end - _start); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_end - _start); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_end - _start); public IAsyncPartition Skip(int count) { @@ -67,7 +67,7 @@ public IAsyncPartition Take(int count) return new RangeAsyncIterator(_start, count); } - public Task ToArrayAsync(CancellationToken cancellationToken) + public ValueTask ToArrayAsync(CancellationToken cancellationToken) { var res = new int[_end - _start]; @@ -78,10 +78,10 @@ public Task ToArrayAsync(CancellationToken cancellationToken) res[i] = value++; } - return Task.FromResult(res); + return new ValueTask(res); } - public Task> ToListAsync(CancellationToken cancellationToken) + public ValueTask> ToListAsync(CancellationToken cancellationToken) { var res = new List(_end - _start); @@ -90,7 +90,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) res.Add(value); } - return Task.FromResult(res); + return new ValueTask>(res); } public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 9f4c719ca7..5e4ff0627f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -32,9 +32,9 @@ public RepeatAsyncIterator(TResult element, int count) public override AsyncIteratorBase Clone() => new RepeatAsyncIterator(_element, _count); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_count); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_count); - public Task ToArrayAsync(CancellationToken cancellationToken) + public ValueTask ToArrayAsync(CancellationToken cancellationToken) { var res = new TResult[_count]; @@ -43,10 +43,10 @@ public Task ToArrayAsync(CancellationToken cancellationToken) res[i] = _element; } - return Task.FromResult(res); + return new ValueTask(res); } - public Task> ToListAsync(CancellationToken cancellationToken) + public ValueTask> ToListAsync(CancellationToken cancellationToken) { var res = new List(_count); @@ -55,7 +55,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) res.Add(_element); } - return Task.FromResult(res); + return new ValueTask>(res); } protected override async ValueTask MoveNextCore() diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index b4ffc6b134..d0b35fb891 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -34,7 +34,7 @@ public ReverseAsyncIterator(IAsyncEnumerable source) _source = source; } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); @@ -50,7 +50,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) return array; } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); @@ -58,7 +58,7 @@ public async Task> ToListAsync(CancellationToken cancellationToken return list; } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { @@ -69,11 +69,11 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT if (!(_source is ICollection) && !(_source is ICollection)) { - return TaskExt.MinusOne; + return new ValueTask(-1); } } - return _source.CountAsync(cancellationToken); + return new ValueTask(_source.CountAsync(cancellationToken)); } public override AsyncIteratorBase Clone() diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 468d77f83e..5ad92e6631 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -272,11 +272,11 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } var count = 0; @@ -291,7 +291,7 @@ public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationT } } - return Task.FromResult(count); + return new ValueTask(count); } public override IAsyncEnumerable Select(Func selector) @@ -299,7 +299,7 @@ public override IAsyncEnumerable Select(Func(_source, CombineSelectors(_selector, selector)); } - public Task ToArrayAsync(CancellationToken cancellationToken) + public ValueTask ToArrayAsync(CancellationToken cancellationToken) { var n = _source.Count; @@ -310,10 +310,10 @@ public Task ToArrayAsync(CancellationToken cancellationToken) res[i] = _selector(_source[i]); } - return Task.FromResult(res); + return new ValueTask(res); } - public Task> ToListAsync(CancellationToken cancellationToken) + public ValueTask> ToListAsync(CancellationToken cancellationToken) { var n = _source.Count; @@ -324,7 +324,7 @@ public Task> ToListAsync(CancellationToken cancellationToken) res.Add(_selector(_source[i])); } - return Task.FromResult(res); + return new ValueTask>(res); } protected override async ValueTask MoveNextCore() @@ -641,16 +641,16 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var count = 0; @@ -673,7 +673,7 @@ public override IAsyncEnumerable Select(Func(_source, CombineSelectors(_selector, selector)); } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var n = _source.Count; @@ -687,7 +687,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) return res; } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var n = _source.Count; @@ -757,16 +757,16 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (onlyIfCheap) { - return TaskExt.MinusOne; + return new ValueTask(-1); } return Core(); - async Task Core() + async ValueTask Core() { var count = 0; @@ -789,7 +789,7 @@ public override IAsyncEnumerable Select(Func(_source, CombineSelectors(_selector, selector)); } - public async Task ToArrayAsync(CancellationToken cancellationToken) + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { var n = _source.Count; @@ -803,7 +803,7 @@ public async Task ToArrayAsync(CancellationToken cancellationToken) return res; } - public async Task> ToListAsync(CancellationToken cancellationToken) + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { var n = _source.Count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs index 2325fa6f00..afdfd94bfc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs @@ -24,9 +24,9 @@ public static Task ToArrayAsync(this IAsyncEnumerable arrayProvider) - return arrayProvider.ToArrayAsync(cancellationToken); + return arrayProvider.ToArrayAsync(cancellationToken).AsTask(); - return AsyncEnumerableHelpers.ToArray(source, cancellationToken); + return AsyncEnumerableHelpers.ToArray(source, cancellationToken).AsTask(); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index c84d12d3dd..b46ce637c7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -80,11 +80,11 @@ protected override async ValueTask MoveNextCore() // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize // and short circuit as appropriate - public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToArray()); + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); - public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToList()); + public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_source.Count()); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_source.Count()); } private sealed class AsyncIListEnumerableAdapter : AsyncIterator, IAsyncIListProvider, IList @@ -139,11 +139,11 @@ protected override async ValueTask MoveNextCore() // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize // and short circuit as appropriate - public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToArray()); + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); - public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToList()); + public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_source.Count); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_source.Count); IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); @@ -226,11 +226,11 @@ protected override async ValueTask MoveNextCore() // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize // and short circuit as appropriate - public Task ToArrayAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToArray()); + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); - public Task> ToListAsync(CancellationToken cancellationToken) => Task.FromResult(_source.ToList()); + public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => Task.FromResult(_source.Count); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_source.Count); IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 2a748af213..85e9ded3ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -29,7 +29,7 @@ public static Task> ToListAsync(this IAsyncEnumerable> ToListCore(IAsyncEnumerable source, CancellationToken cancellationToken) { if (source is IAsyncIListProvider listProvider) - return listProvider.ToListAsync(cancellationToken); + return listProvider.ToListAsync(cancellationToken).AsTask(); return Core(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index c27a1d7126..27378e8fae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -92,7 +92,7 @@ private void StoreFirst() _set = set; } - private async Task GetNextAsync() + private async ValueTask GetNextAsync() { var set = _set; Debug.Assert(set != null); @@ -188,11 +188,33 @@ private async Task> FillSetAsync(CancellationToken cancellationToke } } - public Task ToArrayAsync(CancellationToken cancellationToken) => FillSetAsync(cancellationToken).ContinueWith(set => set.Result.ToArray()); + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return set.ToArray(); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return set.ToList(); + } + + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return new ValueTask(-1); + } - public Task> ToListAsync(CancellationToken cancellationToken) => FillSetAsync(cancellationToken).ContinueWith(set => set.Result.ToList()); + return Core(); - public Task GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => onlyIfCheap ? TaskExt.MinusOne : FillSetAsync(cancellationToken).ContinueWith(set => set.Result.Count); + async ValueTask Core() + { + var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return set.Count; + } + } } /// From 5838158e96e995b7abc1f66e8d22213c0ceb2a2a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 15:17:20 -0800 Subject: [PATCH 572/862] Clean up conversions. --- .../System/Linq/AsyncEnumerableTests.cs | 6 +- .../System/Linq/Operators/CreateEnumerable.cs | 2 +- .../System/Linq/Operators/CreateEnumerator.cs | 1 - .../Linq/Operators/ToAsyncEnumerable.cs | 190 ++++++++++++--- .../System/Linq/Operators/ToObservable.cs | 6 +- .../System/Linq/AsyncEnumerable.cs | 30 ++- .../System/Linq/AsyncEnumerator.cs | 41 ++-- .../Operators/ToAsyncEnumerable.Observable.cs | 227 ++++++++++-------- .../System/Threading/Tasks/TaskExt.cs | 8 + 9 files changed, 344 insertions(+), 167 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 0aa0ab000a..0999aa858f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -78,11 +78,11 @@ protected static IAsyncEnumerable Throw(Exception exception) var moveNextThrows = new ValueTask(Task.FromException(exception)); #endif - return AsyncEnumerable.CreateEnumerable( + return AsyncEnumerable.Create( _ => AsyncEnumerator.Create( () => moveNextThrows, - current: null, - dispose: null) + getCurrent: null, + disposeAsync: null) ); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs index 07c472b1c9..59389d8f2c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerable.cs @@ -13,7 +13,7 @@ public class CreateEnumerable : AsyncEnumerableTests [Fact] public void CreateEnumerable_Null() { - Assert.Throws(() => AsyncEnumerable.CreateEnumerable(default)); + Assert.Throws(() => AsyncEnumerable.Create(default)); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs index c5024f966f..0da468b321 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/CreateEnumerator.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index 4197705c36..44ad2f8030 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Xunit; @@ -21,7 +22,7 @@ public void ToAsyncEnumerable_Null() } [Fact] - public async Task ToAsyncEnumerable1Async() + public async Task ToAsyncEnumerable_Array1_Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); @@ -33,7 +34,7 @@ public async Task ToAsyncEnumerable1Async() } [Fact] - public async Task ToAsyncEnumerable2Async() + public async Task ToAsyncEnumerable_Enumerable1_Async() { var ex = new Exception("Bang"); var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); @@ -49,7 +50,7 @@ private IEnumerable ToAsyncEnumerable_Sequence(Exception e) } [Fact] - public async Task ToAsyncEnumerable3Async() + public async Task ToAsyncEnumerable_Observable1_Async() { var subscribed = false; @@ -67,14 +68,15 @@ public async Task ToAsyncEnumerable3Async() var e = xs.GetAsyncEnumerator(); - Assert.True(subscribed); + // NB: Breaking change to align with lazy nature of async iterators. + // Assert.True(subscribed); await HasNextAsync(e, 42); await NoNextAsync(e); } [Fact] - public async Task ToAsyncEnumerable4Async() + public async Task ToAsyncEnumerable_Observable2_Async() { var ex = new Exception("Bang!"); var subscribed = false; @@ -92,13 +94,14 @@ public async Task ToAsyncEnumerable4Async() var e = xs.GetAsyncEnumerator(); - Assert.True(subscribed); + // NB: Breaking change to align with lazy nature of async iterators. + // Assert.True(subscribed); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task ToAsyncEnumerable5Async() + public async Task ToAsyncEnumerable_Enumerable2_Async() { var set = new HashSet(new[] { 1, 2, 3, 4 }); @@ -112,7 +115,7 @@ public async Task ToAsyncEnumerable5Async() } [Fact] - public async Task ToAsyncEnumerable6() + public async Task ToAsyncEnumerable_Enumerable3_Async() { var set = new HashSet(new[] { 1, 2, 3, 4, 5, 6, 7, 8 }); @@ -124,7 +127,7 @@ public async Task ToAsyncEnumerable6() } [Fact] - public async Task ToAsyncEnumerable7() + public async Task ToAsyncEnumerable_Enumerable4_Async() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -135,7 +138,7 @@ public async Task ToAsyncEnumerable7() } [Fact] - public async Task ToAsyncEnumerable8() + public async Task ToAsyncEnumerable_Enumerable5_Async() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -146,7 +149,7 @@ public async Task ToAsyncEnumerable8() } [Fact] - public async Task ToAsyncEnumerable9() + public async Task ToAsyncEnumerable_Enumerable6_Async() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -155,14 +158,14 @@ public async Task ToAsyncEnumerable9() } [Fact] - public async Task ToAsyncEnumerable10() + public async Task ToAsyncEnumerable_Array2_Async() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); await SequenceIdentity(xs); } [Fact] - public void ToAsyncEnumerable11() + public void ToAsyncEnumerable_Enumerable7() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -175,7 +178,6 @@ public void ToAsyncEnumerable11() xc.Add(5); - Assert.True(xc.Contains(5)); Assert.True(xc.Remove(5)); @@ -188,7 +190,7 @@ public void ToAsyncEnumerable11() } [Fact] - public void ToAsyncEnumerable12() + public void ToAsyncEnumerable_Enumerable8() { var set = new List { 1, 2, 3, 4 }; var xs = set.ToAsyncEnumerable(); @@ -260,34 +262,168 @@ public async Task ToAsyncEnumerable_With_Canceled_TaskAsync() await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } - private sealed class MyObservable : IObservable + [Fact] + public async Task ToAsyncEnumerable_Observable3_Async() { - private readonly Func, IDisposable> _subscribe; + var stop = new ManualResetEvent(false); + + var xs = new MyObservable(obs => + { + var cts = new CancellationTokenSource(); + + Task.Run(async () => + { + for (var i = 0; !cts.IsCancellationRequested; i++) + { + await Task.Delay(10); + obs.OnNext(i); + } + + stop.Set(); + }); - public MyObservable(Func, IDisposable> subscribe) + return new MyDisposable(cts.Cancel); + }).ToAsyncEnumerable(); + + var e = xs.GetAsyncEnumerator(); + + for (var i = 0; i < 10; i++) { - _subscribe = subscribe; + await HasNextAsync(e, i); } - public IDisposable Subscribe(IObserver observer) + await e.DisposeAsync(); + stop.WaitOne(); + } + + [Fact] + public async Task ToAsyncEnumerable_Observable4_Async() + { + var subCount = 0; + + var stop = new ManualResetEvent(false); + + var xs = new MyObservable(obs => + { + subCount++; + + var cts = new CancellationTokenSource(); + + Task.Run(async () => + { + for (var i = 0; !cts.IsCancellationRequested; i++) + { + await Task.Delay(10); + obs.OnNext(i); + } + + stop.Set(); + }); + + return new MyDisposable(cts.Cancel); + }).ToAsyncEnumerable(); + + var e = xs.Zip(xs, (l, r) => l == r).GetAsyncEnumerator(); + + for (var i = 0; i < 10; i++) { - return _subscribe(observer); + await HasNextAsync(e, true); } + + await e.DisposeAsync(); + stop.WaitOne(); + + Assert.Equal(2, subCount); } - private sealed class MyDisposable : IDisposable + [Fact] + public async Task ToAsyncEnumerable_Observable5_Async() { - private readonly Action _dispose; + var stop = new ManualResetEvent(false); + + var xs = new MyObservable(obs => + { + var cts = new CancellationTokenSource(); - public MyDisposable(Action dispose) + Task.Run(async () => + { + for (var i = 0; !cts.IsCancellationRequested; i++) + { + await Task.Delay(10); + obs.OnNext(i); + } + + stop.Set(); + }); + + return new MyDisposable(cts.Cancel); + }).ToAsyncEnumerable(); + + var c = new CancellationTokenSource(); + + var e = xs.GetAsyncEnumerator(c.Token); + + for (var i = 0; i < 10; i++) { - _dispose = dispose; + await HasNextAsync(e, i); } - public void Dispose() + c.Cancel(); + stop.WaitOne(); + } + + [Fact] + public async Task ToAsyncEnumerable_Observable6_Async() + { + var stop = new ManualResetEvent(false); + + var xs = new MyObservable(obs => + { + var cts = new CancellationTokenSource(); + + Task.Run(async () => + { + for (var i = 0; !cts.IsCancellationRequested; i++) + { + await Task.Yield(); + obs.OnNext(i); + } + + stop.Set(); + }); + + return new MyDisposable(cts.Cancel); + }).ToAsyncEnumerable(); + + var e = xs.GetAsyncEnumerator(); + + for (var i = 0; i < 10_000; i++) { - _dispose(); + await HasNextAsync(e, i); } + + await e.DisposeAsync(); + stop.WaitOne(); + } + + // TODO: Add more tests for Observable conversion. + + private sealed class MyObservable : IObservable + { + private readonly Func, IDisposable> _subscribe; + + public MyObservable(Func, IDisposable> subscribe) => _subscribe = subscribe; + + public IDisposable Subscribe(IObserver observer) => _subscribe(observer); + } + + private sealed class MyDisposable : IDisposable + { + private readonly Action _dispose; + + public MyDisposable(Action dispose) => _dispose = dispose; + + public void Dispose() => _dispose(); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs index e0847d0598..27dc41a24f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs @@ -141,7 +141,7 @@ public void ToObservable_DisposesEnumeratorOnCompletion() var fail = false; var evt = new ManualResetEvent(false); - var ae = AsyncEnumerable.CreateEnumerable( + var ae = AsyncEnumerable.Create( _ => AsyncEnumerator.Create( () => new ValueTask(false), () => { throw new InvalidOperationException(); }, @@ -175,7 +175,7 @@ public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed() var subscription = default(IDisposable); var subscriptionAssignedTcs = new TaskCompletionSource(); - var ae = AsyncEnumerable.CreateEnumerable( + var ae = AsyncEnumerable.Create( _ => AsyncEnumerator.Create( async () => { @@ -221,7 +221,7 @@ public void ToObservable_DesNotCallMoveNextAgainWhenSubscriptionIsDisposed() var subscription = default(IDisposable); var subscriptionAssignedTcs = new TaskCompletionSource(); - var ae = AsyncEnumerable.CreateEnumerable( + var ae = AsyncEnumerable.Create( _ => AsyncEnumerator.Create( async () => { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs index 1e4b0a362b..eb4ac52ba6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs @@ -3,31 +3,39 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Diagnostics; using System.Threading; namespace System.Linq { + /// + /// Provides a set of extension methods for . + /// public static partial class AsyncEnumerable { - public static IAsyncEnumerable CreateEnumerable(Func> getEnumerator) + // + // REVIEW: Create methods may not belong in System.Linq.Async. Async iterators can be + // used to implement these interfaces. Move to System.Interactive.Async? + // + + /// + /// Creates a new enumerable using the specified delegates implementing the members of . + /// + /// The type of the elements returned by the enumerable sequence. + /// The delegate implementing the method. + /// A new enumerable instance. + public static IAsyncEnumerable Create(Func> getAsyncEnumerator) { - if (getEnumerator == null) - throw Error.ArgumentNull(nameof(getEnumerator)); + if (getAsyncEnumerator == null) + throw Error.ArgumentNull(nameof(getAsyncEnumerator)); - return new AnonymousAsyncEnumerable(getEnumerator); + return new AnonymousAsyncEnumerable(getAsyncEnumerator); } private sealed class AnonymousAsyncEnumerable : IAsyncEnumerable { private readonly Func> _getEnumerator; - public AnonymousAsyncEnumerable(Func> getEnumerator) - { - Debug.Assert(getEnumerator != null); - - _getEnumerator = getEnumerator; - } + public AnonymousAsyncEnumerable(Func> getEnumerator) => _getEnumerator = getEnumerator; public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index 2cb46efd6f..fd389f549c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -14,22 +14,29 @@ namespace System.Collections.Generic /// public static partial class AsyncEnumerator { + // + // REVIEW: Create methods may not belong in System.Linq.Async. Async iterators can be + // used to implement these interfaces. Move to System.Interactive.Async? + // + /// /// Creates a new enumerator using the specified delegates implementing the members of . /// /// The type of the elements returned by the enumerator. - /// The delegate implementing the method. - /// The delegate implementing the property getter. - /// The delegate implementing the method. + /// The delegate implementing the method. + /// The delegate implementing the property getter. + /// The delegate implementing the method. /// A new enumerator instance. - public static IAsyncEnumerator Create(Func> moveNext, Func current, Func dispose) + public static IAsyncEnumerator Create(Func> moveNextAsync, Func getCurrent, Func disposeAsync) { - if (moveNext == null) - throw Error.ArgumentNull(nameof(moveNext)); - - // Note: Many methods pass null in for the second two params. We're assuming - // That the caller is responsible and knows what they're doing - return new AnonymousAsyncIterator(moveNext, current, dispose); + if (moveNextAsync == null) + throw Error.ArgumentNull(nameof(moveNextAsync)); + + // + // NB: Callers can pass null for the second two parameters, which can be useful to + // implement enumerators that throw or yield no results. + // + return new AnonymousAsyncIterator(moveNextAsync, getCurrent, disposeAsync); } /// @@ -52,20 +59,6 @@ public static ValueTask MoveNextAsync(this IAsyncEnumerator source, return source.MoveNextAsync(); } - internal static IAsyncEnumerator Create(Func, ValueTask> moveNext, Func current, Func dispose) - { - return new AnonymousAsyncIterator( - async () => - { - var tcs = new TaskCompletionSource(); - - return await moveNext(tcs).ConfigureAwait(false); - }, - current, - dispose - ); - } - private sealed class AnonymousAsyncIterator : AsyncIterator { private readonly Func _currentFunc; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs index 41710acfc0..6c434cbfb3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs @@ -2,7 +2,9 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Collections.Concurrent; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -14,146 +16,177 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IObserva if (source == null) throw Error.ArgumentNull(nameof(source)); - return CreateEnumerable( - ct => - { - var observer = new ToAsyncEnumerableObserver(); + return new ObservableAsyncEnumerable(source); + } + + private sealed class ObservableAsyncEnumerable : AsyncIterator, IObserver + { + private readonly IObservable _source; - var subscription = source.Subscribe(observer); + private ConcurrentQueue _values = new ConcurrentQueue(); + private Exception _error; + private bool _completed; + private TaskCompletionSource _signal; + private IDisposable _subscription; + private CancellationTokenRegistration _ctr; - // REVIEW: Review possible concurrency issues with Dispose calls. + public ObservableAsyncEnumerable(IObservable source) => _source = source; - var ctr = ct.Register(subscription.Dispose); + public override AsyncIteratorBase Clone() => new ObservableAsyncEnumerable(_source); + + public override ValueTask DisposeAsync() + { + Dispose(); + + return base.DisposeAsync(); + } - return AsyncEnumerator.Create( - tcs => + protected override async ValueTask MoveNextCore() + { + // + // REVIEW: How often should we check? At the very least, we want to prevent + // subscribing if cancellation is requested. A case may be made to + // check for each iteration, namely because this operator is a bridge + // with another interface. However, we also wire up cancellation to + // the observable subscription, so there's redundancy here. + // + _cancellationToken.ThrowIfCancellationRequested(); + + switch (_state) + { + case AsyncIteratorState.Allocated: + // + // NB: Breaking change to align with lazy nature of async iterators. + // + // In previous implementations, the Subscribe call happened during + // the call to GetAsyncEnumerator. + // + // REVIEW: Confirm this design point. This implementation is compatible + // with an async iterator using "yield return", e.g. subscribing + // to the observable sequence and yielding values out of a local + // queue filled by observer callbacks. However, it departs from + // the dual treatment of Subscribe/GetEnumerator. + // + + _subscription = _source.Subscribe(this); + _ctr = _cancellationToken.Register(OnCanceled, state: null); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + while (true) { - var hasValue = false; - var hasCompleted = false; - var error = default(Exception); + var completed = Volatile.Read(ref _completed); - lock (observer.SyncRoot) + if (_values.TryDequeue(out _current)) { - if (observer.Values.Count > 0) - { - hasValue = true; - observer.Current = observer.Values.Dequeue(); - } - else if (observer.HasCompleted) - { - hasCompleted = true; - } - else if (observer.Error != null) - { - error = observer.Error; - } - else + return true; + } + else if (completed) + { + var error = _error; + + if (error != null) { - observer.TaskCompletionSource = tcs; + throw error; } - } - if (hasValue) - { - tcs.TrySetResult(true); - } - else if (hasCompleted) - { - tcs.TrySetResult(false); - } - else if (error != null) - { - tcs.TrySetException(error); + return false; } - return new ValueTask(tcs.Task); - }, - () => observer.Current, - () => - { - ctr.Dispose(); - subscription.Dispose(); - // Should we cancel in-flight operations somehow? - return default; - }); - }); - } - - private sealed class ToAsyncEnumerableObserver : IObserver - { - public readonly Queue Values; + await Resume().ConfigureAwait(false); + Volatile.Write(ref _signal, null); + } + } - public T Current; - public Exception Error; - public bool HasCompleted; - public TaskCompletionSource TaskCompletionSource; + await DisposeAsync().ConfigureAwait(false); + return false; + } - public ToAsyncEnumerableObserver() + public void OnCompleted() { - Values = new Queue(); + Volatile.Write(ref _completed, true); + + DisposeSubscription(); + OnNotification(); } - public object SyncRoot + public void OnError(Exception error) { - get { return Values; } + _error = error; + Volatile.Write(ref _completed, true); + + DisposeSubscription(); + OnNotification(); } - public void OnCompleted() + public void OnNext(TSource value) { - var tcs = default(TaskCompletionSource); + _values?.Enqueue(value); - lock (SyncRoot) + OnNotification(); + } + + private void OnNotification() + { + while (true) { - HasCompleted = true; + var signal = Volatile.Read(ref _signal); - if (TaskCompletionSource != null) + if (signal == TaskExt.True) { - tcs = TaskCompletionSource; - TaskCompletionSource = null; + return; } - } - tcs?.TrySetResult(false); - } - - public void OnError(Exception error) - { - var tcs = default(TaskCompletionSource); - - lock (SyncRoot) - { - Error = error; + if (signal != null) + { + signal.TrySetResult(true); + return; + } - if (TaskCompletionSource != null) + if (Interlocked.CompareExchange(ref _signal, TaskExt.True, null) == null) { - tcs = TaskCompletionSource; - TaskCompletionSource = null; + return; } } + } + + private void Dispose() + { + _ctr.Dispose(); + DisposeSubscription(); - tcs?.TrySetException(error); + _values = null; + _error = null; } - public void OnNext(T value) + private void DisposeSubscription() => Interlocked.Exchange(ref _subscription, null)?.Dispose(); + + private void OnCanceled(object state) => Dispose(); + + private Task Resume() { - var tcs = default(TaskCompletionSource); + TaskCompletionSource newSignal = null; - lock (SyncRoot) + while (true) { - if (TaskCompletionSource == null) + var signal = Volatile.Read(ref _signal); + + if (signal != null) { - Values.Enqueue(value); + return signal.Task; } - else + + if (newSignal == null) { - Current = value; + newSignal = new TaskCompletionSource(); + } - tcs = TaskCompletionSource; - TaskCompletionSource = null; + if (Interlocked.CompareExchange(ref _signal, newSignal, null) == null) + { + return newSignal.Task; } } - - tcs?.TrySetResult(true); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs index bd2d093e90..1e2e1655b9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs @@ -7,5 +7,13 @@ namespace System.Threading.Tasks internal static class TaskExt { public static readonly Task MinusOne = Task.FromResult(-1); + + public static readonly TaskCompletionSource True; + + static TaskExt() + { + True = new TaskCompletionSource(); + True.SetResult(true); + } } } From 001476c67eff13efcee46099f1c0fae5fa11cfb0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 16:11:45 -0800 Subject: [PATCH 573/862] Remove some dead code. --- .../AsyncTests.Bugs.cs | 7 ------- .../AsyncTests.cs | 2 -- .../System/Linq/AsyncEnumerableTests.cs | 21 ------------------- 3 files changed, 30 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs index 988b5c3c6c..be27a01d9b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Bugs.cs @@ -69,13 +69,6 @@ public async Task DisposesUponError() Assert.True(result); } - private static IEnumerable Blocking(ManualResetEvent evt, ManualResetEvent blockingStarted) - { - blockingStarted.Set(); - evt.WaitOne(); - yield return 42; - } - [Fact] public async Task TakeOneFromSelectMany() { diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs index 5fa0d0268b..a945c7e035 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.cs @@ -9,8 +9,6 @@ namespace Tests { public partial class AsyncTests { - private const int WaitTimeoutMs = 5000; - #pragma warning disable xUnit1013 // Public method should be marked as test public void AssertThrows(Action a) where E : Exception diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs index 0999aa858f..8874635dc4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs @@ -85,26 +85,5 @@ protected static IAsyncEnumerable Throw(Exception exception) disposeAsync: null) ); } - - private void AssertThrows(Action a, Func assert) - where E : Exception - { - var hasFailed = false; - - try - { - a(); - } - catch (E e) - { - Assert.True(assert(e)); - hasFailed = true; - } - - if (!hasFailed) - { - Assert.True(false); - } - } } } From 190e5b2631735bbcda8e1a00e0f55aa51cf145f5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 16:11:51 -0800 Subject: [PATCH 574/862] Use pattern matching. --- .../System/Linq/Operators/DefaultIfEmpty.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index aaae2fab2b..8a1ca757c2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -117,10 +117,13 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca { count = await _source.CountAsync(cancellationToken).ConfigureAwait(false); } + else if (_source is IAsyncIListProvider listProv) + { + count = await listProv.GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + } else { - var listProv = _source as IAsyncIListProvider; - count = listProv == null ? -1 : await listProv.GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + count = -1; } return count == 0 ? 1 : count; From faed6f3977b6efbbde569c7e20277b53dc2bcb04 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 16:15:35 -0800 Subject: [PATCH 575/862] Link cancellation tokens. --- .../Linq/AsyncEnumerable.WithCancellation.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs index ab1bee9ccb..339f865f67 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs @@ -38,7 +38,24 @@ public WithCancellationTokenAsyncEnumerable(IAsyncEnumerable source, Cancella // REVIEW: [LDM-2018-11-28] Should we have eager cancellation here too? public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - => new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(_cancellationToken)); + { + CancellationToken token; + + if (cancellationToken == default) + { + token = _cancellationToken; + } + else if (_cancellationToken == default) + { + token = cancellationToken; + } + else + { + token = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken, cancellationToken).Token; + } + + return new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(token)); + } IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => GetAsyncEnumerator(cancellationToken); From b83c4ac69dbb4cc7cc1eae02b51fbc591af3ce85 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 16:39:51 -0800 Subject: [PATCH 576/862] Fix a link. --- .../System.Linq.Async/System/Linq/Operators/Concat.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 4951ef215d..8e4200cccd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -159,8 +159,12 @@ protected override async ValueTask MoveNextCore() _current = _enumerator.Current; return true; } - // note, this is simply to match the logic of - // https://github.com/dotnet/corefx/blob/ec2685715b01d12f16b08d0dfa326649b12db8ec/src/system.linq/src/system/linq/concatenate.cs#L173-L173 + + // + // NB: This is simply to match the logic of + // https://github.com/dotnet/corefx/blob/f7539b726c4bc2385b7f49e5751c1cff2f2c7368/src/System.Linq/src/System/Linq/Concat.cs#L240 + // + var next = GetAsyncEnumerable(_counter++ - 1); if (next != null) { From 2a65944376e624e1858cd9bf2d97967858c69540 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 16:40:03 -0800 Subject: [PATCH 577/862] Clean up some comments. --- .../Linq/Operators/ToAsyncEnumerable.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index b46ce637c7..163cc85e00 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -17,7 +17,6 @@ public static IAsyncEnumerable ToAsyncEnumerable(this IEnumera if (source == null) throw Error.ArgumentNull(nameof(source)); - // optimize these adapters for lists and collections switch (source) { case IList list: @@ -78,8 +77,11 @@ protected override async ValueTask MoveNextCore() return false; } - // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize - // and short circuit as appropriate + // + // NB: These optimizations rely on the System.Linq implementation of IEnumerable operators to optimize + // and short-circuit as appropriate. + // + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); @@ -137,8 +139,11 @@ protected override async ValueTask MoveNextCore() public override IAsyncEnumerable Select(Func selector) => new SelectIListIterator(_source, selector); - // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize - // and short circuit as appropriate + // + // NB: These optimizations rely on the System.Linq implementation of IEnumerable operators to optimize + // and short-circuit as appropriate. + // + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); @@ -224,8 +229,11 @@ protected override async ValueTask MoveNextCore() return false; } - // These optimizations rely on the Sys.Linq impls from IEnumerable to optimize - // and short circuit as appropriate + // + // NB: These optimizations rely on the System.Linq implementation of IEnumerable operators to optimize + // and short-circuit as appropriate. + // + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); From aa2430bb42a978c933d4df343096a57917243fe7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 27 Dec 2018 16:56:35 -0800 Subject: [PATCH 578/862] Check for cancellation in a few more places. --- .../System/Linq/AsyncEnumerableHelpers.cs | 2 + .../System/Linq/Operators/AppendPrepend.cs | 6 +- .../System/Linq/Operators/Concat.cs | 4 ++ .../System/Linq/Operators/Lookup.cs | 12 ++++ .../System/Linq/Operators/Repeat.cs | 4 ++ .../System/Linq/Operators/Select.cs | 18 ++++++ .../Linq/Operators/ToAsyncEnumerable.cs | 63 ++++++++++++++++--- .../System/Linq/Operators/Union.cs | 2 + 8 files changed, 101 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 8e7d6f9314..97ab453312 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -20,6 +20,8 @@ internal static async ValueTask ToArray(IAsyncEnumerable source, Canc internal static async ValueTask> ToArrayWithLength(IAsyncEnumerable source, CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var result = new ArrayWithLength(); // Check for short circuit optimizations. This one is very unlikely // but could be here as a group diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index bcf09f5fc7..d162f4c5d2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -185,6 +185,8 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel return await AsyncEnumerableHelpers.ToArray(this, cancellationToken).ConfigureAwait(false); } + cancellationToken.ThrowIfCancellationRequested(); + var array = new TSource[count]; int index; if (_appending) @@ -230,6 +232,9 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel public override async ValueTask> ToListAsync(CancellationToken cancellationToken) { var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + + cancellationToken.ThrowIfCancellationRequested(); + var list = count == -1 ? new List() : new List(count); if (!_appending) @@ -237,7 +242,6 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(_item); } - var en = _source.GetAsyncEnumerator(cancellationToken); try diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 8e4200cccd..97aee1ba56 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -73,6 +73,8 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) public async ValueTask> ToListAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var list = new List(); for (var i = 0; ; i++) { @@ -111,6 +113,8 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { + cancellationToken.ThrowIfCancellationRequested(); + var count = 0; for (var i = 0; ; i++) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index e6899c917e..c99f96414e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -281,6 +281,8 @@ IAsyncEnumerator> IAsyncEnumerable>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var list = new List>(Count); var g = _lastGrouping; if (g != null) @@ -298,6 +300,8 @@ ValueTask>> IAsyncIListProvider[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var array = new IAsyncGrouping[Count]; var index = 0; var g = _lastGrouping; @@ -608,6 +612,8 @@ internal async Task ToArray(Func ToArray(Func, CancellationToken, ValueTask> resultSelector, CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var array = new TResult[Count]; var index = 0; var g = _lastGrouping; @@ -648,6 +654,8 @@ internal async Task> ToList(Func> ToList(Func, CancellationToken, ValueTask> resultSelector, CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var list = new List(Count); var g = _lastGrouping; if (g != null) @@ -696,6 +704,8 @@ IAsyncEnumerator> IAsyncEnumerable>> IAsyncIListProvider>.ToListAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var list = new List>(Count); var g = _lastGrouping; if (g != null) @@ -713,6 +723,8 @@ ValueTask>> IAsyncIListProvider[]> IAsyncIListProvider>.ToArrayAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var array = new IAsyncGrouping[Count]; var index = 0; var g = _lastGrouping; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs index 5e4ff0627f..289c45a949 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Repeat.cs @@ -36,6 +36,8 @@ public RepeatAsyncIterator(TResult element, int count) public ValueTask ToArrayAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var res = new TResult[_count]; for (var i = 0; i < _count; i++) @@ -48,6 +50,8 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) public ValueTask> ToListAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var res = new List(_count); for (var i = 0; i < _count; i++) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 5ad92e6631..86a338b137 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -279,6 +279,8 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella return new ValueTask(-1); } + cancellationToken.ThrowIfCancellationRequested(); + var count = 0; foreach (var item in _source) @@ -301,6 +303,8 @@ public override IAsyncEnumerable Select(Func ToArrayAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var n = _source.Count; var res = new TResult[n]; @@ -315,6 +319,8 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) public ValueTask> ToListAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var n = _source.Count; var res = new List(n); @@ -652,6 +658,8 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { + cancellationToken.ThrowIfCancellationRequested(); + var count = 0; foreach (var item in _source) @@ -675,6 +683,8 @@ public override IAsyncEnumerable Select(Func ToArrayAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var n = _source.Count; var res = new TResult[n]; @@ -689,6 +699,8 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok public async ValueTask> ToListAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var n = _source.Count; var res = new List(n); @@ -768,6 +780,8 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { + cancellationToken.ThrowIfCancellationRequested(); + var count = 0; foreach (var item in _source) @@ -791,6 +805,8 @@ public override IAsyncEnumerable Select(Func ToArrayAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var n = _source.Count; var res = new TResult[n]; @@ -805,6 +821,8 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok public async ValueTask> ToListAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var n = _source.Count; var res = new List(n); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs index 163cc85e00..3b65f6f0bb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.cs @@ -82,11 +82,26 @@ protected override async ValueTask MoveNextCore() // and short-circuit as appropriate. // - public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); + public ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + + return new ValueTask(_source.ToArray()); + } + + public ValueTask> ToListAsync(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + + return new ValueTask>(_source.ToList()); + } - public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); - public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_source.Count()); + return new ValueTask(_source.Count()); + } } private sealed class AsyncIListEnumerableAdapter : AsyncIterator, IAsyncIListProvider, IList @@ -144,11 +159,26 @@ protected override async ValueTask MoveNextCore() // and short-circuit as appropriate. // - public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); + public ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); - public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); + return new ValueTask(_source.ToArray()); + } - public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_source.Count); + public ValueTask> ToListAsync(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + + return new ValueTask>(_source.ToList()); + } + + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + + return new ValueTask(_source.Count); + } IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); @@ -234,11 +264,26 @@ protected override async ValueTask MoveNextCore() // and short-circuit as appropriate. // - public ValueTask ToArrayAsync(CancellationToken cancellationToken) => new ValueTask(_source.ToArray()); + public ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); - public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(_source.ToList()); + return new ValueTask(_source.ToArray()); + } - public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(_source.Count); + public ValueTask> ToListAsync(CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + + return new ValueTask>(_source.ToList()); + } + + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + + return new ValueTask(_source.Count); + } IEnumerator IEnumerable.GetEnumerator() => _source.GetEnumerator(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 27378e8fae..aa3cb5cfba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -162,6 +162,8 @@ protected sealed override async ValueTask MoveNextCore() private async Task> FillSetAsync(CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); + var set = new Set(_comparer); for (var index = 0; ; ++index) From 555dbb681017b6711fe7dd9f725d99fd8f3dcf53 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 10:58:23 -0800 Subject: [PATCH 579/862] Changing a few classes to private. --- .../System/Linq/Operators/Cast.cs | 6 +----- .../System/Linq/Operators/GroupBy.cs | 18 +++++++++--------- .../System/Linq/Operators/Join.cs | 6 +++--- .../System/Linq/Operators/OfType.cs | 6 +----- .../System/Linq/Operators/Select.cs | 10 +++++----- .../System/Linq/Operators/Where.cs | 8 ++++---- 6 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index fe456ec37f..1ac2edec5b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Diagnostics; using System.Threading.Tasks; namespace System.Linq @@ -15,7 +14,6 @@ public static IAsyncEnumerable Cast(this IAsyncEnumerable typedSource) { return typedSource; @@ -24,15 +22,13 @@ public static IAsyncEnumerable Cast(this IAsyncEnumerable(source); } - internal sealed class CastAsyncIterator : AsyncIterator + private sealed class CastAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; public CastAsyncIterator(IAsyncEnumerable source) { - Debug.Assert(source != null); - _source = source; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 0cc6b988a4..c224cc0352 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -315,7 +315,7 @@ public static IAsyncEnumerable GroupBy : AsyncIterator, IAsyncIListProvider + private sealed class GroupedResultAsyncEnumerable : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable _source; private readonly Func _keySelector; @@ -408,7 +408,7 @@ async ValueTask Core() } } - internal sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IAsyncIListProvider + private sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable _source; private readonly Func> _keySelector; @@ -502,7 +502,7 @@ async ValueTask Core() } #if !NO_DEEP_CANCELLATION - internal sealed class GroupedResultAsyncEnumerableWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider + private sealed class GroupedResultAsyncEnumerableWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider { private readonly IAsyncEnumerable _source; private readonly Func> _keySelector; @@ -596,7 +596,7 @@ async ValueTask Core() } #endif - internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> + private sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; private readonly Func _keySelector; @@ -689,7 +689,7 @@ async ValueTask Core() } } - internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> + private sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; private readonly Func> _keySelector; @@ -783,7 +783,7 @@ async ValueTask Core() } #if !NO_DEEP_CANCELLATION - internal sealed class GroupedAsyncEnumerableWithTaskAndCancellation : AsyncIterator>, IAsyncIListProvider> + private sealed class GroupedAsyncEnumerableWithTaskAndCancellation : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; private readonly Func> _keySelector; @@ -877,7 +877,7 @@ async ValueTask Core() } #endif - internal sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> + private sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; private readonly Func _keySelector; @@ -967,7 +967,7 @@ async ValueTask Core() } } - internal sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> + private sealed class GroupedAsyncEnumerableWithTask : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; private readonly Func> _keySelector; @@ -1058,7 +1058,7 @@ async ValueTask Core() } #if !NO_DEEP_CANCELLATION - internal sealed class GroupedAsyncEnumerableWithTaskAndCancellation : AsyncIterator>, IAsyncIListProvider> + private sealed class GroupedAsyncEnumerableWithTaskAndCancellation : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; private readonly Func> _keySelector; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index fd2466d2da..3a883d6941 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -111,7 +111,7 @@ public static IAsyncEnumerable Join(this } #endif - internal sealed class JoinAsyncIterator : AsyncIterator + private sealed class JoinAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _outer; private readonly IAsyncEnumerable _inner; @@ -238,7 +238,7 @@ protected override async ValueTask MoveNextCore() } } - internal sealed class JoinAsyncIteratorWithTask : AsyncIterator + private sealed class JoinAsyncIteratorWithTask : AsyncIterator { private readonly IAsyncEnumerable _outer; private readonly IAsyncEnumerable _inner; @@ -366,7 +366,7 @@ protected override async ValueTask MoveNextCore() } #if !NO_DEEP_CANCELLATION - internal sealed class JoinAsyncIteratorWithTaskAndCancellation : AsyncIterator + private sealed class JoinAsyncIteratorWithTaskAndCancellation : AsyncIterator { private readonly IAsyncEnumerable _outer; private readonly IAsyncEnumerable _inner; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index 7f9cc30d34..48a5a757c5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -19,15 +17,13 @@ public static IAsyncEnumerable OfType(this IAsyncEnumerable(source); } - internal sealed class OfTypeAsyncIterator : AsyncIterator + private sealed class OfTypeAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _source; private IAsyncEnumerator _enumerator; public OfTypeAsyncIterator(IAsyncEnumerable source) { - Debug.Assert(source != null); - _source = source; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 86a338b137..baaa8edf6c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -177,7 +177,7 @@ protected override async ValueTask MoveNextCore() } } - internal sealed class SelectEnumerableWithIndexAsyncIterator : AsyncIterator + private sealed class SelectEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _selector; private readonly IAsyncEnumerable _source; @@ -481,7 +481,7 @@ protected override async ValueTask MoveNextCore() } #endif - internal sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator + private sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _selector; private readonly IAsyncEnumerable _source; @@ -546,7 +546,7 @@ protected override async ValueTask MoveNextCore() } #if !NO_DEEP_CANCELLATION - internal sealed class SelectEnumerableWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + private sealed class SelectEnumerableWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator { private readonly Func> _selector; private readonly IAsyncEnumerable _source; @@ -616,7 +616,7 @@ protected override async ValueTask MoveNextCore() // elements in order to ensure side-effects. We should consider whether we want to follow this implementation // strategy or support IAsyncPartition in a less efficient but more correct manner here. - internal sealed class SelectIListIteratorWithTask : AsyncIterator, IAsyncIListProvider + private sealed class SelectIListIteratorWithTask : AsyncIterator, IAsyncIListProvider { private readonly Func> _selector; private readonly IList _source; @@ -738,7 +738,7 @@ protected override async ValueTask MoveNextCore() } #if !NO_DEEP_CANCELLATION - internal sealed class SelectIListIteratorWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider + private sealed class SelectIListIteratorWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider { private readonly Func> _selector; private readonly IList _source; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 9c4d1e30d6..3d5af66827 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -179,7 +179,7 @@ protected override async ValueTask MoveNextCore() } } - internal sealed class WhereEnumerableWithIndexAsyncIterator : AsyncIterator + private sealed class WhereEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _predicate; private readonly IAsyncEnumerable _source; @@ -377,7 +377,7 @@ protected override async ValueTask MoveNextCore() } #endif - internal sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator + private sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; private readonly IAsyncEnumerable _source; @@ -446,7 +446,7 @@ protected override async ValueTask MoveNextCore() } #if !NO_DEEP_CANCELLATION - internal sealed class WhereEnumerableWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator + private sealed class WhereEnumerableWithIndexAsyncIteratorWithTaskAndCancellation : AsyncIterator { private readonly Func> _predicate; private readonly IAsyncEnumerable _source; @@ -515,7 +515,7 @@ protected override async ValueTask MoveNextCore() } #endif - internal sealed class WhereSelectEnumerableAsyncIterator : AsyncIterator + private sealed class WhereSelectEnumerableAsyncIterator : AsyncIterator { private readonly Func _predicate; private readonly Func _selector; From 06a0a4e9616498a59e02ddc116fbe939027886f3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:10:51 -0800 Subject: [PATCH 580/862] Remove unused namespace. --- .../Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 28c009db1f..794e51af8a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq From 2678bde660a6e1eeebb8a5097fc813068fb01a7c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:16:31 -0800 Subject: [PATCH 581/862] Allow null for comparer. --- .../System/Linq/Operators/Distinct.cs | 2 -- .../System/Linq/Operators/DistinctUntilChanged.cs | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index be94bfaa69..71e3f61f29 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -50,8 +50,6 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return DistinctCore(source, keySelector, comparer); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 398edc8518..5a8ee4ceac 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -75,8 +75,6 @@ public static IAsyncEnumerable DistinctUntilChanged(this throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return DistinctUntilChangedCore(source, keySelector, comparer); } @@ -88,8 +86,6 @@ public static IAsyncEnumerable DistinctUntilChanged(this throw Error.ArgumentNull(nameof(source)); if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - if (comparer == null) - throw Error.ArgumentNull(nameof(comparer)); return DistinctUntilChangedCore(source, keySelector, comparer); } From 21f77a3ec9389e1a9c7f27c6e3ac3b53d732ef1d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:30:22 -0800 Subject: [PATCH 582/862] Exclude WIthCancellation from AsyncQueryable. --- .../System/Linq/AsyncQueryable.Generated.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index ecb36b91d6..51cc992370 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -14,7 +14,7 @@ <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# -var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable" }; +var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; var toQuotedImpl = default(Func); toQuotedImpl = (t, i, b) => From 4247bf778412dcaddd8575edbae7e713930eecd9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:30:33 -0800 Subject: [PATCH 583/862] Implement missing Distinct overloads. --- .../System/Linq/Operators/Distinct.cs | 176 +++++++++++++++++- 1 file changed, 174 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 71e3f61f29..f198b8a1af 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -41,7 +41,16 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer: null); } -#if !NO_DEEP_CANCELLATION // TODO +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return DistinctCore(source, keySelector, comparer: null); + } #endif public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) @@ -54,7 +63,16 @@ public static IAsyncEnumerable Distinct(this IAsyncEnume return DistinctCore(source, keySelector, comparer); } -#if !NO_DEEP_CANCELLATION // TODO +#if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return DistinctCore(source, keySelector, comparer); + } #endif private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) @@ -67,6 +85,13 @@ private static IAsyncEnumerable DistinctCore(IAsyncEnume return new DistinctAsyncIteratorWithTask(source, keySelector, comparer); } +#if !NO_DEEP_CANCELLATION + private static IAsyncEnumerable DistinctCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + return new DistinctAsyncIteratorWithTaskAndCancellation(source, keySelector, comparer); + } +#endif + private sealed class DistinctAsyncIterator : AsyncIterator, IAsyncIListProvider { private readonly IEqualityComparer _comparer; @@ -356,5 +381,152 @@ private async ValueTask> FillSetAsync(CancellationToken cancellati return r; } } + +#if !NO_DEEP_CANCELLATION + private sealed class DistinctAsyncIteratorWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider + { + private readonly IEqualityComparer _comparer; + private readonly Func> _keySelector; + private readonly IAsyncEnumerable _source; + + private IAsyncEnumerator _enumerator; + private Set _set; + + public DistinctAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) + { + Debug.Assert(source != null); + Debug.Assert(keySelector != null); + + _source = source; + _keySelector = keySelector; + _comparer = comparer; + } + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s.ToArray(); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + return s; + } + + public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return -1; + } + + var count = 0; + var s = new Set(_comparer); + + var enu = _source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var item = enu.Current; + if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) + { + count++; + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return count; + } + + public override AsyncIteratorBase Clone() + { + return new DistinctAsyncIteratorWithTaskAndCancellation(_source, _keySelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _set = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _enumerator = _source.GetAsyncEnumerator(_cancellationToken); + + if (!await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + await DisposeAsync().ConfigureAwait(false); + return false; + } + + var element = _enumerator.Current; + _set = new Set(_comparer); + _set.Add(await _keySelector(element, _cancellationToken).ConfigureAwait(false)); + _current = element; + + _state = AsyncIteratorState.Iterating; + return true; + + case AsyncIteratorState.Iterating: + while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + element = _enumerator.Current; + if (_set.Add(await _keySelector(element, _cancellationToken).ConfigureAwait(false))) + { + _current = element; + return true; + } + } + + break; + } + + await DisposeAsync().ConfigureAwait(false); + return false; + } + + private async ValueTask> FillSetAsync(CancellationToken cancellationToken) + { + var s = new Set(_comparer); + var r = new List(); + + var enu = _source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await enu.MoveNextAsync().ConfigureAwait(false)) + { + var item = enu.Current; + if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) + { + r.Add(item); + } + } + } + finally + { + await enu.DisposeAsync().ConfigureAwait(false); + } + + return r; + } + } +#endif } } From 190a2775af683b096e3002f075c5841c3c5d0ba7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:38:31 -0800 Subject: [PATCH 584/862] Regenerate AsyncQueryableEx. --- .../System/Linq/AsyncQueryableEx.Generated.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 31be24b08b..ff0fe67a46 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -118,6 +118,20 @@ public static IAsyncQueryable Concat(this IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); +#endif + } + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -146,6 +160,22 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya #endif } + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (comparer == null) + throw new ArgumentNullException(nameof(comparer)); + +#if CRIPPLED_REFLECTION + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#else + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); +#endif + } + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) From 374bf630ac664b963da65845da1949892aa02e1c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:45:14 -0800 Subject: [PATCH 585/862] Regenerate tests. --- .../AsyncQueryableExTests.Generated.cs | 209 +- .../AsyncQueryableTests.Generated.cs | 1856 +++++++++++++---- .../AsyncQueryableTests.Generated.tt | 2 +- 3 files changed, 1629 insertions(+), 438 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs index bafdc05d41..b993151e38 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs @@ -78,6 +78,17 @@ public void Catch3() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Catch4() + { + AssertEx.Throws(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), (Exception arg0, CancellationToken arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "handler"); + + var res = AsyncQueryableEx.Catch(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (Exception arg0, CancellationToken arg1) => default(ValueTask>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Concat1() { @@ -112,6 +123,17 @@ public void Distinct2() [Fact] public void Distinct3() + { + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Distinct4() { AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -123,7 +145,7 @@ public void Distinct3() } [Fact] - public void Distinct4() + public void Distinct5() { AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -134,6 +156,18 @@ public void Distinct4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Distinct6() + { + AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void DistinctUntilChanged1() { @@ -179,6 +213,17 @@ public void DistinctUntilChanged4() [Fact] public void DistinctUntilChanged5() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void DistinctUntilChanged6() { AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -190,7 +235,7 @@ public void DistinctUntilChanged5() } [Fact] - public void DistinctUntilChanged6() + public void DistinctUntilChanged7() { AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -201,6 +246,18 @@ public void DistinctUntilChanged6() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void DistinctUntilChanged8() + { + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Do1() { @@ -236,6 +293,17 @@ public void Do3() [Fact] public void Do4() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "onNext"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do5() { AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), () => { }), ane => ane.ParamName == "onNext"); @@ -247,7 +315,7 @@ public void Do4() } [Fact] - public void Do5() + public void Do6() { AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), () => default(Task)), ane => ane.ParamName == "onNext"); @@ -259,7 +327,19 @@ public void Do5() } [Fact] - public void Do6() + public void Do7() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(Task), (CancellationToken arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (CancellationToken arg0) => default(Task)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task), default(Expression>)), ane => ane.ParamName == "onCompleted"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task), (CancellationToken arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do8() { AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine()), ane => ane.ParamName == "onNext"); @@ -271,7 +351,7 @@ public void Do6() } [Fact] - public void Do7() + public void Do9() { AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), (Exception arg0) => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => default(Task)), ane => ane.ParamName == "onNext"); @@ -283,7 +363,32 @@ public void Do7() } [Fact] - public void Do8() + public void Do10() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(Task), (Exception arg0, CancellationToken arg1) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0, CancellationToken arg1) => default(Task)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task), default(Expression>)), ane => ane.ParamName == "onError"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task), (Exception arg0, CancellationToken arg1) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do11() + { + AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(Task), (Exception arg0, CancellationToken arg1) => default(Task), (CancellationToken arg0) => default(Task)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0, CancellationToken arg1) => default(Task), (CancellationToken arg0) => default(Task)), ane => ane.ParamName == "onNext"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task), default(Expression>), (CancellationToken arg0) => default(Task)), ane => ane.ParamName == "onError"); + AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task), (Exception arg0, CancellationToken arg1) => default(Task), default(Expression>)), ane => ane.ParamName == "onCompleted"); + + var res = AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(Task), (Exception arg0, CancellationToken arg1) => default(Task), (CancellationToken arg0) => default(Task)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Do12() { AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => Console.WriteLine(), (Exception arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => Console.WriteLine(), () => { }), ane => ane.ParamName == "onNext"); @@ -296,7 +401,7 @@ public void Do8() } [Fact] - public void Do9() + public void Do13() { AssertEx.Throws(() => AsyncQueryableEx.Do(default(IAsyncQueryable), (int arg0) => default(Task), (Exception arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Do(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (Exception arg0) => default(Task), () => default(Task)), ane => ane.ParamName == "onNext"); @@ -332,6 +437,18 @@ public void Expand2() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Expand3() + { + AssertEx.Throws(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryableEx.Expand(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>)); + res = res.Take(5); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Finally1() { @@ -444,6 +561,16 @@ public void MaxByAsync4() [Fact] public void MaxByAsync5() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxByAsync6() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -454,7 +581,7 @@ public void MaxByAsync5() } [Fact] - public void MaxByAsync6() + public void MaxByAsync7() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -465,7 +592,7 @@ public void MaxByAsync6() } [Fact] - public void MaxByAsync7() + public void MaxByAsync8() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -476,7 +603,7 @@ public void MaxByAsync7() } [Fact] - public void MaxByAsync8() + public void MaxByAsync9() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -486,6 +613,17 @@ public void MaxByAsync8() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void MaxByAsync10() + { + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Merge1() { @@ -558,6 +696,16 @@ public void MinByAsync4() [Fact] public void MinByAsync5() + { + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinByAsync6() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -568,7 +716,7 @@ public void MinByAsync5() } [Fact] - public void MinByAsync6() + public void MinByAsync7() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -579,7 +727,7 @@ public void MinByAsync6() } [Fact] - public void MinByAsync7() + public void MinByAsync8() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -590,7 +738,7 @@ public void MinByAsync7() } [Fact] - public void MinByAsync8() + public void MinByAsync9() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -600,6 +748,17 @@ public void MinByAsync8() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void MinByAsync10() + { + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void OnErrorResumeNext1() { @@ -677,6 +836,17 @@ public void Scan2() [Fact] public void Scan3() + { + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Scan4() { AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); @@ -687,7 +857,7 @@ public void Scan3() } [Fact] - public void Scan4() + public void Scan5() { AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); @@ -697,6 +867,17 @@ public void Scan4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Scan6() + { + AssertEx.Throws(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryableEx.Scan(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void SelectMany1() { diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index d77045ab8a..ca9deb8fa8 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -56,6 +56,16 @@ public void AggregateAsync4() [Fact] public void AggregateAsync5() + { + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AggregateAsync6() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); @@ -65,7 +75,7 @@ public void AggregateAsync5() } [Fact] - public void AggregateAsync6() + public void AggregateAsync7() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); @@ -75,7 +85,7 @@ public void AggregateAsync6() } [Fact] - public void AggregateAsync7() + public void AggregateAsync8() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -85,7 +95,7 @@ public void AggregateAsync7() } [Fact] - public void AggregateAsync8() + public void AggregateAsync9() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -95,7 +105,17 @@ public void AggregateAsync8() } [Fact] - public void AggregateAsync9() + public void AggregateAsync10() + { + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AggregateAsync11() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "accumulator"); @@ -106,7 +126,7 @@ public void AggregateAsync9() } [Fact] - public void AggregateAsync10() + public void AggregateAsync12() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "accumulator"); @@ -117,7 +137,7 @@ public void AggregateAsync10() } [Fact] - public void AggregateAsync11() + public void AggregateAsync13() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -128,7 +148,7 @@ public void AggregateAsync11() } [Fact] - public void AggregateAsync12() + public void AggregateAsync14() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -138,6 +158,17 @@ public void AggregateAsync12() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void AggregateAsync15() + { + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void AllAsync1() { @@ -178,6 +209,16 @@ public void AllAsync4() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void AllAsync5() + { + AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void AnyAsync1() { @@ -237,35 +278,27 @@ public void AnyAsync6() } [Fact] - public void Append1() - { - AssertEx.Throws(() => AsyncQueryable.Append(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.Append(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void AverageAsync1() + public void AnyAsync7() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync2() + public void Append1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Append(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Append(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync3() + public void AverageAsync1() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -274,7 +307,7 @@ public void AverageAsync3() } [Fact] - public void AverageAsync4() + public void AverageAsync2() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -283,7 +316,7 @@ public void AverageAsync4() } [Fact] - public void AverageAsync5() + public void AverageAsync3() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -292,7 +325,7 @@ public void AverageAsync5() } [Fact] - public void AverageAsync6() + public void AverageAsync4() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -301,7 +334,7 @@ public void AverageAsync6() } [Fact] - public void AverageAsync7() + public void AverageAsync5() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -310,7 +343,7 @@ public void AverageAsync7() } [Fact] - public void AverageAsync8() + public void AverageAsync6() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -319,7 +352,7 @@ public void AverageAsync8() } [Fact] - public void AverageAsync9() + public void AverageAsync7() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -328,7 +361,7 @@ public void AverageAsync9() } [Fact] - public void AverageAsync10() + public void AverageAsync8() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -337,16 +370,25 @@ public void AverageAsync10() } [Fact] - public void AverageAsync11() + public void AverageAsync9() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync12() + public void AverageAsync10() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.AverageAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync11() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -355,7 +397,7 @@ public void AverageAsync12() } [Fact] - public void AverageAsync13() + public void AverageAsync12() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -364,7 +406,7 @@ public void AverageAsync13() } [Fact] - public void AverageAsync14() + public void AverageAsync13() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -373,7 +415,7 @@ public void AverageAsync14() } [Fact] - public void AverageAsync15() + public void AverageAsync14() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -382,7 +424,7 @@ public void AverageAsync15() } [Fact] - public void AverageAsync16() + public void AverageAsync15() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -391,7 +433,7 @@ public void AverageAsync16() } [Fact] - public void AverageAsync17() + public void AverageAsync16() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -400,7 +442,7 @@ public void AverageAsync17() } [Fact] - public void AverageAsync18() + public void AverageAsync17() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -409,7 +451,7 @@ public void AverageAsync18() } [Fact] - public void AverageAsync19() + public void AverageAsync18() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -418,7 +460,7 @@ public void AverageAsync19() } [Fact] - public void AverageAsync20() + public void AverageAsync19() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -427,37 +469,16 @@ public void AverageAsync20() } [Fact] - public void AverageAsync21() - { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AverageAsync22() - { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AverageAsync23() + public void AverageAsync20() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync24() + public void AverageAsync21() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -467,7 +488,7 @@ public void AverageAsync24() } [Fact] - public void AverageAsync25() + public void AverageAsync22() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -477,7 +498,7 @@ public void AverageAsync25() } [Fact] - public void AverageAsync26() + public void AverageAsync23() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -487,7 +508,7 @@ public void AverageAsync26() } [Fact] - public void AverageAsync27() + public void AverageAsync24() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -497,7 +518,7 @@ public void AverageAsync27() } [Fact] - public void AverageAsync28() + public void AverageAsync25() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -507,7 +528,7 @@ public void AverageAsync28() } [Fact] - public void AverageAsync29() + public void AverageAsync26() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -517,7 +538,7 @@ public void AverageAsync29() } [Fact] - public void AverageAsync30() + public void AverageAsync27() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -527,7 +548,7 @@ public void AverageAsync30() } [Fact] - public void AverageAsync31() + public void AverageAsync28() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -537,7 +558,7 @@ public void AverageAsync31() } [Fact] - public void AverageAsync32() + public void AverageAsync29() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -547,7 +568,7 @@ public void AverageAsync32() } [Fact] - public void AverageAsync33() + public void AverageAsync30() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -557,7 +578,7 @@ public void AverageAsync33() } [Fact] - public void AverageAsync34() + public void AverageAsync31() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -567,7 +588,7 @@ public void AverageAsync34() } [Fact] - public void AverageAsync35() + public void AverageAsync32() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -577,7 +598,7 @@ public void AverageAsync35() } [Fact] - public void AverageAsync36() + public void AverageAsync33() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -587,7 +608,7 @@ public void AverageAsync36() } [Fact] - public void AverageAsync37() + public void AverageAsync34() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -597,7 +618,7 @@ public void AverageAsync37() } [Fact] - public void AverageAsync38() + public void AverageAsync35() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -607,7 +628,7 @@ public void AverageAsync38() } [Fact] - public void AverageAsync39() + public void AverageAsync36() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -617,7 +638,7 @@ public void AverageAsync39() } [Fact] - public void AverageAsync40() + public void AverageAsync37() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -627,37 +648,37 @@ public void AverageAsync40() } [Fact] - public void AverageAsync41() + public void AverageAsync38() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync42() + public void AverageAsync39() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync43() + public void AverageAsync40() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync44() + public void AverageAsync41() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -667,7 +688,7 @@ public void AverageAsync44() } [Fact] - public void AverageAsync45() + public void AverageAsync42() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -677,7 +698,17 @@ public void AverageAsync45() } [Fact] - public void AverageAsync46() + public void AverageAsync43() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync44() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -687,7 +718,7 @@ public void AverageAsync46() } [Fact] - public void AverageAsync47() + public void AverageAsync45() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -697,7 +728,17 @@ public void AverageAsync47() } [Fact] - public void AverageAsync48() + public void AverageAsync46() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync47() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -707,7 +748,7 @@ public void AverageAsync48() } [Fact] - public void AverageAsync49() + public void AverageAsync48() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -716,6 +757,16 @@ public void AverageAsync49() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void AverageAsync49() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void AverageAsync50() { @@ -738,6 +789,16 @@ public void AverageAsync51() [Fact] public void AverageAsync52() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync53() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -747,7 +808,7 @@ public void AverageAsync52() } [Fact] - public void AverageAsync53() + public void AverageAsync54() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -757,7 +818,17 @@ public void AverageAsync53() } [Fact] - public void AverageAsync54() + public void AverageAsync55() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync56() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -767,7 +838,7 @@ public void AverageAsync54() } [Fact] - public void AverageAsync55() + public void AverageAsync57() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -777,7 +848,17 @@ public void AverageAsync55() } [Fact] - public void AverageAsync56() + public void AverageAsync58() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync59() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -787,7 +868,7 @@ public void AverageAsync56() } [Fact] - public void AverageAsync57() + public void AverageAsync60() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -797,7 +878,17 @@ public void AverageAsync57() } [Fact] - public void AverageAsync58() + public void AverageAsync61() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync62() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -807,7 +898,7 @@ public void AverageAsync58() } [Fact] - public void AverageAsync59() + public void AverageAsync63() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -817,7 +908,17 @@ public void AverageAsync59() } [Fact] - public void AverageAsync60() + public void AverageAsync64() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync65() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -826,6 +927,56 @@ public void AverageAsync60() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void AverageAsync66() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync67() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync68() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync69() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void AverageAsync70() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Cast1() { @@ -943,6 +1094,16 @@ public void CountAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void CountAsync7() + { + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void DefaultIfEmpty1() { @@ -1101,6 +1262,16 @@ public void FirstAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void FirstAsync7() + { + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void FirstOrDefaultAsync1() { @@ -1159,6 +1330,16 @@ public void FirstOrDefaultAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void FirstOrDefaultAsync7() + { + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void GroupBy1() { @@ -1183,6 +1364,17 @@ public void GroupBy2() [Fact] public void GroupBy3() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy4() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1194,7 +1386,7 @@ public void GroupBy3() } [Fact] - public void GroupBy4() + public void GroupBy5() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1206,7 +1398,19 @@ public void GroupBy4() } [Fact] - public void GroupBy5() + public void GroupBy6() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy7() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); @@ -1218,7 +1422,7 @@ public void GroupBy5() } [Fact] - public void GroupBy6() + public void GroupBy8() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); @@ -1230,7 +1434,19 @@ public void GroupBy6() } [Fact] - public void GroupBy7() + public void GroupBy9() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy10() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); @@ -1242,7 +1458,7 @@ public void GroupBy7() } [Fact] - public void GroupBy8() + public void GroupBy11() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); @@ -1254,7 +1470,19 @@ public void GroupBy8() } [Fact] - public void GroupBy9() + public void GroupBy12() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy13() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1267,7 +1495,7 @@ public void GroupBy9() } [Fact] - public void GroupBy10() + public void GroupBy14() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1280,7 +1508,20 @@ public void GroupBy10() } [Fact] - public void GroupBy11() + public void GroupBy15() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy16() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1293,7 +1534,7 @@ public void GroupBy11() } [Fact] - public void GroupBy12() + public void GroupBy17() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1306,7 +1547,20 @@ public void GroupBy12() } [Fact] - public void GroupBy13() + public void GroupBy18() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy19() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); @@ -1319,7 +1573,7 @@ public void GroupBy13() } [Fact] - public void GroupBy14() + public void GroupBy20() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); @@ -1332,7 +1586,20 @@ public void GroupBy14() } [Fact] - public void GroupBy15() + public void GroupBy21() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupBy22() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1346,7 +1613,7 @@ public void GroupBy15() } [Fact] - public void GroupBy16() + public void GroupBy23() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -1359,6 +1626,20 @@ public void GroupBy16() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void GroupBy24() + { + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void GroupJoin1() { @@ -1389,6 +1670,20 @@ public void GroupJoin2() [Fact] public void GroupJoin3() + { + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void GroupJoin4() { AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); @@ -1403,7 +1698,7 @@ public void GroupJoin3() } [Fact] - public void GroupJoin4() + public void GroupJoin5() { AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); @@ -1417,6 +1712,21 @@ public void GroupJoin4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void GroupJoin6() + { + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Intersect1() { @@ -1470,6 +1780,20 @@ public void Join2() [Fact] public void Join3() + { + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Join4() { AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); @@ -1484,7 +1808,7 @@ public void Join3() } [Fact] - public void Join4() + public void Join5() { AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); @@ -1498,6 +1822,21 @@ public void Join4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Join6() + { + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void LastAsync1() { @@ -1556,6 +1895,16 @@ public void LastAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void LastAsync7() + { + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void LastOrDefaultAsync1() { @@ -1614,6 +1963,16 @@ public void LastOrDefaultAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void LastOrDefaultAsync7() + { + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void LongCountAsync1() { @@ -1672,6 +2031,16 @@ public void LongCountAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void LongCountAsync7() + { + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void MaxAsync1() { @@ -1872,6 +2241,16 @@ public void MaxAsync22() [Fact] public void MaxAsync23() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync24() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1881,7 +2260,7 @@ public void MaxAsync23() } [Fact] - public void MaxAsync24() + public void MaxAsync25() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1891,7 +2270,7 @@ public void MaxAsync24() } [Fact] - public void MaxAsync25() + public void MaxAsync26() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1901,7 +2280,7 @@ public void MaxAsync25() } [Fact] - public void MaxAsync26() + public void MaxAsync27() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1911,7 +2290,7 @@ public void MaxAsync26() } [Fact] - public void MaxAsync27() + public void MaxAsync28() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1921,7 +2300,7 @@ public void MaxAsync27() } [Fact] - public void MaxAsync28() + public void MaxAsync29() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1931,7 +2310,7 @@ public void MaxAsync28() } [Fact] - public void MaxAsync29() + public void MaxAsync30() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1941,7 +2320,7 @@ public void MaxAsync29() } [Fact] - public void MaxAsync30() + public void MaxAsync31() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1951,7 +2330,7 @@ public void MaxAsync30() } [Fact] - public void MaxAsync31() + public void MaxAsync32() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1961,7 +2340,7 @@ public void MaxAsync31() } [Fact] - public void MaxAsync32() + public void MaxAsync33() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1971,7 +2350,7 @@ public void MaxAsync32() } [Fact] - public void MaxAsync33() + public void MaxAsync34() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -1981,7 +2360,7 @@ public void MaxAsync33() } [Fact] - public void MaxAsync34() + public void MaxAsync35() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -1991,7 +2370,7 @@ public void MaxAsync34() } [Fact] - public void MaxAsync35() + public void MaxAsync36() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2001,7 +2380,7 @@ public void MaxAsync35() } [Fact] - public void MaxAsync36() + public void MaxAsync37() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2011,7 +2390,7 @@ public void MaxAsync36() } [Fact] - public void MaxAsync37() + public void MaxAsync38() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2021,7 +2400,7 @@ public void MaxAsync37() } [Fact] - public void MaxAsync38() + public void MaxAsync39() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2031,7 +2410,7 @@ public void MaxAsync38() } [Fact] - public void MaxAsync39() + public void MaxAsync40() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2041,7 +2420,7 @@ public void MaxAsync39() } [Fact] - public void MaxAsync40() + public void MaxAsync41() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2051,7 +2430,7 @@ public void MaxAsync40() } [Fact] - public void MaxAsync41() + public void MaxAsync42() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2061,27 +2440,27 @@ public void MaxAsync41() } [Fact] - public void MaxAsync42() + public void MaxAsync43() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync43() + public void MaxAsync44() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync44() + public void MaxAsync45() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2091,7 +2470,7 @@ public void MaxAsync44() } [Fact] - public void MaxAsync45() + public void MaxAsync46() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2101,7 +2480,17 @@ public void MaxAsync45() } [Fact] - public void MaxAsync46() + public void MaxAsync47() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync48() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2111,7 +2500,7 @@ public void MaxAsync46() } [Fact] - public void MaxAsync47() + public void MaxAsync49() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2121,7 +2510,17 @@ public void MaxAsync47() } [Fact] - public void MaxAsync48() + public void MaxAsync50() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync51() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2131,7 +2530,7 @@ public void MaxAsync48() } [Fact] - public void MaxAsync49() + public void MaxAsync52() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2141,7 +2540,17 @@ public void MaxAsync49() } [Fact] - public void MaxAsync50() + public void MaxAsync53() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync54() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2151,7 +2560,7 @@ public void MaxAsync50() } [Fact] - public void MaxAsync51() + public void MaxAsync55() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2161,7 +2570,17 @@ public void MaxAsync51() } [Fact] - public void MaxAsync52() + public void MaxAsync56() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync57() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2171,7 +2590,7 @@ public void MaxAsync52() } [Fact] - public void MaxAsync53() + public void MaxAsync58() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2181,7 +2600,17 @@ public void MaxAsync53() } [Fact] - public void MaxAsync54() + public void MaxAsync59() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync60() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2191,7 +2620,7 @@ public void MaxAsync54() } [Fact] - public void MaxAsync55() + public void MaxAsync61() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2201,7 +2630,17 @@ public void MaxAsync55() } [Fact] - public void MaxAsync56() + public void MaxAsync62() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync63() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2211,7 +2650,7 @@ public void MaxAsync56() } [Fact] - public void MaxAsync57() + public void MaxAsync64() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2221,7 +2660,17 @@ public void MaxAsync57() } [Fact] - public void MaxAsync58() + public void MaxAsync65() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync66() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2231,7 +2680,7 @@ public void MaxAsync58() } [Fact] - public void MaxAsync59() + public void MaxAsync67() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2241,7 +2690,17 @@ public void MaxAsync59() } [Fact] - public void MaxAsync60() + public void MaxAsync68() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync69() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2251,7 +2710,7 @@ public void MaxAsync60() } [Fact] - public void MaxAsync61() + public void MaxAsync70() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2261,7 +2720,17 @@ public void MaxAsync61() } [Fact] - public void MaxAsync62() + public void MaxAsync71() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MaxAsync72() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2271,7 +2740,7 @@ public void MaxAsync62() } [Fact] - public void MaxAsync63() + public void MaxAsync73() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2281,7 +2750,7 @@ public void MaxAsync63() } [Fact] - public void MaxAsync64() + public void MaxAsync74() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2291,7 +2760,7 @@ public void MaxAsync64() } [Fact] - public void MaxAsync65() + public void MaxAsync75() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2301,7 +2770,7 @@ public void MaxAsync65() } [Fact] - public void MaxAsync66() + public void MaxAsync76() { AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2310,8 +2779,36 @@ public void MaxAsync66() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void MaxAsync77() + { + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void MinAsync1() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync2() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + + var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync3() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2320,7 +2817,7 @@ public void MinAsync1() } [Fact] - public void MinAsync2() + public void MinAsync4() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2329,7 +2826,7 @@ public void MinAsync2() } [Fact] - public void MinAsync3() + public void MinAsync5() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2338,7 +2835,7 @@ public void MinAsync3() } [Fact] - public void MinAsync4() + public void MinAsync6() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2347,7 +2844,7 @@ public void MinAsync4() } [Fact] - public void MinAsync5() + public void MinAsync7() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2356,7 +2853,7 @@ public void MinAsync5() } [Fact] - public void MinAsync6() + public void MinAsync8() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2365,7 +2862,7 @@ public void MinAsync6() } [Fact] - public void MinAsync7() + public void MinAsync9() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2374,7 +2871,7 @@ public void MinAsync7() } [Fact] - public void MinAsync8() + public void MinAsync10() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); @@ -2383,25 +2880,25 @@ public void MinAsync8() } [Fact] - public void MinAsync9() + public void MinAsync11() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync10() + public void MinAsync12() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync11() + public void MinAsync13() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2410,7 +2907,7 @@ public void MinAsync11() } [Fact] - public void MinAsync12() + public void MinAsync14() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2419,7 +2916,7 @@ public void MinAsync12() } [Fact] - public void MinAsync13() + public void MinAsync15() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2428,7 +2925,7 @@ public void MinAsync13() } [Fact] - public void MinAsync14() + public void MinAsync16() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2437,7 +2934,7 @@ public void MinAsync14() } [Fact] - public void MinAsync15() + public void MinAsync17() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2446,7 +2943,7 @@ public void MinAsync15() } [Fact] - public void MinAsync16() + public void MinAsync18() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2455,7 +2952,7 @@ public void MinAsync16() } [Fact] - public void MinAsync17() + public void MinAsync19() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2464,7 +2961,7 @@ public void MinAsync17() } [Fact] - public void MinAsync18() + public void MinAsync20() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -2473,43 +2970,55 @@ public void MinAsync18() } [Fact] - public void MinAsync19() + public void MinAsync21() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync20() + public void MinAsync22() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync21() + public void MinAsync23() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync22() + public void MinAsync24() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync23() + public void MinAsync25() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync26() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2519,7 +3028,7 @@ public void MinAsync23() } [Fact] - public void MinAsync24() + public void MinAsync27() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2529,7 +3038,7 @@ public void MinAsync24() } [Fact] - public void MinAsync25() + public void MinAsync28() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2539,7 +3048,7 @@ public void MinAsync25() } [Fact] - public void MinAsync26() + public void MinAsync29() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2549,7 +3058,7 @@ public void MinAsync26() } [Fact] - public void MinAsync27() + public void MinAsync30() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2559,7 +3068,7 @@ public void MinAsync27() } [Fact] - public void MinAsync28() + public void MinAsync31() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2569,7 +3078,7 @@ public void MinAsync28() } [Fact] - public void MinAsync29() + public void MinAsync32() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2579,7 +3088,7 @@ public void MinAsync29() } [Fact] - public void MinAsync30() + public void MinAsync33() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2589,7 +3098,7 @@ public void MinAsync30() } [Fact] - public void MinAsync31() + public void MinAsync34() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2599,7 +3108,7 @@ public void MinAsync31() } [Fact] - public void MinAsync32() + public void MinAsync35() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2609,7 +3118,7 @@ public void MinAsync32() } [Fact] - public void MinAsync33() + public void MinAsync36() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2619,7 +3128,7 @@ public void MinAsync33() } [Fact] - public void MinAsync34() + public void MinAsync37() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2629,7 +3138,7 @@ public void MinAsync34() } [Fact] - public void MinAsync35() + public void MinAsync38() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2639,7 +3148,7 @@ public void MinAsync35() } [Fact] - public void MinAsync36() + public void MinAsync39() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2649,7 +3158,7 @@ public void MinAsync36() } [Fact] - public void MinAsync37() + public void MinAsync40() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2659,7 +3168,7 @@ public void MinAsync37() } [Fact] - public void MinAsync38() + public void MinAsync41() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2669,7 +3178,7 @@ public void MinAsync38() } [Fact] - public void MinAsync39() + public void MinAsync42() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2679,37 +3188,77 @@ public void MinAsync39() } [Fact] - public void MinAsync40() + public void MinAsync43() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync41() + public void MinAsync44() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync42() + public void MinAsync45() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync43() + public void MinAsync46() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync47() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync48() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync49() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync50() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2719,7 +3268,17 @@ public void MinAsync43() } [Fact] - public void MinAsync44() + public void MinAsync51() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync52() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2729,7 +3288,7 @@ public void MinAsync44() } [Fact] - public void MinAsync45() + public void MinAsync53() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2739,7 +3298,17 @@ public void MinAsync45() } [Fact] - public void MinAsync46() + public void MinAsync54() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync55() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2749,7 +3318,7 @@ public void MinAsync46() } [Fact] - public void MinAsync47() + public void MinAsync56() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2759,7 +3328,17 @@ public void MinAsync47() } [Fact] - public void MinAsync48() + public void MinAsync57() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync58() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2769,7 +3348,7 @@ public void MinAsync48() } [Fact] - public void MinAsync49() + public void MinAsync59() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2779,7 +3358,17 @@ public void MinAsync49() } [Fact] - public void MinAsync50() + public void MinAsync60() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync61() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2789,7 +3378,7 @@ public void MinAsync50() } [Fact] - public void MinAsync51() + public void MinAsync62() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2799,7 +3388,17 @@ public void MinAsync51() } [Fact] - public void MinAsync52() + public void MinAsync63() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync64() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2809,7 +3408,7 @@ public void MinAsync52() } [Fact] - public void MinAsync53() + public void MinAsync65() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2819,7 +3418,17 @@ public void MinAsync53() } [Fact] - public void MinAsync54() + public void MinAsync66() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync67() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2829,7 +3438,7 @@ public void MinAsync54() } [Fact] - public void MinAsync55() + public void MinAsync68() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2839,7 +3448,7 @@ public void MinAsync55() } [Fact] - public void MinAsync56() + public void MinAsync69() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2849,7 +3458,7 @@ public void MinAsync56() } [Fact] - public void MinAsync57() + public void MinAsync70() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2859,57 +3468,37 @@ public void MinAsync57() } [Fact] - public void MinAsync58() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync59() + public void MinAsync71() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync60() + public void MinAsync72() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync61() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync62() + public void MinAsync73() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync63() + public void MinAsync74() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2919,17 +3508,17 @@ public void MinAsync63() } [Fact] - public void MinAsync64() + public void MinAsync75() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync65() + public void MinAsync76() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2939,12 +3528,12 @@ public void MinAsync65() } [Fact] - public void MinAsync66() + public void MinAsync77() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2996,6 +3585,16 @@ public void OrderBy4() var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } + [Fact] + public void OrderBy5() + { + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + } + [Fact] public void OrderByDescending1() { @@ -3016,6 +3615,15 @@ public void OrderByDescending2() [Fact] public void OrderByDescending3() + { + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + } + + [Fact] + public void OrderByDescending4() { AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -3025,7 +3633,7 @@ public void OrderByDescending3() } [Fact] - public void OrderByDescending4() + public void OrderByDescending5() { AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -3034,6 +3642,16 @@ public void OrderByDescending4() var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } + [Fact] + public void OrderByDescending6() + { + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + } + [Fact] public void Prepend1() { @@ -3089,6 +3707,17 @@ public void Select3() [Fact] public void Select4() + { + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Select5() { AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3098,6 +3727,17 @@ public void Select4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Select6() + { + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void SelectMany1() { @@ -3122,6 +3762,17 @@ public void SelectMany2() [Fact] public void SelectMany3() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany4() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3132,7 +3783,7 @@ public void SelectMany3() } [Fact] - public void SelectMany4() + public void SelectMany5() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); @@ -3143,7 +3794,18 @@ public void SelectMany4() } [Fact] - public void SelectMany5() + public void SelectMany6() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany7() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); @@ -3155,7 +3817,7 @@ public void SelectMany5() } [Fact] - public void SelectMany6() + public void SelectMany8() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); @@ -3167,7 +3829,19 @@ public void SelectMany6() } [Fact] - public void SelectMany7() + public void SelectMany9() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SelectMany10() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); @@ -3179,7 +3853,7 @@ public void SelectMany7() } [Fact] - public void SelectMany8() + public void SelectMany11() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); @@ -3190,6 +3864,18 @@ public void SelectMany8() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void SelectMany12() + { + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void SequenceEqualAsync1() { @@ -3290,6 +3976,16 @@ public void SingleAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void SingleAsync7() + { + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void SingleOrDefaultAsync1() { @@ -3348,6 +4044,16 @@ public void SingleOrDefaultAsync6() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void SingleOrDefaultAsync7() + { + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Skip1() { @@ -3403,6 +4109,17 @@ public void SkipWhile3() [Fact] public void SkipWhile4() + { + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SkipWhile5() { AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); @@ -3412,30 +4129,41 @@ public void SkipWhile4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void SkipWhile6() + { + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void SumAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3487,45 +4215,45 @@ public void SumAsync8() [Fact] public void SumAsync9() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync10() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync11() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync12() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync13() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3577,23 +4305,33 @@ public void SumAsync18() [Fact] public void SumAsync19() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync20() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync21() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync22() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3603,7 +4341,7 @@ public void SumAsync21() } [Fact] - public void SumAsync22() + public void SumAsync23() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3613,7 +4351,7 @@ public void SumAsync22() } [Fact] - public void SumAsync23() + public void SumAsync24() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3623,7 +4361,7 @@ public void SumAsync23() } [Fact] - public void SumAsync24() + public void SumAsync25() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3633,7 +4371,7 @@ public void SumAsync24() } [Fact] - public void SumAsync25() + public void SumAsync26() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3642,28 +4380,8 @@ public void SumAsync25() AssertEx.SucceedOrFailProper(() => res.Wait()); } - [Fact] - public void SumAsync26() - { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - [Fact] public void SumAsync27() - { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SumAsync28() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3673,7 +4391,7 @@ public void SumAsync28() } [Fact] - public void SumAsync29() + public void SumAsync28() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3683,7 +4401,7 @@ public void SumAsync29() } [Fact] - public void SumAsync30() + public void SumAsync29() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3693,7 +4411,7 @@ public void SumAsync30() } [Fact] - public void SumAsync31() + public void SumAsync30() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3703,7 +4421,7 @@ public void SumAsync31() } [Fact] - public void SumAsync32() + public void SumAsync31() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3713,7 +4431,7 @@ public void SumAsync32() } [Fact] - public void SumAsync33() + public void SumAsync32() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3723,7 +4441,7 @@ public void SumAsync33() } [Fact] - public void SumAsync34() + public void SumAsync33() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3733,7 +4451,7 @@ public void SumAsync34() } [Fact] - public void SumAsync35() + public void SumAsync34() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3743,7 +4461,7 @@ public void SumAsync35() } [Fact] - public void SumAsync36() + public void SumAsync35() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -3753,7 +4471,7 @@ public void SumAsync36() } [Fact] - public void SumAsync37() + public void SumAsync36() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -3762,33 +4480,43 @@ public void SumAsync37() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void SumAsync37() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void SumAsync38() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync39() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync40() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3814,6 +4542,16 @@ public void SumAsync42() [Fact] public void SumAsync43() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync44() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3823,7 +4561,7 @@ public void SumAsync43() } [Fact] - public void SumAsync44() + public void SumAsync45() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3833,47 +4571,47 @@ public void SumAsync44() } [Fact] - public void SumAsync45() + public void SumAsync46() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync46() + public void SumAsync47() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync47() + public void SumAsync48() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync48() + public void SumAsync49() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync49() + public void SumAsync50() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3883,7 +4621,7 @@ public void SumAsync49() } [Fact] - public void SumAsync50() + public void SumAsync51() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3893,7 +4631,17 @@ public void SumAsync50() } [Fact] - public void SumAsync51() + public void SumAsync52() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync53() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3903,7 +4651,7 @@ public void SumAsync51() } [Fact] - public void SumAsync52() + public void SumAsync54() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3913,7 +4661,17 @@ public void SumAsync52() } [Fact] - public void SumAsync53() + public void SumAsync55() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync56() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3923,7 +4681,7 @@ public void SumAsync53() } [Fact] - public void SumAsync54() + public void SumAsync57() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3933,7 +4691,17 @@ public void SumAsync54() } [Fact] - public void SumAsync55() + public void SumAsync58() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync59() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3943,7 +4711,7 @@ public void SumAsync55() } [Fact] - public void SumAsync56() + public void SumAsync60() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3953,7 +4721,17 @@ public void SumAsync56() } [Fact] - public void SumAsync57() + public void SumAsync61() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync62() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3963,7 +4741,7 @@ public void SumAsync57() } [Fact] - public void SumAsync58() + public void SumAsync63() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3973,7 +4751,17 @@ public void SumAsync58() } [Fact] - public void SumAsync59() + public void SumAsync64() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync65() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3983,7 +4771,7 @@ public void SumAsync59() } [Fact] - public void SumAsync60() + public void SumAsync66() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -3992,6 +4780,46 @@ public void SumAsync60() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void SumAsync67() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync68() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync69() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void SumAsync70() + { + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Take1() { @@ -4046,6 +4874,17 @@ public void TakeWhile3() [Fact] public void TakeWhile4() + { + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void TakeWhile5() { AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); @@ -4055,6 +4894,17 @@ public void TakeWhile4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void TakeWhile6() + { + AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void ThenBy1() { @@ -4075,6 +4925,15 @@ public void ThenBy2() [Fact] public void ThenBy3() + { + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); + } + + [Fact] + public void ThenBy4() { AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -4084,7 +4943,7 @@ public void ThenBy3() } [Fact] - public void ThenBy4() + public void ThenBy5() { AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -4093,6 +4952,16 @@ public void ThenBy4() var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } + [Fact] + public void ThenBy6() + { + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + } + [Fact] public void ThenByDescending1() { @@ -4113,6 +4982,15 @@ public void ThenByDescending2() [Fact] public void ThenByDescending3() + { + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); + } + + [Fact] + public void ThenByDescending4() { AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -4122,7 +5000,7 @@ public void ThenByDescending3() } [Fact] - public void ThenByDescending4() + public void ThenByDescending5() { AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); @@ -4131,6 +5009,16 @@ public void ThenByDescending4() var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } + [Fact] + public void ThenByDescending6() + { + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + } + [Fact] public void ToArrayAsync1() { @@ -4192,33 +5080,32 @@ public void ToDictionaryAsync4() [Fact] public void ToDictionaryAsync5() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionaryAsync6() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionaryAsync7() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4235,6 +5122,28 @@ public void ToDictionaryAsync8() [Fact] public void ToDictionaryAsync9() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionaryAsync10() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionaryAsync11() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); @@ -4245,7 +5154,7 @@ public void ToDictionaryAsync9() } [Fact] - public void ToDictionaryAsync10() + public void ToDictionaryAsync12() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); @@ -4256,7 +5165,7 @@ public void ToDictionaryAsync10() } [Fact] - public void ToDictionaryAsync11() + public void ToDictionaryAsync13() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4267,7 +5176,7 @@ public void ToDictionaryAsync11() } [Fact] - public void ToDictionaryAsync12() + public void ToDictionaryAsync14() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4278,7 +5187,18 @@ public void ToDictionaryAsync12() } [Fact] - public void ToDictionaryAsync13() + public void ToDictionaryAsync15() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToDictionaryAsync16() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4290,7 +5210,7 @@ public void ToDictionaryAsync13() } [Fact] - public void ToDictionaryAsync14() + public void ToDictionaryAsync17() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4302,7 +5222,7 @@ public void ToDictionaryAsync14() } [Fact] - public void ToDictionaryAsync15() + public void ToDictionaryAsync18() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4314,7 +5234,7 @@ public void ToDictionaryAsync15() } [Fact] - public void ToDictionaryAsync16() + public void ToDictionaryAsync19() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4325,6 +5245,18 @@ public void ToDictionaryAsync16() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void ToDictionaryAsync20() + { + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void ToHashSetAsync1() { @@ -4423,6 +5355,16 @@ public void ToLookupAsync4() [Fact] public void ToLookupAsync5() + { + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookupAsync6() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4433,7 +5375,7 @@ public void ToLookupAsync5() } [Fact] - public void ToLookupAsync6() + public void ToLookupAsync7() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4444,7 +5386,7 @@ public void ToLookupAsync6() } [Fact] - public void ToLookupAsync7() + public void ToLookupAsync8() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4455,7 +5397,7 @@ public void ToLookupAsync7() } [Fact] - public void ToLookupAsync8() + public void ToLookupAsync9() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4466,7 +5408,18 @@ public void ToLookupAsync8() } [Fact] - public void ToLookupAsync9() + public void ToLookupAsync10() + { + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookupAsync11() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); @@ -4477,7 +5430,7 @@ public void ToLookupAsync9() } [Fact] - public void ToLookupAsync10() + public void ToLookupAsync12() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); @@ -4488,7 +5441,7 @@ public void ToLookupAsync10() } [Fact] - public void ToLookupAsync11() + public void ToLookupAsync13() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4499,7 +5452,7 @@ public void ToLookupAsync11() } [Fact] - public void ToLookupAsync12() + public void ToLookupAsync14() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4510,7 +5463,18 @@ public void ToLookupAsync12() } [Fact] - public void ToLookupAsync13() + public void ToLookupAsync15() + { + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void ToLookupAsync16() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4522,7 +5486,7 @@ public void ToLookupAsync13() } [Fact] - public void ToLookupAsync14() + public void ToLookupAsync17() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); @@ -4534,7 +5498,7 @@ public void ToLookupAsync14() } [Fact] - public void ToLookupAsync15() + public void ToLookupAsync18() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4546,7 +5510,7 @@ public void ToLookupAsync15() } [Fact] - public void ToLookupAsync16() + public void ToLookupAsync19() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -4557,6 +5521,18 @@ public void ToLookupAsync16() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void ToLookupAsync20() + { + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); + + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Union1() { @@ -4615,6 +5591,17 @@ public void Where3() [Fact] public void Where4() + { + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void Where5() { AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); @@ -4624,6 +5611,17 @@ public void Where4() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Where6() + { + AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void Zip1() { @@ -4648,5 +5646,17 @@ public void Zip2() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Zip3() + { + AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + } } \ No newline at end of file diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt index 20fff5ab21..959c640195 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt @@ -15,7 +15,7 @@ <#@ output extension=".cs" #> <# var failing = new[] { "TakeLast" }; -var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable" }; +var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; var toQuotedImpl = default(Func); toQuotedImpl = (t, i, b) => From c3d0ef085442bb86e342f25ade8c01b191967176 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:52:28 -0800 Subject: [PATCH 586/862] Allowing null for comparers in AsyncQueryable[Ex] surface. --- .../AsyncQueryableExTests.Generated.cs | 21 --- .../AsyncQueryableExTests.Generated.tt | 5 +- .../System/Linq/AsyncQueryableEx.Generated.cs | 42 ------ .../System/Linq/AsyncQueryableEx.Generated.tt | 3 +- .../AsyncQueryableTests.Generated.cs | 60 --------- .../AsyncQueryableTests.Generated.tt | 3 +- .../System/Linq/AsyncQueryable.Generated.cs | 120 ------------------ .../System/Linq/AsyncQueryable.Generated.tt | 3 +- 8 files changed, 9 insertions(+), 248 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs index b993151e38..74599713ff 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs @@ -137,7 +137,6 @@ public void Distinct4() { AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -149,7 +148,6 @@ public void Distinct5() { AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -161,7 +159,6 @@ public void Distinct6() { AssertEx.Throws(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -182,7 +179,6 @@ public void DistinctUntilChanged1() public void DistinctUntilChanged2() { AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -227,7 +223,6 @@ public void DistinctUntilChanged6() { AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -239,7 +234,6 @@ public void DistinctUntilChanged7() { AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -251,7 +245,6 @@ public void DistinctUntilChanged8() { AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.DistinctUntilChanged(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -503,7 +496,6 @@ public void IsEmptyAsync2() public void MaxAsync1() { AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -513,7 +505,6 @@ public void MaxAsync1() public void MaxAsync2() { AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -574,7 +565,6 @@ public void MaxByAsync6() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -585,7 +575,6 @@ public void MaxByAsync7() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -596,7 +585,6 @@ public void MaxByAsync8() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -607,7 +595,6 @@ public void MaxByAsync9() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -618,7 +605,6 @@ public void MaxByAsync10() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -638,7 +624,6 @@ public void Merge1() public void MinAsync1() { AssertEx.Throws(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -648,7 +633,6 @@ public void MinAsync1() public void MinAsync2() { AssertEx.Throws(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -709,7 +693,6 @@ public void MinByAsync6() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -720,7 +703,6 @@ public void MinByAsync7() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -731,7 +713,6 @@ public void MinByAsync8() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -742,7 +723,6 @@ public void MinByAsync9() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -753,7 +733,6 @@ public void MinByAsync10() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt index c409ad5d73..8f56d1f33f 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt @@ -15,7 +15,8 @@ <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# -var failing = new[] { "TakeLast" }; +var nullableParameterNames = new[] { "comparer" }; +var failing = new string[0]; var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable" }; var toQuotedImpl = default(Func); @@ -269,7 +270,7 @@ var indexes = new List(); var j = 0; foreach (var p in m.GetParameters()) { - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) { indexes.Add(j); } diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index ff0fe67a46..9f1517e03a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -166,8 +166,6 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -182,8 +180,6 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -198,8 +194,6 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -224,8 +218,6 @@ public static IAsyncQueryable DistinctUntilChanged(this IAsync { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -282,8 +274,6 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -298,8 +288,6 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -314,8 +302,6 @@ public static IAsyncQueryable DistinctUntilChanged(this throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -640,8 +626,6 @@ public static Task MaxAsync(this IAsyncQueryable sour { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -654,8 +638,6 @@ public static Task MaxAsync(this IAsyncQueryable sour { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -726,8 +708,6 @@ public static Task> MaxByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -756,8 +736,6 @@ public static Task> MaxByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -772,8 +750,6 @@ public static Task> MaxByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -788,8 +764,6 @@ public static Task> MaxByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -804,8 +778,6 @@ public static Task> MaxByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -830,8 +802,6 @@ public static Task MinAsync(this IAsyncQueryable sour { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -844,8 +814,6 @@ public static Task MinAsync(this IAsyncQueryable sour { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -916,8 +884,6 @@ public static Task> MinByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -946,8 +912,6 @@ public static Task> MinByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); @@ -962,8 +926,6 @@ public static Task> MinByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -978,8 +940,6 @@ public static Task> MinByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -994,8 +954,6 @@ public static Task> MinByAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt index 66440fb702..117f7859a2 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -15,6 +15,7 @@ <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# +var nullableParameterNames = new[] { "comparer" }; var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable" }; var toQuotedImpl = default(Func); @@ -254,7 +255,7 @@ foreach (var m in typeof(AsyncEnumerableEx).GetMethods() var any = false; foreach (var p in m.GetParameters()) { - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) { any = true; #> diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index ca9deb8fa8..59d569a19a 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -1020,7 +1020,6 @@ public void ContainsAsync2() public void ContainsAsync3() { AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -1030,7 +1029,6 @@ public void ContainsAsync3() public void ContainsAsync4() { AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -1138,7 +1136,6 @@ public void Distinct1() public void Distinct2() { AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1197,7 +1194,6 @@ public void Except2() { AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1378,7 +1374,6 @@ public void GroupBy4() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1390,7 +1385,6 @@ public void GroupBy5() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1402,7 +1396,6 @@ public void GroupBy6() { AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1487,7 +1480,6 @@ public void GroupBy13() AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1500,7 +1492,6 @@ public void GroupBy14() AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1513,7 +1504,6 @@ public void GroupBy15() AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1526,7 +1516,6 @@ public void GroupBy16() AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1539,7 +1528,6 @@ public void GroupBy17() AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1552,7 +1540,6 @@ public void GroupBy18() AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1605,7 +1592,6 @@ public void GroupBy22() AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1619,7 +1605,6 @@ public void GroupBy23() AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1633,7 +1618,6 @@ public void GroupBy24() AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1690,7 +1674,6 @@ public void GroupJoin4() AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1705,7 +1688,6 @@ public void GroupJoin5() AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1720,7 +1702,6 @@ public void GroupJoin6() AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1743,7 +1724,6 @@ public void Intersect2() { AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1800,7 +1780,6 @@ public void Join4() AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1815,7 +1794,6 @@ public void Join5() AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -1830,7 +1808,6 @@ public void Join6() AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); @@ -3570,7 +3547,6 @@ public void OrderBy3() { AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); } @@ -3580,7 +3556,6 @@ public void OrderBy4() { AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } @@ -3590,7 +3565,6 @@ public void OrderBy5() { AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } @@ -3627,7 +3601,6 @@ public void OrderByDescending4() { AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); } @@ -3637,7 +3610,6 @@ public void OrderByDescending5() { AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } @@ -3647,7 +3619,6 @@ public void OrderByDescending6() { AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } @@ -3901,7 +3872,6 @@ public void SequenceEqualAsync3() { AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -3912,7 +3882,6 @@ public void SequenceEqualAsync4() { AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "first"); AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -4937,7 +4906,6 @@ public void ThenBy4() { AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); } @@ -4947,7 +4915,6 @@ public void ThenBy5() { AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } @@ -4957,7 +4924,6 @@ public void ThenBy6() { AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } @@ -4994,7 +4960,6 @@ public void ThenByDescending4() { AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); } @@ -5004,7 +4969,6 @@ public void ThenByDescending5() { AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } @@ -5014,7 +4978,6 @@ public void ThenByDescending6() { AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), default(IComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } @@ -5092,7 +5055,6 @@ public void ToDictionaryAsync6() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5103,7 +5065,6 @@ public void ToDictionaryAsync7() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5114,7 +5075,6 @@ public void ToDictionaryAsync8() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5125,7 +5085,6 @@ public void ToDictionaryAsync9() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5136,7 +5095,6 @@ public void ToDictionaryAsync10() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5203,7 +5161,6 @@ public void ToDictionaryAsync16() AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5215,7 +5172,6 @@ public void ToDictionaryAsync17() AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5227,7 +5183,6 @@ public void ToDictionaryAsync18() AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5239,7 +5194,6 @@ public void ToDictionaryAsync19() AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5251,7 +5205,6 @@ public void ToDictionaryAsync20() AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5279,7 +5232,6 @@ public void ToHashSetAsync2() public void ToHashSetAsync3() { AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5289,7 +5241,6 @@ public void ToHashSetAsync3() public void ToHashSetAsync4() { AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5368,7 +5319,6 @@ public void ToLookupAsync6() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5379,7 +5329,6 @@ public void ToLookupAsync7() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5390,7 +5339,6 @@ public void ToLookupAsync8() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5401,7 +5349,6 @@ public void ToLookupAsync9() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5412,7 +5359,6 @@ public void ToLookupAsync10() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5479,7 +5425,6 @@ public void ToLookupAsync16() AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5491,7 +5436,6 @@ public void ToLookupAsync17() AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5503,7 +5447,6 @@ public void ToLookupAsync18() AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5515,7 +5458,6 @@ public void ToLookupAsync19() AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5527,7 +5469,6 @@ public void ToLookupAsync20() AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(IEqualityComparer), CancellationToken.None), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); @@ -5549,7 +5490,6 @@ public void Union2() { AssertEx.Throws(() => AsyncQueryable.Union(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(IEqualityComparer)), ane => ane.ParamName == "comparer"); var res = AsyncQueryable.Union(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt index 959c640195..ebc3949eed 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt @@ -14,6 +14,7 @@ <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# +var nullableParameterNames = new[] { "comparer" }; var failing = new[] { "TakeLast" }; var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; @@ -268,7 +269,7 @@ var indexes = new List(); var j = 0; foreach (var p in m.GetParameters()) { - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) { indexes.Add(j); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 725c3b98d9..24cdbf4b2c 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -1402,8 +1402,6 @@ public static Task ContainsAsync(this IAsyncQueryable so { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -1416,8 +1414,6 @@ public static Task ContainsAsync(this IAsyncQueryable so { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -1560,8 +1556,6 @@ public static IAsyncQueryable Distinct(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1638,8 +1632,6 @@ public static IAsyncQueryable Except(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1884,8 +1876,6 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1900,8 +1890,6 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -1916,8 +1904,6 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2030,8 +2016,6 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(keySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2048,8 +2032,6 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2066,8 +2048,6 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(keySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2084,8 +2064,6 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2102,8 +2080,6 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(keySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2120,8 +2096,6 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2194,8 +2168,6 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2214,8 +2186,6 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2234,8 +2204,6 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2316,8 +2284,6 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2338,8 +2304,6 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2360,8 +2324,6 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2390,8 +2352,6 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2472,8 +2432,6 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2494,8 +2452,6 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -2516,8 +2472,6 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(innerKeySelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); @@ -4922,8 +4876,6 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -4938,8 +4890,6 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -4954,8 +4904,6 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -5012,8 +4960,6 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -5028,8 +4974,6 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -5044,8 +4988,6 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -5376,8 +5318,6 @@ public static Task SequenceEqualAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -5392,8 +5332,6 @@ public static Task SequenceEqualAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -6794,8 +6732,6 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6810,8 +6746,6 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6826,8 +6760,6 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6884,8 +6816,6 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6900,8 +6830,6 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -6916,8 +6844,6 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); @@ -7012,8 +6938,6 @@ public static Task> ToDictionaryAsync(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7042,8 +6966,6 @@ public static Task> ToDictionaryAsync(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7058,8 +6980,6 @@ public static Task> ToDictionaryAsync(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7074,8 +6994,6 @@ public static Task> ToDictionaryAsync(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7090,8 +7008,6 @@ public static Task> ToDictionaryAsync(t throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7172,8 +7088,6 @@ public static Task> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7206,8 +7120,6 @@ public static Task> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7224,8 +7136,6 @@ public static Task> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7242,8 +7152,6 @@ public static Task> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7260,8 +7168,6 @@ public static Task> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7298,8 +7204,6 @@ public static Task> ToHashSetAsync(this IAsyncQueryabl { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7312,8 +7216,6 @@ public static Task> ToHashSetAsync(this IAsyncQueryabl { if (source == null) throw new ArgumentNullException(nameof(source)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7408,8 +7310,6 @@ public static Task> ToLookupAsync(this IAs throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7438,8 +7338,6 @@ public static Task> ToLookupAsync(this IAs throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7454,8 +7352,6 @@ public static Task> ToLookupAsync(this IAs throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7470,8 +7366,6 @@ public static Task> ToLookupAsync(this IAs throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7486,8 +7380,6 @@ public static Task> ToLookupAsync(this IAs throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (comparer == null) - throw new ArgumentNullException(nameof(comparer)); #if CRIPPLED_REFLECTION return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7568,8 +7460,6 @@ public static Task> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7602,8 +7492,6 @@ public static Task> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); @@ -7620,8 +7508,6 @@ public static Task> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7638,8 +7524,6 @@ public static Task> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7656,8 +7540,6 @@ public static Task> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); @@ -7686,8 +7568,6 @@ public static IAsyncQueryable Union(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index 51cc992370..445847aa4f 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -14,6 +14,7 @@ <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# +var nullableParameterNames = new[] { "comparer" }; var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; var toQuotedImpl = default(Func); @@ -253,7 +254,7 @@ foreach (var m in typeof(AsyncEnumerable).GetMethods() var any = false; foreach (var p in m.GetParameters()) { - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter) + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) { any = true; #> From c59f42942f608ba80f58fae0164ad8944465ed87 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 11:55:24 -0800 Subject: [PATCH 587/862] Undo special case for test hang. --- .../AsyncQueryableTests.Generated.cs | 3 ++- .../AsyncQueryableTests.Generated.tt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index 59d569a19a..72eb747c02 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -4805,7 +4805,8 @@ public void TakeLast1() AssertEx.Throws(() => AsyncQueryable.TakeLast(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); var res = AsyncQueryable.TakeLast(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - // TODO: investigate test hang + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt index ebc3949eed..e27f0093e4 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt @@ -15,7 +15,7 @@ <#@ output extension=".cs" #> <# var nullableParameterNames = new[] { "comparer" }; -var failing = new[] { "TakeLast" }; +var failing = new string[0]; var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; var toQuotedImpl = default(Func); From 876ee400a9d90b5de25ff107605a960ef3ddd6e1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 14:20:34 -0800 Subject: [PATCH 588/862] Use only var when type is obvious. --- .editorconfig | 268 ++++-------- .../System/Linq/Operators/Amb.cs | 24 +- .../System/Linq/Operators/Buffer.cs | 4 +- .../System/Linq/Operators/Catch.cs | 12 +- .../System/Linq/Operators/Distinct.cs | 42 +- .../Linq/Operators/DistinctUntilChanged.cs | 14 +- .../System/Linq/Operators/Expand.cs | 18 +- .../System/Linq/Operators/Max.cs | 6 +- .../System/Linq/Operators/Merge.cs | 14 +- .../System/Linq/Operators/Min.cs | 6 +- .../System/Linq/Operators/MinBy.cs | 36 +- .../System/Linq/Operators/Retry.cs | 4 +- .../System/Linq/Operators/Scan.cs | 12 +- .../System/Linq/Operators/Throw.cs | 2 +- .../System/Linq/Operators/Timeout.cs | 6 +- .../System/Linq/AsyncEnumerableRewriter.cs | 52 +-- .../System/Linq/AsyncEnumerableHelpers.cs | 15 +- .../System/Linq/AsyncEnumerablePartition.cs | 36 +- .../System/Linq/AsyncEnumerator.cs | 2 +- .../System/Linq/AsyncIterator.cs | 2 +- .../System/Linq/AsyncListPartition.cs | 36 +- .../System/Linq/Disposables.cs | 4 +- .../System/Linq/Operators/Aggregate.cs | 32 +- .../System/Linq/Operators/All.cs | 6 +- .../System/Linq/Operators/Any.cs | 8 +- .../System/Linq/Operators/AppendPrepend.cs | 42 +- .../Linq/Operators/Average.Generated.cs | 1 - .../System/Linq/Operators/Average.cs | 245 +++++++---- .../System/Linq/Operators/Concat.cs | 10 +- .../System/Linq/Operators/Contains.cs | 2 +- .../System/Linq/Operators/Count.cs | 8 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 8 +- .../System/Linq/Operators/ElementAt.cs | 4 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/Except.cs | 2 +- .../System/Linq/Operators/First.cs | 8 +- .../System/Linq/Operators/FirstOrDefault.cs | 22 +- .../System/Linq/Operators/ForEach.cs | 8 +- .../System/Linq/Operators/GroupBy.cs | 30 +- .../System/Linq/Operators/GroupJoin.cs | 18 +- .../System/Linq/Operators/Intersect.cs | 2 +- .../System/Linq/Operators/Join.cs | 12 +- .../System/Linq/Operators/Last.cs | 8 +- .../System/Linq/Operators/LastOrDefault.cs | 25 +- .../System/Linq/Operators/LongCount.cs | 8 +- .../System/Linq/Operators/Lookup.cs | 179 ++++---- .../System/Linq/Operators/Max.Generic.cs | 40 +- .../System/Linq/Operators/Max.Primitive.cs | 364 +++++++++------- .../System/Linq/Operators/Min.Generic.cs | 40 +- .../System/Linq/Operators/Min.Primitive.cs | 388 +++++++++++------- .../System/Linq/Operators/OfType.cs | 3 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 12 +- .../System/Linq/Operators/Range.cs | 8 +- .../System/Linq/Operators/Reverse.cs | 6 +- .../System/Linq/Operators/Select.cs | 30 +- .../System/Linq/Operators/SelectMany.cs | 24 +- .../System/Linq/Operators/SequenceEqual.cs | 4 +- .../System/Linq/Operators/Single.cs | 16 +- .../System/Linq/Operators/SingleLinkedNode.cs | 8 +- .../System/Linq/Operators/SingleOrDefault.cs | 16 +- .../System/Linq/Operators/SkipLast.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 12 +- .../System/Linq/Operators/Sum.Generated.cs | 220 +++++----- .../System/Linq/Operators/Sum.Generated.tt | 23 +- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 12 +- .../Operators/ToAsyncEnumerable.Observable.cs | 8 +- .../System/Linq/Operators/ToDictionary.cs | 24 +- .../System/Linq/Operators/ToEnumerable.cs | 6 +- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/ToObservable.cs | 2 +- .../System/Linq/Operators/Union.cs | 24 +- .../System/Linq/Operators/Where.cs | 14 +- .../System.Linq.Async/System/Linq/Set.cs | 32 +- 76 files changed, 1422 insertions(+), 1233 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8ad1e1b8b2..bdb8ab95f6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,216 +1,104 @@ -# EditorConfig is awesome:http://EditorConfig.org -# From https://raw.githubusercontent.com/dotnet/roslyn/master/.editorconfig +# editorconfig.org # top-most EditorConfig file root = true -# Don't use tabs for indentation. +# Default settings: +# A newline ending every file +# Use 4 spaces as indentation [*] +insert_final_newline = true indent_style = space -trim_trailing_whitespace = true -# (Please don't specify an indent_size here; that has too many unintended consequences.) - -# Code files -[*.{cs,csx,vb,vbx}] indent_size = 4 -insert_final_newline = true -charset = utf-8-bom - -# Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] -indent_size = 2 - -# Xml config files -[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] -indent_size = 2 - -# Yml/Yaml files -[*.{yaml,yml}] -indent_size = 2 - -# Powershell files -[*.ps1] -indent_size = 2 -# JSON files -[*.json] +[project.json] indent_size = 2 -# Shell scripts -[*.sh] -end_of_line = lf - -[*.{cmd,bat}] -end_of_line = crlf +# C# files +[*.cs] +# New line preferences +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true -# Dotnet code style settings: -[*.{cs,vb}] -# Sort using and Import directives with System.* appearing first -dotnet_sort_system_directives_first = true -# Put a blank line between System.* and Microsoft.* -dotnet_separate_import_directive_groups = true +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current -# Avoid "this." and "Me." if not necessary +# avoid this. unless absolutely necessary dotnet_style_qualification_for_field = false:suggestion dotnet_style_qualification_for_property = false:suggestion dotnet_style_qualification_for_method = false:suggestion dotnet_style_qualification_for_event = false:suggestion -# Use language keywords instead of framework type names for type references +# only use var when it's obvious what the variable type is +csharp_style_var_for_built_in_types = false:none +csharp_style_var_when_type_is_apparent = false:none +csharp_style_var_elsewhere = false:suggestion + +# use language keywords instead of BCL types dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion dotnet_style_predefined_type_for_member_access = true:suggestion -# Prefer read-only on fields -dotnet_style_readonly_field = true:warning - -# Suggest more modern language features when available -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_null_propagation = true:suggestion -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_prefer_inferred_tuple_names = true:suggestion -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion -dotnet_style_prefer_conditional_expression_over_return = false -dotnet_style_prefer_conditional_expression_over_assignment = false -dotnet_style_prefer_auto_properties = true:suggestion - -# Parentheses -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent - -# Accessibility modifiers -dotnet_style_require_accessibility_modifiers = always:suggestion - - -# Naming Rules - -# Interfaces start with an I and are PascalCased -dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.symbols = interface_symbols -dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.style = pascal_case_and_prefix_with_I_style -dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.severity = warning - -# External members are PascalCased -dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.symbols = externally_visible_symbols -dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.style = pascal_case_style -dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.severity = warning - -# Parameters are camelCased -dotnet_naming_rule.parameters_must_be_camel_cased.symbols = parameter_symbols -dotnet_naming_rule.parameters_must_be_camel_cased.style = camel_case_style -dotnet_naming_rule.parameters_must_be_camel_cased.severity = warning - -# Constants are PascalCased -dotnet_naming_rule.constants_must_be_pascal_cased.symbols = constant_symbols -dotnet_naming_rule.constants_must_be_pascal_cased.style = pascal_case_style -dotnet_naming_rule.constants_must_be_pascal_cased.severity = warning - -# Uncomment this group and comment out the next group if you prefer s_ prefixes for static fields - -# Private static fields are prefixed with s_ and are camelCased like s_myStatic -#dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.symbols = private_static_field_symbols -#dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.style = camel_case_and_prefix_with_s_underscore_style -#dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.severity = warning +# name all constant fields using PascalCase +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style -# Static readonly fields are PascalCased -dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.symbols = private_static_readonly_field_symbols -dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.style = pascal_case_style -dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = warning +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const -# Comment this group and uncomment out the next group if you don't want _ prefixed fields. +dotnet_naming_style.pascal_case_style.capitalization = pascal_case -# Private instance fields are camelCased with an _ like _myField -dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.symbols = private_field_symbols -dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.style = camel_case_and_prefix_with_underscore_style -dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.severity = warning +# static fields should have s_ prefix +dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion +dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields +dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style -# Private instance fields are camelCased -#dotnet_naming_rule.private_instance_fields_must_be_camel_cased.symbols = private_field_symbols -#dotnet_naming_rule.private_instance_fields_must_be_camel_cased.style = camel_case_style -#dotnet_naming_rule.private_instance_fields_must_be_camel_cased.severity = warning +dotnet_naming_symbols.static_fields.applicable_kinds = field +dotnet_naming_symbols.static_fields.required_modifiers = static -# Symbols -dotnet_naming_symbols.externally_visible_symbols.applicable_kinds = class,struct,interface,enum,property,method,field,event,delegate -dotnet_naming_symbols.externally_visible_symbols.applicable_accessibilities = public,internal,friend,protected,protected_internal,protected_friend,private_protected +dotnet_naming_style.static_prefix_style.required_prefix = s_ +dotnet_naming_style.static_prefix_style.capitalization = camel_case -dotnet_naming_symbols.interface_symbols.applicable_kinds = interface -dotnet_naming_symbols.interface_symbols.applicable_accessibilities = * +# internal and private fields should be _camelCase +dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style -dotnet_naming_symbols.parameter_symbols.applicable_kinds = parameter -dotnet_naming_symbols.parameter_symbols.applicable_accessibilities = * +dotnet_naming_symbols.private_internal_fields.applicable_kinds = field +dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal -dotnet_naming_symbols.constant_symbols.applicable_kinds = field -dotnet_naming_symbols.constant_symbols.required_modifiers = const -dotnet_naming_symbols.constant_symbols.applicable_accessibilities = * - -dotnet_naming_symbols.private_static_field_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_field_symbols.required_modifiers = static,shared -dotnet_naming_symbols.private_static_field_symbols.applicable_accessibilities = private - -dotnet_naming_symbols.private_static_readonly_field_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_readonly_field_symbols.required_modifiers = static,shared,readonly -dotnet_naming_symbols.private_static_readonly_field_symbols.applicable_accessibilities = private - -dotnet_naming_symbols.private_field_symbols.applicable_kinds = field -dotnet_naming_symbols.private_field_symbols.applicable_accessibilities = private - -# Styles -dotnet_naming_style.camel_case_style.capitalization = camel_case - -dotnet_naming_style.pascal_case_style.capitalization = pascal_case - -dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.required_prefix = s_ -dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.capitalization = camel_case - -dotnet_naming_style.camel_case_and_prefix_with_underscore_style.required_prefix = _ -dotnet_naming_style.camel_case_and_prefix_with_underscore_style.capitalization = camel_case - -dotnet_naming_style.pascal_case_and_prefix_with_I_style.required_prefix = I -dotnet_naming_style.pascal_case_and_prefix_with_I_style.capitalization = pascal_case - - -# CSharp code style settings: -[*.cs] -# Modifier order -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion - -# Code block -csharp_prefer_braces = false:none - -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_switch_labels = true -csharp_indent_labels = flush_left - -# Prefer "var" everywhere -csharp_style_var_for_built_in_types = true:suggestion -csharp_style_var_when_type_is_apparent = true:suggestion -csharp_style_var_elsewhere = true:suggestion +dotnet_naming_style.camel_case_underscore_style.required_prefix = _ +dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case # Code style defaults +dotnet_sort_system_directives_first = true csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true +csharp_preserve_single_line_statements = false -# Prefer method-like constructs to have a block body +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion + +# Expression-bodied members csharp_style_expression_bodied_methods = false:none csharp_style_expression_bodied_constructors = false:none csharp_style_expression_bodied_operators = false:none - -# Prefer property-like constructs to have an expression-body csharp_style_expression_bodied_properties = true:none csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none -# Expression -csharp_prefer_simple_default_expression = true:suggestion -csharp_style_deconstructed_variable_declaration = true:suggestion -csharp_style_pattern_local_over_anonymous_function = true:suggestion - # Pattern matching csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion csharp_style_pattern_matching_over_as_with_null_check = true:suggestion @@ -220,15 +108,6 @@ csharp_style_inlined_variable_declaration = true:suggestion csharp_style_throw_expression = true:suggestion csharp_style_conditional_delegate_call = true:suggestion -# Newline settings -csharp_new_line_before_open_brace = all -csharp_new_line_before_else = true -csharp_new_line_before_catch = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_between_query_expression_clauses = true - # Space preferences csharp_space_after_cast = false csharp_space_after_colon_in_inheritance_clause = true @@ -253,10 +132,29 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false csharp_space_between_square_brackets = false +# C++ Files +[*.{cpp,h,in}] +curly_bracket_next_line = true +indent_brace_style = Allman +# Xml project files +[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] +indent_size = 2 +# Xml build files +[*.builds] +indent_size = 2 +# Xml files +[*.{xml,stylecop,resx,ruleset}] +indent_size = 2 +# Xml config files +[*.{props,targets,config,nuspec}] +indent_size = 2 - - +# Shell scripts +[*.sh] +end_of_line = lf +[*.{cmd, bat}] +end_of_line = crlf \ No newline at end of file diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 830f7c417e..4b8b510ddc 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -74,13 +74,13 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - var firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); - var secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerator firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerator secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); - var firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); - var secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); + Task firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); + Task secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); - var winner = await Task.WhenAny(firstMoveNext, secondMoveNext).ConfigureAwait(false); + Task winner = await Task.WhenAny(firstMoveNext, secondMoveNext).ConfigureAwait(false); // // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: @@ -95,7 +95,7 @@ protected override async ValueTask MoveNextCore() { _enumerator = firstEnumerator; - var ignored = secondMoveNext.ContinueWith(_ => + Task ignored = secondMoveNext.ContinueWith(_ => { secondEnumerator.DisposeAsync(); }); @@ -104,7 +104,7 @@ protected override async ValueTask MoveNextCore() { _enumerator = secondEnumerator; - var ignored = firstMoveNext.ContinueWith(_ => + Task ignored = firstMoveNext.ContinueWith(_ => { firstEnumerator.DisposeAsync(); }); @@ -169,20 +169,20 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - var n = _sources.Length; + int n = _sources.Length; var enumerators = new IAsyncEnumerator[n]; var moveNexts = new ValueTask[n]; for (var i = 0; i < n; i++) { - var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerator enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); enumerators[i] = enumerator; moveNexts[i] = enumerator.MoveNextAsync(); } - var winner = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); + Task winner = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); // // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: @@ -193,7 +193,7 @@ protected override async ValueTask MoveNextCore() // The approach below has one drawback, namely that exceptions raised by any loser are dropped on the floor. // - var winnerIndex = Array.IndexOf(moveNexts, winner); + int winnerIndex = Array.IndexOf(moveNexts, winner); _enumerator = enumerators[winnerIndex]; @@ -201,7 +201,7 @@ protected override async ValueTask MoveNextCore() { if (i != winnerIndex) { - var ignored = moveNexts[i].AsTask().ContinueWith(_ => + Task ignored = moveNexts[i].AsTask().ContinueWith(_ => { enumerators[i].DisposeAsync(); }); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 7a676ae61e..cb4dd5babb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -91,13 +91,13 @@ protected override async ValueTask MoveNextCore() { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (_index++ % _skip == 0) { _buffers.Enqueue(new List(_count)); } - foreach (var buffer in _buffers) + foreach (IList buffer in _buffers) { buffer.Add(item); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index f158be885d..6e82244bc7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -140,8 +140,8 @@ protected override async ValueTask MoveNextCore() // Note: Ideally we'd dipose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - var inner = _handler(ex); - var err = inner.GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerable inner = _handler(ex); + IAsyncEnumerator err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { @@ -233,8 +233,8 @@ protected override async ValueTask MoveNextCore() // Note: Ideally we'd dipose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - var inner = await _handler(ex).ConfigureAwait(false); - var err = inner.GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerable inner = await _handler(ex).ConfigureAwait(false); + IAsyncEnumerator err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { @@ -327,8 +327,8 @@ protected override async ValueTask MoveNextCore() // Note: Ideally we'd dipose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - var inner = await _handler(ex, _cancellationToken).ConfigureAwait(false); - var err = inner.GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerable inner = await _handler(ex, _cancellationToken).ConfigureAwait(false); + IAsyncEnumerator err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index f198b8a1af..aa0e40181d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -113,13 +113,13 @@ public DistinctAsyncIterator(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } @@ -133,13 +133,13 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca var count = 0; var s = new Set(_comparer); - var enu = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var item = enu.Current; + TSource item = enu.Current; if (s.Add(_keySelector(item))) { count++; @@ -184,7 +184,7 @@ protected override async ValueTask MoveNextCore() return false; } - var element = _enumerator.Current; + TSource element = _enumerator.Current; _set = new Set(_comparer); _set.Add(_keySelector(element)); _current = element; @@ -215,13 +215,13 @@ private async Task> FillSetAsync(CancellationToken cancellationTok var s = new Set(_comparer); var r = new List(); - var enu = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var item = enu.Current; + TSource item = enu.Current; if (s.Add(_keySelector(item))) { r.Add(item); @@ -258,13 +258,13 @@ public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } @@ -278,13 +278,13 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca var count = 0; var s = new Set(_comparer); - var enu = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var item = enu.Current; + TSource item = enu.Current; if (s.Add(await _keySelector(item).ConfigureAwait(false))) { count++; @@ -329,7 +329,7 @@ protected override async ValueTask MoveNextCore() return false; } - var element = _enumerator.Current; + TSource element = _enumerator.Current; _set = new Set(_comparer); _set.Add(await _keySelector(element).ConfigureAwait(false)); _current = element; @@ -360,13 +360,13 @@ private async ValueTask> FillSetAsync(CancellationToken cancellati var s = new Set(_comparer); var r = new List(); - var enu = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var item = enu.Current; + TSource item = enu.Current; if (s.Add(await _keySelector(item).ConfigureAwait(false))) { r.Add(item); @@ -404,13 +404,13 @@ public DistinctAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable so public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } @@ -424,13 +424,13 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca var count = 0; var s = new Set(_comparer); - var enu = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var item = enu.Current; + TSource item = enu.Current; if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) { count++; @@ -475,7 +475,7 @@ protected override async ValueTask MoveNextCore() return false; } - var element = _enumerator.Current; + TSource element = _enumerator.Current; _set = new Set(_comparer); _set.Add(await _keySelector(element, _cancellationToken).ConfigureAwait(false)); _current = element; @@ -506,13 +506,13 @@ private async ValueTask> FillSetAsync(CancellationToken cancellati var s = new Set(_comparer); var r = new List(); - var enu = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var item = enu.Current; + TSource item = enu.Current; if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) { r.Add(item); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 5a8ee4ceac..5325f0bac7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -159,7 +159,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; var comparerEquals = false; if (_hasCurrentValue) @@ -230,8 +230,8 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; - var key = _keySelector(item); + TSource item = _enumerator.Current; + TKey key = _keySelector(item); var comparerEquals = false; if (_hasCurrentKey) @@ -301,8 +301,8 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; - var key = await _keySelector(item).ConfigureAwait(false); + TSource item = _enumerator.Current; + TKey key = await _keySelector(item).ConfigureAwait(false); var comparerEquals = false; if (_hasCurrentKey) @@ -373,8 +373,8 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; - var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + TSource item = _enumerator.Current; + TKey key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); var comparerEquals = false; if (_hasCurrentKey) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index bb7aeda337..cac1a2a377 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -97,7 +97,7 @@ protected override async ValueTask MoveNextCore() { if (_queue.Count > 0) { - var src = _queue.Dequeue(); + IAsyncEnumerable src = _queue.Dequeue(); if (_enumerator != null) { @@ -114,8 +114,8 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; - var next = _selector(item); + TSource item = _enumerator.Current; + IAsyncEnumerable next = _selector(item); _queue.Enqueue(next); _current = item; return true; @@ -187,7 +187,7 @@ protected override async ValueTask MoveNextCore() { if (_queue.Count > 0) { - var src = _queue.Dequeue(); + IAsyncEnumerable src = _queue.Dequeue(); if (_enumerator != null) { @@ -204,8 +204,8 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; - var next = await _selector(item).ConfigureAwait(false); + TSource item = _enumerator.Current; + IAsyncEnumerable next = await _selector(item).ConfigureAwait(false); _queue.Enqueue(next); _current = item; return true; @@ -278,7 +278,7 @@ protected override async ValueTask MoveNextCore() { if (_queue.Count > 0) { - var src = _queue.Dequeue(); + IAsyncEnumerable src = _queue.Dequeue(); if (_enumerator != null) { @@ -295,8 +295,8 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; - var next = await _selector(item, _cancellationToken).ConfigureAwait(false); + TSource item = _enumerator.Current; + IAsyncEnumerable next = await _selector(item, _cancellationToken).ConfigureAwait(false); _queue.Enqueue(next); _current = item; return true; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 2e2e49a537..988813b566 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -33,18 +33,18 @@ private static async Task MaxCore(IAsyncEnumerable so comparer = Comparer.Default; } - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - var max = e.Current; + TSource max = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; + TSource cur = e.Current; if (comparer.Compare(cur, max) > 0) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 14955d0b40..bbe20745ce 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -59,13 +59,13 @@ public override async ValueTask DisposeAsync() { if (_enumerators != null) { - var n = _enumerators.Length; + int n = _enumerators.Length; var disposes = new ValueTask[n]; for (var i = 0; i < n; i++) { - var dispose = _enumerators[i].DisposeAsync(); + ValueTask dispose = _enumerators[i].DisposeAsync(); disposes[i] = dispose; } @@ -81,7 +81,7 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - var n = _sources.Length; + int n = _sources.Length; _enumerators = new IAsyncEnumerator[n]; _moveNexts = new ValueTask[n]; @@ -89,7 +89,7 @@ protected override async ValueTask MoveNextCore() for (var i = 0; i < n; i++) { - var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerator enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); _enumerators[i] = enumerator; _moveNexts[i] = enumerator.MoveNextAsync(); } @@ -106,9 +106,9 @@ protected override async ValueTask MoveNextCore() // want to consider a "prefer fairness" option. // - var moveNext = await Task.WhenAny(_moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); + Task moveNext = await Task.WhenAny(_moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); - var index = Array.IndexOf(_moveNexts, moveNext); + int index = Array.IndexOf(_moveNexts, moveNext); if (!await moveNext.ConfigureAwait(false)) { @@ -117,7 +117,7 @@ protected override async ValueTask MoveNextCore() } else { - var enumerator = _enumerators[index]; + IAsyncEnumerator enumerator = _enumerators[index]; _current = enumerator.Current; _moveNexts[index] = enumerator.MoveNextAsync(); return true; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 09337d7636..81cdd27151 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -33,18 +33,18 @@ private static async Task MinCore(IAsyncEnumerable so comparer = Comparer.Default; } - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - var min = e.Current; + TSource min = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; + TSource cur = e.Current; if (comparer.Compare(cur, min) < 0) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 892af69474..d010d41ec9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -150,23 +150,23 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - var current = e.Current; - var resKey = keySelector(current); + TSource current = e.Current; + TKey resKey = keySelector(current); result.Add(current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var key = keySelector(cur); + TSource cur = e.Current; + TKey key = keySelector(cur); - var cmp = compare(key, resKey); + int cmp = compare(key, resKey); if (cmp == 0) { result.Add(cur); @@ -190,23 +190,23 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - var current = e.Current; - var resKey = await keySelector(current).ConfigureAwait(false); + TSource current = e.Current; + TKey resKey = await keySelector(current).ConfigureAwait(false); result.Add(current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var key = await keySelector(cur).ConfigureAwait(false); + TSource cur = e.Current; + TKey key = await keySelector(cur).ConfigureAwait(false); - var cmp = compare(key, resKey); + int cmp = compare(key, resKey); if (cmp == 0) { result.Add(cur); @@ -231,23 +231,23 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - var current = e.Current; - var resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); + TSource current = e.Current; + TKey resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); result.Add(current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var key = await keySelector(cur, cancellationToken).ConfigureAwait(false); + TSource cur = e.Current; + TKey key = await keySelector(cur, cancellationToken).ConfigureAwait(false); - var cmp = compare(key, resKey); + int cmp = compare(key, resKey); if (cmp == 0) { result.Add(cur); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs index 8ef41c117c..87c9c076ca 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs @@ -30,7 +30,7 @@ private static IEnumerable Repeat(this IEnumerable so { while (true) { - foreach (var item in source) + foreach (TSource item in source) { yield return item; } @@ -41,7 +41,7 @@ private static IEnumerable Repeat(this IEnumerable so { for (var i = 0; i < count; i++) { - foreach (var item in source) + foreach (TSource item in source) { yield return item; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 82cb3e838a..2b2ba46767 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -127,7 +127,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (!_hasSeed) { _hasSeed = true; @@ -199,7 +199,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; _accumulated = _accumulator(_accumulated, item); _current = _accumulated; return true; @@ -265,7 +265,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (!_hasSeed) { _hasSeed = true; @@ -340,7 +340,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (!_hasSeed) { _hasSeed = true; @@ -413,7 +413,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; _accumulated = await _accumulator(_accumulated, item).ConfigureAwait(false); _current = _accumulated; return true; @@ -479,7 +479,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; _accumulated = await _accumulator(_accumulated, item, _cancellationToken).ConfigureAwait(false); _current = _accumulated; return true; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index aecc4352da..0f661c8681 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -61,7 +61,7 @@ public ValueTask DisposeAsync() public ValueTask MoveNextAsync() { - var result = _moveNextThrows; + ValueTask result = _moveNextThrows; _moveNextThrows = new ValueTask(false); return result; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index ff56076096..aaefcbcd54 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -73,7 +73,7 @@ protected override async ValueTask MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - var moveNext = _enumerator.MoveNextAsync(); + ValueTask moveNext = _enumerator.MoveNextAsync(); if (!moveNext.IsCompleted) { @@ -81,9 +81,9 @@ protected override async ValueTask MoveNextCore() { var delay = Task.Delay(_timeout, delayCts.Token); - var next = moveNext.AsTask(); + Task next = moveNext.AsTask(); - var winner = await Task.WhenAny(next, delay).ConfigureAwait(false); + Task winner = await Task.WhenAny(next, delay).ConfigureAwait(false); if (winner == delay) { diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs index fa691301b6..f555e2c800 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs @@ -15,7 +15,7 @@ namespace System.Linq /// internal class AsyncEnumerableRewriter : ExpressionVisitor { - private static volatile ILookup _methods; + private static volatile ILookup s_methods; protected override Expression VisitConstant(ConstantExpression node) { @@ -34,7 +34,7 @@ protected override Expression VisitConstant(ConstantExpression node) // if (enumerableQuery.Enumerable != null) { - var publicType = GetPublicType(enumerableQuery.Enumerable.GetType()); + Type publicType = GetPublicType(enumerableQuery.Enumerable.GetType()); return Expression.Constant(enumerableQuery.Enumerable, publicType); } @@ -46,8 +46,8 @@ protected override Expression VisitConstant(ConstantExpression node) protected override Expression VisitMethodCall(MethodCallExpression node) { - var obj = Visit(node.Object); - var args = Visit(node.Arguments); + Expression obj = Visit(node.Object); + ReadOnlyCollection args = Visit(node.Arguments); // // Nothing changed during the visit; just some unrelated method call that can @@ -58,7 +58,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node) return node; } - var typeArgs = node.Method.IsGenericMethod ? node.Method.GetGenericArguments() : null; + Type[] typeArgs = node.Method.IsGenericMethod ? node.Method.GetGenericArguments() : null; // // Check whether the method is compatible with the recursively rewritten instance @@ -115,11 +115,11 @@ private static Type GetPublicType(Type type) return type; } - foreach (var ifType in type.GetInterfaces()) + foreach (Type ifType in type.GetInterfaces()) { if (ifType.IsGenericType()) { - var def = ifType.GetGenericTypeDefinition(); + Type def = ifType.GetGenericTypeDefinition(); if (def == typeof(IAsyncEnumerable<>) || def == typeof(IAsyncGrouping<,>)) { return ifType; @@ -143,7 +143,7 @@ private static bool ArgsMatch(MethodInfo method, ReadOnlyCollection // // Number of parameters should match the number of arguments to bind. // - var parameters = method.GetParameters(); + ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != args.Count) { return false; @@ -198,7 +198,7 @@ private static bool ArgsMatch(MethodInfo method, ReadOnlyCollection // for (var i = 0; i < args.Count; i++) { - var type = parameters[i].ParameterType; + Type type = parameters[i].ParameterType; // // Hardening against reflection quirks. @@ -218,7 +218,7 @@ private static bool ArgsMatch(MethodInfo method, ReadOnlyCollection type = type.GetElementType(); } - var expression = args[i]; + Expression expression = args[i]; // // If the expression is assignable to the parameter, all is good. If not, @@ -255,7 +255,7 @@ private static ReadOnlyCollection FixupQuotedArgs(MethodInfo method, // // Get all of the method parameters. No fix-up needed if empty. // - var parameters = method.GetParameters(); + ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != 0) { var list = default(List); @@ -266,8 +266,8 @@ private static ReadOnlyCollection FixupQuotedArgs(MethodInfo method, // for (var i = 0; i < parameters.Length; i++) { - var expression = argList[i]; - var parameterInfo = parameters[i]; + Expression expression = argList[i]; + ParameterInfo parameterInfo = parameters[i]; // // Perform the fix-up if needed and check the outcome. If a @@ -305,7 +305,7 @@ private static ReadOnlyCollection FixupQuotedArgs(MethodInfo method, private static Expression FixupQuotedExpression(Type type, Expression expression) { - var res = expression; + Expression res = expression; // // Keep unquoting until assignability checks pass. @@ -322,13 +322,13 @@ private static Expression FixupQuotedExpression(Type type, Expression expression // if (!type.IsAssignableFrom(res.Type) && type.IsArray && res.NodeType == ExpressionType.NewArrayInit) { - var unquotedType = StripExpression(res.Type); + Type unquotedType = StripExpression(res.Type); if (type.IsAssignableFrom(unquotedType)) { var newArrayExpression = (NewArrayExpression)res; var count = newArrayExpression.Expressions.Count; - var elementType = type.GetElementType(); + Type elementType = type.GetElementType(); var list = new List(count); for (var i = 0; i < count; i++) @@ -357,12 +357,12 @@ private static Type StripExpression(Type type) // // Array of quotes need to be stripped, so extract the element type. // - var elemType = type.IsArray ? type.GetElementType() : type; + Type elemType = type.IsArray ? type.GetElementType() : type; // // Try to find Expression and obtain T. // - var genType = FindGenericType(typeof(Expression<>), elemType); + Type genType = FindGenericType(typeof(Expression<>), elemType); if (genType != null) { elemType = genType.GetGenericArguments()[0]; @@ -393,15 +393,15 @@ private static MethodInfo FindEnumerableMethod(string name, ReadOnlyCollection m.Name); + s_methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.Static | BindingFlags.Public).ToLookup(m => m.Name); } // // Find a match based on the method name and the argument types. // - var method = _methods[name].FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); + MethodInfo method = s_methods[name].FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); if (method == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find method with name '{0}' on type '{1}'.", name, typeof(Enumerable))); @@ -423,12 +423,12 @@ private static MethodInfo FindMethod(Type type, string name, ReadOnlyCollection< // // Support the enumerable methods to be defined on another type. // - var targetType = type.GetTypeInfo().GetCustomAttribute()?.TargetType ?? type; + Type targetType = type.GetTypeInfo().GetCustomAttribute()?.TargetType ?? type; // // Get all the candidates based on name and fail if none are found. // - var methods = targetType.GetMethods(flags).Where(m => m.Name == name).ToArray(); + MethodInfo[] methods = targetType.GetMethods(flags).Where(m => m.Name == name).ToArray(); if (methods.Length == 0) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find method with name '{0}' on type '{1}'.", name, type)); @@ -437,7 +437,7 @@ private static MethodInfo FindMethod(Type type, string name, ReadOnlyCollection< // // Find a match based on arguments and fail if no match is found. // - var method = methods.FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); + MethodInfo method = methods.FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); if (method == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find a matching method with name '{0}' on type '{1}'.", name, type)); @@ -471,9 +471,9 @@ private static Type FindGenericType(Type definition, Type type) // if (definition.IsInterface()) { - foreach (var ifType in type.GetInterfaces()) + foreach (Type ifType in type.GetInterfaces()) { - var res = FindGenericType(definition, ifType); + Type res = FindGenericType(definition, ifType); if (res != null) { return res; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 97ab453312..c2657aeed4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -13,7 +13,7 @@ internal static class AsyncEnumerableHelpers { internal static async ValueTask ToArray(IAsyncEnumerable source, CancellationToken cancellationToken) { - var result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false); + ArrayWithLength result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false); Array.Resize(ref result.Array, result.Length); return result.Array; } @@ -23,11 +23,13 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE cancellationToken.ThrowIfCancellationRequested(); var result = new ArrayWithLength(); + // Check for short circuit optimizations. This one is very unlikely // but could be here as a group if (source is ICollection ic) { - var count = ic.Count; + int count = ic.Count; + if (count != 0) { // Allocate an array of the desired size, then copy the elements into it. Note that this has the same @@ -44,15 +46,17 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } else { - var en = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = source.GetAsyncEnumerator(cancellationToken); try { if (await en.MoveNextAsync().ConfigureAwait(false)) { const int DefaultCapacity = 4; + var arr = new T[DefaultCapacity]; arr[0] = en.Current; + var count = 1; while (await en.MoveNextAsync().ConfigureAwait(false)) @@ -76,7 +80,8 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE // larger than that. For that case, we then ensure that the newLength is large enough to hold // the desired capacity. This does mean that in the very rare case where we've grown to such a // large size, each new element added after MaxArrayLength will end up doing a resize. - var newLength = count << 1; + int newLength = count << 1; + if ((uint)newLength > MaxArrayLength) { newLength = MaxArrayLength <= count ? count + 1 : MaxArrayLength; @@ -110,7 +115,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE internal static async Task> ToSet(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index bfca968637..2f11ae8111 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -80,7 +80,7 @@ async ValueTask Core() return Math.Max(await _source.CountAsync(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); } - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -93,7 +93,7 @@ async ValueTask Core() // At the same time, however, we are guaranteed that our max count can fit // in an int because if that is true, then _minIndexInclusive must > 0. - var count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en).ConfigureAwait(false); + uint count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en).ConfigureAwait(false); Debug.Assert(count != (uint)int.MaxValue + 1 || _minIndexInclusive > 0, "Our return value will be incorrect."); return Math.Max((int)count - _minIndexInclusive, 0); } @@ -166,7 +166,8 @@ public override IAsyncEnumerable Select(Func Skip(int count) { - var minIndex = _minIndexInclusive + count; + int minIndex = _minIndexInclusive + count; + if (!HasLimit) { if (minIndex < 0) @@ -191,7 +192,8 @@ public IAsyncPartition Skip(int count) public IAsyncPartition Take(int count) { - var maxIndex = _minIndexInclusive + count - 1; + int maxIndex = _minIndexInclusive + count - 1; + if (!HasLimit) { if (maxIndex < 0) @@ -222,7 +224,7 @@ public async ValueTask> TryGetElementAsync(int index, Cancellatio // If the index is negative or >= our max count, return early. if (index >= 0 && (!HasLimit || index < Limit)) { - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -244,7 +246,7 @@ public async ValueTask> TryGetElementAsync(int index, Cancellatio public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -263,14 +265,14 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cancel public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { - var remaining = Limit - 1; // Max number of items left, not counting the current element. - var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + int remaining = Limit - 1; // Max number of items left, not counting the current element. + int comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. TSource result; do @@ -293,16 +295,16 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancell public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { - var remaining = Limit - 1; // Max number of items left, not counting the current element. - var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + int remaining = Limit - 1; // Max number of items left, not counting the current element. + int comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. - var maxCapacity = HasLimit ? Limit : int.MaxValue; + int maxCapacity = HasLimit ? Limit : int.MaxValue; var builder = new List(maxCapacity); do @@ -331,14 +333,14 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { - var remaining = Limit - 1; // Max number of items left, not counting the current element. - var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + int remaining = Limit - 1; // Max number of items left, not counting the current element. + int comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. do { @@ -360,7 +362,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation private static async ValueTask SkipBeforeAsync(int index, IAsyncEnumerator en) { - var n = await SkipAndCountAsync(index, en).ConfigureAwait(false); + int n = await SkipAndCountAsync(index, en).ConfigureAwait(false); return n == index; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index fd389f549c..e0c7ff533f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -84,7 +84,7 @@ public override AsyncIteratorBase Clone() public override async ValueTask DisposeAsync() { - var dispose = Interlocked.Exchange(ref _dispose, null); + Func dispose = Interlocked.Exchange(ref _dispose, null); if (dispose != null) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 21720b8a70..132a29db54 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -32,7 +32,7 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati { cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. - var enumerator = _state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId + AsyncIteratorBase enumerator = _state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 4d0fdd24a2..9beb257697 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -27,6 +27,7 @@ public AsyncListPartition(IList source, int minIndexInclusive, int maxI Debug.Assert(source != null); Debug.Assert(minIndexInclusive >= 0); Debug.Assert(minIndexInclusive <= maxIndexInclusive); + _source = source; _minIndexInclusive = minIndexInclusive; _maxIndexInclusive = maxIndexInclusive; @@ -70,7 +71,8 @@ public override IEnumerable Select(Func Skip(int count) { - var minIndex = _minIndexInclusive + count; + int minIndex = _minIndexInclusive + count; + if ((uint)minIndex > (uint)_maxIndexInclusive) { return AsyncEnumerable.EmptyAsyncIterator.Instance; @@ -83,7 +85,8 @@ public IAsyncPartition Skip(int count) public IAsyncPartition Take(int count) { - var maxIndex = _minIndexInclusive + count - 1; + int maxIndex = _minIndexInclusive + count - 1; + if ((uint)maxIndex >= (uint)_maxIndexInclusive) { return this; @@ -98,7 +101,7 @@ public ValueTask> TryGetElementAsync(int index, CancellationToken { if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < _source.Count - _minIndexInclusive) { - var res = _source[_minIndexInclusive + index]; + TSource res = _source[_minIndexInclusive + index]; return new ValueTask>(new Maybe(res)); } @@ -109,7 +112,7 @@ public ValueTask> TryGetFirstAsync(CancellationToken cancellation { if (_source.Count > _minIndexInclusive) { - var res = _source[_minIndexInclusive]; + TSource res = _source[_minIndexInclusive]; return new ValueTask>(new Maybe(res)); } @@ -118,10 +121,11 @@ public ValueTask> TryGetFirstAsync(CancellationToken cancellation public ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { - var lastIndex = _source.Count - 1; + int lastIndex = _source.Count - 1; + if (lastIndex >= _minIndexInclusive) { - var res = _source[Math.Min(lastIndex, _maxIndexInclusive)]; + TSource res = _source[Math.Min(lastIndex, _maxIndexInclusive)]; return new ValueTask>(new Maybe(res)); } @@ -132,7 +136,8 @@ private int Count { get { - var count = _source.Count; + int count = _source.Count; + if (count <= _minIndexInclusive) { return 0; @@ -144,7 +149,8 @@ private int Count public ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var count = Count; + int count = Count; + if (count == 0) { return new ValueTask( @@ -157,6 +163,7 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) } var array = new TSource[count]; + for (int i = 0, curIdx = _minIndexInclusive; i != array.Length; ++i, ++curIdx) { array[i] = _source[curIdx]; @@ -167,15 +174,17 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) public ValueTask> ToListAsync(CancellationToken cancellationToken) { - var count = Count; + int count = Count; + if (count == 0) { return new ValueTask>(new List()); } var list = new List(count); - var end = _minIndexInclusive + count; - for (var i = _minIndexInclusive; i != end; ++i) + int end = _minIndexInclusive + count; + + for (int i = _minIndexInclusive; i != end; ++i) { list.Add(_source[i]); } @@ -183,9 +192,6 @@ public ValueTask> ToListAsync(CancellationToken cancellationToken) return new ValueTask>(list); } - public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - return new ValueTask(Count); - } + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(Count); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs index d5fee14f94..383a7aa21c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs @@ -41,12 +41,12 @@ public BinaryDisposable(IDisposable d1, IDisposable d2) public void Dispose() { - var d1 = Interlocked.Exchange(ref _d1, null); + IDisposable d1 = Interlocked.Exchange(ref _d1, null); if (d1 != null) { d1.Dispose(); - var d2 = Interlocked.Exchange(ref _d2, null); + IDisposable d2 = Interlocked.Exchange(ref _d2, null); if (d2 != null) { d2.Dispose(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index b70c1775a6..eede6f3387 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -178,9 +178,9 @@ public static Task AggregateAsync(this I private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { - var acc = seed; + TAccumulate acc = seed; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -199,7 +199,7 @@ private static async Task AggregateCore( private static async Task AggregateCore(IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -208,7 +208,7 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) { - var acc = seed; + TResult acc = seed; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -247,9 +247,9 @@ private static async Task AggregateCore(IAsyncEnumera #if !NO_DEEP_CANCELLATION private static async Task AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) { - var acc = seed; + TResult acc = seed; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -269,9 +269,9 @@ private static async Task AggregateCore(IAsyncEnumera private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { - var acc = seed; + TAccumulate acc = seed; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -291,9 +291,9 @@ private static async Task AggregateCore( #if !NO_DEEP_CANCELLATION private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { - var acc = seed; + TAccumulate acc = seed; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -313,7 +313,7 @@ private static async Task AggregateCore( private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -322,7 +322,7 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -349,7 +349,7 @@ private static async Task AggregateCore(IAsyncEnumerable AllAsync(this IAsyncEnumerable source private static async Task AllCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -84,7 +84,7 @@ private static async Task AllCore(IAsyncEnumerable sourc private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -105,7 +105,7 @@ private static async Task AllCore(IAsyncEnumerable sourc #if !NO_DEEP_CANCELLATION private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index eecd57d415..19c033eda2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -80,7 +80,7 @@ public static Task AnyAsync(this IAsyncEnumerable source private static async Task AnyCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -94,7 +94,7 @@ private static async Task AnyCore(IAsyncEnumerable sourc private static async Task AnyCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -114,7 +114,7 @@ private static async Task AnyCore(IAsyncEnumerable sourc private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -135,7 +135,7 @@ private static async Task AnyCore(IAsyncEnumerable sourc #if !NO_DEEP_CANCELLATION private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index d162f4c5d2..fd96138164 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -179,7 +179,8 @@ public override AppendPrependAsyncIterator Prepend(TSource element) public override async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + if (count == -1) { return await AsyncEnumerableHelpers.ToArray(this, cancellationToken).ConfigureAwait(false); @@ -189,6 +190,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel var array = new TSource[count]; int index; + if (_appending) { index = 0; @@ -205,7 +207,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -231,18 +233,18 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel public override async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); - var list = count == -1 ? new List() : new List(count); + List list = count == -1 ? new List() : new List(count); if (!_appending) { list.Add(_item); } - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -268,7 +270,7 @@ public override async ValueTask GetCountAsync(bool onlyIfCheap, Cancellatio { if (_source is IAsyncIListProvider listProv) { - var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + int count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + 1; } @@ -380,19 +382,20 @@ protected override async ValueTask MoveNextCore() public override AppendPrependAsyncIterator Append(TSource item) { - var res = _appended != null ? _appended.Add(item) : new SingleLinkedNode(item); + SingleLinkedNode res = _appended != null ? _appended.Add(item) : new SingleLinkedNode(item); return new AppendPrependNAsyncIterator(_source, _prepended, res, _prependCount, _appendCount + 1); } public override AppendPrependAsyncIterator Prepend(TSource item) { - var res = _prepended != null ? _prepended.Add(item) : new SingleLinkedNode(item); + SingleLinkedNode res = _prepended != null ? _prepended.Add(item) : new SingleLinkedNode(item); return new AppendPrependNAsyncIterator(_source, res, _appended, _prependCount + 1, _appendCount); } public override async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + if (count == -1) { return await AsyncEnumerableHelpers.ToArray(this, cancellationToken).ConfigureAwait(false); @@ -400,7 +403,8 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel var array = new TSource[count]; var index = 0; - for (var n = _prepended; n != null; n = n.Linked) + + for (SingleLinkedNode n = _prepended; n != null; n = n.Linked) { array[index] = n.Item; ++index; @@ -412,7 +416,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -429,7 +433,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } index = array.Length; - for (var n = _appended; n != null; n = n.Linked) + for (SingleLinkedNode n = _appended; n != null; n = n.Linked) { --index; array[index] = n.Item; @@ -440,14 +444,16 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel public override async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); - var list = count == -1 ? new List() : new List(count); - for (var n = _prepended; n != null; n = n.Linked) + int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + + List list = count == -1 ? new List() : new List(count); + + for (SingleLinkedNode n = _prepended; n != null; n = n.Linked) { list.Add(n.Item); } - var en = _source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -463,7 +469,7 @@ public override async ValueTask> ToListAsync(CancellationToken can if (_appended != null) { - using (var en2 = _appended.GetEnumerator(_appendCount)) + using (IEnumerator en2 = _appended.GetEnumerator(_appendCount)) { while (en2.MoveNext()) { @@ -479,7 +485,7 @@ public override async ValueTask GetCountAsync(bool onlyIfCheap, Cancellatio { if (_source is IAsyncIListProvider listProv) { - var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + int count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + _appendCount + _prependCount; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 7937b617c8..954a46b879 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -689,6 +689,5 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } #endif - } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index 76c20af694..8ea4fbf1c0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -12,7 +12,7 @@ public static partial class AsyncEnumerable { private static async Task AverageCore(this IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -23,6 +23,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, long sum = e.Current; long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -42,7 +43,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, private static async Task AverageCore(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -53,6 +54,7 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -83,6 +85,7 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -114,6 +117,7 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + int? v = e.Current; + if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -172,22 +179,25 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = selector(e.Current); + int? v = selector(e.Current); + if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -210,22 +220,25 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current).ConfigureAwait(false); + int? v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -249,22 +262,25 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -288,7 +304,7 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -297,8 +313,9 @@ private static async Task AverageCore(IAsyncEnumerable source, Can throw Error.NoElements(); } - var sum = e.Current; + long sum = e.Current; long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -318,7 +335,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -327,8 +344,9 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - var sum = selector(e.Current); + long sum = selector(e.Current); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -348,7 +366,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -357,8 +375,9 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - var sum = await selector(e.Current).ConfigureAwait(false); + long sum = await selector(e.Current).ConfigureAwait(false); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -379,7 +398,7 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -388,8 +407,9 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -410,22 +430,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + long? v = e.Current; + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -448,22 +471,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = selector(e.Current); + long? v = selector(e.Current); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -486,22 +512,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current).ConfigureAwait(false); + long? v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -525,22 +554,25 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + long sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -564,7 +596,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -573,8 +605,9 @@ private static async Task AverageCore(IAsyncEnumerable source, C throw Error.NoElements(); } - var sum = e.Current; + double sum = e.Current; long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -594,7 +627,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -603,8 +636,9 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - var sum = selector(e.Current); + double sum = selector(e.Current); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -624,7 +658,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -633,8 +667,9 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - var sum = await selector(e.Current).ConfigureAwait(false); + double sum = await selector(e.Current).ConfigureAwait(false); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -655,7 +690,7 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -664,8 +699,9 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -686,22 +722,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + double? v = e.Current; + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -724,22 +763,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = selector(e.Current); + double? v = selector(e.Current); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -762,22 +804,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current).ConfigureAwait(false); + double? v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -801,22 +846,25 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -840,7 +888,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -851,6 +899,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can double sum = e.Current; long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; @@ -867,7 +916,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -878,6 +927,7 @@ private static async Task AverageCore(IAsyncEnumerable double sum = selector(e.Current); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += selector(e.Current); @@ -894,7 +944,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -905,6 +955,7 @@ private static async Task AverageCore(IAsyncEnumerable double sum = await selector(e.Current).ConfigureAwait(false); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += await selector(e.Current).ConfigureAwait(false); @@ -922,7 +973,7 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -933,6 +984,7 @@ private static async Task AverageCore(IAsyncEnumerable double sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); @@ -950,22 +1002,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + float? v = e.Current; + if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -988,22 +1043,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = selector(e.Current); + float? v = selector(e.Current); + if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1026,22 +1084,25 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current).ConfigureAwait(false); + float? v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1065,22 +1126,25 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; + checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1104,7 +1168,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1113,8 +1177,9 @@ private static async Task AverageCore(IAsyncEnumerable source, throw Error.NoElements(); } - var sum = e.Current; + decimal sum = e.Current; long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; @@ -1131,7 +1196,7 @@ private static async Task AverageCore(IAsyncEnumerable source, private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1158,7 +1223,7 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1167,8 +1232,9 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1195,8 +1261,9 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + decimal? v = e.Current; + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + decimal sum = v.GetValueOrDefault(); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1249,20 +1319,23 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = selector(e.Current); + decimal? v = selector(e.Current); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + decimal sum = v.GetValueOrDefault(); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1284,20 +1357,23 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current).ConfigureAwait(false); + decimal? v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + decimal sum = v.GetValueOrDefault(); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1320,20 +1396,23 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + decimal? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { - var sum = v.GetValueOrDefault(); + decimal sum = v.GetValueOrDefault(); long count = 1; + while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (v.HasValue) { sum += v.GetValueOrDefault(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 97aee1ba56..b7de4bb094 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -78,13 +78,13 @@ public async ValueTask> ToListAsync(CancellationToken cancellation var list = new List(); for (var i = 0; ; i++) { - var source = GetAsyncEnumerable(i); + IAsyncEnumerable source = GetAsyncEnumerable(i); if (source == null) { break; } - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -118,7 +118,7 @@ async ValueTask Core() var count = 0; for (var i = 0; ; i++) { - var source = GetAsyncEnumerable(i); + IAsyncEnumerable source = GetAsyncEnumerable(i); if (source == null) { break; @@ -169,7 +169,7 @@ protected override async ValueTask MoveNextCore() // https://github.com/dotnet/corefx/blob/f7539b726c4bc2385b7f49e5751c1cff2f2c7368/src/System.Linq/src/System/Linq/Concat.cs#L240 // - var next = GetAsyncEnumerable(_counter++ - 1); + IAsyncEnumerable next = GetAsyncEnumerable(_counter++ - 1); if (next != null) { await _enumerator.DisposeAsync().ConfigureAwait(false); @@ -242,7 +242,7 @@ internal override IAsyncEnumerable GetAsyncEnumerable(int index) // that has its _nextIndex equal to index. If we don't find one, then it // must be prior to any of them, so call GetEnumerable on the previous // Concat2Iterator. This avoids a deep recursive call chain. - var current = this; + ConcatNAsyncIterator current = this; while (true) { if (index == current._nextIndex) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 95addaf118..b4989fb76f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -54,7 +54,7 @@ private static Task ContainsCore(IAsyncEnumerable source private static async Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index e8c020054a..c72dd750bb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -97,7 +97,7 @@ async Task Core() { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -122,7 +122,7 @@ private static async Task CountCore(IAsyncEnumerable sour { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -149,7 +149,7 @@ private static async Task CountCore(this IAsyncEnumerable { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -177,7 +177,7 @@ private static async Task CountCore(this IAsyncEnumerable { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 8a1ca757c2..944ed96f93 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -95,13 +95,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); + TSource[] array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); return array.Length == 0 ? new[] { _defaultValue } : array; } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); + List list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); if (list.Count == 0) { list.Add(_defaultValue); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index fb201adb70..8d31fc1392 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -45,13 +45,13 @@ public DistinctAsyncIterator(IAsyncEnumerable source, IEqualityComparer public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + Set s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + Set s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToList(); } @@ -66,7 +66,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + Set s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.Count; } } @@ -100,7 +100,7 @@ protected override async ValueTask MoveNextCore() return false; } - var element = _enumerator.Current; + TSource element = _enumerator.Current; _set = new Set(_comparer); _set.Add(element); _current = element; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 0a16541b41..d6daceeea8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -30,7 +30,7 @@ private static async Task ElementAtCore(IAsyncEnumerable p) { - var first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); + Maybe first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { @@ -46,7 +46,7 @@ private static async Task ElementAtCore(IAsyncEnumerable= 0) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 71e6483938..ecb23be764 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -30,7 +30,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera { if (source is IAsyncPartition p) { - var first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); + Maybe first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { @@ -49,7 +49,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera } else { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 9b69ba5da0..a648f394d4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -92,7 +92,7 @@ protected override async ValueTask MoveNextCore() if (moveNext) { - var item = _firstEnumerator.Current; + TSource item = _firstEnumerator.Current; if (_set.Add(item)) { _current = item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 6ca57a3175..f76d4074eb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -80,21 +80,21 @@ public static Task FirstAsync(this IAsyncEnumerable s private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } private static async Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } @@ -103,7 +103,7 @@ private static async Task FirstCore(IAsyncEnumerable private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index b516e800bb..af5eb00edd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -80,21 +80,21 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -102,7 +102,7 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -127,7 +127,7 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core() { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -150,13 +150,13 @@ async ValueTask> Core() private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = e.Current; + TSource value = e.Current; if (predicate(value)) { @@ -174,13 +174,13 @@ private static async Task> TryGetFirst(IAsyncEnumerable< private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = e.Current; + TSource value = e.Current; if (await predicate(value).ConfigureAwait(false)) { @@ -199,13 +199,13 @@ private static async Task> TryGetFirst(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = e.Current; + TSource value = e.Current; if (await predicate(value, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 25f0a0b577..14602a1374 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -119,7 +119,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -136,7 +136,7 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -155,7 +155,7 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { var index = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -174,7 +174,7 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { var index = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index c224cc0352..87920895d2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -380,13 +380,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.ToArray(_resultSelector); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.ToList(_resultSelector); } @@ -401,7 +401,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -473,13 +473,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArray(_resultSelector).ConfigureAwait(false); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToList(_resultSelector).ConfigureAwait(false); } @@ -494,7 +494,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -567,13 +567,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArray(_resultSelector, cancellationToken).ConfigureAwait(false); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToList(_resultSelector, cancellationToken).ConfigureAwait(false); } @@ -588,7 +588,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -682,7 +682,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -775,7 +775,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -869,7 +869,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -960,7 +960,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -1050,7 +1050,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -1141,7 +1141,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 6d8ee96a12..0fdd7be10f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -192,10 +192,10 @@ public async ValueTask MoveNextAsync() _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } - var item = _outer.Current; + TOuter item = _outer.Current; - var outerKey = _outerKeySelector(item); - var inner = _lookup[outerKey].ToAsyncEnumerable(); + TKey outerKey = _outerKeySelector(item); + IAsyncEnumerable inner = _lookup[outerKey].ToAsyncEnumerable(); Current = _resultSelector(item, inner); @@ -290,10 +290,10 @@ public async ValueTask MoveNextAsync() _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } - var item = _outer.Current; + TOuter item = _outer.Current; - var outerKey = await _outerKeySelector(item).ConfigureAwait(false); - var inner = _lookup[outerKey].ToAsyncEnumerable(); + TKey outerKey = await _outerKeySelector(item).ConfigureAwait(false); + IAsyncEnumerable inner = _lookup[outerKey].ToAsyncEnumerable(); Current = await _resultSelector(item, inner).ConfigureAwait(false); @@ -389,10 +389,10 @@ public async ValueTask MoveNextAsync() _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } - var item = _outer.Current; + TOuter item = _outer.Current; - var outerKey = await _outerKeySelector(item, _cancellationToken).ConfigureAwait(false); - var inner = _lookup[outerKey].ToAsyncEnumerable(); + TKey outerKey = await _outerKeySelector(item, _cancellationToken).ConfigureAwait(false); + IAsyncEnumerable inner = _lookup[outerKey].ToAsyncEnumerable(); Current = await _resultSelector(item, inner, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 799648659f..3a95ff47bd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -93,7 +93,7 @@ protected override async ValueTask MoveNextCore() if (moveNext) { - var item = _firstEnumerator.Current; + TSource item = _firstEnumerator.Current; if (_set.Remove(item)) { _current = item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 3a883d6941..eb92d03dec 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -196,7 +196,7 @@ protected override async ValueTask MoveNextCore() case State_DoLoop: _item = _outerEnumerator.Current; - var g = _lookup.GetGrouping(_outerKeySelector(_item), create: false); + Internal.Grouping g = _lookup.GetGrouping(_outerKeySelector(_item), create: false); if (g != null) { _count = g._count; @@ -221,7 +221,7 @@ protected override async ValueTask MoveNextCore() return true; case State_While: - var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); + bool hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; @@ -323,7 +323,7 @@ protected override async ValueTask MoveNextCore() case State_DoLoop: _item = _outerEnumerator.Current; - var g = _lookup.GetGrouping(await _outerKeySelector(_item).ConfigureAwait(false), create: false); + Internal.Grouping g = _lookup.GetGrouping(await _outerKeySelector(_item).ConfigureAwait(false), create: false); if (g != null) { _count = g._count; @@ -348,7 +348,7 @@ protected override async ValueTask MoveNextCore() return true; case State_While: - var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); + bool hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; @@ -451,7 +451,7 @@ protected override async ValueTask MoveNextCore() case State_DoLoop: _item = _outerEnumerator.Current; - var g = _lookup.GetGrouping(await _outerKeySelector(_item, _cancellationToken).ConfigureAwait(false), create: false); + Internal.Grouping g = _lookup.GetGrouping(await _outerKeySelector(_item, _cancellationToken).ConfigureAwait(false), create: false); if (g != null) { _count = g._count; @@ -476,7 +476,7 @@ protected override async ValueTask MoveNextCore() return true; case State_While: - var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); + bool hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index aa56a914f7..f8eb18634e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -80,21 +80,21 @@ public static Task LastAsync(this IAsyncEnumerable so private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } private static async Task LastCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } @@ -102,7 +102,7 @@ private static async Task LastCore(IAsyncEnumerable s #if !NO_DEEP_CANCELLATION private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 93ac785c87..21eb66cfec 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -80,21 +80,21 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -102,7 +102,7 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -112,7 +112,8 @@ private static ValueTask> TryGetLast(IAsyncEnumerable list) { - var count = list.Count; + int count = list.Count; + if (count > 0) { return new ValueTask>(new Maybe(list[count - 1])); @@ -131,7 +132,7 @@ async ValueTask> Core() var last = default(TSource); var hasLast = false; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -158,13 +159,13 @@ private static async Task> TryGetLast(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = e.Current; + TSource value = e.Current; if (predicate(value)) { @@ -191,13 +192,13 @@ private static async Task> TryGetLast(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = e.Current; + TSource value = e.Current; if (await predicate(value).ConfigureAwait(false)) { @@ -225,13 +226,13 @@ private static async Task> TryGetLast(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = e.Current; + TSource value = e.Current; if (await predicate(value, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 8af207fe35..e75bc74de7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -82,7 +82,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -106,7 +106,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -133,7 +133,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -161,7 +161,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index c99f96414e..63e044e8cf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -30,7 +30,8 @@ public IEnumerable this[TKey key] { get { - var grouping = GetGrouping(key, create: false); + Grouping grouping = GetGrouping(key, create: false); + if (grouping != null) { return grouping; @@ -44,19 +45,14 @@ public IEnumerable this[TKey key] } } - public bool Contains(TKey key) - { - return GetGrouping(key, create: false) != null; - } + public bool Contains(TKey key) => GetGrouping(key, create: false) != null; - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerator> GetEnumerator() { - var g = _lastGrouping; + Grouping g = _lastGrouping; + if (g != null) { do @@ -69,7 +65,8 @@ public IEnumerator> GetEnumerator() public IEnumerable ApplyResultSelector(Func, TResult> resultSelector) { - var g = _lastGrouping; + Grouping g = _lastGrouping; + if (g != null) { do @@ -77,7 +74,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = keySelector(enu.Current); - var group = lookup.GetGrouping(key, create: true); + TKey key = keySelector(enu.Current); + Grouping group = lookup.GetGrouping(key, create: true); - var element = elementSelector(enu.Current); + TElement element = elementSelector(enu.Current); group.Add(element); } } @@ -119,13 +116,13 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = keySelector(enu.Current); + TKey key = keySelector(enu.Current); lookup.GetGrouping(key, create: true).Add(enu.Current); } } @@ -141,13 +138,14 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { var lookup = new Lookup(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = keySelector(enu.Current); + TKey key = keySelector(enu.Current); + if (key != null) { lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -164,8 +162,9 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum internal Grouping GetGrouping(TKey key, bool create) { - var hashCode = InternalGetHashCode(key); - for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) + int hashCode = InternalGetHashCode(key); + + for (Grouping g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) { if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) { @@ -180,7 +179,8 @@ internal Grouping GetGrouping(TKey key, bool create) Resize(); } - var index = hashCode % _groupings.Length; + int index = hashCode % _groupings.Length; + var g = new Grouping { _key = key, @@ -188,7 +188,9 @@ internal Grouping GetGrouping(TKey key, bool create) _elements = new TElement[1], _hashNext = _groupings[index] }; + _groupings[index] = g; + if (_lastGrouping == null) { g._next = g; @@ -201,6 +203,7 @@ internal Grouping GetGrouping(TKey key, bool create) _lastGrouping = g; Count++; + return g; } @@ -217,13 +220,16 @@ internal TResult[] ToArray(Func, TResu { var array = new TResult[Count]; var index = 0; - var g = _lastGrouping; + + Grouping g = _lastGrouping; + if (g != null) { do { g = g._next; g.Trim(); + array[index] = resultSelector(g._key, g._elements.ToAsyncEnumerable()); ++index; } while (g != _lastGrouping); @@ -235,7 +241,9 @@ internal TResult[] ToArray(Func, TResu internal List ToList(Func, TResult> resultSelector) { var list = new List(Count); - var g = _lastGrouping; + + Grouping g = _lastGrouping; + if (g != null) { do @@ -243,7 +251,7 @@ internal List ToList(Func, TR g = g._next; g.Trim(); - var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); + TResult result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); list.Add(result); } while (g != _lastGrouping); } @@ -253,13 +261,16 @@ internal List ToList(Func, TR private void Resize() { - var newSize = checked((Count * 2) + 1); + int newSize = checked((Count * 2) + 1); var newGroupings = new Grouping[newSize]; - var g = _lastGrouping; + + Grouping g = _lastGrouping; + do { g = g._next; - var index = g._hashCode % newSize; + + int index = g._hashCode % newSize; g._hashNext = newGroupings[index]; newGroupings[index] = g; } while (g != _lastGrouping); @@ -267,10 +278,7 @@ private void Resize() _groupings = newGroupings; } - public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) - { - return new ValueTask(Count); - } + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(Count); IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) { @@ -284,7 +292,9 @@ ValueTask>> IAsyncIListProvider>(Count); - var g = _lastGrouping; + + Grouping g = _lastGrouping; + if (g != null) { do @@ -304,7 +314,9 @@ ValueTask[]> IAsyncIListProvider[Count]; var index = 0; - var g = _lastGrouping; + + Grouping g = _lastGrouping; + if (g != null) { do @@ -338,7 +350,8 @@ public IEnumerable this[TKey key] { get { - var grouping = GetGrouping(key, create: false); + Grouping grouping = GetGrouping(key, create: false); + if (grouping != null) { return grouping; @@ -352,19 +365,14 @@ public IEnumerable this[TKey key] } } - public bool Contains(TKey key) - { - return GetGrouping(key, create: false) != null; - } + public bool Contains(TKey key) => GetGrouping(key, create: false) != null; - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerator> GetEnumerator() { - var g = _lastGrouping; + Grouping g = _lastGrouping; + if (g != null) { do @@ -383,16 +391,16 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current).ConfigureAwait(false); - var group = lookup.GetGrouping(key, create: true); + TKey key = await keySelector(enu.Current).ConfigureAwait(false); + Grouping group = lookup.GetGrouping(key, create: true); - var element = await elementSelector(enu.Current).ConfigureAwait(false); + TElement element = await elementSelector(enu.Current).ConfigureAwait(false); group.Add(element); } } @@ -413,16 +421,16 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); - var group = lookup.GetGrouping(key, create: true); + TKey key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + Grouping group = lookup.GetGrouping(key, create: true); - var element = await elementSelector(enu.Current, cancellationToken).ConfigureAwait(false); + TElement element = await elementSelector(enu.Current, cancellationToken).ConfigureAwait(false); group.Add(element); } } @@ -442,13 +450,13 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current).ConfigureAwait(false); + TKey key = await keySelector(enu.Current).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(enu.Current); } } @@ -468,13 +476,13 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + TKey key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(enu.Current); } } @@ -491,13 +499,14 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current).ConfigureAwait(false); + TKey key = await keySelector(enu.Current).ConfigureAwait(false); + if (key != null) { lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -517,13 +526,14 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); - var enu = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + TKey key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + if (key != null) { lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -541,8 +551,9 @@ internal static async Task> CreateForJoinAsync(IA internal Grouping GetGrouping(TKey key, bool create) { - var hashCode = InternalGetHashCode(key); - for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) + int hashCode = InternalGetHashCode(key); + + for (Grouping g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) { if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) { @@ -557,7 +568,8 @@ internal Grouping GetGrouping(TKey key, bool create) Resize(); } - var index = hashCode % _groupings.Length; + int index = hashCode % _groupings.Length; + var g = new Grouping { _key = key, @@ -565,7 +577,9 @@ internal Grouping GetGrouping(TKey key, bool create) _elements = new TElement[1], _hashNext = _groupings[index] }; + _groupings[index] = g; + if (_lastGrouping == null) { g._next = g; @@ -594,13 +608,16 @@ internal async Task ToArray(Func g = _lastGrouping; + if (g != null) { do { g = g._next; g.Trim(); + array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); ++index; } while (g != _lastGrouping); @@ -616,13 +633,16 @@ internal async Task ToArray(Func g = _lastGrouping; + if (g != null) { do { g = g._next; g.Trim(); + array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable(), cancellationToken).ConfigureAwait(false); ++index; } while (g != _lastGrouping); @@ -635,7 +655,9 @@ internal async Task ToArray(Func> ToList(Func, ValueTask> resultSelector) { var list = new List(Count); - var g = _lastGrouping; + + Grouping g = _lastGrouping; + if (g != null) { do @@ -643,7 +665,7 @@ internal async Task> ToList(Func> ToList(Func(Count); - var g = _lastGrouping; + Grouping g = _lastGrouping; if (g != null) { do @@ -665,7 +687,7 @@ internal async Task> ToList(Func> ToList(Func[newSize]; - var g = _lastGrouping; + + Grouping g = _lastGrouping; + do { g = g._next; - var index = g._hashCode % newSize; + + int index = g._hashCode % newSize; g._hashNext = newGroupings[index]; newGroupings[index] = g; } while (g != _lastGrouping); @@ -707,7 +732,9 @@ ValueTask>> IAsyncIListProvider>(Count); - var g = _lastGrouping; + + Grouping g = _lastGrouping; + if (g != null) { do @@ -727,7 +754,9 @@ ValueTask[]> IAsyncIListProvider[Count]; var index = 0; - var g = _lastGrouping; + + Grouping g = _lastGrouping; + if (g != null) { do diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs index 2682b9f608..100af49e7c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs @@ -12,11 +12,11 @@ public static partial class AsyncEnumerable { private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TSource); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -33,7 +33,7 @@ private static async Task MaxCore(IAsyncEnumerable so while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + TSource x = e.Current; if (x != null && comparer.Compare(x, value) > 0) { value = x; @@ -47,7 +47,7 @@ private static async Task MaxCore(IAsyncEnumerable so } else { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -59,7 +59,7 @@ private static async Task MaxCore(IAsyncEnumerable so value = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + TSource x = e.Current; if (comparer.Compare(x, value) > 0) { value = x; @@ -77,11 +77,11 @@ private static async Task MaxCore(IAsyncEnumerable so private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TResult); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -98,7 +98,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -112,7 +112,7 @@ private static async Task MaxCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { @@ -124,7 +124,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -142,11 +142,11 @@ private static async Task MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TResult); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -163,7 +163,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -177,7 +177,7 @@ private static async Task MaxCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { @@ -189,7 +189,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -208,11 +208,11 @@ private static async Task MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TResult); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -229,7 +229,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -243,7 +243,7 @@ private static async Task MaxCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { @@ -255,7 +255,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs index cce4651d80..6988421fbe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs @@ -14,7 +14,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -24,9 +24,11 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + int x = e.Current; + if (x > value) { value = x; @@ -45,7 +47,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -60,7 +62,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -71,8 +74,9 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + int? cur = e.Current; + int x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -84,8 +88,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + int? cur = e.Current; + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -109,7 +113,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -119,9 +123,11 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + long x = e.Current; + if (x > value) { value = x; @@ -140,7 +146,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -155,13 +161,15 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + long? cur = e.Current; + long x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -173,8 +181,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + long? cur = e.Current; + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -198,7 +206,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -225,7 +233,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + double x = e.Current; + if (x > value) { value = x; @@ -244,7 +253,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -259,7 +268,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -267,7 +277,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance return value; } - var cur = e.Current; + double? cur = e.Current; + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -276,8 +287,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + double? cur = e.Current; + double x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -300,7 +311,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -310,6 +321,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell } value = e.Current; + while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -322,7 +334,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + float x = e.Current; + if (x > value) { value = x; @@ -341,7 +354,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -356,7 +369,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -364,7 +378,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell return value; } - var cur = e.Current; + float? cur = e.Current; + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -373,8 +388,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + float? cur = e.Current; + float x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -397,7 +412,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Can { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -407,9 +422,11 @@ private static async Task MaxCore(IAsyncEnumerable source, Can } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + decimal x = e.Current; + if (x > value) { value = x; @@ -428,7 +445,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Can { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -443,11 +460,13 @@ private static async Task MaxCore(IAsyncEnumerable source, Can } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + decimal? cur = e.Current; + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) { valueVal = x; @@ -467,7 +486,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -477,9 +496,11 @@ private static async Task MaxCore(IAsyncEnumerable source } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + int x = selector(e.Current); + if (x > value) { value = x; @@ -498,7 +519,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -513,7 +534,8 @@ private static async Task MaxCore(IAsyncEnumerable source } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -524,8 +546,9 @@ private static async Task MaxCore(IAsyncEnumerable source // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + int? cur = selector(e.Current); + int x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -537,8 +560,8 @@ private static async Task MaxCore(IAsyncEnumerable source { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + int? cur = selector(e.Current); + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -562,7 +585,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -572,9 +595,11 @@ private static async Task MaxCore(IAsyncEnumerable sourc } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + long x = selector(e.Current); + if (x > value) { value = x; @@ -593,7 +618,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -608,13 +633,15 @@ private static async Task MaxCore(IAsyncEnumerable sourc } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + long? cur = selector(e.Current); + long x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -626,8 +653,8 @@ private static async Task MaxCore(IAsyncEnumerable sourc { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + long? cur = selector(e.Current); + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -651,7 +678,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -661,6 +688,7 @@ private static async Task MaxCore(IAsyncEnumerable sour } value = selector(e.Current); + while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -673,7 +701,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + float x = selector(e.Current); + if (x > value) { value = x; @@ -692,7 +721,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -707,7 +736,8 @@ private static async Task MaxCore(IAsyncEnumerable sour } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -715,7 +745,8 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - var cur = selector(e.Current); + float? cur = selector(e.Current); + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -724,8 +755,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + float? cur = selector(e.Current); + float x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -748,7 +779,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -775,7 +806,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + double x = selector(e.Current); + if (x > value) { value = x; @@ -794,7 +826,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -809,7 +841,8 @@ private static async Task MaxCore(IAsyncEnumerable sou } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -817,7 +850,8 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - var cur = selector(e.Current); + double? cur = selector(e.Current); + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -826,8 +860,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + double? cur = selector(e.Current); + double x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -850,7 +884,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -860,9 +894,11 @@ private static async Task MaxCore(IAsyncEnumerable so } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + decimal x = selector(e.Current); + if (x > value) { value = x; @@ -881,7 +917,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -896,11 +932,13 @@ private static async Task MaxCore(IAsyncEnumerable so } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + decimal? cur = selector(e.Current); + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) { valueVal = x; @@ -920,7 +958,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -930,9 +968,11 @@ private static async Task MaxCore(IAsyncEnumerable source } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + int x = await selector(e.Current).ConfigureAwait(false); + if (x > value) { value = x; @@ -951,7 +991,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -966,7 +1006,8 @@ private static async Task MaxCore(IAsyncEnumerable source } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -977,8 +1018,9 @@ private static async Task MaxCore(IAsyncEnumerable source // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + int? cur = await selector(e.Current).ConfigureAwait(false); + int x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -990,8 +1032,8 @@ private static async Task MaxCore(IAsyncEnumerable source { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + int? cur = await selector(e.Current).ConfigureAwait(false); + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1015,7 +1057,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1025,9 +1067,11 @@ private static async Task MaxCore(IAsyncEnumerable sourc } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + long x = await selector(e.Current).ConfigureAwait(false); + if (x > value) { value = x; @@ -1046,7 +1090,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1061,13 +1105,15 @@ private static async Task MaxCore(IAsyncEnumerable sourc } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + long? cur = await selector(e.Current).ConfigureAwait(false); + long x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -1079,8 +1125,8 @@ private static async Task MaxCore(IAsyncEnumerable sourc { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + long? cur = await selector(e.Current).ConfigureAwait(false); + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1104,7 +1150,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1114,6 +1160,7 @@ private static async Task MaxCore(IAsyncEnumerable sour } value = await selector(e.Current).ConfigureAwait(false); + while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1126,7 +1173,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + float x = await selector(e.Current).ConfigureAwait(false); + if (x > value) { value = x; @@ -1145,7 +1193,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1160,7 +1208,8 @@ private static async Task MaxCore(IAsyncEnumerable sour } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1168,7 +1217,8 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - var cur = await selector(e.Current).ConfigureAwait(false); + float? cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1177,8 +1227,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + float? cur = await selector(e.Current).ConfigureAwait(false); + float x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1201,7 +1251,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1228,7 +1278,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + double x = await selector(e.Current).ConfigureAwait(false); + if (x > value) { value = x; @@ -1247,7 +1298,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1262,7 +1313,8 @@ private static async Task MaxCore(IAsyncEnumerable sou } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1270,7 +1322,8 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - var cur = await selector(e.Current).ConfigureAwait(false); + double? cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1279,8 +1332,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + double? cur = await selector(e.Current).ConfigureAwait(false); + double x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1303,7 +1356,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1313,9 +1366,11 @@ private static async Task MaxCore(IAsyncEnumerable so } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + decimal x = await selector(e.Current).ConfigureAwait(false); + if (x > value) { value = x; @@ -1334,7 +1389,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1349,11 +1404,13 @@ private static async Task MaxCore(IAsyncEnumerable so } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + decimal? cur = await selector(e.Current).ConfigureAwait(false); + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) { valueVal = x; @@ -1374,7 +1431,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1384,9 +1441,11 @@ private static async Task MaxCore(IAsyncEnumerable source } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) { value = x; @@ -1405,7 +1464,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1420,7 +1479,8 @@ private static async Task MaxCore(IAsyncEnumerable source } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -1431,8 +1491,9 @@ private static async Task MaxCore(IAsyncEnumerable source // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + int? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -1444,8 +1505,8 @@ private static async Task MaxCore(IAsyncEnumerable source { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + int? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1469,7 +1530,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1479,9 +1540,11 @@ private static async Task MaxCore(IAsyncEnumerable sourc } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) { value = x; @@ -1500,7 +1563,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1515,13 +1578,15 @@ private static async Task MaxCore(IAsyncEnumerable sourc } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + long? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long x = cur.GetValueOrDefault(); + if (x > valueVal) { valueVal = x; @@ -1533,8 +1598,8 @@ private static async Task MaxCore(IAsyncEnumerable sourc { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + long? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1558,7 +1623,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1568,6 +1633,7 @@ private static async Task MaxCore(IAsyncEnumerable sour } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1580,7 +1646,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) { value = x; @@ -1599,7 +1666,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1614,7 +1681,8 @@ private static async Task MaxCore(IAsyncEnumerable sour } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1622,7 +1690,8 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1631,8 +1700,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + float? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1655,7 +1724,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1682,7 +1751,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) { value = x; @@ -1701,7 +1771,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1716,7 +1786,8 @@ private static async Task MaxCore(IAsyncEnumerable sou } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1724,7 +1795,8 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1733,8 +1805,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + double? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1757,7 +1829,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1767,9 +1839,11 @@ private static async Task MaxCore(IAsyncEnumerable so } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + decimal x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x > value) { value = x; @@ -1788,7 +1862,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1803,11 +1877,13 @@ private static async Task MaxCore(IAsyncEnumerable so } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + decimal? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) { valueVal = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs index e7bf900793..23eff3e6d7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs @@ -12,11 +12,11 @@ public static partial class AsyncEnumerable { private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TSource); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -33,7 +33,7 @@ private static async Task MinCore(IAsyncEnumerable so while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + TSource x = e.Current; if (x != null && comparer.Compare(x, value) < 0) { value = x; @@ -47,7 +47,7 @@ private static async Task MinCore(IAsyncEnumerable so } else { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -59,7 +59,7 @@ private static async Task MinCore(IAsyncEnumerable so value = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + TSource x = e.Current; if (comparer.Compare(x, value) < 0) { value = x; @@ -77,11 +77,11 @@ private static async Task MinCore(IAsyncEnumerable so private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TResult); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -98,7 +98,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { @@ -124,7 +124,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TResult); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -163,7 +163,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { @@ -189,7 +189,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var comparer = Comparer.Default; + Comparer comparer = Comparer.Default; var value = default(TResult); if (value == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -229,7 +229,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); try { @@ -255,7 +255,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Cancellatio { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -24,9 +24,11 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellatio } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + int x = e.Current; + if (x < value) { value = x; @@ -45,7 +47,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellatio { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -64,11 +66,12 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellatio // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + int? cur = e.Current; + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -91,7 +94,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -101,9 +104,11 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + long x = e.Current; + if (x < value) { value = x; @@ -122,7 +127,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -137,11 +142,12 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + long? cur = e.Current; + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -164,7 +170,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -174,24 +180,25 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + float x = e.Current; + if (x < value) { value = x; } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. return x; } } @@ -208,7 +215,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -223,13 +230,16 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; + float? cur = e.Current; + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + float x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -254,7 +264,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cance { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -264,9 +274,11 @@ private static async Task MinCore(IAsyncEnumerable source, Cance } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + double x = e.Current; + if (x < value) { value = x; @@ -289,7 +301,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cance { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -304,13 +316,16 @@ private static async Task MinCore(IAsyncEnumerable source, Cance } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; + double? cur = e.Current; + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + double x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -335,7 +350,7 @@ private static async Task MinCore(IAsyncEnumerable source, Can { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -345,9 +360,11 @@ private static async Task MinCore(IAsyncEnumerable source, Can } value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + decimal x = e.Current; + if (x < value) { value = x; @@ -366,7 +383,7 @@ private static async Task MinCore(IAsyncEnumerable source, Can { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -381,11 +398,13 @@ private static async Task MinCore(IAsyncEnumerable source, Can } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); + decimal? cur = e.Current; + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) { valueVal = x; @@ -405,7 +424,7 @@ private static async Task MinCore(IAsyncEnumerable source { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -415,9 +434,11 @@ private static async Task MinCore(IAsyncEnumerable source } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + int x = selector(e.Current); + if (x < value) { value = x; @@ -436,7 +457,7 @@ private static async Task MinCore(IAsyncEnumerable source { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -455,11 +476,12 @@ private static async Task MinCore(IAsyncEnumerable source // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + int? cur = selector(e.Current); + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -482,7 +504,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -492,9 +514,11 @@ private static async Task MinCore(IAsyncEnumerable sourc } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + long x = selector(e.Current); + if (x < value) { value = x; @@ -513,7 +537,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -528,11 +552,12 @@ private static async Task MinCore(IAsyncEnumerable sourc } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + long? cur = selector(e.Current); + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -555,7 +580,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -565,24 +590,25 @@ private static async Task MinCore(IAsyncEnumerable sour } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + float x = selector(e.Current); + if (x < value) { value = x; } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. return x; } } @@ -599,7 +625,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -614,13 +640,16 @@ private static async Task MinCore(IAsyncEnumerable sour } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); + float? cur = selector(e.Current); + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + float x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -645,7 +674,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -655,9 +684,11 @@ private static async Task MinCore(IAsyncEnumerable sou } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + double x = selector(e.Current); + if (x < value) { value = x; @@ -680,7 +711,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -695,13 +726,16 @@ private static async Task MinCore(IAsyncEnumerable sou } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); + double? cur = selector(e.Current); + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + double x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -726,7 +760,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -736,9 +770,11 @@ private static async Task MinCore(IAsyncEnumerable so } value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + decimal x = selector(e.Current); + if (x < value) { value = x; @@ -757,7 +793,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -772,11 +808,13 @@ private static async Task MinCore(IAsyncEnumerable so } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); + decimal? cur = selector(e.Current); + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) { valueVal = x; @@ -796,7 +834,7 @@ private static async Task MinCore(IAsyncEnumerable source { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -806,9 +844,11 @@ private static async Task MinCore(IAsyncEnumerable source } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + int x = await selector(e.Current).ConfigureAwait(false); + if (x < value) { value = x; @@ -827,7 +867,7 @@ private static async Task MinCore(IAsyncEnumerable source { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -846,11 +886,12 @@ private static async Task MinCore(IAsyncEnumerable source // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + int? cur = await selector(e.Current).ConfigureAwait(false); + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -873,7 +914,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -883,9 +924,11 @@ private static async Task MinCore(IAsyncEnumerable sourc } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + long x = await selector(e.Current).ConfigureAwait(false); + if (x < value) { value = x; @@ -904,7 +947,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -919,11 +962,12 @@ private static async Task MinCore(IAsyncEnumerable sourc } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + long? cur = await selector(e.Current).ConfigureAwait(false); + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -946,7 +990,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -956,24 +1000,25 @@ private static async Task MinCore(IAsyncEnumerable sour } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + float x = await selector(e.Current).ConfigureAwait(false); + if (x < value) { value = x; } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. return x; } } @@ -990,7 +1035,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1005,13 +1050,16 @@ private static async Task MinCore(IAsyncEnumerable sour } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); + float? cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + float x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -1036,7 +1084,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1046,9 +1094,11 @@ private static async Task MinCore(IAsyncEnumerable sou } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + double x = await selector(e.Current).ConfigureAwait(false); + if (x < value) { value = x; @@ -1071,7 +1121,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1086,13 +1136,16 @@ private static async Task MinCore(IAsyncEnumerable sou } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); + double? cur = await selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + double x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -1117,7 +1170,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1127,9 +1180,11 @@ private static async Task MinCore(IAsyncEnumerable so } value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + decimal x = await selector(e.Current).ConfigureAwait(false); + if (x < value) { value = x; @@ -1148,7 +1203,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1163,11 +1218,13 @@ private static async Task MinCore(IAsyncEnumerable so } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + decimal? cur = await selector(e.Current).ConfigureAwait(false); + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) { valueVal = x; @@ -1188,7 +1245,7 @@ private static async Task MinCore(IAsyncEnumerable source { int value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1198,9 +1255,11 @@ private static async Task MinCore(IAsyncEnumerable source } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) { value = x; @@ -1219,7 +1278,7 @@ private static async Task MinCore(IAsyncEnumerable source { int? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1238,11 +1297,12 @@ private static async Task MinCore(IAsyncEnumerable source // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + int valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + int? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1265,7 +1325,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1275,9 +1335,11 @@ private static async Task MinCore(IAsyncEnumerable sourc } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) { value = x; @@ -1296,7 +1358,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1311,11 +1373,12 @@ private static async Task MinCore(IAsyncEnumerable sourc } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + long valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + long? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1338,7 +1401,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1348,24 +1411,25 @@ private static async Task MinCore(IAsyncEnumerable sour } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) { value = x; } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. return x; } } @@ -1382,7 +1446,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1397,13 +1461,16 @@ private static async Task MinCore(IAsyncEnumerable sour } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + float valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + float x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -1428,7 +1495,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1438,9 +1505,11 @@ private static async Task MinCore(IAsyncEnumerable sou } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) { value = x; @@ -1463,7 +1532,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1478,13 +1547,16 @@ private static async Task MinCore(IAsyncEnumerable sou } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + double valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (cur.HasValue) { - var x = cur.GetValueOrDefault(); + double x = cur.GetValueOrDefault(); + if (x < valueVal) { valueVal = x; @@ -1509,7 +1581,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal value; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1519,9 +1591,11 @@ private static async Task MinCore(IAsyncEnumerable so } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + decimal x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x < value) { value = x; @@ -1540,7 +1614,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal? value = null; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1555,11 +1629,13 @@ private static async Task MinCore(IAsyncEnumerable so } while (!value.HasValue); - var valueVal = value.GetValueOrDefault(); + decimal valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + decimal? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + decimal x = cur.GetValueOrDefault(); + if (cur.HasValue && x < valueVal) { valueVal = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index 48a5a757c5..9dd0306dbd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -55,7 +55,8 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + object item = _enumerator.Current; + if (item is TResult res) { _current = res; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 0b18381a44..ba161a79c5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -42,7 +42,7 @@ protected override async ValueTask MoveNextCore() // REVIEW: If we add selectors with CancellationToken support, we should feed the token to Sort. - var sorter = GetAsyncEnumerableSorter(next: null, _cancellationToken); + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(next: null, _cancellationToken); _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); _index = 0; @@ -213,9 +213,9 @@ private void QuickSort(int[] map, int left, int right) { do { - var i = left; - var j = right; - var x = map[i + (j - i >> 1)]; + int i = left; + int j = right; + int x = map[i + (j - i >> 1)]; do { @@ -236,7 +236,7 @@ private void QuickSort(int[] map, int left, int right) if (i < j) { - var temp = map[i]; + int temp = map[i]; map[i] = map[j]; map[j] = temp; } @@ -285,7 +285,7 @@ public AsyncEnumerableSorterBase(IComparer comparer, bool descending, Asyn internal override int CompareKeys(int index1, int index2) { - var c = _comparer.Compare(_keys[index1], _keys[index2]); + int c = _comparer.Compare(_keys[index1], _keys[index2]); if (c == 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index be401c8e90..e497433c79 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -16,7 +16,7 @@ public static IAsyncEnumerable Range(int start, int count) if (count < 0) throw Error.ArgumentOutOfRange(nameof(count)); - var end = (long)start + count - 1L; + long end = (long)start + count - 1L; if (count < 0 || end > int.MaxValue) throw Error.ArgumentOutOfRange(nameof(count)); @@ -45,7 +45,7 @@ public RangeAsyncIterator(int start, int count) public IAsyncPartition Skip(int count) { - var n = _end - _start; + int n = _end - _start; if (count >= n) { @@ -57,7 +57,7 @@ public IAsyncPartition Skip(int count) public IAsyncPartition Take(int count) { - var n = _end - _start; + int n = _end - _start; if (count >= n) { @@ -71,7 +71,7 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) { var res = new int[_end - _start]; - var value = _start; + int value = _start; for (var i = 0; i < res.Length; i++) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index d0b35fb891..e712cfa989 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -36,13 +36,13 @@ public ReverseAsyncIterator(IAsyncEnumerable source) public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); + TSource[] array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); // Array.Reverse() involves boxing for non-primitive value types, but // checking that has its own cost, so just use this approach for all types. for (int i = 0, j = array.Length - 1; i < j; ++i, --j) { - var temp = array[i]; + TSource temp = array[i]; array[i] = array[j]; array[j] = temp; } @@ -52,7 +52,7 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); + List list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); list.Reverse(); return list; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index baaa8edf6c..c3c514c684 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -222,7 +222,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -281,9 +281,9 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella cancellationToken.ThrowIfCancellationRequested(); - var count = 0; + int count = 0; - foreach (var item in _source) + foreach (TSource item in _source) { _selector(item); @@ -305,7 +305,7 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - var n = _source.Count; + int n = _source.Count; var res = new TResult[n]; @@ -321,7 +321,7 @@ public ValueTask> ToListAsync(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - var n = _source.Count; + int n = _source.Count; var res = new List(n); @@ -526,7 +526,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -591,7 +591,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -660,9 +660,9 @@ async ValueTask Core() { cancellationToken.ThrowIfCancellationRequested(); - var count = 0; + int count = 0; - foreach (var item in _source) + foreach (TSource item in _source) { await _selector(item).ConfigureAwait(false); @@ -685,7 +685,7 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok { cancellationToken.ThrowIfCancellationRequested(); - var n = _source.Count; + int n = _source.Count; var res = new TResult[n]; @@ -701,7 +701,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { cancellationToken.ThrowIfCancellationRequested(); - var n = _source.Count; + int n = _source.Count; var res = new List(n); @@ -782,9 +782,9 @@ async ValueTask Core() { cancellationToken.ThrowIfCancellationRequested(); - var count = 0; + int count = 0; - foreach (var item in _source) + foreach (TSource item in _source) { await _selector(item, cancellationToken).ConfigureAwait(false); @@ -807,7 +807,7 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok { cancellationToken.ThrowIfCancellationRequested(); - var n = _source.Count; + int n = _source.Count; var res = new TResult[n]; @@ -823,7 +823,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { cancellationToken.ThrowIfCancellationRequested(); - var n = _source.Count; + int n = _source.Count; var res = new List(n); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index d7d14031f1..62b1b03b4a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -215,7 +215,7 @@ protected override async ValueTask MoveNextCore() await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - var inner = _selector(_sourceEnumerator.Current); + IAsyncEnumerable inner = _selector(_sourceEnumerator.Current); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -306,7 +306,7 @@ protected override async ValueTask MoveNextCore() await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - var inner = await _selector(_sourceEnumerator.Current).ConfigureAwait(false); + IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -398,7 +398,7 @@ protected override async ValueTask MoveNextCore() await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - var inner = await _selector(_sourceEnumerator.Current, _cancellationToken).ConfigureAwait(false); + IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -497,7 +497,7 @@ protected override async ValueTask MoveNextCore() } _currentSource = _sourceEnumerator.Current; - var inner = _collectionSelector(_currentSource); + IAsyncEnumerable inner = _collectionSelector(_currentSource); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -595,7 +595,7 @@ protected override async ValueTask MoveNextCore() } _currentSource = _sourceEnumerator.Current; - var inner = await _collectionSelector(_currentSource).ConfigureAwait(false); + IAsyncEnumerable inner = await _collectionSelector(_currentSource).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -694,7 +694,7 @@ protected override async ValueTask MoveNextCore() } _currentSource = _sourceEnumerator.Current; - var inner = await _collectionSelector(_currentSource, _cancellationToken).ConfigureAwait(false); + IAsyncEnumerable inner = await _collectionSelector(_currentSource, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -801,7 +801,7 @@ protected override async ValueTask MoveNextCore() _index++; } - var inner = _collectionSelector(_currentSource, _index); + IAsyncEnumerable inner = _collectionSelector(_currentSource, _index); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -907,7 +907,7 @@ protected override async ValueTask MoveNextCore() _index++; } - var inner = await _collectionSelector(_currentSource, _index).ConfigureAwait(false); + IAsyncEnumerable inner = await _collectionSelector(_currentSource, _index).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1014,7 +1014,7 @@ protected override async ValueTask MoveNextCore() _index++; } - var inner = await _collectionSelector(_currentSource, _index, _cancellationToken).ConfigureAwait(false); + IAsyncEnumerable inner = await _collectionSelector(_currentSource, _index, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1113,7 +1113,7 @@ protected override async ValueTask MoveNextCore() _index++; } - var inner = _selector(_sourceEnumerator.Current, _index); + IAsyncEnumerable inner = _selector(_sourceEnumerator.Current, _index); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1211,7 +1211,7 @@ protected override async ValueTask MoveNextCore() _index++; } - var inner = await _selector(_sourceEnumerator.Current, _index).ConfigureAwait(false); + IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current, _index).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1310,7 +1310,7 @@ protected override async ValueTask MoveNextCore() _index++; } - var inner = await _selector(_sourceEnumerator.Current, _index, _cancellationToken).ConfigureAwait(false); + IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current, _index, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 1a41182ed2..db27e09014 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -66,11 +66,11 @@ private static Task SequenceEqualCore(IAsyncEnumerable f async Task Core() { - var e1 = first.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e1 = first.GetAsyncEnumerator(cancellationToken); try { - var e2 = second.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e2 = second.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 3140d3a6a4..be23fdbcc9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -91,7 +91,7 @@ private static async Task SingleCore(IAsyncEnumerable throw Error.MoreThanOneElement(); } - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -100,7 +100,7 @@ private static async Task SingleCore(IAsyncEnumerable throw Error.NoElements(); } - var result = e.Current; + TSource result = e.Current; if (await e.MoveNextAsync().ConfigureAwait(false)) { throw Error.MoreThanOneElement(); @@ -116,13 +116,13 @@ private static async Task SingleCore(IAsyncEnumerable private static async Task SingleCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var result = e.Current; + TSource result = e.Current; if (predicate(result)) { @@ -148,13 +148,13 @@ private static async Task SingleCore(IAsyncEnumerable private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var result = e.Current; + TSource result = e.Current; if (await predicate(result).ConfigureAwait(false)) { @@ -181,13 +181,13 @@ private static async Task SingleCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var result = e.Current; + TSource result = e.Current; if (await predicate(result, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs index 0b0cc56592..a8b1673066 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs @@ -58,7 +58,7 @@ private SingleLinkedNode(SingleLinkedNode linked, TSource item) public int GetCount() { var count = 0; - for (var node = this; node != null; node = node.Linked) + for (SingleLinkedNode node = this; node != null; node = node.Linked) { count++; } @@ -86,7 +86,7 @@ public SingleLinkedNode GetNode(int index) { Debug.Assert(index >= 0 && index < GetCount()); - var node = this; + SingleLinkedNode node = this; for (; index > 0; index--) { node = node.Linked; @@ -105,8 +105,8 @@ private TSource[] ToArray(int count) Debug.Assert(count == GetCount()); var array = new TSource[count]; - var index = count; - for (var node = this; node != null; node = node.Linked) + int index = count; + for (SingleLinkedNode node = this; node != null; node = node.Linked) { --index; array[index] = node.Item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index de507c35f6..dd07de88d1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -91,7 +91,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable throw Error.MoreThanOneElement(); } - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -100,7 +100,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable return default; } - var result = e.Current; + TSource result = e.Current; if (!await e.MoveNextAsync().ConfigureAwait(false)) { @@ -117,13 +117,13 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var result = e.Current; + TSource result = e.Current; if (predicate(result)) { @@ -149,13 +149,13 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var result = e.Current; + TSource result = e.Current; if (await predicate(result).ConfigureAwait(false)) { @@ -182,13 +182,13 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var result = e.Current; + TSource result = e.Current; if (await predicate(result, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index fd6daac5be..9de96c9467 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -81,7 +81,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; _queue.Enqueue(item); if (_queue.Count > _count) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 51d2eeb081..af4197f7c2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -118,7 +118,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = _enumerator.Current; + TSource element = _enumerator.Current; if (!_predicate(element)) { _doMoveNext = false; @@ -196,7 +196,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = _enumerator.Current; + TSource element = _enumerator.Current; checked { @@ -278,7 +278,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = _enumerator.Current; + TSource element = _enumerator.Current; if (!await _predicate(element).ConfigureAwait(false)) { _doMoveNext = false; @@ -355,7 +355,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = _enumerator.Current; + TSource element = _enumerator.Current; if (!await _predicate(element, _cancellationToken).ConfigureAwait(false)) { _doMoveNext = false; @@ -434,7 +434,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = _enumerator.Current; + TSource element = _enumerator.Current; checked { @@ -519,7 +519,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = _enumerator.Current; + TSource element = _enumerator.Current; checked { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 22eb5968c5..966acfbce1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -80,9 +80,9 @@ public static Task SumAsync(this IAsyncEnumerable source, private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -104,15 +104,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cancellatio private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + int value = selector(e.Current); checked { @@ -130,15 +130,15 @@ private static async Task SumCore(IAsyncEnumerable source private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + int value = await selector(e.Current).ConfigureAwait(false); checked { @@ -157,15 +157,15 @@ private static async Task SumCore(IAsyncEnumerable source #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -252,9 +252,9 @@ public static Task SumAsync(this IAsyncEnumerable source private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -276,15 +276,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cancellat private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + long value = selector(e.Current); checked { @@ -302,15 +302,15 @@ private static async Task SumCore(IAsyncEnumerable sourc private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + long value = await selector(e.Current).ConfigureAwait(false); checked { @@ -329,15 +329,15 @@ private static async Task SumCore(IAsyncEnumerable sourc #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -424,9 +424,9 @@ public static Task SumAsync(this IAsyncEnumerable sourc private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -445,15 +445,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cancell private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + float value = selector(e.Current); sum += value; } @@ -468,15 +468,15 @@ private static async Task SumCore(IAsyncEnumerable sour private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + float value = await selector(e.Current).ConfigureAwait(false); sum += value; } @@ -492,15 +492,15 @@ private static async Task SumCore(IAsyncEnumerable sour #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value; } @@ -584,9 +584,9 @@ public static Task SumAsync(this IAsyncEnumerable sour private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -605,15 +605,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cance private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + double value = selector(e.Current); sum += value; } @@ -628,15 +628,15 @@ private static async Task SumCore(IAsyncEnumerable sou private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + double value = await selector(e.Current).ConfigureAwait(false); sum += value; } @@ -652,15 +652,15 @@ private static async Task SumCore(IAsyncEnumerable sou #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value; } @@ -744,9 +744,9 @@ public static Task SumAsync(this IAsyncEnumerable sou private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -765,15 +765,15 @@ private static async Task SumCore(IAsyncEnumerable source, Can private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + decimal value = selector(e.Current); sum += value; } @@ -788,15 +788,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + decimal value = await selector(e.Current).ConfigureAwait(false); sum += value; } @@ -812,15 +812,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + decimal value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value; } @@ -904,9 +904,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -928,15 +928,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + int? value = selector(e.Current); checked { @@ -954,15 +954,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + int? value = await selector(e.Current).ConfigureAwait(false); checked { @@ -981,15 +981,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0; + int sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + int? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -1076,9 +1076,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1100,15 +1100,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + long? value = selector(e.Current); checked { @@ -1126,15 +1126,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + long? value = await selector(e.Current).ConfigureAwait(false); checked { @@ -1153,15 +1153,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0L; + long sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + long? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -1248,9 +1248,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1269,15 +1269,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + float? value = selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1292,15 +1292,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + float? value = await selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1316,15 +1316,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0f; + float sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + float? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1408,9 +1408,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1429,15 +1429,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + double? value = selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1452,15 +1452,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + double? value = await selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1476,15 +1476,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0.0; + double sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + double? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1568,9 +1568,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1589,15 +1589,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + decimal? value = selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1612,15 +1612,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + decimal? value = await selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1636,15 +1636,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = 0m; + decimal sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + decimal? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 70af0128bb..f3d64f4fc4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -34,6 +34,7 @@ var os = new[] foreach (var o in os) { var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; + var nonNullType = o.type.EndsWith("?") ? o.type.TrimEnd('?') : o.type; #> public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source) { @@ -105,9 +106,9 @@ foreach (var o in os) private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { - var sum = <#=o.zero#>; + <#=nonNullType#> sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator<<#=o.type#>> e = source.GetAsyncEnumerator(cancellationToken); try { @@ -142,15 +143,15 @@ else private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - var sum = <#=o.zero#>; + <#=nonNullType#> sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + <#=o.type#> value = selector(e.Current); <# if (o.@checked) @@ -181,15 +182,15 @@ else private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { - var sum = <#=o.zero#>; + <#=nonNullType#> sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + <#=o.type#> value = await selector(e.Current).ConfigureAwait(false); <# if (o.@checked) @@ -221,15 +222,15 @@ else #if !NO_DEEP_CANCELLATION private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { - var sum = <#=o.zero#>; + <#=nonNullType#> sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + <#=o.type#> value = await selector(e.Current, cancellationToken).ConfigureAwait(false); <# if (o.@checked) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 794e51af8a..5750b84658 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -80,7 +80,7 @@ protected override async ValueTask MoveNextCore() { if (_count > 0) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (_queue.Count >= _count) { _queue.Dequeue(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 6e2c81005e..e51331437d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -120,7 +120,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (!_predicate(item)) { break; @@ -184,7 +184,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -253,7 +253,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (!await _predicate(item).ConfigureAwait(false)) { break; @@ -318,7 +318,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (!await _predicate(item, _cancellationToken).ConfigureAwait(false)) { break; @@ -383,7 +383,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -454,7 +454,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs index 6c434cbfb3..f5b6ba763e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs @@ -76,7 +76,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (true) { - var completed = Volatile.Read(ref _completed); + bool completed = Volatile.Read(ref _completed); if (_values.TryDequeue(out _current)) { @@ -84,7 +84,7 @@ protected override async ValueTask MoveNextCore() } else if (completed) { - var error = _error; + Exception error = _error; if (error != null) { @@ -131,7 +131,7 @@ private void OnNotification() { while (true) { - var signal = Volatile.Read(ref _signal); + TaskCompletionSource signal = Volatile.Read(ref _signal); if (signal == TaskExt.True) { @@ -170,7 +170,7 @@ private Task Resume() while (true) { - var signal = Volatile.Read(ref _signal); + TaskCompletionSource signal = Volatile.Read(ref _signal); if (signal != null) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 822161b94e..57d6513fdb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -240,7 +240,7 @@ public static Task> ToDictionaryAsync> ToDictionaryCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -248,10 +248,10 @@ private static async Task> ToDictionaryCore> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -274,10 +274,10 @@ private static async Task> ToDictionaryCore> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { @@ -301,10 +301,10 @@ private static async Task> ToDictionaryCore ToEnumerable(this IAsyncEnumerable Core() { - var e = source.GetAsyncEnumerator(default); + IAsyncEnumerator e = source.GetAsyncEnumerator(default); try { @@ -46,7 +46,7 @@ IEnumerable Core() private static void Wait(ValueTask task) { - var awaiter = task.GetAwaiter(); + Runtime.CompilerServices.ValueTaskAwaiter awaiter = task.GetAwaiter(); if (!awaiter.IsCompleted) { @@ -59,7 +59,7 @@ private static void Wait(ValueTask task) private static T Wait(ValueTask task) { - var awaiter = task.GetAwaiter(); + Runtime.CompilerServices.ValueTaskAwaiter awaiter = task.GetAwaiter(); if (!awaiter.IsCompleted) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 607aff12ae..d83e8722a0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -44,7 +44,7 @@ public static Task> ToHashSetAsync(this IAsyncEnumerab private static async Task> ToHashSetCore(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 85e9ded3ae..a7f4530ce4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -35,7 +35,7 @@ private static Task> ToListCore(IAsyncEnumerable async Task> Core() { - var e = source.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index f2e74d95bd..264130b0ab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -28,7 +28,7 @@ public ToObservableObservable(IAsyncEnumerable source) public IDisposable Subscribe(IObserver observer) { var ctd = new CancellationTokenDisposable(); - var e = _source.GetAsyncEnumerator(ctd.Token); + IAsyncEnumerator e = _source.GetAsyncEnumerator(ctd.Token); async void Core() { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index aa3cb5cfba..11f136aa97 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -86,7 +86,7 @@ private async Task SetEnumeratorAsync(IAsyncEnumerator enumerator) private void StoreFirst() { var set = new Set(_comparer); - var element = _enumerator.Current; + TSource element = _enumerator.Current; set.Add(element); _current = element; _set = set; @@ -94,12 +94,12 @@ private void StoreFirst() private async ValueTask GetNextAsync() { - var set = _set; + Set set = _set; Debug.Assert(set != null); while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var element = _enumerator.Current; + TSource element = _enumerator.Current; if (set.Add(element)) { _current = element; @@ -117,11 +117,11 @@ protected sealed override async ValueTask MoveNextCore() case AsyncIteratorState.Allocated: _index = 0; - for (var enumerable = GetEnumerable(0); enumerable != null; enumerable = GetEnumerable(_index)) + for (IAsyncEnumerable enumerable = GetEnumerable(0); enumerable != null; enumerable = GetEnumerable(_index)) { ++_index; - var enumerator = enumerable.GetAsyncEnumerator(_cancellationToken); + IAsyncEnumerator enumerator = enumerable.GetAsyncEnumerator(_cancellationToken); if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -143,7 +143,7 @@ protected sealed override async ValueTask MoveNextCore() return true; } - var enumerable = GetEnumerable(_index); + IAsyncEnumerable enumerable = GetEnumerable(_index); if (enumerable == null) { break; @@ -168,13 +168,13 @@ private async Task> FillSetAsync(CancellationToken cancellationToke for (var index = 0; ; ++index) { - var enumerable = GetEnumerable(index); + IAsyncEnumerable enumerable = GetEnumerable(index); if (enumerable == null) { return set; } - var e = enumerable.GetAsyncEnumerator(cancellationToken); + IAsyncEnumerator e = enumerable.GetAsyncEnumerator(cancellationToken); try { @@ -192,13 +192,13 @@ private async Task> FillSetAsync(CancellationToken cancellationToke public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + Set set = await FillSetAsync(cancellationToken).ConfigureAwait(false); return set.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + Set set = await FillSetAsync(cancellationToken).ConfigureAwait(false); return set.ToList(); } @@ -213,7 +213,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + Set set = await FillSetAsync(cancellationToken).ConfigureAwait(false); return set.Count; } } @@ -255,7 +255,7 @@ internal override IAsyncEnumerable GetEnumerable(int index) internal override UnionAsyncIterator Union(IAsyncEnumerable next) { - var sources = new SingleLinkedNode>(_first).Add(_second).Add(next); + SingleLinkedNode> sources = new SingleLinkedNode>(_first).Add(_second).Add(next); return new UnionAsyncIteratorN(sources, 2, _comparer); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 3d5af66827..264023b924 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -163,7 +163,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (_predicate(item)) { _current = item; @@ -225,7 +225,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -295,7 +295,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (await _predicate(item).ConfigureAwait(false)) { _current = item; @@ -360,7 +360,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) { _current = item; @@ -423,7 +423,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -492,7 +492,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; checked { @@ -567,7 +567,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - var item = _enumerator.Current; + TSource item = _enumerator.Current; if (_predicate(item)) { _current = _selector(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index aa3286f005..b2037b9f0e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -35,8 +35,9 @@ public bool Add(TElement value) #if DEBUG Debug.Assert(!_haveRemoved, "This class is optimized for never calling Add after Remove. If your changes need to do so, undo that optimization."); #endif - var hashCode = InternalGetHashCode(value); - for (var i = _buckets[hashCode % _buckets.Length] - 1; i >= 0; i = _slots[i]._next) + int hashCode = InternalGetHashCode(value); + + for (int i = _buckets[hashCode % _buckets.Length] - 1; i >= 0; i = _slots[i]._next) { if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) { @@ -49,13 +50,15 @@ public bool Add(TElement value) Resize(); } - var index = Count; + int index = Count; Count++; - var bucket = hashCode % _buckets.Length; + + int bucket = hashCode % _buckets.Length; _slots[index]._hashCode = hashCode; _slots[index]._value = value; _slots[index]._next = _buckets[bucket] - 1; _buckets[bucket] = index + 1; + return true; } @@ -65,10 +68,11 @@ public bool Remove(TElement value) #if DEBUG _haveRemoved = true; #endif - var hashCode = InternalGetHashCode(value); - var bucket = hashCode % _buckets.Length; - var last = -1; - for (var i = _buckets[bucket] - 1; i >= 0; last = i, i = _slots[i]._next) + int hashCode = InternalGetHashCode(value); + int bucket = hashCode % _buckets.Length; + int last = -1; + + for (int i = _buckets[bucket] - 1; i >= 0; last = i, i = _slots[i]._next) { if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) { @@ -84,6 +88,7 @@ public bool Remove(TElement value) _slots[i]._hashCode = -1; _slots[i]._value = default; _slots[i]._next = -1; + return true; } } @@ -103,6 +108,7 @@ internal TElement[] ToArray() Debug.Assert(!_haveRemoved, "Optimized ToArray cannot be called if Remove has been called."); #endif var array = new TElement[Count]; + for (var i = 0; i != array.Length; ++i) { array[i] = _slots[i]._value; @@ -116,8 +122,9 @@ internal List ToList() #if DEBUG Debug.Assert(!_haveRemoved, "Optimized ToList cannot be called if Remove has been called."); #endif - var count = Count; + int count = Count; var list = new List(count); + for (var i = 0; i != count; ++i) { list.Add(_slots[i]._value); @@ -128,13 +135,16 @@ internal List ToList() private void Resize() { - var newSize = checked((Count * 2) + 1); + int newSize = checked((Count * 2) + 1); var newBuckets = new int[newSize]; var newSlots = new Slot[newSize]; + Array.Copy(_slots, 0, newSlots, 0, Count); + for (var i = 0; i < Count; i++) { - var bucket = newSlots[i]._hashCode % newSize; + int bucket = newSlots[i]._hashCode % newSize; + newSlots[i]._next = newBuckets[bucket] - 1; newBuckets[bucket] = i + 1; } From 48017129aaf5967aba52b3ab1ec1a6c5ec481c8c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 14:25:15 -0800 Subject: [PATCH 589/862] Add missing null check to StartWith. --- .../System.Interactive.Async/System/Linq/Operators/StartWith.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs index 9b7786b4a2..87818ac81f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs @@ -12,6 +12,8 @@ public static IAsyncEnumerable StartWith(this IAsyncEnumerable { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (values == null) + throw Error.ArgumentNull(nameof(values)); return values.ToAsyncEnumerable().Concat(source); } From cd755fd11331c1cd5fd99569b8435081d75b4c36 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 14:33:27 -0800 Subject: [PATCH 590/862] Some minor cosmetics. --- .../System/Linq/Operators/Amb.cs | 1 - .../System/Linq/Operators/Buffer.cs | 1 + .../System/Linq/Operators/Catch.cs | 6 +++--- .../System/Linq/Operators/Distinct.cs | 9 +++++++++ .../System/Linq/Operators/DistinctUntilChanged.cs | 3 +++ .../System/Linq/Operators/Merge.cs | 1 - .../System/Linq/Operators/MinBy.cs | 3 +++ .../System/Linq/Operators/Never.cs | 10 ++-------- .../System/Linq/Operators/Repeat.cs | 5 +---- .../System/Linq/Operators/Return.cs | 15 +++------------ .../System/Linq/Operators/Scan.cs | 3 +++ 11 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 4b8b510ddc..2ec0088f5b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index cb4dd5babb..96b8d740a2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -92,6 +92,7 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { TSource item = _enumerator.Current; + if (_index++ % _skip == 0) { _buffers.Enqueue(new List(_count)); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 6e82244bc7..4608447723 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -137,7 +137,7 @@ protected override async ValueTask MoveNextCore() } catch (TException ex) { - // Note: Ideally we'd dipose of the previous enumerator before + // Note: Ideally we'd dispose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior IAsyncEnumerable inner = _handler(ex); @@ -230,7 +230,7 @@ protected override async ValueTask MoveNextCore() } catch (TException ex) { - // Note: Ideally we'd dipose of the previous enumerator before + // Note: Ideally we'd dispose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior IAsyncEnumerable inner = await _handler(ex).ConfigureAwait(false); @@ -324,7 +324,7 @@ protected override async ValueTask MoveNextCore() } catch (TException ex) { - // Note: Ideally we'd dipose of the previous enumerator before + // Note: Ideally we'd dispose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior IAsyncEnumerable inner = await _handler(ex, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index aa0e40181d..9e1056c556 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -140,6 +140,7 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca while (await enu.MoveNextAsync().ConfigureAwait(false)) { TSource item = enu.Current; + if (s.Add(_keySelector(item))) { count++; @@ -196,6 +197,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { element = _enumerator.Current; + if (_set.Add(_keySelector(element))) { _current = element; @@ -222,6 +224,7 @@ private async Task> FillSetAsync(CancellationToken cancellationTok while (await enu.MoveNextAsync().ConfigureAwait(false)) { TSource item = enu.Current; + if (s.Add(_keySelector(item))) { r.Add(item); @@ -285,6 +288,7 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca while (await enu.MoveNextAsync().ConfigureAwait(false)) { TSource item = enu.Current; + if (s.Add(await _keySelector(item).ConfigureAwait(false))) { count++; @@ -341,6 +345,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { element = _enumerator.Current; + if (_set.Add(await _keySelector(element).ConfigureAwait(false))) { _current = element; @@ -367,6 +372,7 @@ private async ValueTask> FillSetAsync(CancellationToken cancellati while (await enu.MoveNextAsync().ConfigureAwait(false)) { TSource item = enu.Current; + if (s.Add(await _keySelector(item).ConfigureAwait(false))) { r.Add(item); @@ -431,6 +437,7 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca while (await enu.MoveNextAsync().ConfigureAwait(false)) { TSource item = enu.Current; + if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) { count++; @@ -487,6 +494,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { element = _enumerator.Current; + if (_set.Add(await _keySelector(element, _cancellationToken).ConfigureAwait(false))) { _current = element; @@ -513,6 +521,7 @@ private async ValueTask> FillSetAsync(CancellationToken cancellati while (await enu.MoveNextAsync().ConfigureAwait(false)) { TSource item = enu.Current; + if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) { r.Add(item); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 5325f0bac7..98f020c2cf 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -238,6 +238,7 @@ protected override async ValueTask MoveNextCore() { comparerEquals = _comparer.Equals(_currentKeyValue, key); } + if (!_hasCurrentKey || !comparerEquals) { _hasCurrentKey = true; @@ -309,6 +310,7 @@ protected override async ValueTask MoveNextCore() { comparerEquals = _comparer.Equals(_currentKeyValue, key); } + if (!_hasCurrentKey || !comparerEquals) { _hasCurrentKey = true; @@ -381,6 +383,7 @@ protected override async ValueTask MoveNextCore() { comparerEquals = _comparer.Equals(_currentKeyValue, key); } + if (!_hasCurrentKey || !comparerEquals) { _hasCurrentKey = true; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index bbe20745ce..20551cd6fb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index d010d41ec9..6e0416d3e6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -167,6 +167,7 @@ private static async Task> ExtremaBy(IAsyncEnumera TKey key = keySelector(cur); int cmp = compare(key, resKey); + if (cmp == 0) { result.Add(cur); @@ -207,6 +208,7 @@ private static async Task> ExtremaBy(IAsyncEnumera TKey key = await keySelector(cur).ConfigureAwait(false); int cmp = compare(key, resKey); + if (cmp == 0) { result.Add(cur); @@ -248,6 +250,7 @@ private static async Task> ExtremaBy(IAsyncEnumera TKey key = await keySelector(cur, cancellationToken).ConfigureAwait(false); int cmp = compare(key, resKey); + if (cmp == 0) { result.Add(cur); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs index c72758369e..c20d01d014 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs @@ -10,10 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static IAsyncEnumerable Never() - { - return NeverAsyncEnumerable.Instance; - } + public static IAsyncEnumerable Never() => NeverAsyncEnumerable.Instance; private sealed class NeverAsyncEnumerable : IAsyncEnumerable { @@ -34,10 +31,7 @@ private sealed class NeverAsyncEnumerator : IAsyncEnumerator private bool _once; private TaskCompletionSource _task; - public NeverAsyncEnumerator(CancellationToken token) - { - _token = token; - } + public NeverAsyncEnumerator(CancellationToken token) => _token = token; public TValue Current => throw new InvalidOperationException(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index 0ab6e03f62..0f581e68be 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -38,10 +38,7 @@ private sealed class RepeatElementAsyncIterator : AsyncIterator _element = element; public override AsyncIteratorBase Clone() { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs index 5e4e76b6af..2c5e864fe3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Return.cs @@ -10,10 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static IAsyncEnumerable Return(TValue value) - { - return new ReturnEnumerable(value); - } + public static IAsyncEnumerable Return(TValue value) => new ReturnEnumerable(value); // REVIEW: Add support for IAsyncPartition. @@ -21,10 +18,7 @@ private sealed class ReturnEnumerable : IAsyncEnumerable, IAsync { private readonly TValue _value; - public ReturnEnumerable(TValue value) - { - _value = value; - } + public ReturnEnumerable(TValue value) => _value = value; public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) { @@ -43,10 +37,7 @@ private sealed class ReturnEnumerator : IAsyncEnumerator { private bool _once; - public ReturnEnumerator(TValue current) - { - Current = current; - } + public ReturnEnumerator(TValue current) => Current = current; public TValue Current { get; private set; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 2b2ba46767..2068402fe1 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -128,6 +128,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { TSource item = _enumerator.Current; + if (!_hasSeed) { _hasSeed = true; @@ -266,6 +267,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { TSource item = _enumerator.Current; + if (!_hasSeed) { _hasSeed = true; @@ -341,6 +343,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { TSource item = _enumerator.Current; + if (!_hasSeed) { _hasSeed = true; From 37d283ac3a4e408fb36765e8905aba95be617fe2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 15:07:31 -0800 Subject: [PATCH 591/862] Check for ICollection to short-circuit. --- .../System.Linq.Async/System/Linq/Operators/AppendPrepend.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index fd96138164..2c16bd91e7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -274,7 +274,7 @@ public override async ValueTask GetCountAsync(bool onlyIfCheap, Cancellatio return count == -1 ? -1 : count + 1; } - return !onlyIfCheap || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + 1 : -1; + return !onlyIfCheap || _source is ICollection || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + 1 : -1; } } @@ -489,7 +489,7 @@ public override async ValueTask GetCountAsync(bool onlyIfCheap, Cancellatio return count == -1 ? -1 : count + _appendCount + _prependCount; } - return !onlyIfCheap || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1; + return !onlyIfCheap || _source is ICollection || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) + _appendCount + _prependCount : -1; } } } From 2c1fdfb73203db87924377ad870dbe5256d139c1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 15:09:30 -0800 Subject: [PATCH 592/862] Add list optimization to SequenceEqual. --- .../System/Linq/Operators/SequenceEqual.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index db27e09014..89d6b4fbcc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -52,14 +52,32 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable SequenceEqualCore(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) { - if (first is ICollection firstCol && second is ICollection secondCol && firstCol.Count != secondCol.Count) + if (comparer == null) { - return Task.FromResult(false); + comparer = EqualityComparer.Default; } - if (comparer == null) + if (first is ICollection firstCol && second is ICollection secondCol) { - comparer = EqualityComparer.Default; + if (firstCol.Count != secondCol.Count) + { + return Task.FromResult(false); + } + + if (firstCol is IList firstList && secondCol is IList secondList) + { + int count = firstCol.Count; + + for (int i = 0; i < count; i++) + { + if (!comparer.Equals(firstList[i], secondList[i])) + { + return Task.FromResult(false); + } + } + + return Task.FromResult(true); + } } return Core(); From 2847c8bdacff698a360e470ceba1e6da6b303681 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 15:11:39 -0800 Subject: [PATCH 593/862] Fix namespace. --- .../System.Linq.Async/System/Linq/Operators/AppendPrepend.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 2c16bd91e7..358939d236 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Threading; From 969e2cd193c8c3dde901edd681090dad773e0f35 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 15:48:36 -0800 Subject: [PATCH 594/862] Tweaking SequenceEqual test. --- .../System/Linq/Operators/SequenceEqual.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index af8fd7768a..1014bd2df0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -172,7 +172,15 @@ public async Task SequenceEqual15Async() public async Task SequenceEqual16Async() { var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); - var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); // NB: Implements IList, resulting in optimized code path. + await Assert.ThrowsAsync(() => xs.SequenceEqualAsync(ys, new EqEx())); + } + + [Fact] + public async Task SequenceEqual17Async() + { + var xs = new[] { 1, 2, -3, 4 }.Select(x => x * 2).ToAsyncEnumerable(); + var ys = new[] { 1, -2, 3, 4 }.Select(x => x * 2).ToAsyncEnumerable(); var res = xs.SequenceEqualAsync(ys, new EqEx()); await AssertThrowsAsync(res); } From d904a174faabe4905cab8111321bc4a9fc98df0e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 16:01:16 -0800 Subject: [PATCH 595/862] Adding IAsyncIListProvider support for OrderBy. --- .../System/Linq/Operators/OrderBy.cs | 47 ++++++++++++ .../Linq/Operators/OrderedAsyncEnumerable.cs | 76 ++++++++++++++++++- 2 files changed, 120 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index 5e54413f89..8d65d41f6b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -211,5 +211,52 @@ public void OrderByThenBy4() Assert.True(ress.SequenceEqual(resa.ToEnumerable())); } + + [Fact] + public async Task OrderBy_Optimize_ToArray() + { + foreach (var seed in new[] { 1905, 1948, 1983 }) + { + var rand = GetRandom(seed, 10_000); + var randAsync = rand.ToAsyncEnumerable(); + + var res = rand.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var resAsync = randAsync.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + var lst = res.ToArray(); + var lstAsync = await resAsync.ToArrayAsync(); + + Assert.True(lst.SequenceEqual(lstAsync)); + } + } + + [Fact] + public async Task OrderBy_Optimize_ToList() + { + foreach (var seed in new[] { 1905, 1948, 1983 }) + { + var rand = GetRandom(seed, 10_000); + var randAsync = rand.ToAsyncEnumerable(); + + var res = rand.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var resAsync = randAsync.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + var lst = res.ToList(); + var lstAsync = await resAsync.ToListAsync(); + + Assert.True(lst.SequenceEqual(lstAsync)); + } + } + + private static IEnumerable GetRandom(int seed, int count) + { + var rand = new Random(seed); + + while (count > 0) + { + yield return rand.Next(); + count--; + } + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index ba161a79c5..bef60bc33d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Threading; @@ -11,7 +12,7 @@ namespace System.Linq { // TODO: Add optimizations for First, Last, and ElementAt. - internal abstract class OrderedAsyncEnumerable : AsyncIterator, IOrderedAsyncEnumerable + internal abstract class OrderedAsyncEnumerable : AsyncIterator, IOrderedAsyncEnumerable, IAsyncIListProvider { protected IAsyncEnumerable _source; private TElement[] _buffer; @@ -40,8 +41,6 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Allocated: _buffer = await _source.ToArrayAsync(_cancellationToken).ConfigureAwait(false); - // REVIEW: If we add selectors with CancellationToken support, we should feed the token to Sort. - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(next: null, _cancellationToken); _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); _index = 0; @@ -72,6 +71,77 @@ public override async ValueTask DisposeAsync() } internal abstract AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next, CancellationToken cancellationToken); + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + + int count = elements.Length; + + if (count == 0) + { +#if NO_ARRAY_EMPTY + return EmptyArray.Value; +#else + return Array.Empty(); +#endif + } + + TElement[] array = elements.Array; + + int[] map = await SortedMap(array, count, cancellationToken).ConfigureAwait(false); + + var result = new TElement[count]; + + for (int i = 0; i < result.Length; i++) + { + result[i] = array[map[i]]; + } + + return result; + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + + int count = elements.Length; + + if (count == 0) + { + return new List(capacity: 0); + } + + TElement[] array = elements.Array; + + int[] map = await SortedMap(array, count, cancellationToken).ConfigureAwait(false); + + var result = new List(count); + + for (int i = 0; i < count; i++) + { + result.Add(array[map[i]]); + } + + return result; + } + + public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (_source is IAsyncIListProvider listProv) + { + int count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + } + + return !onlyIfCheap || _source is ICollection || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) : -1; + } + + private ValueTask SortedMap(TElement[] elements, int count, CancellationToken cancellationToken) + { + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(next: null, cancellationToken); + + return sorter.Sort(elements, count); + } } internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnumerable From 8d2882a48f7bdddcbcbdc72f0c24b636ef0be3f1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 16:05:59 -0800 Subject: [PATCH 596/862] Fixing name of TryGetElementAtAsync. --- .../System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs | 2 +- .../Source/System.Linq.Async/System/Linq/AsyncListPartition.cs | 2 +- Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs | 2 +- .../System/Linq/Operators/ElementAtOrDefault.cs | 2 +- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs | 2 +- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 2f11ae8111..7dc059990f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -219,7 +219,7 @@ public IAsyncPartition Take(int count) return new AsyncEnumerablePartition(_source, _minIndexInclusive, maxIndex); } - public async ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) + public async ValueTask> TryGetElementAtAsync(int index, CancellationToken cancellationToken) { // If the index is negative or >= our max count, return early. if (index >= 0 && (!HasLimit || index < Limit)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index 9beb257697..bda836973e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -97,7 +97,7 @@ public IAsyncPartition Take(int count) } } - public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) + public ValueTask> TryGetElementAtAsync(int index, CancellationToken cancellationToken) { if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < _source.Count - _minIndexInclusive) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs index b94e80d9ab..a84366a7a9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/IAsyncPartition.cs @@ -32,7 +32,7 @@ internal interface IAsyncPartition : IAsyncIListProvider /// The 0-based index to access. /// Token to observe for cancellation requests. /// The element if found, otherwise, the default value of . - ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken); + ValueTask> TryGetElementAtAsync(int index, CancellationToken cancellationToken); /// /// Gets the first item in this sequence. diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index d6daceeea8..c326380d80 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -30,7 +30,7 @@ private static async Task ElementAtCore(IAsyncEnumerable p) { - Maybe first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); + Maybe first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index ecb23be764..bd68930792 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -30,7 +30,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera { if (source is IAsyncPartition p) { - Maybe first = await p.TryGetElementAsync(index, cancellationToken).ConfigureAwait(false); + Maybe first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs index 3f8a50a221..1ceb249ee8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Empty.cs @@ -34,7 +34,7 @@ internal sealed class EmptyAsyncIterator : IAsyncPartition, IAsy public ValueTask> ToListAsync(CancellationToken cancellationToken) => new ValueTask>(new List()); - public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) => new ValueTask>(new Maybe()); + public ValueTask> TryGetElementAtAsync(int index, CancellationToken cancellationToken) => new ValueTask>(new Maybe()); public ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) => new ValueTask>(new Maybe()); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index e497433c79..67d19d4813 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -93,7 +93,7 @@ public ValueTask> ToListAsync(CancellationToken cancellationToken) return new ValueTask>(res); } - public ValueTask> TryGetElementAsync(int index, CancellationToken cancellationToken) + public ValueTask> TryGetElementAtAsync(int index, CancellationToken cancellationToken) { if ((uint)index < (uint)(_end - _start)) { From e8f01e5d41bc5dac0a8945702215200711cbef78 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 22:36:37 -0800 Subject: [PATCH 597/862] Making code coverage work for debug builds. --- Ix.NET/Source/Directory.build.props | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index 8082df8e71..73c239ded0 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -20,6 +20,11 @@ true true + + + + full + From 32ab9c89761db61ee84346e93fb93b129ee5a9e0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 22:37:29 -0800 Subject: [PATCH 598/862] Optimizing OrderBy for Skip/Take/etc. --- .../Linq/Operators/OrderedAsyncEnumerable.cs | 930 +++++++++++++++++- 1 file changed, 893 insertions(+), 37 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index bef60bc33d..5d92775d31 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -10,15 +10,23 @@ namespace System.Linq { - // TODO: Add optimizations for First, Last, and ElementAt. - - internal abstract class OrderedAsyncEnumerable : AsyncIterator, IOrderedAsyncEnumerable, IAsyncIListProvider + // NB: Large portions of the implementation are based on https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/OrderedEnumerable.cs. + + internal abstract class OrderedAsyncEnumerable : AsyncIterator, IOrderedAsyncEnumerable, IAsyncPartition { - protected IAsyncEnumerable _source; + protected readonly IAsyncEnumerable _source; + private TElement[] _buffer; private int[] _indexes; private int _index; + protected OrderedAsyncEnumerable(IAsyncEnumerable source) + { + Debug.Assert(source != null); + + _source = source; + } + IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending) { return new OrderedAsyncEnumerable(_source, keySelector, comparer, descending, this); @@ -39,9 +47,9 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - _buffer = await _source.ToArrayAsync(_cancellationToken).ConfigureAwait(false); + _buffer = await _source.ToArrayAsync(_cancellationToken).ConfigureAwait(false); // TODO: Use buffer. - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(next: null, _cancellationToken); + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(_cancellationToken); _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); _index = 0; @@ -72,6 +80,8 @@ public override async ValueTask DisposeAsync() internal abstract AsyncEnumerableSorter GetAsyncEnumerableSorter(AsyncEnumerableSorter next, CancellationToken cancellationToken); + internal AsyncEnumerableSorter GetAsyncEnumerableSorter(CancellationToken cancellationToken) => GetAsyncEnumerableSorter(next: null, cancellationToken); + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); @@ -101,6 +111,49 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTo return result; } + internal async ValueTask ToArrayAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) + { + AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + + int count = elements.Length; + + if (count <= minIndexInclusive) + { +#if NO_ARRAY_EMPTY + return EmptyArray.Value; +#else + return Array.Empty(); +#endif + } + + if (count <= maxIndexInclusive) + { + maxIndexInclusive = count - 1; + } + + TElement[] array = elements.Array; + + if (minIndexInclusive == maxIndexInclusive) + { + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + + TElement element = await sorter.ElementAt(array, count, minIndexInclusive).ConfigureAwait(false); + + return new TElement[] { element }; + } + + int[] map = await SortedMap(array, count, minIndexInclusive, maxIndexInclusive, cancellationToken).ConfigureAwait(false); + + var result = new TElement[maxIndexInclusive - minIndexInclusive + 1]; + + for (int i = 0; minIndexInclusive <= maxIndexInclusive; i++) + { + result[i] = array[map[minIndexInclusive++]]; + } + + return result; + } + public async ValueTask> ToListAsync(CancellationToken cancellationToken) { AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); @@ -126,6 +179,45 @@ public async ValueTask> ToListAsync(CancellationToken cancellatio return result; } + internal async ValueTask> ToListAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) + { + AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + + int count = elements.Length; + + if (count <= minIndexInclusive) + { + return new List(0); + } + + if (count <= maxIndexInclusive) + { + maxIndexInclusive = count - 1; + } + + TElement[] array = elements.Array; + + if (minIndexInclusive == maxIndexInclusive) + { + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + + TElement element = await sorter.ElementAt(array, count, minIndexInclusive).ConfigureAwait(false); + + return new List(1) { element }; + } + + int[] map = await SortedMap(array, count, minIndexInclusive, maxIndexInclusive, cancellationToken).ConfigureAwait(false); + + var list = new List(maxIndexInclusive - minIndexInclusive + 1); + + while (minIndexInclusive <= maxIndexInclusive) + { + list.Add(array[map[minIndexInclusive++]]); + } + + return list; + } + public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) { if (_source is IAsyncIListProvider listProv) @@ -136,12 +228,197 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca return !onlyIfCheap || _source is ICollection || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) : -1; } + internal async ValueTask GetCountAsync(int minIndexInclusive, int maxIndexInclusive, bool onlyIfCheap, CancellationToken cancellationToken) + { + int count = await GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + + if (count <= 0) + { + return count; + } + + if (count <= minIndexInclusive) + { + return 0; + } + + return (count <= maxIndexInclusive ? count : maxIndexInclusive + 1) - minIndexInclusive; + } + private ValueTask SortedMap(TElement[] elements, int count, CancellationToken cancellationToken) { - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(next: null, cancellationToken); + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); return sorter.Sort(elements, count); } + + private ValueTask SortedMap(TElement[] elements, int count, int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) + { + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + + return sorter.Sort(elements, count, minIndexInclusive, maxIndexInclusive); + } + + private AsyncCachingComparer GetComparer() => GetComparer(childComparer: null); + + internal abstract AsyncCachingComparer GetComparer(AsyncCachingComparer childComparer); + + public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) + { + IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return new Maybe(); + } + + TElement value = e.Current; + + AsyncCachingComparer comparer = GetComparer(); + + await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + TElement x = e.Current; + + if (await comparer.Compare(x, cacheLower: true, cancellationToken).ConfigureAwait(false) < 0) + { + value = x; + } + } + + return new Maybe(value); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) + { + IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return new Maybe(); + } + + TElement value = e.Current; + + AsyncCachingComparer comparer = GetComparer(); + + await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + TElement current = e.Current; + + if (await comparer.Compare(current, cacheLower: false, cancellationToken).ConfigureAwait(false) >= 0) + { + value = current; + } + } + + return new Maybe(value); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } + + internal async ValueTask> TryGetLastAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) + { + AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + + int count = elements.Length; + + if (minIndexInclusive >= count) + { + return new Maybe(); + } + + TElement[] array = elements.Array; + + TElement last; + + if (maxIndexInclusive < count - 1) + { + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + + last = await sorter.ElementAt(array, count, maxIndexInclusive).ConfigureAwait(false); + } + else + { + last = await Last(array, count, cancellationToken).ConfigureAwait(false); + } + + return new Maybe(last); + } + + private async ValueTask Last(TElement[] items, int count, CancellationToken cancellationToken) + { + TElement value = items[0]; + + AsyncCachingComparer comparer = GetComparer(); + + await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); + + for (int i = 1; i != count; ++i) + { + TElement x = items[i]; + + if (await comparer.Compare(x, cacheLower: false, cancellationToken).ConfigureAwait(false) >= 0) + { + value = x; + } + } + + return value; + } + + public IAsyncPartition Skip(int count) => new OrderedAsyncPartition(this, count, int.MaxValue); + + public IAsyncPartition Take(int count) => new OrderedAsyncPartition(this, 0, count - 1); + + public ValueTask> TryGetElementAtAsync(int index, CancellationToken cancellationToken) + { + if (index == 0) + { + return TryGetFirstAsync(cancellationToken); + } + + if (index > 0) + { + return Core(); + + async ValueTask> Core() + { + AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + + int count = elements.Length; + + if (index < count) + { + AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + + TElement element = await sorter.ElementAt(elements.Array, count, index).ConfigureAwait(false); + + return new Maybe(element); + } + + return new Maybe(); + } + } + + return new ValueTask>(new Maybe()); + } } internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnumerable @@ -152,11 +429,10 @@ internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnume private readonly OrderedAsyncEnumerable _parent; public OrderedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) + : base(source) { - Debug.Assert(source != null); Debug.Assert(keySelector != null); - _source = source; _keySelector = keySelector; _comparer = comparer; _descending = descending; @@ -179,6 +455,15 @@ internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(Async return sorter; } + + internal override AsyncCachingComparer GetComparer(AsyncCachingComparer childComparer) + { + AsyncCachingComparer cmp = childComparer == null + ? new AsyncCachingComparer(_keySelector, _comparer, _descending) + : new AsyncCachingComparerWithChild(_keySelector, _comparer, _descending, childComparer); + + return _parent != null ? _parent.GetComparer(cmp) : cmp; + } } internal sealed class OrderedAsyncEnumerableWithTask : OrderedAsyncEnumerable @@ -189,11 +474,10 @@ internal sealed class OrderedAsyncEnumerableWithTask : OrderedAs private readonly OrderedAsyncEnumerable _parent; public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) + : base(source) { - Debug.Assert(source != null); Debug.Assert(keySelector != null); - _source = source; _keySelector = keySelector; _comparer = comparer; _descending = descending; @@ -216,6 +500,15 @@ internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(Async return sorter; } + + internal override AsyncCachingComparer GetComparer(AsyncCachingComparer childComparer) + { + AsyncCachingComparer cmp = childComparer == null + ? new AsyncCachingComparerWithTask(_keySelector, _comparer, _descending) + : new AsyncCachingComparerWithTaskAndChild(_keySelector, _comparer, _descending, childComparer); + + return _parent != null ? _parent.GetComparer(cmp) : cmp; + } } #if !NO_DEEP_CANCELLATION @@ -227,11 +520,10 @@ internal sealed class OrderedAsyncEnumerableWithTaskAndCancellation _parent; public OrderedAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) + : base(source) { - Debug.Assert(source != null); Debug.Assert(keySelector != null); - _source = source; _keySelector = keySelector; _comparer = comparer; _descending = descending; @@ -254,6 +546,15 @@ internal override AsyncEnumerableSorter GetAsyncEnumerableSorter(Async return sorter; } + + internal override AsyncCachingComparer GetComparer(AsyncCachingComparer childComparer) + { + AsyncCachingComparer cmp = childComparer == null + ? new AsyncCachingComparerWithTaskAndCancellation(_keySelector, _comparer, _descending) + : new AsyncCachingComparerWithTaskAndCancellationAndChild(_keySelector, _comparer, _descending, childComparer); + + return _parent != null ? _parent.GetComparer(cmp) : cmp; + } } #endif @@ -261,9 +562,36 @@ internal abstract class AsyncEnumerableSorter { internal abstract ValueTask ComputeKeys(TElement[] elements, int count); - internal abstract int CompareKeys(int index1, int index2); + internal abstract int CompareAnyKeys(int index1, int index2); public async ValueTask Sort(TElement[] elements, int count) + { + int[] map = await ComputeMap(elements, count).ConfigureAwait(false); + + QuickSort(map, 0, count - 1); + + return map; + } + + public async ValueTask Sort(TElement[] elements, int count, int minIndexInclusive, int maxIndexInclusive) + { + int[] map = await ComputeMap(elements, count).ConfigureAwait(false); + + PartialQuickSort(map, 0, count - 1, minIndexInclusive, maxIndexInclusive); + + return map; + } + + public async ValueTask ElementAt(TElement[] elements, int count, int index) + { + int[] map = await ComputeMap(elements, count).ConfigureAwait(false); + + return index == 0 ? + elements[Min(map, count)] : + elements[QuickSelect(map, count - 1, index)]; + } + + private async ValueTask ComputeMap(TElement[] elements, int count) { await ComputeKeys(elements, count).ConfigureAwait(false); @@ -274,18 +602,57 @@ public async ValueTask Sort(TElement[] elements, int count) map[i] = i; } - QuickSort(map, 0, count - 1); - return map; } - private void QuickSort(int[] map, int left, int right) + protected abstract void QuickSort(int[] map, int left, int right); + + protected abstract void PartialQuickSort(int[] map, int left, int right, int minIndexInclusive, int maxIndexInclusive); + + protected abstract int QuickSelect(int[] map, int right, int idx); + + protected abstract int Min(int[] map, int count); + } + + internal abstract class AsyncEnumerableSorterBase : AsyncEnumerableSorter + { + private readonly IComparer _comparer; + private readonly bool _descending; + protected readonly AsyncEnumerableSorter _next; + protected TKey[] _keys; + + public AsyncEnumerableSorterBase(IComparer comparer, bool descending, AsyncEnumerableSorter next) + { + _comparer = comparer ?? Comparer.Default; + _descending = descending; + _next = next; + } + + internal sealed override int CompareAnyKeys(int index1, int index2) + { + int c = _comparer.Compare(_keys[index1], _keys[index2]); + + if (c == 0) + { + return _next == null ? index1 - index2 : _next.CompareAnyKeys(index1, index2); + } + else + { + return (_descending != (c > 0)) ? 1 : -1; + } + } + + private int CompareKeys(int index1, int index2) => index1 == index2 ? 0 : CompareAnyKeys(index1, index2); + + protected override void QuickSort(int[] map, int left, int right) { + // REVIEW: Consider using Array.Sort, see https://github.com/dotnet/corefx/commit/a6aff797a33e606a60ec0c9ca034a161c609620f#diff-d90239bd8284188e2bd210790483f5ca. + do { int i = left; int j = right; - int x = map[i + (j - i >> 1)]; + int x = map[i + ((j - i) >> 1)]; do { @@ -337,34 +704,156 @@ private void QuickSort(int[] map, int left, int right) } while (left < right); } - } - - internal abstract class AsyncEnumerableSorterBase : AsyncEnumerableSorter - { - private readonly IComparer _comparer; - private readonly bool _descending; - protected readonly AsyncEnumerableSorter _next; - protected TKey[] _keys; - public AsyncEnumerableSorterBase(IComparer comparer, bool descending, AsyncEnumerableSorter next) + protected override void PartialQuickSort(int[] map, int left, int right, int minIndexInclusive, int maxIndexInclusive) { - _comparer = comparer ?? Comparer.Default; - _descending = descending; - _next = next; + do + { + int i = left; + int j = right; + int x = map[i + ((j - i) >> 1)]; + do + { + while (i < map.Length && CompareKeys(x, map[i]) > 0) + { + i++; + } + + while (j >= 0 && CompareKeys(x, map[j]) < 0) + { + j--; + } + + if (i > j) + { + break; + } + + if (i < j) + { + int temp = map[i]; + map[i] = map[j]; + map[j] = temp; + } + + i++; + j--; + } + while (i <= j); + + if (minIndexInclusive >= i) + { + left = i + 1; + } + else if (maxIndexInclusive <= j) + { + right = j - 1; + } + + if (j - left <= right - i) + { + if (left < j) + { + PartialQuickSort(map, left, j, minIndexInclusive, maxIndexInclusive); + } + + left = i; + } + else + { + if (i < right) + { + PartialQuickSort(map, i, right, minIndexInclusive, maxIndexInclusive); + } + + right = j; + } + } + while (left < right); } - internal override int CompareKeys(int index1, int index2) + protected override int QuickSelect(int[] map, int right, int idx) { - int c = _comparer.Compare(_keys[index1], _keys[index2]); - - if (c == 0) + int left = 0; + do { - return _next == null ? index1 - index2 : _next.CompareKeys(index1, index2); + int i = left; + int j = right; + int x = map[i + ((j - i) >> 1)]; + + do + { + while (i < map.Length && CompareKeys(x, map[i]) > 0) + { + i++; + } + + while (j >= 0 && CompareKeys(x, map[j]) < 0) + { + j--; + } + + if (i > j) + { + break; + } + + if (i < j) + { + int temp = map[i]; + map[i] = map[j]; + map[j] = temp; + } + + i++; + j--; + } + while (i <= j); + + if (i <= idx) + { + left = i + 1; + } + else + { + right = j - 1; + } + + if (j - left <= right - i) + { + if (left < j) + { + right = j; + } + + left = i; + } + else + { + if (i < right) + { + left = i; + } + + right = j; + } } - else + while (left < right); + + return map[idx]; + } + + protected override int Min(int[] map, int count) + { + int index = 0; + for (int i = 1; i < count; i++) { - return (_descending != (c > 0)) ? 1 : -1; + if (CompareKeys(map[i], map[index]) < 0) + { + index = i; + } } + return map[index]; } } @@ -449,4 +938,371 @@ internal override async ValueTask ComputeKeys(TElement[] elements, int count) } } #endif + + internal sealed class OrderedAsyncPartition : AsyncIterator, IAsyncPartition + { + private readonly OrderedAsyncEnumerable _source; + private readonly int _minIndexInclusive; + private readonly int _maxIndexInclusive; + + public OrderedAsyncPartition(OrderedAsyncEnumerable source, int minIndexInclusive, int maxIndexInclusive) + { + _source = source; + _minIndexInclusive = minIndexInclusive; + _maxIndexInclusive = maxIndexInclusive; + } + + public override AsyncIteratorBase Clone() => new OrderedAsyncPartition(_source, _minIndexInclusive, _maxIndexInclusive); + + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => + _source.GetCountAsync(_minIndexInclusive, _maxIndexInclusive, onlyIfCheap, cancellationToken); + + public IAsyncPartition Skip(int count) + { + int minIndex = unchecked(_minIndexInclusive + count); + + if (unchecked((uint)minIndex > (uint)_maxIndexInclusive)) + { + return AsyncEnumerable.EmptyAsyncIterator.Instance; + } + + return new OrderedAsyncPartition(_source, minIndex, _maxIndexInclusive); + } + + public IAsyncPartition Take(int count) + { + int maxIndex = unchecked(_minIndexInclusive + count - 1); + + if (unchecked((uint)maxIndex >= (uint)_maxIndexInclusive)) + { + return this; + } + + return new OrderedAsyncPartition(_source, _minIndexInclusive, maxIndex); + } + + public ValueTask ToArrayAsync(CancellationToken cancellationToken) => + _source.ToArrayAsync(_minIndexInclusive, _maxIndexInclusive, cancellationToken); + + public ValueTask> ToListAsync(CancellationToken cancellationToken) => + _source.ToListAsync(_minIndexInclusive, _maxIndexInclusive, cancellationToken); + + public ValueTask> TryGetElementAtAsync(int index, CancellationToken cancellationToken) + { + if (unchecked((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive))) + { + return _source.TryGetElementAtAsync(index + _minIndexInclusive, cancellationToken); + } + + return new ValueTask>(new Maybe()); + } + + public ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) => + _source.TryGetElementAtAsync(_minIndexInclusive, cancellationToken); + + public ValueTask> TryGetLastAsync(CancellationToken cancellationToken) => + _source.TryGetLastAsync(_minIndexInclusive, _maxIndexInclusive, cancellationToken); + + // REVIEW: Consider to tear off an iterator object rather than storing this state here? + + private TElement[] _buffer; + private int[] _indexes; + private int _minIndexIterator; + private int _maxIndexIterator; + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _buffer = await _source.ToArrayAsync(_cancellationToken).ConfigureAwait(false); // TODO: Use buffer. + + _minIndexIterator = _minIndexInclusive; + _maxIndexIterator = _maxIndexInclusive; + + int count = _buffer.Length; + + if (count > _minIndexIterator) + { + if (count <= _maxIndexIterator) + { + _maxIndexIterator = count - 1; + } + + AsyncEnumerableSorter sorter = _source.GetAsyncEnumerableSorter(_cancellationToken); + + if (_minIndexIterator == _maxIndexIterator) + { + _current = await sorter.ElementAt(_buffer, _buffer.Length, _minIndexIterator).ConfigureAwait(false); + + _minIndexIterator = int.MaxValue; + _maxIndexIterator = int.MinValue; + + _state = AsyncIteratorState.Iterating; + return true; + } + else + { + _indexes = await sorter.Sort(_buffer, _buffer.Length, _minIndexIterator, _maxIndexIterator).ConfigureAwait(false); + } + + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + } + + await DisposeAsync(); + break; + + case AsyncIteratorState.Iterating: + if (_minIndexIterator <= _maxIndexIterator) + { + _current = _buffer[_indexes[_minIndexIterator++]]; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public override async ValueTask DisposeAsync() + { + _buffer = null; + _indexes = null; + + await base.DisposeAsync().ConfigureAwait(false); + } + } + + internal abstract class AsyncCachingComparer + { + internal abstract ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken); + + internal abstract ValueTask SetElement(TElement element, CancellationToken cancellationToken); + } + + internal class AsyncCachingComparer : AsyncCachingComparer + { + protected readonly Func _keySelector; + protected readonly IComparer _comparer; + protected readonly bool _descending; + protected TKey _lastKey; + + public AsyncCachingComparer(Func keySelector, IComparer comparer, bool descending) + { + _keySelector = keySelector; + _comparer = comparer; + _descending = descending; + } + + internal override ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) + { + TKey newKey = _keySelector(element); + + int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + + if (cacheLower == cmp < 0) + { + _lastKey = newKey; + } + + return new ValueTask(cmp); + } + + internal override ValueTask SetElement(TElement element, CancellationToken cancellationToken) + { + _lastKey = _keySelector(element); + + return new ValueTask(); + } + } + + internal sealed class AsyncCachingComparerWithChild : AsyncCachingComparer + { + private readonly AsyncCachingComparer _child; + + public AsyncCachingComparerWithChild(Func keySelector, IComparer comparer, bool descending, AsyncCachingComparer child) + : base(keySelector, comparer, descending) + { + _child = child; + } + + internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) + { + TKey newKey = _keySelector(element); + + int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + + if (cmp == 0) + { + return await _child.Compare(element, cacheLower, cancellationToken).ConfigureAwait(false); + } + + if (cacheLower == cmp < 0) + { + _lastKey = newKey; + + await _child.SetElement(element, cancellationToken).ConfigureAwait(false); + } + + return cmp; + } + + internal override async ValueTask SetElement(TElement element, CancellationToken cancellationToken) + { + await base.SetElement(element, cancellationToken).ConfigureAwait(false); + + await _child.SetElement(element, cancellationToken).ConfigureAwait(false); + } + } + + internal class AsyncCachingComparerWithTask : AsyncCachingComparer + { + protected readonly Func> _keySelector; + protected readonly IComparer _comparer; + protected readonly bool _descending; + protected TKey _lastKey; + + public AsyncCachingComparerWithTask(Func> keySelector, IComparer comparer, bool descending) + { + _keySelector = keySelector; + _comparer = comparer; + _descending = descending; + } + + internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) + { + TKey newKey = await _keySelector(element).ConfigureAwait(false); + + int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + + if (cacheLower == cmp < 0) + { + _lastKey = newKey; + } + + return cmp; + } + + internal override async ValueTask SetElement(TElement element, CancellationToken cancellationToken) + { + _lastKey = await _keySelector(element).ConfigureAwait(false); + } + } + + internal sealed class AsyncCachingComparerWithTaskAndChild : AsyncCachingComparerWithTask + { + private readonly AsyncCachingComparer _child; + + public AsyncCachingComparerWithTaskAndChild(Func> keySelector, IComparer comparer, bool descending, AsyncCachingComparer child) + : base(keySelector, comparer, descending) + { + _child = child; + } + + internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) + { + TKey newKey = await _keySelector(element).ConfigureAwait(false); + + int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + + if (cmp == 0) + { + return await _child.Compare(element, cacheLower, cancellationToken).ConfigureAwait(false); + } + + if (cacheLower == cmp < 0) + { + _lastKey = newKey; + + await _child.SetElement(element, cancellationToken).ConfigureAwait(false); + } + + return cmp; + } + + internal override async ValueTask SetElement(TElement element, CancellationToken cancellationToken) + { + await base.SetElement(element, cancellationToken).ConfigureAwait(false); + + await _child.SetElement(element, cancellationToken).ConfigureAwait(false); + } + } + +#if !NO_DEEP_CANCELLATION + internal class AsyncCachingComparerWithTaskAndCancellation : AsyncCachingComparer + { + protected readonly Func> _keySelector; + protected readonly IComparer _comparer; + protected readonly bool _descending; + protected TKey _lastKey; + + public AsyncCachingComparerWithTaskAndCancellation(Func> keySelector, IComparer comparer, bool descending) + { + _keySelector = keySelector; + _comparer = comparer; + _descending = descending; + } + + internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) + { + TKey newKey = await _keySelector(element, cancellationToken).ConfigureAwait(false); + + int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + + if (cacheLower == cmp < 0) + { + _lastKey = newKey; + } + + return cmp; + } + + internal override async ValueTask SetElement(TElement element, CancellationToken cancellationToken) + { + _lastKey = await _keySelector(element, cancellationToken).ConfigureAwait(false); + } + } + + internal sealed class AsyncCachingComparerWithTaskAndCancellationAndChild : AsyncCachingComparerWithTaskAndCancellation + { + private readonly AsyncCachingComparer _child; + + public AsyncCachingComparerWithTaskAndCancellationAndChild(Func> keySelector, IComparer comparer, bool descending, AsyncCachingComparer child) + : base(keySelector, comparer, descending) + { + _child = child; + } + + internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) + { + TKey newKey = await _keySelector(element, cancellationToken).ConfigureAwait(false); + + int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + + if (cmp == 0) + { + return await _child.Compare(element, cacheLower, cancellationToken).ConfigureAwait(false); + } + + if (cacheLower == cmp < 0) + { + _lastKey = newKey; + + await _child.SetElement(element, cancellationToken).ConfigureAwait(false); + } + + return cmp; + } + + internal override async ValueTask SetElement(TElement element, CancellationToken cancellationToken) + { + await base.SetElement(element, cancellationToken).ConfigureAwait(false); + + await _child.SetElement(element, cancellationToken).ConfigureAwait(false); + } + } +#endif } From 4ed7c60120b671c5106398bf166ea032e5e7260a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 28 Dec 2018 22:49:07 -0800 Subject: [PATCH 599/862] Improving test coverage for Min and Max. --- .../System/Linq/Operators/Max.cs | 21 +++++++++++++++++++ .../System/Linq/Operators/Min.cs | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs index 51bdb95511..72d4d34ff7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -98,6 +98,7 @@ public async Task Max1Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -107,6 +108,7 @@ public async Task Max2Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -116,6 +118,7 @@ public async Task Max3Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -125,6 +128,7 @@ public async Task Max4Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -134,6 +138,7 @@ public async Task Max5Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -143,6 +148,7 @@ public async Task Max6Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -152,6 +158,7 @@ public async Task Max7Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -161,6 +168,7 @@ public async Task Max8Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -170,6 +178,7 @@ public async Task Max9Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -179,6 +188,7 @@ public async Task Max10Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } [Fact] @@ -188,6 +198,17 @@ public async Task Max11Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task Max12Async() + { + var xs = new[] { "foo", "bar", "qux", "baz", "fred", "wilma" }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Max(), await ys.MaxAsync()); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); + Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs index 6950981801..9eb003ae64 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -98,6 +98,7 @@ public async Task Min1Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -107,6 +108,7 @@ public async Task Min2Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -116,6 +118,7 @@ public async Task Min3Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -125,6 +128,7 @@ public async Task Min4Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -134,6 +138,7 @@ public async Task Min5Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -143,6 +148,7 @@ public async Task Min6Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -152,6 +158,7 @@ public async Task Min7Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -161,6 +168,7 @@ public async Task Min8Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -170,6 +178,7 @@ public async Task Min9Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -179,6 +188,7 @@ public async Task Min10Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } [Fact] @@ -188,6 +198,17 @@ public async Task Min11Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task Min12Async() + { + var xs = new[] { "foo", "bar", "qux", "baz", "fred", "wilma" }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Min(), await ys.MinAsync()); + Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); + Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); } } } From ac2525488cdba81b82d9334779a85e82c63b5e16 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 29 Dec 2018 15:27:21 -0800 Subject: [PATCH 600/862] More tests for Min and Max. --- .../System.Linq.Async.Tests.csproj | 28 + .../System/Linq/Operators/Max.cs | 55 + .../System/Linq/Operators/Min.cs | 55 + .../System/Linq/Operators/MinMax.Generated.cs | 9663 +++++++++++++++++ .../System/Linq/Operators/MinMax.Generated.tt | 361 + 5 files changed, 10162 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index e9ec63c71f..bc4ef35c3d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -13,6 +13,15 @@ + + + + True + True + MinMax.Generated.tt + + + @@ -25,4 +34,23 @@ + + + TextTemplatingFileGenerator + MinMax.Generated.cs + + + + + + + + + + True + True + MinMax.Generated.tt + + + diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs index 72d4d34ff7..f71238dc95 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -38,6 +38,17 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); @@ -49,9 +60,22 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); @@ -86,9 +110,40 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); +#endif + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); +#endif } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs index 9eb003ae64..12b52e9d3a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -38,6 +38,17 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); @@ -49,9 +60,22 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); @@ -86,9 +110,40 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); +#endif + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); +#endif } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs new file mode 100644 index 0000000000..beaad722d6 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs @@ -0,0 +1,9663 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class MinMax : AsyncEnumerableTests + { + [Fact] + public async Task Min_Empty_Int32() + { + await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Int32() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(int), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Int32() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Int32() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Empty_Nullable_Int32() + { + Assert.Null(await new int?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Nullable_Int32() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(int?), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Nullable_Int32() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Int32() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Empty_Int64() + { + await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Int64() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(long), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Int64() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Int64() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Empty_Nullable_Int64() + { + Assert.Null(await new long?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Nullable_Int64() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(long?), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Nullable_Int64() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Int64() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Empty_Single() + { + await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Single() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(float), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Single() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Single() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Empty_Nullable_Single() + { + Assert.Null(await new float?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Nullable_Single() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(float?), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Nullable_Single() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Single() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Empty_Double() + { + await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Double() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(double), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Double() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Double() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Empty_Nullable_Double() + { + Assert.Null(await new double?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Nullable_Double() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(double?), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Nullable_Double() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Double() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Empty_Decimal() + { + await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Decimal() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(decimal), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Decimal() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Decimal() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Empty_Nullable_Decimal() + { + Assert.Null(await new decimal?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + } + + [Fact] + public async Task Min_Selector_Empty_Nullable_Decimal() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(decimal?), CancellationToken.None)); + } + + [Fact] + public async Task Min_AsyncSelector_Empty_Nullable_Decimal() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Decimal() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Min_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Min_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_Selector_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Min_AsyncSelector_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Min(); + var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Empty_Int32() + { + await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Int32() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(int), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Int32() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Int32() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Empty_Nullable_Int32() + { + Assert.Null(await new int?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Nullable_Int32() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(int?), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Nullable_Int32() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Int32() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_1() + { + var input = new int[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_NoNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(int?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_SomeNull() + { + var input = new int?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_4() + { + var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_NoNull() + { + var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(int?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_SomeNull() + { + var input = new int?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_8() + { + var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_NoNull() + { + var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(int?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_SomeNull() + { + var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_16() + { + var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_NoNull() + { + var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(int?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() + { + var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Empty_Int64() + { + await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Int64() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(long), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Int64() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Int64() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Empty_Nullable_Int64() + { + Assert.Null(await new long?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Nullable_Int64() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(long?), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Nullable_Int64() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Int64() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_1() + { + var input = new long[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_NoNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(long?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_SomeNull() + { + var input = new long?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_4() + { + var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_NoNull() + { + var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(long?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_SomeNull() + { + var input = new long?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_8() + { + var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_NoNull() + { + var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(long?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_SomeNull() + { + var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_16() + { + var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_NoNull() + { + var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(long?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() + { + var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Empty_Single() + { + await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Single() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(float), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Single() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Single() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Empty_Nullable_Single() + { + Assert.Null(await new float?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Nullable_Single() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(float?), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Nullable_Single() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Single() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_1() + { + var input = new float[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_NoNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(float?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_SomeNull() + { + var input = new float?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_4() + { + var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_NoNull() + { + var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(float?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_SomeNull() + { + var input = new float?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_8() + { + var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_NoNull() + { + var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(float?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_SomeNull() + { + var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_16() + { + var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_NoNull() + { + var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(float?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull() + { + var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Empty_Double() + { + await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Double() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(double), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Double() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Double() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Empty_Nullable_Double() + { + Assert.Null(await new double?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Nullable_Double() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(double?), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Nullable_Double() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Double() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_1() + { + var input = new double[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_NoNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(double?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_SomeNull() + { + var input = new double?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_4() + { + var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_NoNull() + { + var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(double?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_SomeNull() + { + var input = new double?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_8() + { + var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_NoNull() + { + var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(double?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_SomeNull() + { + var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_16() + { + var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_NoNull() + { + var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(double?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull() + { + var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Empty_Decimal() + { + await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Decimal() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(decimal), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Decimal() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Decimal() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Empty_Nullable_Decimal() + { + Assert.Null(await new decimal?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + } + + [Fact] + public async Task Max_Selector_Empty_Nullable_Decimal() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(decimal?), CancellationToken.None)); + } + + [Fact] + public async Task Max_AsyncSelector_Empty_Nullable_Decimal() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Decimal() + { + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + } +#endif + + [Fact] + public async Task Max_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_1() + { + var input = new decimal[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_NoNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 1); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_SomeNull() + { + var input = new decimal?[] { 33 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_4() + { + var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_NoNull() + { + var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 4); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_SomeNull() + { + var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_8() + { + var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_NoNull() + { + var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 8); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_SomeNull() + { + var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_16() + { + var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_16_NoNull() + { + var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_16_AllNull() + { + var input = Enumerable.Repeat(default(decimal?), 16); + + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task Max_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_Selector_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task Max_AsyncSelector_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_16_SomeNull() + { + var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); + + for (var i = 0; i < 4; i++) + { + var expected = input.Max(); + var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + + private static IEnumerable Shuffle(IEnumerable source) + { + var rand = new Random(42); + return source.OrderBy(x => rand.Next()); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt new file mode 100644 index 0000000000..bf4667f039 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt @@ -0,0 +1,361 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# +int ShuffleCount = 4; + +var types = new[] { typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) }; + +Func toCSharp = t => +{ + if (t == typeof(int)) + return "int"; + else if (t == typeof(long)) + return "long"; + else if (t == typeof(float)) + return "float"; + else if (t == typeof(double)) + return "double"; + else if (t == typeof(decimal)) + return "decimal"; + + throw new Exception(); +}; + +Func getRandom = (seed, N, min, max) => +{ + var rand = new Random(seed); + return Enumerable.Range(0, N).Select(i => rand.Next(min, max)).ToArray(); +}; +#> +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class MinMax : AsyncEnumerableTests + { +<# +foreach (var op in new[] { "Min", "Max" }) +{ + foreach (var t in types) + { + var cs = toCSharp(t); +#> + [Fact] + public async Task <#=op#>_Empty_<#=t.Name#>() + { + await AssertThrowsAsync(new <#=cs#>[0].ToAsyncEnumerable().<#=op#>Async(CancellationToken.None)); + } + + [Fact] + public async Task <#=op#>_Selector_Empty_<#=t.Name#>() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(<#=cs#>), CancellationToken.None)); + } + + [Fact] + public async Task <#=op#>_AsyncSelector_Empty_<#=t.Name#>() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(ValueTask<<#=cs#>>), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task <#=op#>_AsyncSelectorWithCancellation_Empty_<#=t.Name#>() + { + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async((x, ct) => default(ValueTask<<#=cs#>>), CancellationToken.None)); + } +#endif + + [Fact] + public async Task <#=op#>_Empty_Nullable_<#=t.Name#>() + { + Assert.Null(await new <#=cs#>?[0].ToAsyncEnumerable().<#=op#>Async(CancellationToken.None)); + } + + [Fact] + public async Task <#=op#>_Selector_Empty_Nullable_<#=t.Name#>() + { + Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(<#=cs#>?), CancellationToken.None)); + } + + [Fact] + public async Task <#=op#>_AsyncSelector_Empty_Nullable_<#=t.Name#>() + { + Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(ValueTask<<#=cs#>?>), CancellationToken.None)); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task <#=op#>_AsyncSelectorWithCancellation_Empty_Nullable_<#=t.Name#>() + { + Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>Async((x, ct) => default(ValueTask<<#=cs#>?>), CancellationToken.None)); + } +#endif + +<# + foreach (var n in new[] { 1, 4, 8, 16 }) + { + var values = string.Join(", ", getRandom(n * 42, n, -100, 100)); + var valuesWithNull = string.Join(", ", getRandom(n * 42, n, -100, 100).Select((x, i) => i % 2 == 0 ? x.ToString() : "null")); +#> + [Fact] + public async Task <#=op#>_<#=t.Name#>_<#=n#>() + { + var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task <#=op#>_Selector_<#=t.Name#>_<#=n#>() + { + var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task <#=op#>_AsyncSelector_<#=t.Name#>_<#=n#>() + { + var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>>(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_<#=n#>() + { + var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task <#=op#>_<#=t.Name#>_Nullable_<#=n#>_NoNull() + { + var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task <#=op#>_Selector_<#=t.Name#>_Nullable_<#=n#>_NoNull() + { + var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task <#=op#>_AsyncSelector_<#=t.Name#>_Nullable_<#=n#>_NoNull() + { + var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_<#=n#>_NoNull() + { + var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + + [Fact] + public async Task <#=op#>_<#=t.Name#>_Nullable_<#=n#>_AllNull() + { + var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); + + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task <#=op#>_Selector_<#=t.Name#>_Nullable_<#=n#>_AllNull() + { + var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); + + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + } + + [Fact] + public async Task <#=op#>_AsyncSelector_<#=t.Name#>_Nullable_<#=n#>_AllNull() + { + var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); + + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + Assert.Equal(expected, actual); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_<#=n#>_AllNull() + { + var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); + + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + Assert.Equal(expected, actual); + } +#endif + + [Fact] + public async Task <#=op#>_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + { + var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task <#=op#>_Selector_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + { + var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => x, CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + + [Fact] + public async Task <#=op#>_AsyncSelector_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + { + var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + { + var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); + + for (var i = 0; i < <#=ShuffleCount#>; i++) + { + var expected = input.<#=op#>(); + var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + Assert.Equal(expected, actual); + + input = Shuffle(input); + } + } +#endif + +<# + } + + foreach (var n in new[] { 1, 4, 8, 16 }) + { + var values = string.Join(", ", getRandom(n * 42, n, -100, 100)); +#> +<# + } + } +} +#> + + private static IEnumerable Shuffle(IEnumerable source) + { + var rand = new Random(42); + return source.OrderBy(x => rand.Next()); + } + } +} From d9b0c05a6901e3e4b38c87e22316029bfeb82b7f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Sat, 29 Dec 2018 16:10:59 -0800 Subject: [PATCH 601/862] Adding more tests for aggregates. --- .../System/Linq/Operators/Average.cs | 112 +++++++++++++-- .../System/Linq/Operators/Max.cs | 130 +++++++++++++----- .../System/Linq/Operators/Min.cs | 130 +++++++++++++----- .../System/Linq/Operators/Sum.cs | 112 +++++++++++++-- 4 files changed, 388 insertions(+), 96 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs index d2de51168b..646a8a702f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs @@ -16,6 +16,8 @@ public class Average : AsyncEnumerableTests [Fact] public async Task Average_Null() { + // Average(IAE

) + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); @@ -27,6 +29,21 @@ public async Task Average_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + // Average(IAE

, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + + // Average(IAE, Func) + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); @@ -49,16 +66,7 @@ public async Task Average_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + // Average(IAE, Func, CT) await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); @@ -81,6 +89,80 @@ public async Task Average_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + // Average(IAE, Func>) + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + + // Average(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + // Average(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); +#endif } [Fact] @@ -90,6 +172,7 @@ public async Task Average1() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -99,6 +182,7 @@ public async Task Average2() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -108,6 +192,7 @@ public async Task Average3() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -117,6 +202,7 @@ public async Task Average4() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -126,6 +212,7 @@ public async Task Average5() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -135,6 +222,7 @@ public async Task Average6() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -144,6 +232,7 @@ public async Task Average7() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -153,6 +242,7 @@ public async Task Average8() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -162,6 +252,7 @@ public async Task Average9() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] @@ -171,6 +262,7 @@ public async Task Average10() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs index f71238dc95..51a8ca1450 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -16,6 +16,8 @@ public class Max : AsyncEnumerableTests [Fact] public async Task Max_Null() { + // Max(IAE

) + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); @@ -27,6 +29,21 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + // Max(IAE

, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + + // Max(IAE, Func) + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); @@ -38,17 +55,6 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); @@ -60,33 +66,7 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + // Max(IAE, Func, CT) await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); @@ -110,6 +90,43 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + // Max(IAE, Func>) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + + // Max(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); @@ -122,6 +139,19 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #if !NO_DEEP_CANCELLATION + // Max(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); @@ -134,13 +164,37 @@ public async Task Max_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #endif + // Max(IAE) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + + // Max(IAE, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + + // Max(IAE, Func) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + + // Max(IAE, Func, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + // Max(IAE, Func>) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + + // Max(IAE, Func>, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #if !NO_DEEP_CANCELLATION + // Max(IAE, Func>, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs index 12b52e9d3a..3aeeb7b958 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -16,6 +16,8 @@ public class Min : AsyncEnumerableTests [Fact] public async Task Min_Null() { + // Min(IAE

) + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); @@ -27,6 +29,21 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + // Min(IAE

, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + + // Min(IAE, Func) + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); @@ -38,17 +55,6 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); @@ -60,33 +66,7 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + // Min(IAE, Func, CT) await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); @@ -110,6 +90,43 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + // Min(IAE, Func>) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + + // Min(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); @@ -122,6 +139,19 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #if !NO_DEEP_CANCELLATION + // Min(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); @@ -134,13 +164,37 @@ public async Task Min_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #endif + // Min(IAE) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + + // Min(IAE, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + + // Min(IAE, Func) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + + // Min(IAE, Func, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + // Min(IAE, Func>) + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + + // Min(IAE, Func>, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #if !NO_DEEP_CANCELLATION + // Min(IAE, Func>, CT) + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs index ea376cf97a..4104969e6b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs @@ -16,6 +16,8 @@ public class Sum : AsyncEnumerableTests [Fact] public async Task Sum_Null() { + // Sum(IAE

) + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); @@ -27,6 +29,21 @@ public async Task Sum_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + // Sum(IAE

, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + + // Sum(IAE, Func) + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); @@ -49,16 +66,7 @@ public async Task Sum_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + // Sum(IAE, Func, CT) await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); @@ -81,6 +89,80 @@ public async Task Sum_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + + // Sum(IAE, Func>) + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + + // Sum(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + // Sum(IAE, Func>, CT) + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); +#endif } [Fact] @@ -90,6 +172,7 @@ public async Task Sum1Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -99,6 +182,7 @@ public async Task Sum2Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -108,6 +192,7 @@ public async Task Sum3Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -117,6 +202,7 @@ public async Task Sum4Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -126,6 +212,7 @@ public async Task Sum5Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -135,6 +222,7 @@ public async Task Sum6Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -144,6 +232,7 @@ public async Task Sum7Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -153,6 +242,7 @@ public async Task Sum8Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -162,6 +252,7 @@ public async Task Sum9Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } [Fact] @@ -171,6 +262,7 @@ public async Task Sum10Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); + Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); } } } From bf9361a43e86e51b9c26f4aaf96cfe9cd7ea1cea Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 31 Dec 2018 11:48:35 -0800 Subject: [PATCH 602/862] More tests for First and Last. --- .../System/Linq/Operators/First.cs | 275 ++++++++++++++++-- .../System/Linq/Operators/FirstOrDefault.cs | 273 +++++++++++++++-- .../System/Linq/Operators/Last.cs | 275 ++++++++++++++++-- .../System/Linq/Operators/LastOrDefault.cs | 274 +++++++++++++++-- 4 files changed, 1024 insertions(+), 73 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index fb74226ea1..9e77b089b3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -13,80 +13,321 @@ namespace Tests public class First : AsyncEnumerableTests { [Fact] - public async Task First_Null() + public async Task FirstAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None)); +#endif } [Fact] - public async Task First1Async() + public async Task FirstAsync_NoParam_Empty() { var res = AsyncEnumerable.Empty().FirstAsync(); await AssertThrowsAsync(res); } [Fact] - public async Task First2Async() + public async Task FirstAsync_NoParam_Empty_Enumerable() { - var res = AsyncEnumerable.Empty().FirstAsync(x => true); + var res = new int[0].Select(x => x).ToAsyncEnumerable().FirstAsync(); await AssertThrowsAsync(res); } [Fact] - public async Task First3Async() + public async Task FirstAsync_NoParam_Empty_IList() { - var res = Return42.FirstAsync(x => x % 2 != 0); + var res = new int[0].ToAsyncEnumerable().FirstAsync(); await AssertThrowsAsync(res); } [Fact] - public async Task First4Async() + public async Task FirstAsync_NoParam_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).FirstAsync(); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task FirstAsync_NoParam_Single_IList() { var res = Return42.FirstAsync(); Assert.Equal(42, await res); } [Fact] - public async Task First5Async() + public async Task FirstAsync_NoParam_Single() + { + var res = new[] { 42 }.Select(x => x).ToAsyncEnumerable().FirstAsync(); + Assert.Equal(42, await res); + } + + [Fact] + public async Task FirstAsync_NoParam_Many_IList() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAsync(); + Assert.Equal(42, await res); + } + + [Fact] + public async Task FirstAsync_NoParam_Many() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstAsync(); + Assert.Equal(42, await res); + } + + [Fact] + public async Task FirstAsync_Predicate_Empty() + { + var res = AsyncEnumerable.Empty().FirstAsync(x => true); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_Predicate_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).FirstAsync(x => true); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task FirstAsync_Predicate_Single_None() + { + var res = Return42.FirstAsync(x => x % 2 != 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_Predicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_Predicate_Many_None() + { + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_Predicate_Single_Pass() { var res = Return42.FirstAsync(x => x % 2 == 0); Assert.Equal(42, await res); } [Fact] - public async Task First6Async() + public async Task FirstAsync_Predicate_Many_IList_Pass1() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstAsync_Predicate_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstAsync_Predicate_Many_Pass1() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstAsync_Predicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstAsync_Predicate_PredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync(x => 1 / x > 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Empty() + { + var res = AsyncEnumerable.Empty().FirstAsync(x => new ValueTask(true)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstAsync(); + var res = Throw(ex).FirstAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task First7Async() + public async Task FirstAsync_AsyncPredicate_Single_None() + { + var res = Return42.FirstAsync(x => new ValueTask(x % 2 != 0)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Many_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select(x => x).FirstAsync(x => new ValueTask(x % 2 != 0)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Single_Pass() + { + var res = Return42.FirstAsync(x => new ValueTask(x % 2 == 0)); + Assert.Equal(42, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Many_IList_Pass1() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Many_Pass1() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicate_AsyncPredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(1 / x > 0)); + await AssertThrowsAsync(res); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Empty() + { + var res = AsyncEnumerable.Empty().FirstAsync((x, ct) => new ValueTask(true), CancellationToken.None); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstAsync(x => true); + var res = Throw(ex).FirstAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res, ex); } [Fact] - public async Task First8Async() + public async Task FirstAsync_AsyncPredicateWithCancellation_Single_None() + { + var res = Return42.FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Many_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select((x, ct) => x).FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Single_Pass() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync(); + var res = Return42.FirstAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); Assert.Equal(42, await res); } [Fact] - public async Task First9Async() + public async Task FirstAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Many_Pass1() + { + var res = new[] { 42, 43, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + await AssertThrowsAsync(res); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index d7e755d1be..2d39aea27d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -16,59 +16,94 @@ public class FirstOrDefault : AsyncEnumerableTests public async Task FirstOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); +#endif } [Fact] - public async Task FirstOrDefault1Async() + public async Task FirstOrDefaultAsync_NoParam_Empty() { var res = AsyncEnumerable.Empty().FirstOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefault2Async() + public async Task FirstOrDefaultAsync_NoParam_Empty_Enumerable() { - var res = AsyncEnumerable.Empty().FirstOrDefaultAsync(x => true); + var res = new int[0].Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefault3Async() + public async Task FirstOrDefaultAsync_NoParam_Empty_IList() { - var res = Return42.FirstOrDefaultAsync(x => x % 2 != 0); + var res = new int[0].ToAsyncEnumerable().FirstOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefault4Async() + public async Task FirstOrDefaultAsync_NoParam_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).FirstOrDefaultAsync(); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task FirstOrDefaultAsync_NoParam_Single_IList() { var res = Return42.FirstOrDefaultAsync(); Assert.Equal(42, await res); } + [Fact] - public async Task FirstOrDefault5Async() + public async Task FirstOrDefaultAsync_NoParam_Single() { - var res = Return42.FirstOrDefaultAsync(x => x % 2 == 0); + var res = new[] { 42 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(); Assert.Equal(42, await res); } [Fact] - public async Task FirstOrDefault6Async() + public async Task FirstOrDefaultAsync_NoParam_Many_IList() { - var ex = new Exception("Bang!"); - var res = Throw(ex).FirstOrDefaultAsync(); - await AssertThrowsAsync(res, ex); + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync(); + Assert.Equal(42, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_NoParam_Many() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(); + Assert.Equal(42, await res); } [Fact] - public async Task FirstOrDefault7Async() + public async Task FirstOrDefaultAsync_Predicate_Empty() + { + var res = AsyncEnumerable.Empty().FirstOrDefaultAsync(x => true); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_Predicate_Throw() { var ex = new Exception("Bang!"); var res = Throw(ex).FirstOrDefaultAsync(x => true); @@ -76,24 +111,224 @@ public async Task FirstOrDefault7Async() } [Fact] - public async Task FirstOrDefault8Async() + public async Task FirstOrDefaultAsync_Predicate_Single_None() + { + var res = Return42.FirstOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_Predicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_Predicate_Many_None() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(); + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_Predicate_Single_Pass() + { + var res = Return42.FirstOrDefaultAsync(x => x % 2 == 0); Assert.Equal(42, await res); } [Fact] - public async Task FirstOrDefault9Async() + public async Task FirstOrDefaultAsync_Predicate_Many_IList_Pass1() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_Predicate_Many_IList_Pass2() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => x % 2 != 0); Assert.Equal(45, await res); } [Fact] - public async Task FirstOrDefault10Async() + public async Task FirstOrDefaultAsync_Predicate_Many_Pass1() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_Predicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_Predicate_PredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => 1 / x > 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Empty() + { + var res = AsyncEnumerable.Empty().FirstOrDefaultAsync(x => new ValueTask(true)); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).FirstOrDefaultAsync(x => new ValueTask(true)); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Single_None() + { + var res = Return42.FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Many_None() + { + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Single_Pass() + { + var res = Return42.FirstOrDefaultAsync(x => new ValueTask(x % 2 == 0)); + Assert.Equal(42, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Many_IList_Pass1() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Many_Pass1() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicate_AsyncPredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(1 / x > 0)); + await AssertThrowsAsync(res); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Empty() + { + var res = AsyncEnumerable.Empty().FirstOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).FirstOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Single_None() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => x < 10); + var res = Return42.FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(0, await res); } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_None() + { + var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(0, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Single_Pass() + { + var res = Return42.FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); + Assert.Equal(42, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass1() + { + var res = new[] { 42, 43, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(43, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + await AssertThrowsAsync(res); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index a876f0215b..d2dd2692e4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -16,77 +16,318 @@ public class Last : AsyncEnumerableTests public async Task Last_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None)); +#endif } [Fact] - public async Task Last1Async() + public async Task LastAsync_NoParam_Empty() { var res = AsyncEnumerable.Empty().LastAsync(); await AssertThrowsAsync(res); } [Fact] - public async Task Last2Async() + public async Task LastAsync_NoParam_Empty_Enumerable() { - var res = AsyncEnumerable.Empty().LastAsync(x => true); + var res = new int[0].Select(x => x).ToAsyncEnumerable().LastAsync(); await AssertThrowsAsync(res); } [Fact] - public async Task Last3Async() + public async Task LastAsync_NoParam_Empty_IList() { - var res = Return42.LastAsync(x => x % 2 != 0); + var res = new int[0].ToAsyncEnumerable().LastAsync(); await AssertThrowsAsync(res); } [Fact] - public async Task Last4Async() + public async Task LastAsync_NoParam_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).LastAsync(); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task LastAsync_NoParam_Single_IList() { var res = Return42.LastAsync(); Assert.Equal(42, await res); } [Fact] - public async Task Last5Async() + public async Task LastAsync_NoParam_Single() + { + var res = new[] { 42 }.Select(x => x).ToAsyncEnumerable().LastAsync(); + Assert.Equal(42, await res); + } + + [Fact] + public async Task LastAsync_NoParam_Many_IList() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().LastAsync(); + Assert.Equal(44, await res); + } + + [Fact] + public async Task LastAsync_NoParam_Many() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().LastAsync(); + Assert.Equal(44, await res); + } + + [Fact] + public async Task LastAsync_Predicate_Empty() + { + var res = AsyncEnumerable.Empty().LastAsync(x => true); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_Predicate_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).LastAsync(x => true); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task LastAsync_Predicate_Single_None() + { + var res = Return42.LastAsync(x => x % 2 != 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_Predicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync(x => x % 2 != 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_Predicate_Many_None() + { + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => x % 2 != 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_Predicate_Single_Pass() { var res = Return42.LastAsync(x => x % 2 == 0); Assert.Equal(42, await res); } [Fact] - public async Task Last6Async() + public async Task LastAsync_Predicate_Many_IList_Pass1() + { + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_Predicate_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_Predicate_Many_Pass1() + { + var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_Predicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_Predicate_PredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync(x => 1 / x > 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Empty() + { + var res = AsyncEnumerable.Empty().LastAsync(x => new ValueTask(true)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastAsync(); + var res = Throw(ex).LastAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task Last7Async() + public async Task LastAsync_AsyncPredicate_Single_None() + { + var res = Return42.LastAsync(x => new ValueTask(x % 2 != 0)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Many_None() + { + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Single_Pass() + { + var res = Return42.LastAsync(x => new ValueTask(x % 2 == 0)); + Assert.Equal(42, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Many_IList_Pass1() + { + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Many_Pass1() + { + var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicate_AsyncPredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(1 / x > 0)); + await AssertThrowsAsync(res); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Empty() + { + var res = AsyncEnumerable.Empty().LastAsync((x, ct) => new ValueTask(true), CancellationToken.None); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastAsync(x => true); + var res = Throw(ex).LastAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res, ex); } [Fact] - public async Task Last8Async() + public async Task LastAsync_AsyncPredicateWithCancellation_Single_None() + { + var res = Return42.LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Many_IList_None() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAsync(); - Assert.Equal(90, await res); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + await AssertThrowsAsync(res); } [Fact] - public async Task Last9Async() + public async Task LastAsync_AsyncPredicateWithCancellation_Many_None() { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastAsync(x => x % 2 != 0); + var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Single_Pass() + { + var res = Return42.LastAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); + Assert.Equal(42, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() + { + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Many_Pass1() + { + var res = new[] { 43, 44, 45 }.Select((x, ct) => x).ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + await AssertThrowsAsync(res); + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 0363541916..511303b82e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -16,84 +16,318 @@ public class LastOrDefault : AsyncEnumerableTests public async Task LastOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); +#endif } [Fact] - public async Task LastOrDefault1Async() + public async Task LastOrDefaultAsync_NoParam_Empty() { var res = AsyncEnumerable.Empty().LastOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefault2Async() + public async Task LasyOrDefaultAsync_NoParam_Empty_Enumerable() { - var res = AsyncEnumerable.Empty().LastOrDefaultAsync(x => true); + var res = new int[0].Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefault3Async() + public async Task LastOrDefaultAsync_NoParam_Empty_IList() { - var res = Return42.LastOrDefaultAsync(x => x % 2 != 0); + var res = new int[0].ToAsyncEnumerable().LastOrDefaultAsync(); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefault4Async() + public async Task LastOrDefaultAsync_NoParam_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).LastOrDefaultAsync(); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task LastOrDefaultAsync_NoParam_Single_IList() { var res = Return42.LastOrDefaultAsync(); Assert.Equal(42, await res); } [Fact] - public async Task LastOrDefault5Async() + public async Task LastOrDefaultAsync_NoParam_Single() { - var res = Return42.LastOrDefaultAsync(x => x % 2 == 0); + var res = new[] { 42 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(); Assert.Equal(42, await res); } [Fact] - public async Task LastOrDefault6Async() + public async Task LastOrDefaultAsync_NoParam_Many_IList() + { + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().LastOrDefaultAsync(); + Assert.Equal(44, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_NoParam_Many() + { + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(); + Assert.Equal(44, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Empty() + { + var res = AsyncEnumerable.Empty().LastOrDefaultAsync(x => true); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastOrDefaultAsync(); + var res = Throw(ex).LastOrDefaultAsync(x => true); await AssertThrowsAsync(res, ex); } [Fact] - public async Task LastOrDefault7Async() + public async Task LastOrDefaultAsync_Predicate_Single_None() + { + var res = Return42.LastOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Many_None() + { + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Single_Pass() + { + var res = Return42.LastOrDefaultAsync(x => x % 2 == 0); + Assert.Equal(42, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Many_IList_Pass1() + { + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Many_Pass1() + { + var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_Predicate_PredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync(x => 1 / x > 0); + await AssertThrowsAsync(res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_Empty() + { + var res = AsyncEnumerable.Empty().LastOrDefaultAsync(x => new ValueTask(true)); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastOrDefaultAsync(x => true); + var res = Throw(ex).LastOrDefaultAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task LastOrDefault8Async() + public async Task LastOrDefaultAsync_AsyncPredicate_Single_None() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(); - Assert.Equal(90, await res); + var res = Return42.LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_Many_None() + { + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefault9Async() + public async Task LastOrDefaultAsync_AsyncPredicate_Single_Pass() { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(x => x % 2 != 0); + var res = Return42.LastOrDefaultAsync(x => new ValueTask(x % 2 == 0)); + Assert.Equal(42, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_Many_IList_Pass1() + { + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefault10Async() + public async Task LastOrDefaultAsync_AsyncPredicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(x => x < 10); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_Many_Pass1() + { + var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicate_AsyncPredicateThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(1 / x > 0)); + await AssertThrowsAsync(res); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Empty() + { + var res = AsyncEnumerable.Empty().LastOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); Assert.Equal(0, await res); } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Throw() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).LastOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Single_None() + { + var res = Return42.LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_None() + { + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_None() + { + var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(0, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Single_Pass() + { + var res = Return42.LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); + Assert.Equal(42, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() + { + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + { + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass1() + { + var res = new[] { 43, 44, 45 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass2() + { + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + Assert.Equal(45, await res); + } + + [Fact] + public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + { + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + await AssertThrowsAsync(res); + } +#endif } } From debd8b1f34dd192e31e84db0befd38c2fb2e0cb5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 31 Dec 2018 12:13:21 -0800 Subject: [PATCH 603/862] More tests for Average. --- .../System.Linq.Async.Tests.csproj | 14 + .../Linq/Operators/Average.Generated.cs | 637 ++++++++++++++++++ .../Linq/Operators/Average.Generated.tt | 174 +++++ 3 files changed, 825 insertions(+) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index bc4ef35c3d..73fe7d1489 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -15,6 +15,11 @@ + + True + True + Average.Generated.tt + True True @@ -35,6 +40,10 @@ + + TextTemplatingFileGenerator + Average.Generated.cs + TextTemplatingFileGenerator MinMax.Generated.cs @@ -46,6 +55,11 @@ + + True + True + Average.Generated.tt + True True diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs new file mode 100644 index 0000000000..9a46f93c36 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs @@ -0,0 +1,637 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class AverageAsync : AsyncEnumerableTests + { + [Fact] + public async Task AverageAsync_Int32_Empty() + { + var ys = new int[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Int32_Many() + { + var xs = new int[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Int32_Empty() + { + var ys = new int[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Int32_Many() + { + var xs = new int[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int32_Empty() + { + var ys = new int[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int32_Many() + { + var xs = new int[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Empty() + { + var ys = new int[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Many() + { + var xs = new int[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Int32_Nullable_Empty() + { + var ys = new int?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Int32_Nullable_Many() + { + var xs = new int?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Int32_Nullable_Empty() + { + var ys = new int?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Int32_Nullable_Many() + { + var xs = new int?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int32_Nullable_Empty() + { + var ys = new int?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int32_Nullable_Many() + { + var xs = new int?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Nullable_Empty() + { + var ys = new int?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Nullable_Many() + { + var xs = new int?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Int64_Empty() + { + var ys = new long[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Int64_Many() + { + var xs = new long[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Int64_Empty() + { + var ys = new long[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Int64_Many() + { + var xs = new long[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int64_Empty() + { + var ys = new long[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int64_Many() + { + var xs = new long[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Empty() + { + var ys = new long[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Many() + { + var xs = new long[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Int64_Nullable_Empty() + { + var ys = new long?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Int64_Nullable_Many() + { + var xs = new long?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Int64_Nullable_Empty() + { + var ys = new long?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Int64_Nullable_Many() + { + var xs = new long?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int64_Nullable_Empty() + { + var ys = new long?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Int64_Nullable_Many() + { + var xs = new long?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Nullable_Empty() + { + var ys = new long?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Nullable_Many() + { + var xs = new long?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Single_Empty() + { + var ys = new float[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Single_Many() + { + var xs = new float[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Single_Empty() + { + var ys = new float[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Single_Many() + { + var xs = new float[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Single_Empty() + { + var ys = new float[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Single_Many() + { + var xs = new float[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Empty() + { + var ys = new float[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Many() + { + var xs = new float[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Single_Nullable_Empty() + { + var ys = new float?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Single_Nullable_Many() + { + var xs = new float?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Single_Nullable_Empty() + { + var ys = new float?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Single_Nullable_Many() + { + var xs = new float?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Single_Nullable_Empty() + { + var ys = new float?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Single_Nullable_Many() + { + var xs = new float?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Nullable_Empty() + { + var ys = new float?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Nullable_Many() + { + var xs = new float?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Double_Empty() + { + var ys = new double[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Double_Many() + { + var xs = new double[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Double_Empty() + { + var ys = new double[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Double_Many() + { + var xs = new double[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Double_Empty() + { + var ys = new double[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Double_Many() + { + var xs = new double[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Empty() + { + var ys = new double[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Many() + { + var xs = new double[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Double_Nullable_Empty() + { + var ys = new double?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Double_Nullable_Many() + { + var xs = new double?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Double_Nullable_Empty() + { + var ys = new double?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Double_Nullable_Many() + { + var xs = new double?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Double_Nullable_Empty() + { + var ys = new double?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Double_Nullable_Many() + { + var xs = new double?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Nullable_Empty() + { + var ys = new double?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Nullable_Many() + { + var xs = new double?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Decimal_Empty() + { + var ys = new decimal[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Decimal_Many() + { + var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Decimal_Empty() + { + var ys = new decimal[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Decimal_Many() + { + var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Decimal_Empty() + { + var ys = new decimal[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Decimal_Many() + { + var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Empty() + { + var ys = new decimal[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Many() + { + var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_Decimal_Nullable_Empty() + { + var ys = new decimal?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Decimal_Nullable_Many() + { + var xs = new decimal?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_Decimal_Nullable_Empty() + { + var ys = new decimal?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_Decimal_Nullable_Many() + { + var xs = new decimal?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Decimal_Nullable_Empty() + { + var ys = new decimal?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_Decimal_Nullable_Many() + { + var xs = new decimal?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Nullable_Empty() + { + var ys = new decimal?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Nullable_Many() + { + var xs = new decimal?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + } +#endif + + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt new file mode 100644 index 0000000000..4de6fe5be9 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt @@ -0,0 +1,174 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# +var types = new[] { typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) }; + +Func toCSharp = t => +{ + if (t == typeof(int)) + return "int"; + else if (t == typeof(long)) + return "long"; + else if (t == typeof(float)) + return "float"; + else if (t == typeof(double)) + return "double"; + else if (t == typeof(decimal)) + return "decimal"; + + throw new Exception(); +}; +#> +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class AverageAsync : AsyncEnumerableTests + { +<# +foreach (var t in types) +{ + var cs = toCSharp(t); +#> + [Fact] + public async Task AverageAsync_<#=t.Name#>_Empty() + { + var ys = new <#=cs#>[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_<#=t.Name#>_Many() + { + var xs = new <#=cs#>[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_<#=t.Name#>_Empty() + { + var ys = new <#=cs#>[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_<#=t.Name#>_Many() + { + var xs = new <#=cs#>[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Empty() + { + var ys = new <#=cs#>[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask<<#=cs#>>(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Many() + { + var xs = new <#=cs#>[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask<<#=cs#>>(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Empty() + { + var ys = new <#=cs#>[0].ToAsyncEnumerable(); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Many() + { + var xs = new <#=cs#>[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None)); + } +#endif + + [Fact] + public async Task AverageAsync_<#=t.Name#>_Nullable_Empty() + { + var ys = new <#=cs#>?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_<#=t.Name#>_Nullable_Many() + { + var xs = new <#=cs#>?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync()); + } + + [Fact] + public async Task AverageAsync_Selector_<#=t.Name#>_Nullable_Empty() + { + var ys = new <#=cs#>?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_Selector_<#=t.Name#>_Nullable_Many() + { + var xs = new <#=cs#>?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Nullable_Empty() + { + var ys = new <#=cs#>?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync(x => new ValueTask<<#=cs#>?>(x))); + } + + [Fact] + public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Nullable_Many() + { + var xs = new <#=cs#>?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask<<#=cs#>?>(x))); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_Empty() + { + var ys = new <#=cs#>?[0].ToAsyncEnumerable(); + Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None)); + } + + [Fact] + public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_Many() + { + var xs = new <#=cs#>?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; + var ys = xs.ToAsyncEnumerable(); + Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None)); + } +#endif + +<# +} +#> + } +} From a5ad50d29b0b8808ca5bb03e15114764063f7e47 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 31 Dec 2018 13:45:32 -0800 Subject: [PATCH 604/862] Adding tests for OrderBy. --- .../System.Linq.Async.Tests.csproj | 14 + .../Linq/Operators/OrderBy.Generated.cs | 5950 +++++++++++++++++ .../Linq/Operators/OrderBy.Generated.tt | 133 + .../System/Linq/Operators/OrderBy.cs | 2 +- .../System/Linq/Operators/OrderBy.cs | 12 + 5 files changed, 6110 insertions(+), 1 deletion(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index 73fe7d1489..e979ac3d5a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -25,6 +25,11 @@ True MinMax.Generated.tt + + True + True + OrderBy.Generated.tt + @@ -48,6 +53,10 @@ TextTemplatingFileGenerator MinMax.Generated.cs + + TextTemplatingFileGenerator + OrderBy.Generated.cs + @@ -65,6 +74,11 @@ True MinMax.Generated.tt + + True + True + OrderBy.Generated.tt + diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs new file mode 100644 index 0000000000..f2acc6f383 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs @@ -0,0 +1,5950 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + partial class OrderBy + { + [Fact] + public async Task OrderBy_OrderBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2); + var syncRes = xs.OrderBy(x => x % 2); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)); + var syncRes = xs.OrderBy(x => x % 2); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)); + var syncRes = xs.OrderBy(x => x % 2); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2); + var syncRes = xs.OrderByDescending(x => x % 2); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)); + var syncRes = xs.OrderByDescending(x => x % 2); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)); + var syncRes = xs.OrderByDescending(x => x % 2); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenBy_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenBy_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenBy_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenBy_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenBy_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenBy_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescending_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescending_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescending_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenBy_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenBy_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenBy_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescending_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenBy_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenBy_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenBy_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescending_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescending_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescending_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescending_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescending_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescending_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescending_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsync_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsync_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsync_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsync_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsync_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsync_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenBy() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByDescending() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsync() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + [Fact] + public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation_ThenByDescendingAsyncWithCancellation() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt new file mode 100644 index 0000000000..7c411b665d --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt @@ -0,0 +1,133 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# +Func getAsyncMethod = (then, desc, async, cancel, body) => +{ + var mtd = (then ? "ThenBy" : "OrderBy") + (desc ? "Descending" : ""); + + var arg = async ? (cancel ? "(x, ct) => " : "x => ") + "new ValueTask(" + body + ")" : "x => " + body; + + return "." + mtd + "(" + arg + ")"; +}; + +Func getAsyncMethodWithVariant = (then, desc, variant, body) => +{ + return getAsyncMethod(then, desc, variant > 0 ? true : false, variant == 2 ? true : false, body); +}; + +Func getSyncMethod = (then, desc, body) => +{ + var mtd = (then ? "ThenBy" : "OrderBy") + (desc ? "Descending" : ""); + + var arg = "x => " + body; + + return "." + mtd + "(" + arg + ")"; +}; + +Func getVariantName = (then, desc, variant) => +{ + var v = variant == 0 ? "" : (variant == 1 ? "Async" : "AsyncWithCancellation"); + return "_" + (then ? "ThenBy" : "OrderBy") + (desc ? "Descending" : "") + v; +}; + +Func>> getAsyncMethodVariants = (then, body) => +{ + var res = new List>(); + + foreach (var desc in new[] { false, true }) + { + foreach (var variant in new[] { 0, 1, 2 }) + { + var v = getVariantName(then, desc, variant); + var async = getAsyncMethodWithVariant(then, desc, variant, body); + var sync = getSyncMethod(then, desc, body); + + res.Add(new Tuple(v, async, sync)); + } + } + + return res; +}; + +Func>> getVariants = null; + +getVariants = depth => +{ + if (depth == 1) + { + return getAsyncMethodVariants(false, "x % 2"); + } + else + { + var res = new List>(); + + var next = getVariants(depth - 1); + + foreach (var item in next) + { + foreach (var variant in getAsyncMethodVariants(true, "x % " + (depth + 1))) + { + res.Add(new Tuple(item.Item1 + variant.Item1, item.Item2 + variant.Item2, item.Item3 + variant.Item3)); + } + } + + return res; + } +}; +#> +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + partial class OrderBy + { +<# +for (var i = 1; i <= 3; i++) +{ + foreach (var v in getVariants(i)) + { + var variant = v.Item1; + var asyncCall = v.Item2; + var syncCall = v.Item3; +#> + [Fact] + public async Task OrderBy<#=variant#>() + { + var rand = new Random(42); + var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); + + var asyncRes = xs.ToAsyncEnumerable()<#=asyncCall#>; + var syncRes = xs<#=syncCall#>; + + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < 100; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } + +<# + } +} +#> + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index 8d65d41f6b..f84f63edd2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -10,7 +10,7 @@ namespace Tests { - public class OrderBy : AsyncEnumerableTests + public partial class OrderBy : AsyncEnumerableTests { [Fact] public void OrderBy_Null() diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index 436830b415..8f8ca393af 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -30,6 +30,18 @@ public static IOrderedAsyncEnumerable OrderBy(this IAsyn return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: false, parent: null); } +#if !NO_DEEP_CANCELLATION + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (keySelector == null) + throw Error.ArgumentNull(nameof(keySelector)); + + return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: false, parent: null); + } +#endif + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) { if (source == null) From ee942bce43bb51041b4ece0761407c3894e41e57 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 31 Dec 2018 13:45:45 -0800 Subject: [PATCH 605/862] Fix null comparer bug for OrderBy. --- .../System/Linq/Operators/OrderedAsyncEnumerable.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 5d92775d31..e4617c4bc7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -434,7 +434,7 @@ public OrderedAsyncEnumerable(IAsyncEnumerable source, Func.Default; _descending = descending; _parent = parent; } @@ -479,7 +479,7 @@ public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func.Default; _descending = descending; _parent = parent; } @@ -525,7 +525,7 @@ public OrderedAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable Debug.Assert(keySelector != null); _keySelector = keySelector; - _comparer = comparer; + _comparer = comparer ?? Comparer.Default; _descending = descending; _parent = parent; } @@ -623,7 +623,7 @@ internal abstract class AsyncEnumerableSorterBase : AsyncEnumera public AsyncEnumerableSorterBase(IComparer comparer, bool descending, AsyncEnumerableSorter next) { - _comparer = comparer ?? Comparer.Default; + _comparer = comparer; _descending = descending; _next = next; } From 24eaf96c77ace77ef9d723b4ff361abdbe217b88 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 31 Dec 2018 14:03:34 -0800 Subject: [PATCH 606/862] Adding a few more tests for OrderBy. --- .../Linq/Operators/OrderBy.Generated.cs | 5171 +++++++++++------ .../Linq/Operators/OrderBy.Generated.tt | 39 +- 2 files changed, 3401 insertions(+), 1809 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs index f2acc6f383..736a8fb09d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs @@ -21,18 +21,24 @@ public async Task OrderBy_OrderBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2); var syncRes = xs.OrderBy(x => x % 2); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -44,18 +50,24 @@ public async Task OrderBy_OrderByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)); var syncRes = xs.OrderBy(x => x % 2); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -67,18 +79,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)); var syncRes = xs.OrderBy(x => x % 2); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -90,18 +108,24 @@ public async Task OrderBy_OrderByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2); var syncRes = xs.OrderByDescending(x => x % 2); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -113,18 +137,24 @@ public async Task OrderBy_OrderByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)); var syncRes = xs.OrderByDescending(x => x % 2); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -136,18 +166,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)); var syncRes = xs.OrderByDescending(x => x % 2); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -159,18 +195,24 @@ public async Task OrderBy_OrderBy_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -182,18 +224,24 @@ public async Task OrderBy_OrderBy_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -205,18 +253,24 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -228,18 +282,24 @@ public async Task OrderBy_OrderBy_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -251,18 +311,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -274,18 +340,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -297,18 +369,24 @@ public async Task OrderBy_OrderByAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -320,18 +398,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -343,18 +427,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -366,18 +456,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -389,18 +485,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -412,18 +514,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -435,18 +543,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -458,18 +572,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -481,18 +601,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -504,18 +630,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -527,18 +659,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -550,18 +688,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -573,18 +717,24 @@ public async Task OrderBy_OrderByDescending_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -596,18 +746,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -619,18 +775,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -642,18 +804,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -665,18 +833,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -688,18 +862,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -711,18 +891,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -734,18 +920,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -757,18 +949,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -780,18 +978,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -803,18 +1007,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -826,18 +1036,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -849,18 +1065,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -872,18 +1094,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -895,18 +1123,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -918,18 +1152,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -941,18 +1181,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -964,18 +1210,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -987,18 +1239,24 @@ public async Task OrderBy_OrderBy_ThenBy_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1010,18 +1268,24 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1033,18 +1297,24 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1056,18 +1326,24 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1079,18 +1355,24 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1102,18 +1384,24 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByDescendingAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1125,18 +1413,24 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1148,18 +1442,24 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1171,18 +1471,24 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1194,18 +1500,24 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1217,18 +1529,24 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1240,18 +1558,24 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescendingAsyncWithCancellat var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1263,18 +1587,24 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1286,18 +1616,24 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1309,18 +1645,24 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByAsyncWithCan var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1332,18 +1674,24 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1355,18 +1703,24 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescendingAs var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1378,18 +1732,24 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescendingAs var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1401,18 +1761,24 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1424,18 +1790,24 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1447,18 +1819,24 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1470,18 +1848,24 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1493,18 +1877,24 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1516,18 +1906,24 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescendingAsyncWithCanc var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1539,18 +1935,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1562,18 +1964,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1585,18 +1993,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByAsyncWithCancellat var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1608,18 +2022,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1631,18 +2051,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1654,18 +2080,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescendingAsyncWit var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1677,18 +2109,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1700,18 +2138,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1723,18 +2167,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1746,18 +2196,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1769,18 +2225,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1792,18 +2254,24 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1815,18 +2283,24 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1838,18 +2312,24 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1861,18 +2341,24 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1884,18 +2370,24 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1907,18 +2399,24 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1930,18 +2428,24 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescendingAsyncWithCancellat var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1953,18 +2457,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1976,18 +2486,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -1999,18 +2515,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2022,18 +2544,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2045,18 +2573,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2068,18 +2602,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescendingAsyncWithCanc var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2091,18 +2631,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2114,18 +2660,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2137,18 +2689,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByAsyncWi var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2160,18 +2718,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescend var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2183,18 +2747,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescend var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2206,18 +2776,24 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescend var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2229,18 +2805,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2252,18 +2834,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2275,18 +2863,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByAsyncWithCancellat var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2298,18 +2892,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2321,18 +2921,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2344,18 +2950,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescendingAsyncWit var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2367,18 +2979,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2390,18 +3008,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2413,18 +3037,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByAsyncWithCanc var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2436,18 +3066,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2459,18 +3095,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescendingAsy var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2482,18 +3124,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescendingAsy var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2505,18 +3153,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2528,18 +3182,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2551,18 +3211,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2574,18 +3240,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2597,18 +3269,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2620,18 +3298,24 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2643,18 +3327,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2666,18 +3356,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2689,18 +3385,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByAsyncWithCan var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2712,18 +3414,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2735,18 +3443,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescendingAs var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2758,18 +3472,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescendingAs var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2781,18 +3501,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2804,18 +3530,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2827,18 +3559,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByAsyncWi var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2850,18 +3588,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescend var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2873,18 +3617,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescend var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2896,18 +3646,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescend var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2919,18 +3675,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2942,18 +3704,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2965,18 +3733,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -2988,18 +3762,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3011,18 +3791,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3034,18 +3820,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3057,18 +3849,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3080,18 +3878,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3103,18 +3907,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3126,18 +3936,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3149,18 +3965,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3172,18 +3994,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3195,18 +4023,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3218,18 +4052,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3241,18 +4081,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3264,18 +4110,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3287,18 +4139,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3310,18 +4168,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3333,18 +4197,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3356,18 +4226,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3379,18 +4255,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3402,18 +4284,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3425,18 +4313,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3448,18 +4342,24 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3471,18 +4371,24 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3494,18 +4400,24 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3517,18 +4429,24 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByAsyncWithCancellation() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3540,18 +4458,24 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3563,18 +4487,24 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3586,18 +4516,24 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescendingAsyncWithCanc var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3609,18 +4545,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3632,18 +4574,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3655,18 +4603,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByAsyncWithCancellat var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3678,18 +4632,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3701,18 +4661,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3724,18 +4690,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescendingAsyncWit var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3747,18 +4719,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3770,18 +4748,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3793,18 +4777,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3816,18 +4806,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3839,18 +4835,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3862,18 +4864,24 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3885,18 +4893,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3908,18 +4922,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3931,18 +4951,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByAsyncWithCanc var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3954,18 +4980,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -3977,18 +5009,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescendingAsy var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4000,18 +5038,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescendingAsy var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4023,18 +5067,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4046,18 +5096,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4069,18 +5125,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByAsyncWit var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4092,18 +5154,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendi var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4115,18 +5183,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendi var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4138,18 +5212,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendi var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4161,18 +5241,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4184,18 +5270,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4207,18 +5299,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4230,18 +5328,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4253,18 +5357,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4276,18 +5386,24 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4299,18 +5415,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4322,18 +5444,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4345,18 +5473,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByAsyncWithCancellat var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4368,18 +5502,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4391,18 +5531,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescendingAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4414,18 +5560,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescendingAsyncWit var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4437,18 +5589,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4460,18 +5618,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4483,18 +5647,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByAsyncWithCanc var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4506,18 +5676,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescending() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4529,18 +5705,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescendingAsy var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4552,18 +5734,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescendingAsy var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4575,18 +5763,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4598,18 +5792,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4621,18 +5821,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4644,18 +5850,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4667,18 +5879,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4690,18 +5908,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4713,18 +5937,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4736,18 +5966,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByAsync() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4759,18 +5995,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByAsyncWit var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4782,18 +6024,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendi var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4805,18 +6053,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendi var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4828,18 +6082,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendi var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4851,18 +6111,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4874,18 +6140,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByAsy var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4897,18 +6169,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByAsy var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4920,18 +6198,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDes var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4943,18 +6227,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDes var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4966,18 +6256,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDes var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -4989,18 +6285,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5012,18 +6314,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5035,18 +6343,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5058,18 +6372,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5081,18 +6401,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5104,18 +6430,24 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5127,18 +6459,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenBy() var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5150,18 +6488,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5173,18 +6517,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByAs var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5196,18 +6546,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5219,18 +6575,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5242,18 +6604,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDe var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5265,18 +6633,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5288,18 +6662,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5311,18 +6691,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5334,18 +6720,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5357,18 +6749,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5380,18 +6778,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5403,18 +6807,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5426,18 +6836,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5449,18 +6865,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5472,18 +6894,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5495,18 +6923,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5518,18 +6952,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5541,18 +6981,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5564,18 +7010,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5587,18 +7039,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5610,18 +7068,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5633,18 +7097,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5656,18 +7126,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5679,18 +7155,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5702,18 +7184,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5725,18 +7213,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5748,18 +7242,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5771,18 +7271,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5794,18 +7300,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5817,18 +7329,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5840,18 +7358,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5863,18 +7387,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5886,18 +7416,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5909,18 +7445,24 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } [Fact] @@ -5932,19 +7474,44 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + await AssertSorted(asyncRes, syncRes); + + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); + + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } + + foreach (var takeCount in new[] { 31, 29, 23 }) + { + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); + } + + await AssertSorted(asyncSegment, syncSegment); + } + + + private async Task AssertSorted(IAsyncEnumerable asyncRes, IEnumerable syncRes) + { + Assert.True(await syncRes.ToAsyncEnumerable().SequenceEqualAsync(asyncRes)); Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + int syncCount = syncRes.Count(); + int asyncCount = await asyncRes.CountAsync(); + Assert.Equal(syncCount, asyncCount); Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); - for (var i = 0; i < 100; i++) + for (var i = 0; i < syncCount; i++) { Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); } } - } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt index 7c411b665d..ec37fc84eb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt @@ -111,23 +111,48 @@ for (var i = 1; i <= 3; i++) var asyncRes = xs.ToAsyncEnumerable()<#=asyncCall#>; var syncRes = xs<#=syncCall#>; - Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); - Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + await AssertSorted(asyncRes, syncRes); - Assert.Equal(syncRes.Count(), await asyncRes.CountAsync()); + var asyncSegment = asyncRes.AsAsyncEnumerable(); + var syncSegment = syncRes.AsEnumerable(); - Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); - Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + foreach (var skipCount in new[] { 3, 7, 2, 5 }) + { + asyncSegment = asyncSegment.Skip(skipCount); + syncSegment = syncSegment.Skip(skipCount); + } - for (var i = 0; i < 100; i++) + foreach (var takeCount in new[] { 31, 29, 23 }) { - Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + asyncSegment = asyncSegment.Take(takeCount); + syncSegment = syncSegment.Take(takeCount); } + + await AssertSorted(asyncSegment, syncSegment); } <# } } #> + + private async Task AssertSorted(IAsyncEnumerable asyncRes, IEnumerable syncRes) + { + Assert.True(await syncRes.ToAsyncEnumerable().SequenceEqualAsync(asyncRes)); + Assert.True(syncRes.ToList().SequenceEqual(await asyncRes.ToListAsync())); + Assert.True(syncRes.ToArray().SequenceEqual(await asyncRes.ToArrayAsync())); + + int syncCount = syncRes.Count(); + int asyncCount = await asyncRes.CountAsync(); + Assert.Equal(syncCount, asyncCount); + + Assert.Equal(syncRes.First(), await asyncRes.FirstAsync()); + Assert.Equal(syncRes.Last(), await asyncRes.LastAsync()); + + for (var i = 0; i < syncCount; i++) + { + Assert.Equal(syncRes.ElementAt(i), await asyncRes.ElementAtAsync(i)); + } + } } } From 2caeab089120b127957d5372c68097a8f15ffc1e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 31 Dec 2018 14:07:51 -0800 Subject: [PATCH 607/862] Misc. tests. --- .../System/Linq/Operators/All.cs | 36 +++++++++++++++++ .../System/Linq/Operators/Any.cs | 39 ++++++++++++++++++- .../System/Linq/Operators/Single.cs | 15 ++++++- .../System/Linq/Operators/SingleOrDefault.cs | 15 ++++++- 4 files changed, 102 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index ea74474bd3..d7a0e56fa4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -20,6 +20,12 @@ public async Task All_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None)); } [Fact] @@ -51,5 +57,35 @@ public async Task All4Async() var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func(x => { throw ex; })); await AssertThrowsAsync(res, ex); } + + [Fact] + public async Task All5Async() + { + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync(x => new ValueTask(x % 2 == 0)); + Assert.False(await res); + } + + [Fact] + public async Task All6Async() + { + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(x => new ValueTask(x % 2 == 0)); + Assert.True(await res); + } + + [Fact] + public async Task All7Async() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).AllAsync(x => new ValueTask(x % 2 == 0)); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task All8Async() + { + var ex = new Exception("Bang!"); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func>(x => { throw ex; })); + await AssertThrowsAsync(res, ex); + } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 5f68643a36..4807b77bb0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -16,12 +16,19 @@ public class Any : AsyncEnumerableTests public async Task Any_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None)); } [Fact] @@ -67,5 +74,35 @@ public async Task Any6Async() var res = new int[0].ToAsyncEnumerable().AnyAsync(); Assert.False(await res); } + + [Fact] + public async Task Any7Async() + { + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync(x => new ValueTask(x % 2 == 0)); + Assert.True(await res); + } + + [Fact] + public async Task Any8Async() + { + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(x => new ValueTask(x % 2 != 0)); + Assert.False(await res); + } + + [Fact] + public async Task Any9Async() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).AnyAsync(x => new ValueTask(x % 2 == 0)); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task Any10Async() + { + var ex = new Exception("Bang!"); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(new Func>(x => { throw ex; })); + await AssertThrowsAsync(res, ex); + } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 836d59d33a..5aec943005 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -16,12 +16,25 @@ public class Single : AsyncEnumerableTests public async Task Single_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None)); +#endif } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index cbec3332ac..7b9192582b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -16,12 +16,25 @@ public class SingleOrDefault : AsyncEnumerableTests public async Task SingleOrDefault_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true, CancellationToken.None)); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func), CancellationToken.None)); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + +#if !NO_DEEP_CANCELLATION + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); +#endif } [Fact] From 5456436f7c6eb8a3e0650a4ff094d2c9a9c1093a Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 10:24:13 -0500 Subject: [PATCH 608/862] Revert "Simplify building ref assemblies." This reverts commit a6a0768b8784bd269ef6b00fadc5422b18802502. --- Ix.NET/Source/Directory.build.props | 2 -- .../System.Interactive.Providers.csproj | 3 ++- .../System.Interactive.csproj | 5 +++- Ix.NET/Source/global.json | 5 ++++ Ix.NET/Source/refs/Directory.build.props | 11 +++++++++ ...tem.Interactive.Async.Providers.Ref.csproj | 19 +++++++++++++++ .../System.Interactive.Async.Ref.csproj | 23 +++++++++++++++++++ .../System.Interactive.Providers.Ref.csproj | 23 +++++++++++++++++++ .../System.Interactive.Ref.csproj | 15 ++++++++++++ .../System.Linq.Async.Queryable.Ref.csproj | 23 +++++++++++++++++++ .../System.Linq.Async.Ref.csproj | 19 +++++++++++++++ 11 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 Ix.NET/Source/global.json create mode 100644 Ix.NET/Source/refs/Directory.build.props create mode 100644 Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj create mode 100644 Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index 73c239ded0..498dfc9dfe 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -17,8 +17,6 @@ true true latest - true - true diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index 661c784e84..1dc90c1d94 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -1,4 +1,4 @@ - + Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. @@ -13,6 +13,7 @@ + diff --git a/Ix.NET/Source/System.Interactive/System.Interactive.csproj b/Ix.NET/Source/System.Interactive/System.Interactive.csproj index 472999194c..2fe04e7d54 100644 --- a/Ix.NET/Source/System.Interactive/System.Interactive.csproj +++ b/Ix.NET/Source/System.Interactive/System.Interactive.csproj @@ -1,4 +1,4 @@ - + Interactive Extensions Main Library used to express queries over enumerable sequences. @@ -10,6 +10,9 @@ + + + diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json new file mode 100644 index 0000000000..eca09e09aa --- /dev/null +++ b/Ix.NET/Source/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "MSBuild.Sdk.Extras": "1.6.55" + } +} \ No newline at end of file diff --git a/Ix.NET/Source/refs/Directory.build.props b/Ix.NET/Source/refs/Directory.build.props new file mode 100644 index 0000000000..613a4047db --- /dev/null +++ b/Ix.NET/Source/refs/Directory.build.props @@ -0,0 +1,11 @@ + + + + + + + 2.1 + $(DefineConstants);REFERENCE_ASSEMBLY + + + diff --git a/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj new file mode 100644 index 0000000000..fac0fd0748 --- /dev/null +++ b/Ix.NET/Source/refs/System.Interactive.Async.Providers.Ref/System.Interactive.Async.Providers.Ref.csproj @@ -0,0 +1,19 @@ + + + + Interactive Extensions Async Providers Library used to build query providers and express queries over enumerable sequences. + Interactive Extensions - Async Providers Library + netcoreapp2.0;netstandard2.1 + Ix;Interactive;Extensions;Enumerable;Asynchronous + + + + + + + + + + + + diff --git a/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj new file mode 100644 index 0000000000..f064a205ae --- /dev/null +++ b/Ix.NET/Source/refs/System.Interactive.Async.Ref/System.Interactive.Async.Ref.csproj @@ -0,0 +1,23 @@ + + + + Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. + Interactive Extensions - Async Library + Microsoft + netcoreapp2.0;netstandard2.1 + Ix;Interactive;Extensions;Enumerable;Asynchronous + + + + + + + + + + + + + + + diff --git a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj new file mode 100644 index 0000000000..d9eb1a846a --- /dev/null +++ b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj @@ -0,0 +1,23 @@ + + + + Interactive Extensions Providers Library used to build query providers and express queries over enumerable sequences. + Interactive Extensions - Providers Library + netstandard1.0;netcoreapp2.0;netstandard2.1 + Ix;Interactive;Extensions;Enumerable + + + + + + + + + + + + + + + + diff --git a/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj new file mode 100644 index 0000000000..7237c5a159 --- /dev/null +++ b/Ix.NET/Source/refs/System.Interactive.Ref/System.Interactive.Ref.csproj @@ -0,0 +1,15 @@ + + + + Interactive Extensions Main Library used to express queries over enumerable sequences. + Interactive Extensions - Main Library + Microsoft + netstandard1.0;netcoreapp2.0;netstandard2.1 + Ix;Interactive;Extensions;Enumerable + + + + + + + diff --git a/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj new file mode 100644 index 0000000000..01fa4992ec --- /dev/null +++ b/Ix.NET/Source/refs/System.Linq.Async.Queryable.Ref/System.Linq.Async.Queryable.Ref.csproj @@ -0,0 +1,23 @@ + + + + LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. + System.Linq.Async.Queryable + Microsoft + netstandard1.0;netcoreapp2.0;netstandard2.1 + Enumerable;Asynchronous;LINQ + + + + + + + + + + + + + + + diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj new file mode 100644 index 0000000000..889887cddb --- /dev/null +++ b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj @@ -0,0 +1,19 @@ + + + + LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. + System.Linq.Async + Microsoft + netstandard1.0;netcoreapp2.0;netstandard2.1 + Enumerable;Asynchronous;LINQ + + + + + + + + + + + From 548e59f1c39bcdf49a62bc2164d60026be5700a9 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 10:24:20 -0500 Subject: [PATCH 609/862] Revert "Remove REFERENCE_ASSEMBLY." This reverts commit f687ae1ec6456adba34d7a3603b2b01101d53028. --- .../System/Linq/QueryableEx.Generated.cs | 8 ++++++++ .../System.Interactive/System/Linq/Operators/SkipLast.cs | 4 ++-- .../System.Interactive/System/Linq/Operators/TakeLast.cs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs index aa2a046c0c..b5cbac93ea 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Providers/System/Linq/QueryableEx.Generated.cs @@ -2152,7 +2152,11 @@ public static IQueryable TakeLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable TakeLast(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return null; +#else return EnumerableEx.TakeLast(source, count); +#endif } #pragma warning restore 1591 @@ -2186,7 +2190,11 @@ public static IQueryable SkipLast(this IQueryable sou [EditorBrowsable(EditorBrowsableState.Never)] public static IEnumerable SkipLast(IEnumerable source, int count) { +#if REFERENCE_ASSEMBLY + return null; +#else return EnumerableEx.SkipLast(source, count); +#endif } #pragma warning restore 1591 diff --git a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs index cbd3f553c1..8cdb1f3180 100644 --- a/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs @@ -8,7 +8,7 @@ namespace System.Linq { public static partial class EnumerableEx { -#if !(NETCOREAPP2_0 || NETSTANDARD2_1) +#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0 || NETSTANDARD2_1)) ///

/// Bypasses a specified number of contiguous elements from the end of the sequence and returns the remaining elements. /// @@ -33,6 +33,7 @@ public static IEnumerable SkipLast(this IEnumerable s return SkipLastCore(source, count); } +#endif private static IEnumerable SkipLastCore(this IEnumerable source, int count) { @@ -48,6 +49,5 @@ private static IEnumerable SkipLastCore(this IEnumerable /// Returns a specified number of contiguous elements from the end of the sequence. ///
@@ -30,6 +30,7 @@ public static IEnumerable TakeLast(this IEnumerable s return TakeLastCore(source, count); } +#endif private static IEnumerable TakeLastCore(IEnumerable source, int count) { @@ -55,6 +56,5 @@ private static IEnumerable TakeLastCore(IEnumerable s yield return q.Dequeue(); } } -#endif } } From 11b2225f8bea08b817d0c841d626b8808e267501 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 10:28:55 -0500 Subject: [PATCH 610/862] Revert "Adding C# 8.0 build flavors to prototype with new language features." This reverts commit 4054bcec72f4d143994966958fab2f7f00016be7. --- Ix.NET/Source/Directory.build.targets | 3 -- Ix.NET/Source/Ix.Async.NET.sln | 38 +------------------ ...m.Interactive.Async.Providers.Tests.csproj | 1 - .../System.Interactive.Async.Providers.csproj | 1 - .../System.Interactive.Async.Tests.csproj | 1 - .../System.Interactive.Async.csproj | 1 - .../System.Linq.Async.Queryable.Tests.csproj | 1 - .../System.Linq.Async.Queryable.csproj | 1 - .../System.Linq.Async.Tests.csproj | 1 - .../System.Linq.Async.csproj | 1 - 10 files changed, 2 insertions(+), 47 deletions(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 8aab913fe3..e43257ab08 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -10,9 +10,6 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION - - $(DefineConstants);CSHARP8 - $(AssemblyName) ($(TargetFramework)) diff --git a/Ix.NET/Source/Ix.Async.NET.sln b/Ix.NET/Source/Ix.Async.NET.sln index ca258f2735..3cf8c2088d 100644 --- a/Ix.NET/Source/Ix.Async.NET.sln +++ b/Ix.NET/Source/Ix.Async.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28407.52 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.3 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}" EndProject @@ -37,74 +37,40 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Interactive.Async.Pr EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug_CSharp8|Any CPU = Debug_CSharp8|Any CPU Debug|Any CPU = Debug|Any CPU - Release_CSharp8|Any CPU = Release_CSharp8|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release|Any CPU.ActiveCfg = Release|Any CPU {A9F6D09B-15B9-4CE8-867F-6F3383C5F247}.Release|Any CPU.Build.0 = Release|Any CPU - {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Debug|Any CPU.Build.0 = Debug|Any CPU - {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release|Any CPU.ActiveCfg = Release|Any CPU {33691BB5-DD5B-4FED-8EE3-52CEE0DE2550}.Release|Any CPU.Build.0 = Release|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU {172BD8C4-5C3E-4928-9D3F-746CF336FFEC}.Release|Any CPU.Build.0 = Release|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B1E5420-E8F3-4B5F-A11A-4D18578F50CE}.Release|Any CPU.Build.0 = Release|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.ActiveCfg = Release|Any CPU {513F9ABD-4FB8-4AC1-89DA-C3300399F34C}.Release|Any CPU.Build.0 = Release|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E23D7AD-0B21-4725-87C4-BD43271260A1}.Release|Any CPU.Build.0 = Release|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {134E9066-6217-4AF0-B408-47D92AB595BD}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.ActiveCfg = Release|Any CPU {134E9066-6217-4AF0-B408-47D92AB595BD}.Release|Any CPU.Build.0 = Release|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug_CSharp8|Any CPU.ActiveCfg = Debug_CSharp8|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug_CSharp8|Any CPU.Build.0 = Debug_CSharp8|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release_CSharp8|Any CPU.ActiveCfg = Release_CSharp8|Any CPU - {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release_CSharp8|Any CPU.Build.0 = Release_CSharp8|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {974056C0-91BD-4EB6-8431-E30A614FD1D4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj index 6cdbe5f13d..2bfd2ccfa1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj @@ -3,7 +3,6 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 - Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index 4411fce272..c716f03892 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -5,7 +5,6 @@ Interactive Extensions - Async Providers Library net45;net46;netstandard1.4;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous - Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index eb09eff87d..c3405f7184 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -3,7 +3,6 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 - Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index ee2ef3e03b..8d9ff6de02 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -5,7 +5,6 @@ Interactive Extensions - Async Library net45;net46;netstandard1.4;netstandard2.0 Ix;Interactive;Extensions;Enumerable;Asynchronous - Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj index 1284677956..e1c1ca58e1 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -3,7 +3,6 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 - Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index bbb69adbca..69dc5f50b2 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -2,7 +2,6 @@ net45;net46;netstandard1.4;netstandard2.0 - Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index e979ac3d5a..9ce4690a44 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -3,7 +3,6 @@ netcoreapp2.1;net461 $(NoWarn);CS0618 - Debug;Release;Debug_CSharp8;Release_CSharp8 diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 4d86a70f97..72ae7239e9 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -2,7 +2,6 @@ net45;net46;netstandard1.4;netstandard2.0 - Debug;Release;Debug_CSharp8;Release_CSharp8 From b9f9514d57019d45a4f5e3477dde84a481a2563e Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 10:36:50 -0500 Subject: [PATCH 611/862] Revert "Use only var when type is obvious." --- .editorconfig | 268 ++++++++---- .../System/Linq/Operators/Amb.cs | 24 +- .../System/Linq/Operators/Buffer.cs | 4 +- .../System/Linq/Operators/Catch.cs | 12 +- .../System/Linq/Operators/Distinct.cs | 42 +- .../Linq/Operators/DistinctUntilChanged.cs | 14 +- .../System/Linq/Operators/Expand.cs | 18 +- .../System/Linq/Operators/Max.cs | 6 +- .../System/Linq/Operators/Merge.cs | 14 +- .../System/Linq/Operators/Min.cs | 6 +- .../System/Linq/Operators/MinBy.cs | 36 +- .../System/Linq/Operators/Retry.cs | 4 +- .../System/Linq/Operators/Scan.cs | 12 +- .../System/Linq/Operators/Throw.cs | 2 +- .../System/Linq/Operators/Timeout.cs | 6 +- .../System/Linq/AsyncEnumerableRewriter.cs | 52 +-- .../System/Linq/AsyncEnumerableHelpers.cs | 15 +- .../System/Linq/AsyncEnumerablePartition.cs | 36 +- .../System/Linq/AsyncEnumerator.cs | 2 +- .../System/Linq/AsyncIterator.cs | 2 +- .../System/Linq/AsyncListPartition.cs | 36 +- .../System/Linq/Disposables.cs | 4 +- .../System/Linq/Operators/Aggregate.cs | 32 +- .../System/Linq/Operators/All.cs | 6 +- .../System/Linq/Operators/Any.cs | 8 +- .../System/Linq/Operators/AppendPrepend.cs | 42 +- .../Linq/Operators/Average.Generated.cs | 1 + .../System/Linq/Operators/Average.cs | 245 ++++------- .../System/Linq/Operators/Concat.cs | 10 +- .../System/Linq/Operators/Contains.cs | 2 +- .../System/Linq/Operators/Count.cs | 8 +- .../System/Linq/Operators/DefaultIfEmpty.cs | 4 +- .../System/Linq/Operators/Distinct.cs | 8 +- .../System/Linq/Operators/ElementAt.cs | 4 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/Except.cs | 2 +- .../System/Linq/Operators/First.cs | 8 +- .../System/Linq/Operators/FirstOrDefault.cs | 22 +- .../System/Linq/Operators/ForEach.cs | 8 +- .../System/Linq/Operators/GroupBy.cs | 30 +- .../System/Linq/Operators/GroupJoin.cs | 18 +- .../System/Linq/Operators/Intersect.cs | 2 +- .../System/Linq/Operators/Join.cs | 12 +- .../System/Linq/Operators/Last.cs | 8 +- .../System/Linq/Operators/LastOrDefault.cs | 25 +- .../System/Linq/Operators/LongCount.cs | 8 +- .../System/Linq/Operators/Lookup.cs | 179 ++++---- .../System/Linq/Operators/Max.Generic.cs | 40 +- .../System/Linq/Operators/Max.Primitive.cs | 364 +++++++--------- .../System/Linq/Operators/Min.Generic.cs | 40 +- .../System/Linq/Operators/Min.Primitive.cs | 388 +++++++----------- .../System/Linq/Operators/OfType.cs | 3 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 24 +- .../System/Linq/Operators/Range.cs | 8 +- .../System/Linq/Operators/Reverse.cs | 6 +- .../System/Linq/Operators/Select.cs | 30 +- .../System/Linq/Operators/SelectMany.cs | 24 +- .../System/Linq/Operators/SequenceEqual.cs | 4 +- .../System/Linq/Operators/Single.cs | 16 +- .../System/Linq/Operators/SingleLinkedNode.cs | 8 +- .../System/Linq/Operators/SingleOrDefault.cs | 16 +- .../System/Linq/Operators/SkipLast.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 12 +- .../System/Linq/Operators/Sum.Generated.cs | 220 +++++----- .../System/Linq/Operators/Sum.Generated.tt | 23 +- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/TakeWhile.cs | 12 +- .../Operators/ToAsyncEnumerable.Observable.cs | 8 +- .../System/Linq/Operators/ToDictionary.cs | 24 +- .../System/Linq/Operators/ToEnumerable.cs | 6 +- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/ToObservable.cs | 2 +- .../System/Linq/Operators/Union.cs | 24 +- .../System/Linq/Operators/Where.cs | 14 +- .../System.Linq.Async/System/Linq/Set.cs | 32 +- 76 files changed, 1239 insertions(+), 1428 deletions(-) diff --git a/.editorconfig b/.editorconfig index bdb8ab95f6..8ad1e1b8b2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,104 +1,216 @@ -# editorconfig.org +# EditorConfig is awesome:http://EditorConfig.org +# From https://raw.githubusercontent.com/dotnet/roslyn/master/.editorconfig # top-most EditorConfig file root = true -# Default settings: -# A newline ending every file -# Use 4 spaces as indentation +# Don't use tabs for indentation. [*] -insert_final_newline = true indent_style = space +trim_trailing_whitespace = true +# (Please don't specify an indent_size here; that has too many unintended consequences.) + +# Code files +[*.{cs,csx,vb,vbx}] indent_size = 4 +insert_final_newline = true +charset = utf-8-bom -[project.json] +# Xml project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] indent_size = 2 -# C# files -[*.cs] -# New line preferences -csharp_new_line_before_open_brace = all -csharp_new_line_before_else = true -csharp_new_line_before_catch = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_between_query_expression_clauses = true +# Xml config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_switch_labels = true -csharp_indent_labels = one_less_than_current +# Yml/Yaml files +[*.{yaml,yml}] +indent_size = 2 + +# Powershell files +[*.ps1] +indent_size = 2 + +# JSON files +[*.json] +indent_size = 2 -# avoid this. unless absolutely necessary +# Shell scripts +[*.sh] +end_of_line = lf + +[*.{cmd,bat}] +end_of_line = crlf + +# Dotnet code style settings: +[*.{cs,vb}] +# Sort using and Import directives with System.* appearing first +dotnet_sort_system_directives_first = true +# Put a blank line between System.* and Microsoft.* +dotnet_separate_import_directive_groups = true + +# Avoid "this." and "Me." if not necessary dotnet_style_qualification_for_field = false:suggestion dotnet_style_qualification_for_property = false:suggestion dotnet_style_qualification_for_method = false:suggestion dotnet_style_qualification_for_event = false:suggestion -# only use var when it's obvious what the variable type is -csharp_style_var_for_built_in_types = false:none -csharp_style_var_when_type_is_apparent = false:none -csharp_style_var_elsewhere = false:suggestion - -# use language keywords instead of BCL types +# Use language keywords instead of framework type names for type references dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion dotnet_style_predefined_type_for_member_access = true:suggestion -# name all constant fields using PascalCase -dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields -dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +# Prefer read-only on fields +dotnet_style_readonly_field = true:warning + +# Suggest more modern language features when available +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = false +dotnet_style_prefer_conditional_expression_over_assignment = false +dotnet_style_prefer_auto_properties = true:suggestion + +# Parentheses +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Accessibility modifiers +dotnet_style_require_accessibility_modifiers = always:suggestion + + +# Naming Rules + +# Interfaces start with an I and are PascalCased +dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.symbols = interface_symbols +dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.style = pascal_case_and_prefix_with_I_style +dotnet_naming_rule.interfaces_must_be_pascal_cased_and_prefixed_with_I.severity = warning + +# External members are PascalCased +dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.symbols = externally_visible_symbols +dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.style = pascal_case_style +dotnet_naming_rule.externally_visible_members_must_be_pascal_cased.severity = warning + +# Parameters are camelCased +dotnet_naming_rule.parameters_must_be_camel_cased.symbols = parameter_symbols +dotnet_naming_rule.parameters_must_be_camel_cased.style = camel_case_style +dotnet_naming_rule.parameters_must_be_camel_cased.severity = warning + +# Constants are PascalCased +dotnet_naming_rule.constants_must_be_pascal_cased.symbols = constant_symbols +dotnet_naming_rule.constants_must_be_pascal_cased.style = pascal_case_style +dotnet_naming_rule.constants_must_be_pascal_cased.severity = warning + +# Uncomment this group and comment out the next group if you prefer s_ prefixes for static fields + +# Private static fields are prefixed with s_ and are camelCased like s_myStatic +#dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.symbols = private_static_field_symbols +#dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.style = camel_case_and_prefix_with_s_underscore_style +#dotnet_naming_rule.private_static_fields_must_be_camel_cased_and_prefixed_with_s_underscore.severity = warning -dotnet_naming_symbols.constant_fields.applicable_kinds = field -dotnet_naming_symbols.constant_fields.required_modifiers = const +# Static readonly fields are PascalCased +dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.symbols = private_static_readonly_field_symbols +dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = warning -dotnet_naming_style.pascal_case_style.capitalization = pascal_case +# Comment this group and uncomment out the next group if you don't want _ prefixed fields. -# static fields should have s_ prefix -dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion -dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields -dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style +# Private instance fields are camelCased with an _ like _myField +dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.symbols = private_field_symbols +dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.style = camel_case_and_prefix_with_underscore_style +dotnet_naming_rule.private_instance_fields_must_be_camel_cased_and_prefixed_with_underscore.severity = warning -dotnet_naming_symbols.static_fields.applicable_kinds = field -dotnet_naming_symbols.static_fields.required_modifiers = static +# Private instance fields are camelCased +#dotnet_naming_rule.private_instance_fields_must_be_camel_cased.symbols = private_field_symbols +#dotnet_naming_rule.private_instance_fields_must_be_camel_cased.style = camel_case_style +#dotnet_naming_rule.private_instance_fields_must_be_camel_cased.severity = warning -dotnet_naming_style.static_prefix_style.required_prefix = s_ -dotnet_naming_style.static_prefix_style.capitalization = camel_case +# Symbols +dotnet_naming_symbols.externally_visible_symbols.applicable_kinds = class,struct,interface,enum,property,method,field,event,delegate +dotnet_naming_symbols.externally_visible_symbols.applicable_accessibilities = public,internal,friend,protected,protected_internal,protected_friend,private_protected -# internal and private fields should be _camelCase -dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion -dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style +dotnet_naming_symbols.interface_symbols.applicable_kinds = interface +dotnet_naming_symbols.interface_symbols.applicable_accessibilities = * -dotnet_naming_symbols.private_internal_fields.applicable_kinds = field -dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal +dotnet_naming_symbols.parameter_symbols.applicable_kinds = parameter +dotnet_naming_symbols.parameter_symbols.applicable_accessibilities = * -dotnet_naming_style.camel_case_underscore_style.required_prefix = _ -dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case +dotnet_naming_symbols.constant_symbols.applicable_kinds = field +dotnet_naming_symbols.constant_symbols.required_modifiers = const +dotnet_naming_symbols.constant_symbols.applicable_accessibilities = * + +dotnet_naming_symbols.private_static_field_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_field_symbols.required_modifiers = static,shared +dotnet_naming_symbols.private_static_field_symbols.applicable_accessibilities = private + +dotnet_naming_symbols.private_static_readonly_field_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_field_symbols.required_modifiers = static,shared,readonly +dotnet_naming_symbols.private_static_readonly_field_symbols.applicable_accessibilities = private + +dotnet_naming_symbols.private_field_symbols.applicable_kinds = field +dotnet_naming_symbols.private_field_symbols.applicable_accessibilities = private + +# Styles +dotnet_naming_style.camel_case_style.capitalization = camel_case + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.required_prefix = s_ +dotnet_naming_style.camel_case_and_prefix_with_s_underscore_style.capitalization = camel_case + +dotnet_naming_style.camel_case_and_prefix_with_underscore_style.required_prefix = _ +dotnet_naming_style.camel_case_and_prefix_with_underscore_style.capitalization = camel_case + +dotnet_naming_style.pascal_case_and_prefix_with_I_style.required_prefix = I +dotnet_naming_style.pascal_case_and_prefix_with_I_style.capitalization = pascal_case + + +# CSharp code style settings: +[*.cs] +# Modifier order +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion + +# Code block +csharp_prefer_braces = false:none + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left + +# Prefer "var" everywhere +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_var_elsewhere = true:suggestion # Code style defaults -dotnet_sort_system_directives_first = true csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = false +csharp_preserve_single_line_statements = true -# Expression-level preferences -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_null_propagation = true:suggestion - -# Expression-bodied members +# Prefer method-like constructs to have a block body csharp_style_expression_bodied_methods = false:none csharp_style_expression_bodied_constructors = false:none csharp_style_expression_bodied_operators = false:none + +# Prefer property-like constructs to have an expression-body csharp_style_expression_bodied_properties = true:none csharp_style_expression_bodied_indexers = true:none csharp_style_expression_bodied_accessors = true:none +# Expression +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion + # Pattern matching csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion csharp_style_pattern_matching_over_as_with_null_check = true:suggestion @@ -108,6 +220,15 @@ csharp_style_inlined_variable_declaration = true:suggestion csharp_style_throw_expression = true:suggestion csharp_style_conditional_delegate_call = true:suggestion +# Newline settings +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + # Space preferences csharp_space_after_cast = false csharp_space_after_colon_in_inheritance_clause = true @@ -132,29 +253,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false csharp_space_between_square_brackets = false -# C++ Files -[*.{cpp,h,in}] -curly_bracket_next_line = true -indent_brace_style = Allman -# Xml project files -[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] -indent_size = 2 -# Xml build files -[*.builds] -indent_size = 2 -# Xml files -[*.{xml,stylecop,resx,ruleset}] -indent_size = 2 -# Xml config files -[*.{props,targets,config,nuspec}] -indent_size = 2 -# Shell scripts -[*.sh] -end_of_line = lf -[*.{cmd, bat}] -end_of_line = crlf \ No newline at end of file + + diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 2ec0088f5b..436c13c62f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -73,13 +73,13 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - IAsyncEnumerator firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); - IAsyncEnumerator secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); + var firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); + var secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); - Task firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); - Task secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); + var firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); + var secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); - Task winner = await Task.WhenAny(firstMoveNext, secondMoveNext).ConfigureAwait(false); + var winner = await Task.WhenAny(firstMoveNext, secondMoveNext).ConfigureAwait(false); // // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: @@ -94,7 +94,7 @@ protected override async ValueTask MoveNextCore() { _enumerator = firstEnumerator; - Task ignored = secondMoveNext.ContinueWith(_ => + var ignored = secondMoveNext.ContinueWith(_ => { secondEnumerator.DisposeAsync(); }); @@ -103,7 +103,7 @@ protected override async ValueTask MoveNextCore() { _enumerator = secondEnumerator; - Task ignored = firstMoveNext.ContinueWith(_ => + var ignored = firstMoveNext.ContinueWith(_ => { firstEnumerator.DisposeAsync(); }); @@ -168,20 +168,20 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - int n = _sources.Length; + var n = _sources.Length; var enumerators = new IAsyncEnumerator[n]; var moveNexts = new ValueTask[n]; for (var i = 0; i < n; i++) { - IAsyncEnumerator enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); + var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); enumerators[i] = enumerator; moveNexts[i] = enumerator.MoveNextAsync(); } - Task winner = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); + var winner = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); // // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: @@ -192,7 +192,7 @@ protected override async ValueTask MoveNextCore() // The approach below has one drawback, namely that exceptions raised by any loser are dropped on the floor. // - int winnerIndex = Array.IndexOf(moveNexts, winner); + var winnerIndex = Array.IndexOf(moveNexts, winner); _enumerator = enumerators[winnerIndex]; @@ -200,7 +200,7 @@ protected override async ValueTask MoveNextCore() { if (i != winnerIndex) { - Task ignored = moveNexts[i].AsTask().ContinueWith(_ => + var ignored = moveNexts[i].AsTask().ContinueWith(_ => { enumerators[i].DisposeAsync(); }); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 96b8d740a2..dd688ee6ad 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -91,14 +91,14 @@ protected override async ValueTask MoveNextCore() { if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (_index++ % _skip == 0) { _buffers.Enqueue(new List(_count)); } - foreach (IList buffer in _buffers) + foreach (var buffer in _buffers) { buffer.Add(item); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 4608447723..05d077ad0d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -140,8 +140,8 @@ protected override async ValueTask MoveNextCore() // Note: Ideally we'd dispose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - IAsyncEnumerable inner = _handler(ex); - IAsyncEnumerator err = inner.GetAsyncEnumerator(_cancellationToken); + var inner = _handler(ex); + var err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { @@ -233,8 +233,8 @@ protected override async ValueTask MoveNextCore() // Note: Ideally we'd dispose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - IAsyncEnumerable inner = await _handler(ex).ConfigureAwait(false); - IAsyncEnumerator err = inner.GetAsyncEnumerator(_cancellationToken); + var inner = await _handler(ex).ConfigureAwait(false); + var err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { @@ -327,8 +327,8 @@ protected override async ValueTask MoveNextCore() // Note: Ideally we'd dispose of the previous enumerator before // invoking the handler, but we use this order to preserve // current behavior - IAsyncEnumerable inner = await _handler(ex, _cancellationToken).ConfigureAwait(false); - IAsyncEnumerator err = inner.GetAsyncEnumerator(_cancellationToken); + var inner = await _handler(ex, _cancellationToken).ConfigureAwait(false); + var err = inner.GetAsyncEnumerator(_cancellationToken); if (_enumerator != null) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs index 9e1056c556..c062547f33 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Distinct.cs @@ -113,13 +113,13 @@ public DistinctAsyncIterator(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) { - List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } @@ -133,13 +133,13 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca var count = 0; var s = new Set(_comparer); - IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TSource item = enu.Current; + var item = enu.Current; if (s.Add(_keySelector(item))) { @@ -185,7 +185,7 @@ protected override async ValueTask MoveNextCore() return false; } - TSource element = _enumerator.Current; + var element = _enumerator.Current; _set = new Set(_comparer); _set.Add(_keySelector(element)); _current = element; @@ -217,13 +217,13 @@ private async Task> FillSetAsync(CancellationToken cancellationTok var s = new Set(_comparer); var r = new List(); - IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TSource item = enu.Current; + var item = enu.Current; if (s.Add(_keySelector(item))) { @@ -261,13 +261,13 @@ public DistinctAsyncIteratorWithTask(IAsyncEnumerable source, Func ToArrayAsync(CancellationToken cancellationToken) { - List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } @@ -281,13 +281,13 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca var count = 0; var s = new Set(_comparer); - IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TSource item = enu.Current; + var item = enu.Current; if (s.Add(await _keySelector(item).ConfigureAwait(false))) { @@ -333,7 +333,7 @@ protected override async ValueTask MoveNextCore() return false; } - TSource element = _enumerator.Current; + var element = _enumerator.Current; _set = new Set(_comparer); _set.Add(await _keySelector(element).ConfigureAwait(false)); _current = element; @@ -365,13 +365,13 @@ private async ValueTask> FillSetAsync(CancellationToken cancellati var s = new Set(_comparer); var r = new List(); - IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TSource item = enu.Current; + var item = enu.Current; if (s.Add(await _keySelector(item).ConfigureAwait(false))) { @@ -410,13 +410,13 @@ public DistinctAsyncIteratorWithTaskAndCancellation(IAsyncEnumerable so public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - List s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s; } @@ -430,13 +430,13 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca var count = 0; var s = new Set(_comparer); - IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TSource item = enu.Current; + var item = enu.Current; if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) { @@ -482,7 +482,7 @@ protected override async ValueTask MoveNextCore() return false; } - TSource element = _enumerator.Current; + var element = _enumerator.Current; _set = new Set(_comparer); _set.Add(await _keySelector(element, _cancellationToken).ConfigureAwait(false)); _current = element; @@ -514,13 +514,13 @@ private async ValueTask> FillSetAsync(CancellationToken cancellati var s = new Set(_comparer); var r = new List(); - IAsyncEnumerator enu = _source.GetAsyncEnumerator(cancellationToken); + var enu = _source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TSource item = enu.Current; + var item = enu.Current; if (s.Add(await _keySelector(item, cancellationToken).ConfigureAwait(false))) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 98f020c2cf..885dc3faf9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -159,7 +159,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; var comparerEquals = false; if (_hasCurrentValue) @@ -230,8 +230,8 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; - TKey key = _keySelector(item); + var item = _enumerator.Current; + var key = _keySelector(item); var comparerEquals = false; if (_hasCurrentKey) @@ -302,8 +302,8 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; - TKey key = await _keySelector(item).ConfigureAwait(false); + var item = _enumerator.Current; + var key = await _keySelector(item).ConfigureAwait(false); var comparerEquals = false; if (_hasCurrentKey) @@ -375,8 +375,8 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; - TKey key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + var item = _enumerator.Current; + var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); var comparerEquals = false; if (_hasCurrentKey) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index cac1a2a377..bb7aeda337 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -97,7 +97,7 @@ protected override async ValueTask MoveNextCore() { if (_queue.Count > 0) { - IAsyncEnumerable src = _queue.Dequeue(); + var src = _queue.Dequeue(); if (_enumerator != null) { @@ -114,8 +114,8 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; - IAsyncEnumerable next = _selector(item); + var item = _enumerator.Current; + var next = _selector(item); _queue.Enqueue(next); _current = item; return true; @@ -187,7 +187,7 @@ protected override async ValueTask MoveNextCore() { if (_queue.Count > 0) { - IAsyncEnumerable src = _queue.Dequeue(); + var src = _queue.Dequeue(); if (_enumerator != null) { @@ -204,8 +204,8 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; - IAsyncEnumerable next = await _selector(item).ConfigureAwait(false); + var item = _enumerator.Current; + var next = await _selector(item).ConfigureAwait(false); _queue.Enqueue(next); _current = item; return true; @@ -278,7 +278,7 @@ protected override async ValueTask MoveNextCore() { if (_queue.Count > 0) { - IAsyncEnumerable src = _queue.Dequeue(); + var src = _queue.Dequeue(); if (_enumerator != null) { @@ -295,8 +295,8 @@ protected override async ValueTask MoveNextCore() if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; - IAsyncEnumerable next = await _selector(item, _cancellationToken).ConfigureAwait(false); + var item = _enumerator.Current; + var next = await _selector(item, _cancellationToken).ConfigureAwait(false); _queue.Enqueue(next); _current = item; return true; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 988813b566..2e2e49a537 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -33,18 +33,18 @@ private static async Task MaxCore(IAsyncEnumerable so comparer = Comparer.Default; } - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - TSource max = e.Current; + var max = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource cur = e.Current; + var cur = e.Current; if (comparer.Compare(cur, max) > 0) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 20551cd6fb..aedf933ac4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -58,13 +58,13 @@ public override async ValueTask DisposeAsync() { if (_enumerators != null) { - int n = _enumerators.Length; + var n = _enumerators.Length; var disposes = new ValueTask[n]; for (var i = 0; i < n; i++) { - ValueTask dispose = _enumerators[i].DisposeAsync(); + var dispose = _enumerators[i].DisposeAsync(); disposes[i] = dispose; } @@ -80,7 +80,7 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: - int n = _sources.Length; + var n = _sources.Length; _enumerators = new IAsyncEnumerator[n]; _moveNexts = new ValueTask[n]; @@ -88,7 +88,7 @@ protected override async ValueTask MoveNextCore() for (var i = 0; i < n; i++) { - IAsyncEnumerator enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); + var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); _enumerators[i] = enumerator; _moveNexts[i] = enumerator.MoveNextAsync(); } @@ -105,9 +105,9 @@ protected override async ValueTask MoveNextCore() // want to consider a "prefer fairness" option. // - Task moveNext = await Task.WhenAny(_moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); + var moveNext = await Task.WhenAny(_moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); - int index = Array.IndexOf(_moveNexts, moveNext); + var index = Array.IndexOf(_moveNexts, moveNext); if (!await moveNext.ConfigureAwait(false)) { @@ -116,7 +116,7 @@ protected override async ValueTask MoveNextCore() } else { - IAsyncEnumerator enumerator = _enumerators[index]; + var enumerator = _enumerators[index]; _current = enumerator.Current; _moveNexts[index] = enumerator.MoveNextAsync(); return true; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 81cdd27151..09337d7636 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -33,18 +33,18 @@ private static async Task MinCore(IAsyncEnumerable so comparer = Comparer.Default; } - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - TSource min = e.Current; + var min = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource cur = e.Current; + var cur = e.Current; if (comparer.Compare(cur, min) < 0) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 6e0416d3e6..b192cf6bf8 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -150,23 +150,23 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - TSource current = e.Current; - TKey resKey = keySelector(current); + var current = e.Current; + var resKey = keySelector(current); result.Add(current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource cur = e.Current; - TKey key = keySelector(cur); + var cur = e.Current; + var key = keySelector(cur); - int cmp = compare(key, resKey); + var cmp = compare(key, resKey); if (cmp == 0) { @@ -191,23 +191,23 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - TSource current = e.Current; - TKey resKey = await keySelector(current).ConfigureAwait(false); + var current = e.Current; + var resKey = await keySelector(current).ConfigureAwait(false); result.Add(current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource cur = e.Current; - TKey key = await keySelector(cur).ConfigureAwait(false); + var cur = e.Current; + var key = await keySelector(cur).ConfigureAwait(false); - int cmp = compare(key, resKey); + var cmp = compare(key, resKey); if (cmp == 0) { @@ -233,23 +233,23 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { if (!await e.MoveNextAsync().ConfigureAwait(false)) throw Error.NoElements(); - TSource current = e.Current; - TKey resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); + var current = e.Current; + var resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); result.Add(current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource cur = e.Current; - TKey key = await keySelector(cur, cancellationToken).ConfigureAwait(false); + var cur = e.Current; + var key = await keySelector(cur, cancellationToken).ConfigureAwait(false); - int cmp = compare(key, resKey); + var cmp = compare(key, resKey); if (cmp == 0) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs index 87c9c076ca..8ef41c117c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Retry.cs @@ -30,7 +30,7 @@ private static IEnumerable Repeat(this IEnumerable so { while (true) { - foreach (TSource item in source) + foreach (var item in source) { yield return item; } @@ -41,7 +41,7 @@ private static IEnumerable Repeat(this IEnumerable so { for (var i = 0; i < count; i++) { - foreach (TSource item in source) + foreach (var item in source) { yield return item; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 2068402fe1..a9467cde4a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -127,7 +127,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (!_hasSeed) { @@ -200,7 +200,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; _accumulated = _accumulator(_accumulated, item); _current = _accumulated; return true; @@ -266,7 +266,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (!_hasSeed) { @@ -342,7 +342,7 @@ protected override async ValueTask MoveNextCore() while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (!_hasSeed) { @@ -416,7 +416,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; _accumulated = await _accumulator(_accumulated, item).ConfigureAwait(false); _current = _accumulated; return true; @@ -482,7 +482,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; _accumulated = await _accumulator(_accumulated, item, _cancellationToken).ConfigureAwait(false); _current = _accumulated; return true; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs index 0f661c8681..aecc4352da 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Throw.cs @@ -61,7 +61,7 @@ public ValueTask DisposeAsync() public ValueTask MoveNextAsync() { - ValueTask result = _moveNextThrows; + var result = _moveNextThrows; _moveNextThrows = new ValueTask(false); return result; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs index aaefcbcd54..ff56076096 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Timeout.cs @@ -73,7 +73,7 @@ protected override async ValueTask MoveNextCore() goto case AsyncIteratorState.Iterating; case AsyncIteratorState.Iterating: - ValueTask moveNext = _enumerator.MoveNextAsync(); + var moveNext = _enumerator.MoveNextAsync(); if (!moveNext.IsCompleted) { @@ -81,9 +81,9 @@ protected override async ValueTask MoveNextCore() { var delay = Task.Delay(_timeout, delayCts.Token); - Task next = moveNext.AsTask(); + var next = moveNext.AsTask(); - Task winner = await Task.WhenAny(next, delay).ConfigureAwait(false); + var winner = await Task.WhenAny(next, delay).ConfigureAwait(false); if (winner == delay) { diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs index f555e2c800..fa691301b6 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs @@ -15,7 +15,7 @@ namespace System.Linq /// internal class AsyncEnumerableRewriter : ExpressionVisitor { - private static volatile ILookup s_methods; + private static volatile ILookup _methods; protected override Expression VisitConstant(ConstantExpression node) { @@ -34,7 +34,7 @@ protected override Expression VisitConstant(ConstantExpression node) // if (enumerableQuery.Enumerable != null) { - Type publicType = GetPublicType(enumerableQuery.Enumerable.GetType()); + var publicType = GetPublicType(enumerableQuery.Enumerable.GetType()); return Expression.Constant(enumerableQuery.Enumerable, publicType); } @@ -46,8 +46,8 @@ protected override Expression VisitConstant(ConstantExpression node) protected override Expression VisitMethodCall(MethodCallExpression node) { - Expression obj = Visit(node.Object); - ReadOnlyCollection args = Visit(node.Arguments); + var obj = Visit(node.Object); + var args = Visit(node.Arguments); // // Nothing changed during the visit; just some unrelated method call that can @@ -58,7 +58,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node) return node; } - Type[] typeArgs = node.Method.IsGenericMethod ? node.Method.GetGenericArguments() : null; + var typeArgs = node.Method.IsGenericMethod ? node.Method.GetGenericArguments() : null; // // Check whether the method is compatible with the recursively rewritten instance @@ -115,11 +115,11 @@ private static Type GetPublicType(Type type) return type; } - foreach (Type ifType in type.GetInterfaces()) + foreach (var ifType in type.GetInterfaces()) { if (ifType.IsGenericType()) { - Type def = ifType.GetGenericTypeDefinition(); + var def = ifType.GetGenericTypeDefinition(); if (def == typeof(IAsyncEnumerable<>) || def == typeof(IAsyncGrouping<,>)) { return ifType; @@ -143,7 +143,7 @@ private static bool ArgsMatch(MethodInfo method, ReadOnlyCollection // // Number of parameters should match the number of arguments to bind. // - ParameterInfo[] parameters = method.GetParameters(); + var parameters = method.GetParameters(); if (parameters.Length != args.Count) { return false; @@ -198,7 +198,7 @@ private static bool ArgsMatch(MethodInfo method, ReadOnlyCollection // for (var i = 0; i < args.Count; i++) { - Type type = parameters[i].ParameterType; + var type = parameters[i].ParameterType; // // Hardening against reflection quirks. @@ -218,7 +218,7 @@ private static bool ArgsMatch(MethodInfo method, ReadOnlyCollection type = type.GetElementType(); } - Expression expression = args[i]; + var expression = args[i]; // // If the expression is assignable to the parameter, all is good. If not, @@ -255,7 +255,7 @@ private static ReadOnlyCollection FixupQuotedArgs(MethodInfo method, // // Get all of the method parameters. No fix-up needed if empty. // - ParameterInfo[] parameters = method.GetParameters(); + var parameters = method.GetParameters(); if (parameters.Length != 0) { var list = default(List); @@ -266,8 +266,8 @@ private static ReadOnlyCollection FixupQuotedArgs(MethodInfo method, // for (var i = 0; i < parameters.Length; i++) { - Expression expression = argList[i]; - ParameterInfo parameterInfo = parameters[i]; + var expression = argList[i]; + var parameterInfo = parameters[i]; // // Perform the fix-up if needed and check the outcome. If a @@ -305,7 +305,7 @@ private static ReadOnlyCollection FixupQuotedArgs(MethodInfo method, private static Expression FixupQuotedExpression(Type type, Expression expression) { - Expression res = expression; + var res = expression; // // Keep unquoting until assignability checks pass. @@ -322,13 +322,13 @@ private static Expression FixupQuotedExpression(Type type, Expression expression // if (!type.IsAssignableFrom(res.Type) && type.IsArray && res.NodeType == ExpressionType.NewArrayInit) { - Type unquotedType = StripExpression(res.Type); + var unquotedType = StripExpression(res.Type); if (type.IsAssignableFrom(unquotedType)) { var newArrayExpression = (NewArrayExpression)res; var count = newArrayExpression.Expressions.Count; - Type elementType = type.GetElementType(); + var elementType = type.GetElementType(); var list = new List(count); for (var i = 0; i < count; i++) @@ -357,12 +357,12 @@ private static Type StripExpression(Type type) // // Array of quotes need to be stripped, so extract the element type. // - Type elemType = type.IsArray ? type.GetElementType() : type; + var elemType = type.IsArray ? type.GetElementType() : type; // // Try to find Expression and obtain T. // - Type genType = FindGenericType(typeof(Expression<>), elemType); + var genType = FindGenericType(typeof(Expression<>), elemType); if (genType != null) { elemType = genType.GetGenericArguments()[0]; @@ -393,15 +393,15 @@ private static MethodInfo FindEnumerableMethod(string name, ReadOnlyCollection m.Name); + _methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.Static | BindingFlags.Public).ToLookup(m => m.Name); } // // Find a match based on the method name and the argument types. // - MethodInfo method = s_methods[name].FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); + var method = _methods[name].FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); if (method == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find method with name '{0}' on type '{1}'.", name, typeof(Enumerable))); @@ -423,12 +423,12 @@ private static MethodInfo FindMethod(Type type, string name, ReadOnlyCollection< // // Support the enumerable methods to be defined on another type. // - Type targetType = type.GetTypeInfo().GetCustomAttribute()?.TargetType ?? type; + var targetType = type.GetTypeInfo().GetCustomAttribute()?.TargetType ?? type; // // Get all the candidates based on name and fail if none are found. // - MethodInfo[] methods = targetType.GetMethods(flags).Where(m => m.Name == name).ToArray(); + var methods = targetType.GetMethods(flags).Where(m => m.Name == name).ToArray(); if (methods.Length == 0) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find method with name '{0}' on type '{1}'.", name, type)); @@ -437,7 +437,7 @@ private static MethodInfo FindMethod(Type type, string name, ReadOnlyCollection< // // Find a match based on arguments and fail if no match is found. // - MethodInfo method = methods.FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); + var method = methods.FirstOrDefault(m => ArgsMatch(m, args, typeArgs)); if (method == null) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find a matching method with name '{0}' on type '{1}'.", name, type)); @@ -471,9 +471,9 @@ private static Type FindGenericType(Type definition, Type type) // if (definition.IsInterface()) { - foreach (Type ifType in type.GetInterfaces()) + foreach (var ifType in type.GetInterfaces()) { - Type res = FindGenericType(definition, ifType); + var res = FindGenericType(definition, ifType); if (res != null) { return res; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index c2657aeed4..97ab453312 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -13,7 +13,7 @@ internal static class AsyncEnumerableHelpers { internal static async ValueTask ToArray(IAsyncEnumerable source, CancellationToken cancellationToken) { - ArrayWithLength result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false); + var result = await ToArrayWithLength(source, cancellationToken).ConfigureAwait(false); Array.Resize(ref result.Array, result.Length); return result.Array; } @@ -23,13 +23,11 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE cancellationToken.ThrowIfCancellationRequested(); var result = new ArrayWithLength(); - // Check for short circuit optimizations. This one is very unlikely // but could be here as a group if (source is ICollection ic) { - int count = ic.Count; - + var count = ic.Count; if (count != 0) { // Allocate an array of the desired size, then copy the elements into it. Note that this has the same @@ -46,17 +44,15 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } else { - IAsyncEnumerator en = source.GetAsyncEnumerator(cancellationToken); + var en = source.GetAsyncEnumerator(cancellationToken); try { if (await en.MoveNextAsync().ConfigureAwait(false)) { const int DefaultCapacity = 4; - var arr = new T[DefaultCapacity]; arr[0] = en.Current; - var count = 1; while (await en.MoveNextAsync().ConfigureAwait(false)) @@ -80,8 +76,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE // larger than that. For that case, we then ensure that the newLength is large enough to hold // the desired capacity. This does mean that in the very rare case where we've grown to such a // large size, each new element added after MaxArrayLength will end up doing a resize. - int newLength = count << 1; - + var newLength = count << 1; if ((uint)newLength > MaxArrayLength) { newLength = MaxArrayLength <= count ? count + 1 : MaxArrayLength; @@ -115,7 +110,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE internal static async Task> ToSet(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs index 7dc059990f..ce928df796 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerablePartition.cs @@ -80,7 +80,7 @@ async ValueTask Core() return Math.Max(await _source.CountAsync(cancellationToken).ConfigureAwait(false) - _minIndexInclusive, 0); } - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -93,7 +93,7 @@ async ValueTask Core() // At the same time, however, we are guaranteed that our max count can fit // in an int because if that is true, then _minIndexInclusive must > 0. - uint count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en).ConfigureAwait(false); + var count = await SkipAndCountAsync((uint)_maxIndexInclusive + 1, en).ConfigureAwait(false); Debug.Assert(count != (uint)int.MaxValue + 1 || _minIndexInclusive > 0, "Our return value will be incorrect."); return Math.Max((int)count - _minIndexInclusive, 0); } @@ -166,8 +166,7 @@ public override IAsyncEnumerable Select(Func Skip(int count) { - int minIndex = _minIndexInclusive + count; - + var minIndex = _minIndexInclusive + count; if (!HasLimit) { if (minIndex < 0) @@ -192,8 +191,7 @@ public IAsyncPartition Skip(int count) public IAsyncPartition Take(int count) { - int maxIndex = _minIndexInclusive + count - 1; - + var maxIndex = _minIndexInclusive + count - 1; if (!HasLimit) { if (maxIndex < 0) @@ -224,7 +222,7 @@ public async ValueTask> TryGetElementAtAsync(int index, Cancellat // If the index is negative or >= our max count, return early. if (index >= 0 && (!HasLimit || index < Limit)) { - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -246,7 +244,7 @@ public async ValueTask> TryGetElementAtAsync(int index, Cancellat public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -265,14 +263,14 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cancel public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { - int remaining = Limit - 1; // Max number of items left, not counting the current element. - int comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + var remaining = Limit - 1; // Max number of items left, not counting the current element. + var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. TSource result; do @@ -295,16 +293,16 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancell public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { - int remaining = Limit - 1; // Max number of items left, not counting the current element. - int comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + var remaining = Limit - 1; // Max number of items left, not counting the current element. + var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. - int maxCapacity = HasLimit ? Limit : int.MaxValue; + var maxCapacity = HasLimit ? Limit : int.MaxValue; var builder = new List(maxCapacity); do @@ -333,14 +331,14 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { if (await SkipBeforeFirstAsync(en).ConfigureAwait(false) && await en.MoveNextAsync().ConfigureAwait(false)) { - int remaining = Limit - 1; // Max number of items left, not counting the current element. - int comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. + var remaining = Limit - 1; // Max number of items left, not counting the current element. + var comparand = HasLimit ? 0 : int.MinValue; // If we don't have an upper bound, have the comparison always return true. do { @@ -362,7 +360,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation private static async ValueTask SkipBeforeAsync(int index, IAsyncEnumerator en) { - int n = await SkipAndCountAsync(index, en).ConfigureAwait(false); + var n = await SkipAndCountAsync(index, en).ConfigureAwait(false); return n == index; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs index e0c7ff533f..fd389f549c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerator.cs @@ -84,7 +84,7 @@ public override AsyncIteratorBase Clone() public override async ValueTask DisposeAsync() { - Func dispose = Interlocked.Exchange(ref _dispose, null); + var dispose = Interlocked.Exchange(ref _dispose, null); if (dispose != null) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs index 132a29db54..21720b8a70 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs @@ -32,7 +32,7 @@ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellati { cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. - AsyncIteratorBase enumerator = _state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId + var enumerator = _state == AsyncIteratorState.New && _threadId == Environment.CurrentManagedThreadId ? this : Clone(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs index bda836973e..02d9f5c7c1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncListPartition.cs @@ -27,7 +27,6 @@ public AsyncListPartition(IList source, int minIndexInclusive, int maxI Debug.Assert(source != null); Debug.Assert(minIndexInclusive >= 0); Debug.Assert(minIndexInclusive <= maxIndexInclusive); - _source = source; _minIndexInclusive = minIndexInclusive; _maxIndexInclusive = maxIndexInclusive; @@ -71,8 +70,7 @@ public override IEnumerable Select(Func Skip(int count) { - int minIndex = _minIndexInclusive + count; - + var minIndex = _minIndexInclusive + count; if ((uint)minIndex > (uint)_maxIndexInclusive) { return AsyncEnumerable.EmptyAsyncIterator.Instance; @@ -85,8 +83,7 @@ public IAsyncPartition Skip(int count) public IAsyncPartition Take(int count) { - int maxIndex = _minIndexInclusive + count - 1; - + var maxIndex = _minIndexInclusive + count - 1; if ((uint)maxIndex >= (uint)_maxIndexInclusive) { return this; @@ -101,7 +98,7 @@ public ValueTask> TryGetElementAtAsync(int index, CancellationTok { if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < _source.Count - _minIndexInclusive) { - TSource res = _source[_minIndexInclusive + index]; + var res = _source[_minIndexInclusive + index]; return new ValueTask>(new Maybe(res)); } @@ -112,7 +109,7 @@ public ValueTask> TryGetFirstAsync(CancellationToken cancellation { if (_source.Count > _minIndexInclusive) { - TSource res = _source[_minIndexInclusive]; + var res = _source[_minIndexInclusive]; return new ValueTask>(new Maybe(res)); } @@ -121,11 +118,10 @@ public ValueTask> TryGetFirstAsync(CancellationToken cancellation public ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { - int lastIndex = _source.Count - 1; - + var lastIndex = _source.Count - 1; if (lastIndex >= _minIndexInclusive) { - TSource res = _source[Math.Min(lastIndex, _maxIndexInclusive)]; + var res = _source[Math.Min(lastIndex, _maxIndexInclusive)]; return new ValueTask>(new Maybe(res)); } @@ -136,8 +132,7 @@ private int Count { get { - int count = _source.Count; - + var count = _source.Count; if (count <= _minIndexInclusive) { return 0; @@ -149,8 +144,7 @@ private int Count public ValueTask ToArrayAsync(CancellationToken cancellationToken) { - int count = Count; - + var count = Count; if (count == 0) { return new ValueTask( @@ -163,7 +157,6 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) } var array = new TSource[count]; - for (int i = 0, curIdx = _minIndexInclusive; i != array.Length; ++i, ++curIdx) { array[i] = _source[curIdx]; @@ -174,17 +167,15 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) public ValueTask> ToListAsync(CancellationToken cancellationToken) { - int count = Count; - + var count = Count; if (count == 0) { return new ValueTask>(new List()); } var list = new List(count); - int end = _minIndexInclusive + count; - - for (int i = _minIndexInclusive; i != end; ++i) + var end = _minIndexInclusive + count; + for (var i = _minIndexInclusive; i != end; ++i) { list.Add(_source[i]); } @@ -192,6 +183,9 @@ public ValueTask> ToListAsync(CancellationToken cancellationToken) return new ValueTask>(list); } - public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(Count); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + return new ValueTask(Count); + } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs index 383a7aa21c..d5fee14f94 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Disposables.cs @@ -41,12 +41,12 @@ public BinaryDisposable(IDisposable d1, IDisposable d2) public void Dispose() { - IDisposable d1 = Interlocked.Exchange(ref _d1, null); + var d1 = Interlocked.Exchange(ref _d1, null); if (d1 != null) { d1.Dispose(); - IDisposable d2 = Interlocked.Exchange(ref _d2, null); + var d2 = Interlocked.Exchange(ref _d2, null); if (d2 != null) { d2.Dispose(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index eede6f3387..b70c1775a6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -178,9 +178,9 @@ public static Task AggregateAsync(this I private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) { - TAccumulate acc = seed; + var acc = seed; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -199,7 +199,7 @@ private static async Task AggregateCore( private static async Task AggregateCore(IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -208,7 +208,7 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) { - TResult acc = seed; + var acc = seed; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -247,9 +247,9 @@ private static async Task AggregateCore(IAsyncEnumera #if !NO_DEEP_CANCELLATION private static async Task AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) { - TResult acc = seed; + var acc = seed; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -269,9 +269,9 @@ private static async Task AggregateCore(IAsyncEnumera private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { - TAccumulate acc = seed; + var acc = seed; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -291,9 +291,9 @@ private static async Task AggregateCore( #if !NO_DEEP_CANCELLATION private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) { - TAccumulate acc = seed; + var acc = seed; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -313,7 +313,7 @@ private static async Task AggregateCore( private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -322,7 +322,7 @@ private static async Task AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -349,7 +349,7 @@ private static async Task AggregateCore(IAsyncEnumerable AllAsync(this IAsyncEnumerable source private static async Task AllCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -84,7 +84,7 @@ private static async Task AllCore(IAsyncEnumerable sourc private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -105,7 +105,7 @@ private static async Task AllCore(IAsyncEnumerable sourc #if !NO_DEEP_CANCELLATION private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 19c033eda2..eecd57d415 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -80,7 +80,7 @@ public static Task AnyAsync(this IAsyncEnumerable source private static async Task AnyCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -94,7 +94,7 @@ private static async Task AnyCore(IAsyncEnumerable sourc private static async Task AnyCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -114,7 +114,7 @@ private static async Task AnyCore(IAsyncEnumerable sourc private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -135,7 +135,7 @@ private static async Task AnyCore(IAsyncEnumerable sourc #if !NO_DEEP_CANCELLATION private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 358939d236..40b3d635ec 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -180,8 +180,7 @@ public override AppendPrependAsyncIterator Prepend(TSource element) public override async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); - + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); if (count == -1) { return await AsyncEnumerableHelpers.ToArray(this, cancellationToken).ConfigureAwait(false); @@ -191,7 +190,6 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel var array = new TSource[count]; int index; - if (_appending) { index = 0; @@ -208,7 +206,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -234,18 +232,18 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel public override async ValueTask> ToListAsync(CancellationToken cancellationToken) { - int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); - List list = count == -1 ? new List() : new List(count); + var list = count == -1 ? new List() : new List(count); if (!_appending) { list.Add(_item); } - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -271,7 +269,7 @@ public override async ValueTask GetCountAsync(bool onlyIfCheap, Cancellatio { if (_source is IAsyncIListProvider listProv) { - int count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + 1; } @@ -383,20 +381,19 @@ protected override async ValueTask MoveNextCore() public override AppendPrependAsyncIterator Append(TSource item) { - SingleLinkedNode res = _appended != null ? _appended.Add(item) : new SingleLinkedNode(item); + var res = _appended != null ? _appended.Add(item) : new SingleLinkedNode(item); return new AppendPrependNAsyncIterator(_source, _prepended, res, _prependCount, _appendCount + 1); } public override AppendPrependAsyncIterator Prepend(TSource item) { - SingleLinkedNode res = _prepended != null ? _prepended.Add(item) : new SingleLinkedNode(item); + var res = _prepended != null ? _prepended.Add(item) : new SingleLinkedNode(item); return new AppendPrependNAsyncIterator(_source, res, _appended, _prependCount + 1, _appendCount); } public override async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); - + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); if (count == -1) { return await AsyncEnumerableHelpers.ToArray(this, cancellationToken).ConfigureAwait(false); @@ -404,8 +401,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel var array = new TSource[count]; var index = 0; - - for (SingleLinkedNode n = _prepended; n != null; n = n.Linked) + for (var n = _prepended; n != null; n = n.Linked) { array[index] = n.Item; ++index; @@ -417,7 +413,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -434,7 +430,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } index = array.Length; - for (SingleLinkedNode n = _appended; n != null; n = n.Linked) + for (var n = _appended; n != null; n = n.Linked) { --index; array[index] = n.Item; @@ -445,16 +441,14 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel public override async ValueTask> ToListAsync(CancellationToken cancellationToken) { - int count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); - - List list = count == -1 ? new List() : new List(count); - - for (SingleLinkedNode n = _prepended; n != null; n = n.Linked) + var count = await GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + var list = count == -1 ? new List() : new List(count); + for (var n = _prepended; n != null; n = n.Linked) { list.Add(n.Item); } - IAsyncEnumerator en = _source.GetAsyncEnumerator(cancellationToken); + var en = _source.GetAsyncEnumerator(cancellationToken); try { @@ -470,7 +464,7 @@ public override async ValueTask> ToListAsync(CancellationToken can if (_appended != null) { - using (IEnumerator en2 = _appended.GetEnumerator(_appendCount)) + using (var en2 = _appended.GetEnumerator(_appendCount)) { while (en2.MoveNext()) { @@ -486,7 +480,7 @@ public override async ValueTask GetCountAsync(bool onlyIfCheap, Cancellatio { if (_source is IAsyncIListProvider listProv) { - int count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); return count == -1 ? -1 : count + _appendCount + _prependCount; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 954a46b879..7937b617c8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -689,5 +689,6 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } #endif + } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs index 8ea4fbf1c0..76c20af694 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs @@ -12,7 +12,7 @@ public static partial class AsyncEnumerable { private static async Task AverageCore(this IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -23,7 +23,6 @@ private static async Task AverageCore(this IAsyncEnumerable source, long sum = e.Current; long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -43,7 +42,7 @@ private static async Task AverageCore(this IAsyncEnumerable source, private static async Task AverageCore(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -54,7 +53,6 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -85,7 +83,6 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -117,7 +114,6 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? v = e.Current; - + var v = e.Current; if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -179,25 +172,22 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? v = selector(e.Current); - + var v = selector(e.Current); if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -220,25 +210,22 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? v = await selector(e.Current).ConfigureAwait(false); - + var v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -262,25 +249,22 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -304,7 +288,7 @@ private static async Task AverageCore(this IAsyncEnumerable AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -313,9 +297,8 @@ private static async Task AverageCore(IAsyncEnumerable source, Can throw Error.NoElements(); } - long sum = e.Current; + var sum = e.Current; long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -335,7 +318,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -344,9 +327,8 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - long sum = selector(e.Current); + var sum = selector(e.Current); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -366,7 +348,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -375,9 +357,8 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - long sum = await selector(e.Current).ConfigureAwait(false); + var sum = await selector(e.Current).ConfigureAwait(false); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -398,7 +379,7 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -407,9 +388,8 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - long sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) @@ -430,25 +410,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? v = e.Current; - + var v = e.Current; if (v.HasValue) { - long sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -471,25 +448,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? v = selector(e.Current); - + var v = selector(e.Current); if (v.HasValue) { - long sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -512,25 +486,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? v = await selector(e.Current).ConfigureAwait(false); - + var v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { - long sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -554,25 +525,22 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (v.HasValue) { - long sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -596,7 +564,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -605,9 +573,8 @@ private static async Task AverageCore(IAsyncEnumerable source, C throw Error.NoElements(); } - double sum = e.Current; + var sum = e.Current; long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -627,7 +594,7 @@ private static async Task AverageCore(IAsyncEnumerable source, C private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -636,9 +603,8 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - double sum = selector(e.Current); + var sum = selector(e.Current); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -658,7 +624,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -667,9 +633,8 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - double sum = await selector(e.Current).ConfigureAwait(false); + var sum = await selector(e.Current).ConfigureAwait(false); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -690,7 +655,7 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -699,9 +664,8 @@ private static async Task AverageCore(IAsyncEnumerable throw Error.NoElements(); } - double sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { // There is an opportunity to short-circuit here, in that if e.Current is @@ -722,25 +686,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? v = e.Current; - + var v = e.Current; if (v.HasValue) { - double sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -763,25 +724,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? v = selector(e.Current); - + var v = selector(e.Current); if (v.HasValue) { - double sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -804,25 +762,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? v = await selector(e.Current).ConfigureAwait(false); - + var v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { - double sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -846,25 +801,22 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (v.HasValue) { - double sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -888,7 +840,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -899,7 +851,6 @@ private static async Task AverageCore(IAsyncEnumerable source, Can double sum = e.Current; long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; @@ -916,7 +867,7 @@ private static async Task AverageCore(IAsyncEnumerable source, Can private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -927,7 +878,6 @@ private static async Task AverageCore(IAsyncEnumerable double sum = selector(e.Current); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += selector(e.Current); @@ -944,7 +894,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -955,7 +905,6 @@ private static async Task AverageCore(IAsyncEnumerable double sum = await selector(e.Current).ConfigureAwait(false); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += await selector(e.Current).ConfigureAwait(false); @@ -973,7 +922,7 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -984,7 +933,6 @@ private static async Task AverageCore(IAsyncEnumerable double sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); @@ -1002,25 +950,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? v = e.Current; - + var v = e.Current; if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1043,25 +988,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? v = selector(e.Current); - + var v = selector(e.Current); if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1084,25 +1026,22 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? v = await selector(e.Current).ConfigureAwait(false); - + var v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1126,25 +1065,22 @@ private static async Task AverageCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; - checked { while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1168,7 +1104,7 @@ private static async Task AverageCore(IAsyncEnumerable private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1177,9 +1113,8 @@ private static async Task AverageCore(IAsyncEnumerable source, throw Error.NoElements(); } - decimal sum = e.Current; + var sum = e.Current; long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; @@ -1196,7 +1131,7 @@ private static async Task AverageCore(IAsyncEnumerable source, private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1223,7 +1158,7 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1232,9 +1167,8 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1261,9 +1195,8 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? v = e.Current; - + var v = e.Current; if (v.HasValue) { - decimal sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { v = e.Current; - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1319,23 +1249,20 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? v = selector(e.Current); - + var v = selector(e.Current); if (v.HasValue) { - decimal sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { v = selector(e.Current); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1357,23 +1284,20 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? v = await selector(e.Current).ConfigureAwait(false); - + var v = await selector(e.Current).ConfigureAwait(false); if (v.HasValue) { - decimal sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1396,23 +1320,20 @@ private static async Task AverageCore(IAsyncEnumerable AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (v.HasValue) { - decimal sum = v.GetValueOrDefault(); + var sum = v.GetValueOrDefault(); long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) { v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) { sum += v.GetValueOrDefault(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index b7de4bb094..97aee1ba56 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -78,13 +78,13 @@ public async ValueTask> ToListAsync(CancellationToken cancellation var list = new List(); for (var i = 0; ; i++) { - IAsyncEnumerable source = GetAsyncEnumerable(i); + var source = GetAsyncEnumerable(i); if (source == null) { break; } - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -118,7 +118,7 @@ async ValueTask Core() var count = 0; for (var i = 0; ; i++) { - IAsyncEnumerable source = GetAsyncEnumerable(i); + var source = GetAsyncEnumerable(i); if (source == null) { break; @@ -169,7 +169,7 @@ protected override async ValueTask MoveNextCore() // https://github.com/dotnet/corefx/blob/f7539b726c4bc2385b7f49e5751c1cff2f2c7368/src/System.Linq/src/System/Linq/Concat.cs#L240 // - IAsyncEnumerable next = GetAsyncEnumerable(_counter++ - 1); + var next = GetAsyncEnumerable(_counter++ - 1); if (next != null) { await _enumerator.DisposeAsync().ConfigureAwait(false); @@ -242,7 +242,7 @@ internal override IAsyncEnumerable GetAsyncEnumerable(int index) // that has its _nextIndex equal to index. If we don't find one, then it // must be prior to any of them, so call GetEnumerable on the previous // Concat2Iterator. This avoids a deep recursive call chain. - ConcatNAsyncIterator current = this; + var current = this; while (true) { if (index == current._nextIndex) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index b4989fb76f..95addaf118 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -54,7 +54,7 @@ private static Task ContainsCore(IAsyncEnumerable source private static async Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index c72dd750bb..e8c020054a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -97,7 +97,7 @@ async Task Core() { var count = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -122,7 +122,7 @@ private static async Task CountCore(IAsyncEnumerable sour { var count = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -149,7 +149,7 @@ private static async Task CountCore(this IAsyncEnumerable { var count = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -177,7 +177,7 @@ private static async Task CountCore(this IAsyncEnumerable { var count = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 944ed96f93..8a1ca757c2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -95,13 +95,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - TSource[] array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); + var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); return array.Length == 0 ? new[] { _defaultValue } : array; } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - List list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); + var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); if (list.Count == 0) { list.Add(_defaultValue); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index 8d31fc1392..fb201adb70 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -45,13 +45,13 @@ public DistinctAsyncIterator(IAsyncEnumerable source, IEqualityComparer public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - Set s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - Set s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.ToList(); } @@ -66,7 +66,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Set s = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var s = await FillSetAsync(cancellationToken).ConfigureAwait(false); return s.Count; } } @@ -100,7 +100,7 @@ protected override async ValueTask MoveNextCore() return false; } - TSource element = _enumerator.Current; + var element = _enumerator.Current; _set = new Set(_comparer); _set.Add(element); _current = element; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index c326380d80..9944b3b1c7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -30,7 +30,7 @@ private static async Task ElementAtCore(IAsyncEnumerable p) { - Maybe first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); + var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { @@ -46,7 +46,7 @@ private static async Task ElementAtCore(IAsyncEnumerable= 0) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index bd68930792..28b6f6a8b1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -30,7 +30,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera { if (source is IAsyncPartition p) { - Maybe first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); + var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); if (first.HasValue) { @@ -49,7 +49,7 @@ private static async Task ElementAtOrDefaultCore(IAsyncEnumera } else { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index a648f394d4..9b69ba5da0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -92,7 +92,7 @@ protected override async ValueTask MoveNextCore() if (moveNext) { - TSource item = _firstEnumerator.Current; + var item = _firstEnumerator.Current; if (_set.Add(item)) { _current = item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index f76d4074eb..6ca57a3175 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -80,21 +80,21 @@ public static Task FirstAsync(this IAsyncEnumerable s private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } private static async Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } @@ -103,7 +103,7 @@ private static async Task FirstCore(IAsyncEnumerable private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index af5eb00edd..b516e800bb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -80,21 +80,21 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -102,7 +102,7 @@ private static async Task FirstOrDefaultCore(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -127,7 +127,7 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core() { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -150,13 +150,13 @@ async ValueTask> Core() private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource value = e.Current; + var value = e.Current; if (predicate(value)) { @@ -174,13 +174,13 @@ private static async Task> TryGetFirst(IAsyncEnumerable< private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource value = e.Current; + var value = e.Current; if (await predicate(value).ConfigureAwait(false)) { @@ -199,13 +199,13 @@ private static async Task> TryGetFirst(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource value = e.Current; + var value = e.Current; if (await predicate(value, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 14602a1374..25f0a0b577 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -119,7 +119,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -136,7 +136,7 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -155,7 +155,7 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { var index = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -174,7 +174,7 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { var index = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 87920895d2..c224cc0352 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -380,13 +380,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.ToArray(_resultSelector); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.ToList(_resultSelector); } @@ -401,7 +401,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -473,13 +473,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArray(_resultSelector).ConfigureAwait(false); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToList(_resultSelector).ConfigureAwait(false); } @@ -494,7 +494,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -567,13 +567,13 @@ protected override async ValueTask MoveNextCore() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToArray(_resultSelector, cancellationToken).ConfigureAwait(false); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return await l.ToList(_resultSelector, cancellationToken).ConfigureAwait(false); } @@ -588,7 +588,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -682,7 +682,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -775,7 +775,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -869,7 +869,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -960,7 +960,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.Lookup l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -1050,7 +1050,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } @@ -1141,7 +1141,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Internal.LookupWithTask l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, cancellationToken).ConfigureAwait(false); return l.Count; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 0fdd7be10f..6d8ee96a12 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -192,10 +192,10 @@ public async ValueTask MoveNextAsync() _lookup = await Internal.Lookup.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } - TOuter item = _outer.Current; + var item = _outer.Current; - TKey outerKey = _outerKeySelector(item); - IAsyncEnumerable inner = _lookup[outerKey].ToAsyncEnumerable(); + var outerKey = _outerKeySelector(item); + var inner = _lookup[outerKey].ToAsyncEnumerable(); Current = _resultSelector(item, inner); @@ -290,10 +290,10 @@ public async ValueTask MoveNextAsync() _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } - TOuter item = _outer.Current; + var item = _outer.Current; - TKey outerKey = await _outerKeySelector(item).ConfigureAwait(false); - IAsyncEnumerable inner = _lookup[outerKey].ToAsyncEnumerable(); + var outerKey = await _outerKeySelector(item).ConfigureAwait(false); + var inner = _lookup[outerKey].ToAsyncEnumerable(); Current = await _resultSelector(item, inner).ConfigureAwait(false); @@ -389,10 +389,10 @@ public async ValueTask MoveNextAsync() _lookup = await Internal.LookupWithTask.CreateForJoinAsync(_inner, _innerKeySelector, _comparer, _cancellationToken).ConfigureAwait(false); } - TOuter item = _outer.Current; + var item = _outer.Current; - TKey outerKey = await _outerKeySelector(item, _cancellationToken).ConfigureAwait(false); - IAsyncEnumerable inner = _lookup[outerKey].ToAsyncEnumerable(); + var outerKey = await _outerKeySelector(item, _cancellationToken).ConfigureAwait(false); + var inner = _lookup[outerKey].ToAsyncEnumerable(); Current = await _resultSelector(item, inner, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 3a95ff47bd..799648659f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -93,7 +93,7 @@ protected override async ValueTask MoveNextCore() if (moveNext) { - TSource item = _firstEnumerator.Current; + var item = _firstEnumerator.Current; if (_set.Remove(item)) { _current = item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index eb92d03dec..3a883d6941 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -196,7 +196,7 @@ protected override async ValueTask MoveNextCore() case State_DoLoop: _item = _outerEnumerator.Current; - Internal.Grouping g = _lookup.GetGrouping(_outerKeySelector(_item), create: false); + var g = _lookup.GetGrouping(_outerKeySelector(_item), create: false); if (g != null) { _count = g._count; @@ -221,7 +221,7 @@ protected override async ValueTask MoveNextCore() return true; case State_While: - bool hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); + var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; @@ -323,7 +323,7 @@ protected override async ValueTask MoveNextCore() case State_DoLoop: _item = _outerEnumerator.Current; - Internal.Grouping g = _lookup.GetGrouping(await _outerKeySelector(_item).ConfigureAwait(false), create: false); + var g = _lookup.GetGrouping(await _outerKeySelector(_item).ConfigureAwait(false), create: false); if (g != null) { _count = g._count; @@ -348,7 +348,7 @@ protected override async ValueTask MoveNextCore() return true; case State_While: - bool hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); + var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; @@ -451,7 +451,7 @@ protected override async ValueTask MoveNextCore() case State_DoLoop: _item = _outerEnumerator.Current; - Internal.Grouping g = _lookup.GetGrouping(await _outerKeySelector(_item, _cancellationToken).ConfigureAwait(false), create: false); + var g = _lookup.GetGrouping(await _outerKeySelector(_item, _cancellationToken).ConfigureAwait(false), create: false); if (g != null) { _count = g._count; @@ -476,7 +476,7 @@ protected override async ValueTask MoveNextCore() return true; case State_While: - bool hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); + var hasNext = await _outerEnumerator.MoveNextAsync().ConfigureAwait(false); if (hasNext) { goto case State_DoLoop; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index f8eb18634e..aa56a914f7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -80,21 +80,21 @@ public static Task LastAsync(this IAsyncEnumerable so private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } private static async Task LastCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } @@ -102,7 +102,7 @@ private static async Task LastCore(IAsyncEnumerable s #if !NO_DEEP_CANCELLATION private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 21eb66cfec..93ac785c87 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -80,21 +80,21 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -102,7 +102,7 @@ private static async Task LastOrDefaultCore(IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - Maybe last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -112,8 +112,7 @@ private static ValueTask> TryGetLast(IAsyncEnumerable list) { - int count = list.Count; - + var count = list.Count; if (count > 0) { return new ValueTask>(new Maybe(list[count - 1])); @@ -132,7 +131,7 @@ async ValueTask> Core() var last = default(TSource); var hasLast = false; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -159,13 +158,13 @@ private static async Task> TryGetLast(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource value = e.Current; + var value = e.Current; if (predicate(value)) { @@ -192,13 +191,13 @@ private static async Task> TryGetLast(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource value = e.Current; + var value = e.Current; if (await predicate(value).ConfigureAwait(false)) { @@ -226,13 +225,13 @@ private static async Task> TryGetLast(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource value = e.Current; + var value = e.Current; if (await predicate(value, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index e75bc74de7..8af207fe35 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -82,7 +82,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -106,7 +106,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -133,7 +133,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -161,7 +161,7 @@ private static async Task LongCountCore(IAsyncEnumerable { var count = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index 63e044e8cf..c99f96414e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -30,8 +30,7 @@ public IEnumerable this[TKey key] { get { - Grouping grouping = GetGrouping(key, create: false); - + var grouping = GetGrouping(key, create: false); if (grouping != null) { return grouping; @@ -45,14 +44,19 @@ public IEnumerable this[TKey key] } } - public bool Contains(TKey key) => GetGrouping(key, create: false) != null; + public bool Contains(TKey key) + { + return GetGrouping(key, create: false) != null; + } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } public IEnumerator> GetEnumerator() { - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -65,8 +69,7 @@ public IEnumerator> GetEnumerator() public IEnumerable ApplyResultSelector(Func, TResult> resultSelector) { - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -74,7 +77,7 @@ public IEnumerable ApplyResultSelector(Func> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = keySelector(enu.Current); - Grouping group = lookup.GetGrouping(key, create: true); + var key = keySelector(enu.Current); + var group = lookup.GetGrouping(key, create: true); - TElement element = elementSelector(enu.Current); + var element = elementSelector(enu.Current); group.Add(element); } } @@ -116,13 +119,13 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = keySelector(enu.Current); + var key = keySelector(enu.Current); lookup.GetGrouping(key, create: true).Add(enu.Current); } } @@ -138,14 +141,13 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { var lookup = new Lookup(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = keySelector(enu.Current); - + var key = keySelector(enu.Current); if (key != null) { lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -162,9 +164,8 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum internal Grouping GetGrouping(TKey key, bool create) { - int hashCode = InternalGetHashCode(key); - - for (Grouping g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) + var hashCode = InternalGetHashCode(key); + for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) { if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) { @@ -179,8 +180,7 @@ internal Grouping GetGrouping(TKey key, bool create) Resize(); } - int index = hashCode % _groupings.Length; - + var index = hashCode % _groupings.Length; var g = new Grouping { _key = key, @@ -188,9 +188,7 @@ internal Grouping GetGrouping(TKey key, bool create) _elements = new TElement[1], _hashNext = _groupings[index] }; - _groupings[index] = g; - if (_lastGrouping == null) { g._next = g; @@ -203,7 +201,6 @@ internal Grouping GetGrouping(TKey key, bool create) _lastGrouping = g; Count++; - return g; } @@ -220,16 +217,13 @@ internal TResult[] ToArray(Func, TResu { var array = new TResult[Count]; var index = 0; - - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do { g = g._next; g.Trim(); - array[index] = resultSelector(g._key, g._elements.ToAsyncEnumerable()); ++index; } while (g != _lastGrouping); @@ -241,9 +235,7 @@ internal TResult[] ToArray(Func, TResu internal List ToList(Func, TResult> resultSelector) { var list = new List(Count); - - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -251,7 +243,7 @@ internal List ToList(Func, TR g = g._next; g.Trim(); - TResult result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); + var result = resultSelector(g._key, g._elements.ToAsyncEnumerable()); list.Add(result); } while (g != _lastGrouping); } @@ -261,16 +253,13 @@ internal List ToList(Func, TR private void Resize() { - int newSize = checked((Count * 2) + 1); + var newSize = checked((Count * 2) + 1); var newGroupings = new Grouping[newSize]; - - Grouping g = _lastGrouping; - + var g = _lastGrouping; do { g = g._next; - - int index = g._hashCode % newSize; + var index = g._hashCode % newSize; g._hashNext = newGroupings[index]; newGroupings[index] = g; } while (g != _lastGrouping); @@ -278,7 +267,10 @@ private void Resize() _groupings = newGroupings; } - public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) => new ValueTask(Count); + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + return new ValueTask(Count); + } IAsyncEnumerator> IAsyncEnumerable>.GetAsyncEnumerator(CancellationToken cancellationToken) { @@ -292,9 +284,7 @@ ValueTask>> IAsyncIListProvider>(Count); - - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -314,9 +304,7 @@ ValueTask[]> IAsyncIListProvider[Count]; var index = 0; - - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -350,8 +338,7 @@ public IEnumerable this[TKey key] { get { - Grouping grouping = GetGrouping(key, create: false); - + var grouping = GetGrouping(key, create: false); if (grouping != null) { return grouping; @@ -365,14 +352,19 @@ public IEnumerable this[TKey key] } } - public bool Contains(TKey key) => GetGrouping(key, create: false) != null; + public bool Contains(TKey key) + { + return GetGrouping(key, create: false) != null; + } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } public IEnumerator> GetEnumerator() { - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -391,16 +383,16 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = await keySelector(enu.Current).ConfigureAwait(false); - Grouping group = lookup.GetGrouping(key, create: true); + var key = await keySelector(enu.Current).ConfigureAwait(false); + var group = lookup.GetGrouping(key, create: true); - TElement element = await elementSelector(enu.Current).ConfigureAwait(false); + var element = await elementSelector(enu.Current).ConfigureAwait(false); group.Add(element); } } @@ -421,16 +413,16 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); - Grouping group = lookup.GetGrouping(key, create: true); + var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + var group = lookup.GetGrouping(key, create: true); - TElement element = await elementSelector(enu.Current, cancellationToken).ConfigureAwait(false); + var element = await elementSelector(enu.Current, cancellationToken).ConfigureAwait(false); group.Add(element); } } @@ -450,13 +442,13 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = await keySelector(enu.Current).ConfigureAwait(false); + var key = await keySelector(enu.Current).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(enu.Current); } } @@ -476,13 +468,13 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(enu.Current); } } @@ -499,14 +491,13 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = await keySelector(enu.Current).ConfigureAwait(false); - + var key = await keySelector(enu.Current).ConfigureAwait(false); if (key != null) { lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -526,14 +517,13 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); - IAsyncEnumerator enu = source.GetAsyncEnumerator(cancellationToken); + var enu = source.GetAsyncEnumerator(cancellationToken); try { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - TKey key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); - + var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); if (key != null) { lookup.GetGrouping(key, create: true).Add(enu.Current); @@ -551,9 +541,8 @@ internal static async Task> CreateForJoinAsync(IA internal Grouping GetGrouping(TKey key, bool create) { - int hashCode = InternalGetHashCode(key); - - for (Grouping g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) + var hashCode = InternalGetHashCode(key); + for (var g = _groupings[hashCode % _groupings.Length]; g != null; g = g._hashNext) { if (g._hashCode == hashCode && _comparer.Equals(g._key, key)) { @@ -568,8 +557,7 @@ internal Grouping GetGrouping(TKey key, bool create) Resize(); } - int index = hashCode % _groupings.Length; - + var index = hashCode % _groupings.Length; var g = new Grouping { _key = key, @@ -577,9 +565,7 @@ internal Grouping GetGrouping(TKey key, bool create) _elements = new TElement[1], _hashNext = _groupings[index] }; - _groupings[index] = g; - if (_lastGrouping == null) { g._next = g; @@ -608,16 +594,13 @@ internal async Task ToArray(Func g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do { g = g._next; g.Trim(); - array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable()).ConfigureAwait(false); ++index; } while (g != _lastGrouping); @@ -633,16 +616,13 @@ internal async Task ToArray(Func g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do { g = g._next; g.Trim(); - array[index] = await resultSelector(g._key, g._elements.ToAsyncEnumerable(), cancellationToken).ConfigureAwait(false); ++index; } while (g != _lastGrouping); @@ -655,9 +635,7 @@ internal async Task ToArray(Func> ToList(Func, ValueTask> resultSelector) { var list = new List(Count); - - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -665,7 +643,7 @@ internal async Task> ToList(Func> ToList(Func(Count); - Grouping g = _lastGrouping; + var g = _lastGrouping; if (g != null) { do @@ -687,7 +665,7 @@ internal async Task> ToList(Func> ToList(Func[newSize]; - - Grouping g = _lastGrouping; - + var g = _lastGrouping; do { g = g._next; - - int index = g._hashCode % newSize; + var index = g._hashCode % newSize; g._hashNext = newGroupings[index]; newGroupings[index] = g; } while (g != _lastGrouping); @@ -732,9 +707,7 @@ ValueTask>> IAsyncIListProvider>(Count); - - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do @@ -754,9 +727,7 @@ ValueTask[]> IAsyncIListProvider[Count]; var index = 0; - - Grouping g = _lastGrouping; - + var g = _lastGrouping; if (g != null) { do diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs index 100af49e7c..2682b9f608 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs @@ -12,11 +12,11 @@ public static partial class AsyncEnumerable { private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TSource); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -33,7 +33,7 @@ private static async Task MaxCore(IAsyncEnumerable so while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource x = e.Current; + var x = e.Current; if (x != null && comparer.Compare(x, value) > 0) { value = x; @@ -47,7 +47,7 @@ private static async Task MaxCore(IAsyncEnumerable so } else { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -59,7 +59,7 @@ private static async Task MaxCore(IAsyncEnumerable so value = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource x = e.Current; + var x = e.Current; if (comparer.Compare(x, value) > 0) { value = x; @@ -77,11 +77,11 @@ private static async Task MaxCore(IAsyncEnumerable so private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TResult); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -98,7 +98,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -112,7 +112,7 @@ private static async Task MaxCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -124,7 +124,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -142,11 +142,11 @@ private static async Task MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TResult); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -163,7 +163,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -177,7 +177,7 @@ private static async Task MaxCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -189,7 +189,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -208,11 +208,11 @@ private static async Task MaxCore(IAsyncEnumerable MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TResult); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -229,7 +229,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; @@ -243,7 +243,7 @@ private static async Task MaxCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -255,7 +255,7 @@ private static async Task MaxCore(IAsyncEnumerable 0) { value = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs index 6988421fbe..cce4651d80 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs @@ -14,7 +14,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -24,11 +24,9 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = e.Current; - + var x = e.Current; if (x > value) { value = x; @@ -47,7 +45,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -62,8 +60,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio } while (!value.HasValue); - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -74,9 +71,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = e.Current; - int x = cur.GetValueOrDefault(); - + var cur = e.Current; + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -88,8 +84,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellatio { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = e.Current; - int x = cur.GetValueOrDefault(); + var cur = e.Current; + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -113,7 +109,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -123,11 +119,9 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = e.Current; - + var x = e.Current; if (x > value) { value = x; @@ -146,7 +140,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -161,15 +155,13 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = e.Current; - long x = cur.GetValueOrDefault(); - + var cur = e.Current; + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -181,8 +173,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancellat { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = e.Current; - long x = cur.GetValueOrDefault(); + var cur = e.Current; + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -206,7 +198,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -233,8 +225,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = e.Current; - + var x = e.Current; if (x > value) { value = x; @@ -253,7 +244,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -268,8 +259,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -277,8 +267,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance return value; } - double? cur = e.Current; - + var cur = e.Current; if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -287,8 +276,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cance while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = e.Current; - double x = cur.GetValueOrDefault(); + var cur = e.Current; + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -311,7 +300,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -321,7 +310,6 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell } value = e.Current; - while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -334,8 +322,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = e.Current; - + var x = e.Current; if (x > value) { value = x; @@ -354,7 +341,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -369,8 +356,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -378,8 +364,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell return value; } - float? cur = e.Current; - + var cur = e.Current; if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -388,8 +373,8 @@ private static async Task MaxCore(IAsyncEnumerable source, Cancell while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = e.Current; - float x = cur.GetValueOrDefault(); + var cur = e.Current; + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -412,7 +397,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Can { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -422,11 +407,9 @@ private static async Task MaxCore(IAsyncEnumerable source, Can } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = e.Current; - + var x = e.Current; if (x > value) { value = x; @@ -445,7 +428,7 @@ private static async Task MaxCore(IAsyncEnumerable source, Can { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -460,13 +443,11 @@ private static async Task MaxCore(IAsyncEnumerable source, Can } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = e.Current; - decimal x = cur.GetValueOrDefault(); - + var cur = e.Current; + var x = cur.GetValueOrDefault(); if (cur.HasValue && x > valueVal) { valueVal = x; @@ -486,7 +467,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -496,11 +477,9 @@ private static async Task MaxCore(IAsyncEnumerable source } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = selector(e.Current); - + var x = selector(e.Current); if (x > value) { value = x; @@ -519,7 +498,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -534,8 +513,7 @@ private static async Task MaxCore(IAsyncEnumerable source } while (!value.HasValue); - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -546,9 +524,8 @@ private static async Task MaxCore(IAsyncEnumerable source // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = selector(e.Current); - int x = cur.GetValueOrDefault(); - + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -560,8 +537,8 @@ private static async Task MaxCore(IAsyncEnumerable source { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = selector(e.Current); - int x = cur.GetValueOrDefault(); + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -585,7 +562,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -595,11 +572,9 @@ private static async Task MaxCore(IAsyncEnumerable sourc } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = selector(e.Current); - + var x = selector(e.Current); if (x > value) { value = x; @@ -618,7 +593,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -633,15 +608,13 @@ private static async Task MaxCore(IAsyncEnumerable sourc } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = selector(e.Current); - long x = cur.GetValueOrDefault(); - + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -653,8 +626,8 @@ private static async Task MaxCore(IAsyncEnumerable sourc { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = selector(e.Current); - long x = cur.GetValueOrDefault(); + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -678,7 +651,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -688,7 +661,6 @@ private static async Task MaxCore(IAsyncEnumerable sour } value = selector(e.Current); - while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -701,8 +673,7 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = selector(e.Current); - + var x = selector(e.Current); if (x > value) { value = x; @@ -721,7 +692,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -736,8 +707,7 @@ private static async Task MaxCore(IAsyncEnumerable sour } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -745,8 +715,7 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - float? cur = selector(e.Current); - + var cur = selector(e.Current); if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -755,8 +724,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = selector(e.Current); - float x = cur.GetValueOrDefault(); + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -779,7 +748,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -806,8 +775,7 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = selector(e.Current); - + var x = selector(e.Current); if (x > value) { value = x; @@ -826,7 +794,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -841,8 +809,7 @@ private static async Task MaxCore(IAsyncEnumerable sou } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -850,8 +817,7 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - double? cur = selector(e.Current); - + var cur = selector(e.Current); if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -860,8 +826,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = selector(e.Current); - double x = cur.GetValueOrDefault(); + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -884,7 +850,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -894,11 +860,9 @@ private static async Task MaxCore(IAsyncEnumerable so } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = selector(e.Current); - + var x = selector(e.Current); if (x > value) { value = x; @@ -917,7 +881,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -932,13 +896,11 @@ private static async Task MaxCore(IAsyncEnumerable so } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = selector(e.Current); - decimal x = cur.GetValueOrDefault(); - + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); if (cur.HasValue && x > valueVal) { valueVal = x; @@ -958,7 +920,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -968,11 +930,9 @@ private static async Task MaxCore(IAsyncEnumerable source } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x > value) { value = x; @@ -991,7 +951,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1006,8 +966,7 @@ private static async Task MaxCore(IAsyncEnumerable source } while (!value.HasValue); - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -1018,9 +977,8 @@ private static async Task MaxCore(IAsyncEnumerable source // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = await selector(e.Current).ConfigureAwait(false); - int x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -1032,8 +990,8 @@ private static async Task MaxCore(IAsyncEnumerable source { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = await selector(e.Current).ConfigureAwait(false); - int x = cur.GetValueOrDefault(); + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1057,7 +1015,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1067,11 +1025,9 @@ private static async Task MaxCore(IAsyncEnumerable sourc } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x > value) { value = x; @@ -1090,7 +1046,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1105,15 +1061,13 @@ private static async Task MaxCore(IAsyncEnumerable sourc } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = await selector(e.Current).ConfigureAwait(false); - long x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -1125,8 +1079,8 @@ private static async Task MaxCore(IAsyncEnumerable sourc { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = await selector(e.Current).ConfigureAwait(false); - long x = cur.GetValueOrDefault(); + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1150,7 +1104,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1160,7 +1114,6 @@ private static async Task MaxCore(IAsyncEnumerable sour } value = await selector(e.Current).ConfigureAwait(false); - while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1173,8 +1126,7 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x > value) { value = x; @@ -1193,7 +1145,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1208,8 +1160,7 @@ private static async Task MaxCore(IAsyncEnumerable sour } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1217,8 +1168,7 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - float? cur = await selector(e.Current).ConfigureAwait(false); - + var cur = await selector(e.Current).ConfigureAwait(false); if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1227,8 +1177,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = await selector(e.Current).ConfigureAwait(false); - float x = cur.GetValueOrDefault(); + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1251,7 +1201,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1278,8 +1228,7 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x > value) { value = x; @@ -1298,7 +1247,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1313,8 +1262,7 @@ private static async Task MaxCore(IAsyncEnumerable sou } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1322,8 +1270,7 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - double? cur = await selector(e.Current).ConfigureAwait(false); - + var cur = await selector(e.Current).ConfigureAwait(false); if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1332,8 +1279,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = await selector(e.Current).ConfigureAwait(false); - double x = cur.GetValueOrDefault(); + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1356,7 +1303,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1366,11 +1313,9 @@ private static async Task MaxCore(IAsyncEnumerable so } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x > value) { value = x; @@ -1389,7 +1334,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1404,13 +1349,11 @@ private static async Task MaxCore(IAsyncEnumerable so } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = await selector(e.Current).ConfigureAwait(false); - decimal x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (cur.HasValue && x > valueVal) { valueVal = x; @@ -1431,7 +1374,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1441,11 +1384,9 @@ private static async Task MaxCore(IAsyncEnumerable source } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x > value) { value = x; @@ -1464,7 +1405,7 @@ private static async Task MaxCore(IAsyncEnumerable source { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1479,8 +1420,7 @@ private static async Task MaxCore(IAsyncEnumerable source } while (!value.HasValue); - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { // We can fast-path this case where we know HasValue will @@ -1491,9 +1431,8 @@ private static async Task MaxCore(IAsyncEnumerable source // uses, it's only been done in this direction for int? and long?. while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - int x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -1505,8 +1444,8 @@ private static async Task MaxCore(IAsyncEnumerable source { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - int x = cur.GetValueOrDefault(); + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1530,7 +1469,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1540,11 +1479,9 @@ private static async Task MaxCore(IAsyncEnumerable sourc } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x > value) { value = x; @@ -1563,7 +1500,7 @@ private static async Task MaxCore(IAsyncEnumerable sourc { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1578,15 +1515,13 @@ private static async Task MaxCore(IAsyncEnumerable sourc } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); if (valueVal >= 0) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (x > valueVal) { valueVal = x; @@ -1598,8 +1533,8 @@ private static async Task MaxCore(IAsyncEnumerable sourc { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long x = cur.GetValueOrDefault(); + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1623,7 +1558,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1633,7 +1568,6 @@ private static async Task MaxCore(IAsyncEnumerable sour } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1646,8 +1580,7 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x > value) { value = x; @@ -1666,7 +1599,7 @@ private static async Task MaxCore(IAsyncEnumerable sour { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1681,8 +1614,7 @@ private static async Task MaxCore(IAsyncEnumerable sour } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1690,8 +1622,7 @@ private static async Task MaxCore(IAsyncEnumerable sour return value; } - float? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1700,8 +1631,8 @@ private static async Task MaxCore(IAsyncEnumerable sour while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - float x = cur.GetValueOrDefault(); + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1724,7 +1655,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1751,8 +1682,7 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x > value) { value = x; @@ -1771,7 +1701,7 @@ private static async Task MaxCore(IAsyncEnumerable sou { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1786,8 +1716,7 @@ private static async Task MaxCore(IAsyncEnumerable sou } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (double.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) @@ -1795,8 +1724,7 @@ private static async Task MaxCore(IAsyncEnumerable sou return value; } - double? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (cur.HasValue) { valueVal = (value = cur).GetValueOrDefault(); @@ -1805,8 +1733,8 @@ private static async Task MaxCore(IAsyncEnumerable sou while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - double x = cur.GetValueOrDefault(); + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1829,7 +1757,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1839,11 +1767,9 @@ private static async Task MaxCore(IAsyncEnumerable so } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x > value) { value = x; @@ -1862,7 +1788,7 @@ private static async Task MaxCore(IAsyncEnumerable so { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1877,13 +1803,11 @@ private static async Task MaxCore(IAsyncEnumerable so } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - decimal x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (cur.HasValue && x > valueVal) { valueVal = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs index 23eff3e6d7..e7bf900793 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs @@ -12,11 +12,11 @@ public static partial class AsyncEnumerable { private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TSource); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -33,7 +33,7 @@ private static async Task MinCore(IAsyncEnumerable so while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource x = e.Current; + var x = e.Current; if (x != null && comparer.Compare(x, value) < 0) { value = x; @@ -47,7 +47,7 @@ private static async Task MinCore(IAsyncEnumerable so } else { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -59,7 +59,7 @@ private static async Task MinCore(IAsyncEnumerable so value = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource x = e.Current; + var x = e.Current; if (comparer.Compare(x, value) < 0) { value = x; @@ -77,11 +77,11 @@ private static async Task MinCore(IAsyncEnumerable so private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TResult); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -98,7 +98,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -124,7 +124,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TResult); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -163,7 +163,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -189,7 +189,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - Comparer comparer = Comparer.Default; + var comparer = Comparer.Default; var value = default(TResult); if (value == null) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -229,7 +229,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -255,7 +255,7 @@ private static async Task MinCore(IAsyncEnumerable MinCore(IAsyncEnumerable source, Cancellatio { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -24,11 +24,9 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellatio } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = e.Current; - + var x = e.Current; if (x < value) { value = x; @@ -47,7 +45,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellatio { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -66,12 +64,11 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellatio // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = e.Current; - int x = cur.GetValueOrDefault(); + var cur = e.Current; + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -94,7 +91,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -104,11 +101,9 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = e.Current; - + var x = e.Current; if (x < value) { value = x; @@ -127,7 +122,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -142,12 +137,11 @@ private static async Task MinCore(IAsyncEnumerable source, Cancellat } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = e.Current; - long x = cur.GetValueOrDefault(); + var cur = e.Current; + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -170,7 +164,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -180,25 +174,24 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = e.Current; - + var x = e.Current; if (x < value) { value = x; } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. return x; } } @@ -215,7 +208,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -230,16 +223,13 @@ private static async Task MinCore(IAsyncEnumerable source, Cancell } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = e.Current; - + var cur = e.Current; if (cur.HasValue) { - float x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -264,7 +254,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cance { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -274,11 +264,9 @@ private static async Task MinCore(IAsyncEnumerable source, Cance } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = e.Current; - + var x = e.Current; if (x < value) { value = x; @@ -301,7 +289,7 @@ private static async Task MinCore(IAsyncEnumerable source, Cance { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -316,16 +304,13 @@ private static async Task MinCore(IAsyncEnumerable source, Cance } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = e.Current; - + var cur = e.Current; if (cur.HasValue) { - double x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -350,7 +335,7 @@ private static async Task MinCore(IAsyncEnumerable source, Can { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -360,11 +345,9 @@ private static async Task MinCore(IAsyncEnumerable source, Can } value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = e.Current; - + var x = e.Current; if (x < value) { value = x; @@ -383,7 +366,7 @@ private static async Task MinCore(IAsyncEnumerable source, Can { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -398,13 +381,11 @@ private static async Task MinCore(IAsyncEnumerable source, Can } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = e.Current; - decimal x = cur.GetValueOrDefault(); - + var cur = e.Current; + var x = cur.GetValueOrDefault(); if (cur.HasValue && x < valueVal) { valueVal = x; @@ -424,7 +405,7 @@ private static async Task MinCore(IAsyncEnumerable source { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -434,11 +415,9 @@ private static async Task MinCore(IAsyncEnumerable source } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = selector(e.Current); - + var x = selector(e.Current); if (x < value) { value = x; @@ -457,7 +436,7 @@ private static async Task MinCore(IAsyncEnumerable source { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -476,12 +455,11 @@ private static async Task MinCore(IAsyncEnumerable source // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = selector(e.Current); - int x = cur.GetValueOrDefault(); + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -504,7 +482,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -514,11 +492,9 @@ private static async Task MinCore(IAsyncEnumerable sourc } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = selector(e.Current); - + var x = selector(e.Current); if (x < value) { value = x; @@ -537,7 +513,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -552,12 +528,11 @@ private static async Task MinCore(IAsyncEnumerable sourc } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = selector(e.Current); - long x = cur.GetValueOrDefault(); + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -580,7 +555,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -590,25 +565,24 @@ private static async Task MinCore(IAsyncEnumerable sour } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = selector(e.Current); - + var x = selector(e.Current); if (x < value) { value = x; } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. return x; } } @@ -625,7 +599,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -640,16 +614,13 @@ private static async Task MinCore(IAsyncEnumerable sour } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = selector(e.Current); - + var cur = selector(e.Current); if (cur.HasValue) { - float x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -674,7 +645,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -684,11 +655,9 @@ private static async Task MinCore(IAsyncEnumerable sou } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = selector(e.Current); - + var x = selector(e.Current); if (x < value) { value = x; @@ -711,7 +680,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -726,16 +695,13 @@ private static async Task MinCore(IAsyncEnumerable sou } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = selector(e.Current); - + var cur = selector(e.Current); if (cur.HasValue) { - double x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -760,7 +726,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -770,11 +736,9 @@ private static async Task MinCore(IAsyncEnumerable so } value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = selector(e.Current); - + var x = selector(e.Current); if (x < value) { value = x; @@ -793,7 +757,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -808,13 +772,11 @@ private static async Task MinCore(IAsyncEnumerable so } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = selector(e.Current); - decimal x = cur.GetValueOrDefault(); - + var cur = selector(e.Current); + var x = cur.GetValueOrDefault(); if (cur.HasValue && x < valueVal) { valueVal = x; @@ -834,7 +796,7 @@ private static async Task MinCore(IAsyncEnumerable source { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -844,11 +806,9 @@ private static async Task MinCore(IAsyncEnumerable source } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x < value) { value = x; @@ -867,7 +827,7 @@ private static async Task MinCore(IAsyncEnumerable source { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -886,12 +846,11 @@ private static async Task MinCore(IAsyncEnumerable source // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = await selector(e.Current).ConfigureAwait(false); - int x = cur.GetValueOrDefault(); + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -914,7 +873,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -924,11 +883,9 @@ private static async Task MinCore(IAsyncEnumerable sourc } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x < value) { value = x; @@ -947,7 +904,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -962,12 +919,11 @@ private static async Task MinCore(IAsyncEnumerable sourc } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = await selector(e.Current).ConfigureAwait(false); - long x = cur.GetValueOrDefault(); + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -990,7 +946,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1000,25 +956,24 @@ private static async Task MinCore(IAsyncEnumerable sour } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x < value) { value = x; } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. return x; } } @@ -1035,7 +990,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1050,16 +1005,13 @@ private static async Task MinCore(IAsyncEnumerable sour } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = await selector(e.Current).ConfigureAwait(false); - + var cur = await selector(e.Current).ConfigureAwait(false); if (cur.HasValue) { - float x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -1084,7 +1036,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1094,11 +1046,9 @@ private static async Task MinCore(IAsyncEnumerable sou } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x < value) { value = x; @@ -1121,7 +1071,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1136,16 +1086,13 @@ private static async Task MinCore(IAsyncEnumerable sou } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = await selector(e.Current).ConfigureAwait(false); - + var cur = await selector(e.Current).ConfigureAwait(false); if (cur.HasValue) { - double x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -1170,7 +1117,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1180,11 +1127,9 @@ private static async Task MinCore(IAsyncEnumerable so } value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = await selector(e.Current).ConfigureAwait(false); - + var x = await selector(e.Current).ConfigureAwait(false); if (x < value) { value = x; @@ -1203,7 +1148,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1218,13 +1163,11 @@ private static async Task MinCore(IAsyncEnumerable so } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = await selector(e.Current).ConfigureAwait(false); - decimal x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (cur.HasValue && x < valueVal) { valueVal = x; @@ -1245,7 +1188,7 @@ private static async Task MinCore(IAsyncEnumerable source { int value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1255,11 +1198,9 @@ private static async Task MinCore(IAsyncEnumerable source } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - int x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x < value) { value = x; @@ -1278,7 +1219,7 @@ private static async Task MinCore(IAsyncEnumerable source { int? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1297,12 +1238,11 @@ private static async Task MinCore(IAsyncEnumerable source // Keep hold of the wrapped value, and do comparisons on that, rather than // using the lifted operation each time. - int valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - int x = cur.GetValueOrDefault(); + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1325,7 +1265,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1335,11 +1275,9 @@ private static async Task MinCore(IAsyncEnumerable sourc } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - long x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x < value) { value = x; @@ -1358,7 +1296,7 @@ private static async Task MinCore(IAsyncEnumerable sourc { long? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1373,12 +1311,11 @@ private static async Task MinCore(IAsyncEnumerable sourc } while (!value.HasValue); - long valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long x = cur.GetValueOrDefault(); + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. @@ -1401,7 +1338,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1411,25 +1348,24 @@ private static async Task MinCore(IAsyncEnumerable sour } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - float x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x < value) { value = x; } + + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. else if (float.IsNaN(x)) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. return x; } } @@ -1446,7 +1382,7 @@ private static async Task MinCore(IAsyncEnumerable sour { float? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1461,16 +1397,13 @@ private static async Task MinCore(IAsyncEnumerable sour } while (!value.HasValue); - float valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (cur.HasValue) { - float x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -1495,7 +1428,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1505,11 +1438,9 @@ private static async Task MinCore(IAsyncEnumerable sou } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - double x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x < value) { value = x; @@ -1532,7 +1463,7 @@ private static async Task MinCore(IAsyncEnumerable sou { double? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1547,16 +1478,13 @@ private static async Task MinCore(IAsyncEnumerable sou } while (!value.HasValue); - double valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (cur.HasValue) { - double x = cur.GetValueOrDefault(); - + var x = cur.GetValueOrDefault(); if (x < valueVal) { valueVal = x; @@ -1581,7 +1509,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal value; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1591,11 +1519,9 @@ private static async Task MinCore(IAsyncEnumerable so } value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); if (x < value) { value = x; @@ -1614,7 +1540,7 @@ private static async Task MinCore(IAsyncEnumerable so { decimal? value = null; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1629,13 +1555,11 @@ private static async Task MinCore(IAsyncEnumerable so } while (!value.HasValue); - decimal valueVal = value.GetValueOrDefault(); - + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - decimal x = cur.GetValueOrDefault(); - + var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); if (cur.HasValue && x < valueVal) { valueVal = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index 9dd0306dbd..48a5a757c5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -55,8 +55,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - object item = _enumerator.Current; - + var item = _enumerator.Current; if (item is TResult res) { _current = res; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index e4617c4bc7..a835be929e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -49,7 +49,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Allocated: _buffer = await _source.ToArrayAsync(_cancellationToken).ConfigureAwait(false); // TODO: Use buffer. - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(_cancellationToken); + var sorter = GetAsyncEnumerableSorter(_cancellationToken); _indexes = await sorter.Sort(_buffer, _buffer.Length).ConfigureAwait(false); _index = 0; @@ -650,9 +650,9 @@ protected override void QuickSort(int[] map, int left, int right) do { - int i = left; - int j = right; - int x = map[i + ((j - i) >> 1)]; + var i = left; + var j = right; + var x = map[i + ((j - i) >> 1)]; do { @@ -673,7 +673,7 @@ protected override void QuickSort(int[] map, int left, int right) if (i < j) { - int temp = map[i]; + var temp = map[i]; map[i] = map[j]; map[j] = temp; } @@ -774,12 +774,12 @@ protected override void PartialQuickSort(int[] map, int left, int right, int min protected override int QuickSelect(int[] map, int right, int idx) { - int left = 0; + var left = 0; do { - int i = left; - int j = right; - int x = map[i + ((j - i) >> 1)]; + var i = left; + var j = right; + var x = map[i + ((j - i) >> 1)]; do { @@ -800,7 +800,7 @@ protected override int QuickSelect(int[] map, int right, int idx) if (i < j) { - int temp = map[i]; + var temp = map[i]; map[i] = map[j]; map[j] = temp; } @@ -845,8 +845,8 @@ protected override int QuickSelect(int[] map, int right, int idx) protected override int Min(int[] map, int count) { - int index = 0; - for (int i = 1; i < count; i++) + var index = 0; + for (var i = 1; i < count; i++) { if (CompareKeys(map[i], map[index]) < 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs index 67d19d4813..c5a885163e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Range.cs @@ -16,7 +16,7 @@ public static IAsyncEnumerable Range(int start, int count) if (count < 0) throw Error.ArgumentOutOfRange(nameof(count)); - long end = (long)start + count - 1L; + var end = (long)start + count - 1L; if (count < 0 || end > int.MaxValue) throw Error.ArgumentOutOfRange(nameof(count)); @@ -45,7 +45,7 @@ public RangeAsyncIterator(int start, int count) public IAsyncPartition Skip(int count) { - int n = _end - _start; + var n = _end - _start; if (count >= n) { @@ -57,7 +57,7 @@ public IAsyncPartition Skip(int count) public IAsyncPartition Take(int count) { - int n = _end - _start; + var n = _end - _start; if (count >= n) { @@ -71,7 +71,7 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) { var res = new int[_end - _start]; - int value = _start; + var value = _start; for (var i = 0; i < res.Length; i++) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index e712cfa989..d0b35fb891 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -36,13 +36,13 @@ public ReverseAsyncIterator(IAsyncEnumerable source) public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - TSource[] array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); + var array = await _source.ToArrayAsync(cancellationToken).ConfigureAwait(false); // Array.Reverse() involves boxing for non-primitive value types, but // checking that has its own cost, so just use this approach for all types. for (int i = 0, j = array.Length - 1; i < j; ++i, --j) { - TSource temp = array[i]; + var temp = array[i]; array[i] = array[j]; array[j] = temp; } @@ -52,7 +52,7 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - List list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); + var list = await _source.ToListAsync(cancellationToken).ConfigureAwait(false); list.Reverse(); return list; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index c3c514c684..baaa8edf6c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -222,7 +222,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -281,9 +281,9 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella cancellationToken.ThrowIfCancellationRequested(); - int count = 0; + var count = 0; - foreach (TSource item in _source) + foreach (var item in _source) { _selector(item); @@ -305,7 +305,7 @@ public ValueTask ToArrayAsync(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - int n = _source.Count; + var n = _source.Count; var res = new TResult[n]; @@ -321,7 +321,7 @@ public ValueTask> ToListAsync(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - int n = _source.Count; + var n = _source.Count; var res = new List(n); @@ -526,7 +526,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -591,7 +591,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -660,9 +660,9 @@ async ValueTask Core() { cancellationToken.ThrowIfCancellationRequested(); - int count = 0; + var count = 0; - foreach (TSource item in _source) + foreach (var item in _source) { await _selector(item).ConfigureAwait(false); @@ -685,7 +685,7 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok { cancellationToken.ThrowIfCancellationRequested(); - int n = _source.Count; + var n = _source.Count; var res = new TResult[n]; @@ -701,7 +701,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { cancellationToken.ThrowIfCancellationRequested(); - int n = _source.Count; + var n = _source.Count; var res = new List(n); @@ -782,9 +782,9 @@ async ValueTask Core() { cancellationToken.ThrowIfCancellationRequested(); - int count = 0; + var count = 0; - foreach (TSource item in _source) + foreach (var item in _source) { await _selector(item, cancellationToken).ConfigureAwait(false); @@ -807,7 +807,7 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTok { cancellationToken.ThrowIfCancellationRequested(); - int n = _source.Count; + var n = _source.Count; var res = new TResult[n]; @@ -823,7 +823,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { cancellationToken.ThrowIfCancellationRequested(); - int n = _source.Count; + var n = _source.Count; var res = new List(n); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 62b1b03b4a..d7d14031f1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -215,7 +215,7 @@ protected override async ValueTask MoveNextCore() await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - IAsyncEnumerable inner = _selector(_sourceEnumerator.Current); + var inner = _selector(_sourceEnumerator.Current); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -306,7 +306,7 @@ protected override async ValueTask MoveNextCore() await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current).ConfigureAwait(false); + var inner = await _selector(_sourceEnumerator.Current).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -398,7 +398,7 @@ protected override async ValueTask MoveNextCore() await _resultEnumerator.DisposeAsync().ConfigureAwait(false); } - IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current, _cancellationToken).ConfigureAwait(false); + var inner = await _selector(_sourceEnumerator.Current, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -497,7 +497,7 @@ protected override async ValueTask MoveNextCore() } _currentSource = _sourceEnumerator.Current; - IAsyncEnumerable inner = _collectionSelector(_currentSource); + var inner = _collectionSelector(_currentSource); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -595,7 +595,7 @@ protected override async ValueTask MoveNextCore() } _currentSource = _sourceEnumerator.Current; - IAsyncEnumerable inner = await _collectionSelector(_currentSource).ConfigureAwait(false); + var inner = await _collectionSelector(_currentSource).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -694,7 +694,7 @@ protected override async ValueTask MoveNextCore() } _currentSource = _sourceEnumerator.Current; - IAsyncEnumerable inner = await _collectionSelector(_currentSource, _cancellationToken).ConfigureAwait(false); + var inner = await _collectionSelector(_currentSource, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -801,7 +801,7 @@ protected override async ValueTask MoveNextCore() _index++; } - IAsyncEnumerable inner = _collectionSelector(_currentSource, _index); + var inner = _collectionSelector(_currentSource, _index); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -907,7 +907,7 @@ protected override async ValueTask MoveNextCore() _index++; } - IAsyncEnumerable inner = await _collectionSelector(_currentSource, _index).ConfigureAwait(false); + var inner = await _collectionSelector(_currentSource, _index).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1014,7 +1014,7 @@ protected override async ValueTask MoveNextCore() _index++; } - IAsyncEnumerable inner = await _collectionSelector(_currentSource, _index, _cancellationToken).ConfigureAwait(false); + var inner = await _collectionSelector(_currentSource, _index, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1113,7 +1113,7 @@ protected override async ValueTask MoveNextCore() _index++; } - IAsyncEnumerable inner = _selector(_sourceEnumerator.Current, _index); + var inner = _selector(_sourceEnumerator.Current, _index); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1211,7 +1211,7 @@ protected override async ValueTask MoveNextCore() _index++; } - IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current, _index).ConfigureAwait(false); + var inner = await _selector(_sourceEnumerator.Current, _index).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; @@ -1310,7 +1310,7 @@ protected override async ValueTask MoveNextCore() _index++; } - IAsyncEnumerable inner = await _selector(_sourceEnumerator.Current, _index, _cancellationToken).ConfigureAwait(false); + var inner = await _selector(_sourceEnumerator.Current, _index, _cancellationToken).ConfigureAwait(false); _resultEnumerator = inner.GetAsyncEnumerator(_cancellationToken); _mode = State_Result; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 89d6b4fbcc..3d25d79fe2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -84,11 +84,11 @@ private static Task SequenceEqualCore(IAsyncEnumerable f async Task Core() { - IAsyncEnumerator e1 = first.GetAsyncEnumerator(cancellationToken); + var e1 = first.GetAsyncEnumerator(cancellationToken); try { - IAsyncEnumerator e2 = second.GetAsyncEnumerator(cancellationToken); + var e2 = second.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index be23fdbcc9..3140d3a6a4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -91,7 +91,7 @@ private static async Task SingleCore(IAsyncEnumerable throw Error.MoreThanOneElement(); } - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -100,7 +100,7 @@ private static async Task SingleCore(IAsyncEnumerable throw Error.NoElements(); } - TSource result = e.Current; + var result = e.Current; if (await e.MoveNextAsync().ConfigureAwait(false)) { throw Error.MoreThanOneElement(); @@ -116,13 +116,13 @@ private static async Task SingleCore(IAsyncEnumerable private static async Task SingleCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource result = e.Current; + var result = e.Current; if (predicate(result)) { @@ -148,13 +148,13 @@ private static async Task SingleCore(IAsyncEnumerable private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource result = e.Current; + var result = e.Current; if (await predicate(result).ConfigureAwait(false)) { @@ -181,13 +181,13 @@ private static async Task SingleCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource result = e.Current; + var result = e.Current; if (await predicate(result, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs index a8b1673066..0b0cc56592 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs @@ -58,7 +58,7 @@ private SingleLinkedNode(SingleLinkedNode linked, TSource item) public int GetCount() { var count = 0; - for (SingleLinkedNode node = this; node != null; node = node.Linked) + for (var node = this; node != null; node = node.Linked) { count++; } @@ -86,7 +86,7 @@ public SingleLinkedNode GetNode(int index) { Debug.Assert(index >= 0 && index < GetCount()); - SingleLinkedNode node = this; + var node = this; for (; index > 0; index--) { node = node.Linked; @@ -105,8 +105,8 @@ private TSource[] ToArray(int count) Debug.Assert(count == GetCount()); var array = new TSource[count]; - int index = count; - for (SingleLinkedNode node = this; node != null; node = node.Linked) + var index = count; + for (var node = this; node != null; node = node.Linked) { --index; array[index] = node.Item; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index dd07de88d1..de507c35f6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -91,7 +91,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable throw Error.MoreThanOneElement(); } - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -100,7 +100,7 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable return default; } - TSource result = e.Current; + var result = e.Current; if (!await e.MoveNextAsync().ConfigureAwait(false)) { @@ -117,13 +117,13 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource result = e.Current; + var result = e.Current; if (predicate(result)) { @@ -149,13 +149,13 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource result = e.Current; + var result = e.Current; if (await predicate(result).ConfigureAwait(false)) { @@ -182,13 +182,13 @@ private static async Task SingleOrDefaultCore(IAsyncEnumerable #if !NO_DEEP_CANCELLATION private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - TSource result = e.Current; + var result = e.Current; if (await predicate(result, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 9de96c9467..fd6daac5be 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -81,7 +81,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; _queue.Enqueue(item); if (_queue.Count > _count) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index af4197f7c2..51d2eeb081 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -118,7 +118,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource element = _enumerator.Current; + var element = _enumerator.Current; if (!_predicate(element)) { _doMoveNext = false; @@ -196,7 +196,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource element = _enumerator.Current; + var element = _enumerator.Current; checked { @@ -278,7 +278,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource element = _enumerator.Current; + var element = _enumerator.Current; if (!await _predicate(element).ConfigureAwait(false)) { _doMoveNext = false; @@ -355,7 +355,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource element = _enumerator.Current; + var element = _enumerator.Current; if (!await _predicate(element, _cancellationToken).ConfigureAwait(false)) { _doMoveNext = false; @@ -434,7 +434,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource element = _enumerator.Current; + var element = _enumerator.Current; checked { @@ -519,7 +519,7 @@ protected override async ValueTask MoveNextCore() // skip elements as requested while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource element = _enumerator.Current; + var element = _enumerator.Current; checked { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 966acfbce1..22eb5968c5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -80,9 +80,9 @@ public static Task SumAsync(this IAsyncEnumerable source, private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -104,15 +104,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cancellatio private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int value = selector(e.Current); + var value = selector(e.Current); checked { @@ -130,15 +130,15 @@ private static async Task SumCore(IAsyncEnumerable source private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); checked { @@ -157,15 +157,15 @@ private static async Task SumCore(IAsyncEnumerable source #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -252,9 +252,9 @@ public static Task SumAsync(this IAsyncEnumerable source private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -276,15 +276,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cancellat private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long value = selector(e.Current); + var value = selector(e.Current); checked { @@ -302,15 +302,15 @@ private static async Task SumCore(IAsyncEnumerable sourc private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); checked { @@ -329,15 +329,15 @@ private static async Task SumCore(IAsyncEnumerable sourc #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -424,9 +424,9 @@ public static Task SumAsync(this IAsyncEnumerable sourc private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -445,15 +445,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cancell private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float value = selector(e.Current); + var value = selector(e.Current); sum += value; } @@ -468,15 +468,15 @@ private static async Task SumCore(IAsyncEnumerable sour private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); sum += value; } @@ -492,15 +492,15 @@ private static async Task SumCore(IAsyncEnumerable sour #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value; } @@ -584,9 +584,9 @@ public static Task SumAsync(this IAsyncEnumerable sour private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -605,15 +605,15 @@ private static async Task SumCore(IAsyncEnumerable source, Cance private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double value = selector(e.Current); + var value = selector(e.Current); sum += value; } @@ -628,15 +628,15 @@ private static async Task SumCore(IAsyncEnumerable sou private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); sum += value; } @@ -652,15 +652,15 @@ private static async Task SumCore(IAsyncEnumerable sou #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value; } @@ -744,9 +744,9 @@ public static Task SumAsync(this IAsyncEnumerable sou private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -765,15 +765,15 @@ private static async Task SumCore(IAsyncEnumerable source, Can private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal value = selector(e.Current); + var value = selector(e.Current); sum += value; } @@ -788,15 +788,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); sum += value; } @@ -812,15 +812,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value; } @@ -904,9 +904,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -928,15 +928,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? value = selector(e.Current); + var value = selector(e.Current); checked { @@ -954,15 +954,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); checked { @@ -981,15 +981,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - int sum = 0; + var sum = 0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - int? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -1076,9 +1076,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1100,15 +1100,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? value = selector(e.Current); + var value = selector(e.Current); checked { @@ -1126,15 +1126,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); checked { @@ -1153,15 +1153,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - long sum = 0L; + var sum = 0L; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - long? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); checked { @@ -1248,9 +1248,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1269,15 +1269,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? value = selector(e.Current); + var value = selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1292,15 +1292,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1316,15 +1316,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - float sum = 0.0f; + var sum = 0.0f; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - float? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1408,9 +1408,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1429,15 +1429,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? value = selector(e.Current); + var value = selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1452,15 +1452,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1476,15 +1476,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - double sum = 0.0; + var sum = 0.0; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - double? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1568,9 +1568,9 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -1589,15 +1589,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? value = selector(e.Current); + var value = selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1612,15 +1612,15 @@ private static async Task SumCore(IAsyncEnumerable so private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1636,15 +1636,15 @@ private static async Task SumCore(IAsyncEnumerable so #if !NO_DEEP_CANCELLATION private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - decimal sum = 0m; + var sum = 0m; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - decimal? value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index f3d64f4fc4..70af0128bb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -34,7 +34,6 @@ var os = new[] foreach (var o in os) { var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; - var nonNullType = o.type.EndsWith("?") ? o.type.TrimEnd('?') : o.type; #> public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source) { @@ -106,9 +105,9 @@ foreach (var o in os) private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) { - <#=nonNullType#> sum = <#=o.zero#>; + var sum = <#=o.zero#>; - IAsyncEnumerator<<#=o.type#>> e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -143,15 +142,15 @@ else private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { - <#=nonNullType#> sum = <#=o.zero#>; + var sum = <#=o.zero#>; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - <#=o.type#> value = selector(e.Current); + var value = selector(e.Current); <# if (o.@checked) @@ -182,15 +181,15 @@ else private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { - <#=nonNullType#> sum = <#=o.zero#>; + var sum = <#=o.zero#>; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - <#=o.type#> value = await selector(e.Current).ConfigureAwait(false); + var value = await selector(e.Current).ConfigureAwait(false); <# if (o.@checked) @@ -222,15 +221,15 @@ else #if !NO_DEEP_CANCELLATION private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) { - <#=nonNullType#> sum = <#=o.zero#>; + var sum = <#=o.zero#>; - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - <#=o.type#> value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); <# if (o.@checked) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 5750b84658..794e51af8a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -80,7 +80,7 @@ protected override async ValueTask MoveNextCore() { if (_count > 0) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (_queue.Count >= _count) { _queue.Dequeue(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index e51331437d..6e2c81005e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -120,7 +120,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (!_predicate(item)) { break; @@ -184,7 +184,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -253,7 +253,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (!await _predicate(item).ConfigureAwait(false)) { break; @@ -318,7 +318,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (!await _predicate(item, _cancellationToken).ConfigureAwait(false)) { break; @@ -383,7 +383,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -454,7 +454,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs index f5b6ba763e..6c434cbfb3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToAsyncEnumerable.Observable.cs @@ -76,7 +76,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (true) { - bool completed = Volatile.Read(ref _completed); + var completed = Volatile.Read(ref _completed); if (_values.TryDequeue(out _current)) { @@ -84,7 +84,7 @@ protected override async ValueTask MoveNextCore() } else if (completed) { - Exception error = _error; + var error = _error; if (error != null) { @@ -131,7 +131,7 @@ private void OnNotification() { while (true) { - TaskCompletionSource signal = Volatile.Read(ref _signal); + var signal = Volatile.Read(ref _signal); if (signal == TaskExt.True) { @@ -170,7 +170,7 @@ private Task Resume() while (true) { - TaskCompletionSource signal = Volatile.Read(ref _signal); + var signal = Volatile.Read(ref _signal); if (signal != null) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 57d6513fdb..822161b94e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -240,7 +240,7 @@ public static Task> ToDictionaryAsync> ToDictionaryCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -248,10 +248,10 @@ private static async Task> ToDictionaryCore> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -274,10 +274,10 @@ private static async Task> ToDictionaryCore> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { @@ -301,10 +301,10 @@ private static async Task> ToDictionaryCore ToEnumerable(this IAsyncEnumerable Core() { - IAsyncEnumerator e = source.GetAsyncEnumerator(default); + var e = source.GetAsyncEnumerator(default); try { @@ -46,7 +46,7 @@ IEnumerable Core() private static void Wait(ValueTask task) { - Runtime.CompilerServices.ValueTaskAwaiter awaiter = task.GetAwaiter(); + var awaiter = task.GetAwaiter(); if (!awaiter.IsCompleted) { @@ -59,7 +59,7 @@ private static void Wait(ValueTask task) private static T Wait(ValueTask task) { - Runtime.CompilerServices.ValueTaskAwaiter awaiter = task.GetAwaiter(); + var awaiter = task.GetAwaiter(); if (!awaiter.IsCompleted) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index d83e8722a0..607aff12ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -44,7 +44,7 @@ public static Task> ToHashSetAsync(this IAsyncEnumerab private static async Task> ToHashSetCore(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index a7f4530ce4..85e9ded3ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -35,7 +35,7 @@ private static Task> ToListCore(IAsyncEnumerable async Task> Core() { - IAsyncEnumerator e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs index 264130b0ab..f2e74d95bd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToObservable.cs @@ -28,7 +28,7 @@ public ToObservableObservable(IAsyncEnumerable source) public IDisposable Subscribe(IObserver observer) { var ctd = new CancellationTokenDisposable(); - IAsyncEnumerator e = _source.GetAsyncEnumerator(ctd.Token); + var e = _source.GetAsyncEnumerator(ctd.Token); async void Core() { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 11f136aa97..aa3cb5cfba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -86,7 +86,7 @@ private async Task SetEnumeratorAsync(IAsyncEnumerator enumerator) private void StoreFirst() { var set = new Set(_comparer); - TSource element = _enumerator.Current; + var element = _enumerator.Current; set.Add(element); _current = element; _set = set; @@ -94,12 +94,12 @@ private void StoreFirst() private async ValueTask GetNextAsync() { - Set set = _set; + var set = _set; Debug.Assert(set != null); while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource element = _enumerator.Current; + var element = _enumerator.Current; if (set.Add(element)) { _current = element; @@ -117,11 +117,11 @@ protected sealed override async ValueTask MoveNextCore() case AsyncIteratorState.Allocated: _index = 0; - for (IAsyncEnumerable enumerable = GetEnumerable(0); enumerable != null; enumerable = GetEnumerable(_index)) + for (var enumerable = GetEnumerable(0); enumerable != null; enumerable = GetEnumerable(_index)) { ++_index; - IAsyncEnumerator enumerator = enumerable.GetAsyncEnumerator(_cancellationToken); + var enumerator = enumerable.GetAsyncEnumerator(_cancellationToken); if (await enumerator.MoveNextAsync().ConfigureAwait(false)) { @@ -143,7 +143,7 @@ protected sealed override async ValueTask MoveNextCore() return true; } - IAsyncEnumerable enumerable = GetEnumerable(_index); + var enumerable = GetEnumerable(_index); if (enumerable == null) { break; @@ -168,13 +168,13 @@ private async Task> FillSetAsync(CancellationToken cancellationToke for (var index = 0; ; ++index) { - IAsyncEnumerable enumerable = GetEnumerable(index); + var enumerable = GetEnumerable(index); if (enumerable == null) { return set; } - IAsyncEnumerator e = enumerable.GetAsyncEnumerator(cancellationToken); + var e = enumerable.GetAsyncEnumerator(cancellationToken); try { @@ -192,13 +192,13 @@ private async Task> FillSetAsync(CancellationToken cancellationToke public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - Set set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); return set.ToArray(); } public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - Set set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); return set.ToList(); } @@ -213,7 +213,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella async ValueTask Core() { - Set set = await FillSetAsync(cancellationToken).ConfigureAwait(false); + var set = await FillSetAsync(cancellationToken).ConfigureAwait(false); return set.Count; } } @@ -255,7 +255,7 @@ internal override IAsyncEnumerable GetEnumerable(int index) internal override UnionAsyncIterator Union(IAsyncEnumerable next) { - SingleLinkedNode> sources = new SingleLinkedNode>(_first).Add(_second).Add(next); + var sources = new SingleLinkedNode>(_first).Add(_second).Add(next); return new UnionAsyncIteratorN(sources, 2, _comparer); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 264023b924..3d5af66827 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -163,7 +163,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (_predicate(item)) { _current = item; @@ -225,7 +225,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -295,7 +295,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (await _predicate(item).ConfigureAwait(false)) { _current = item; @@ -360,7 +360,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) { _current = item; @@ -423,7 +423,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -492,7 +492,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; checked { @@ -567,7 +567,7 @@ protected override async ValueTask MoveNextCore() case AsyncIteratorState.Iterating: while (await _enumerator.MoveNextAsync().ConfigureAwait(false)) { - TSource item = _enumerator.Current; + var item = _enumerator.Current; if (_predicate(item)) { _current = _selector(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs index b2037b9f0e..aa3286f005 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Set.cs @@ -35,9 +35,8 @@ public bool Add(TElement value) #if DEBUG Debug.Assert(!_haveRemoved, "This class is optimized for never calling Add after Remove. If your changes need to do so, undo that optimization."); #endif - int hashCode = InternalGetHashCode(value); - - for (int i = _buckets[hashCode % _buckets.Length] - 1; i >= 0; i = _slots[i]._next) + var hashCode = InternalGetHashCode(value); + for (var i = _buckets[hashCode % _buckets.Length] - 1; i >= 0; i = _slots[i]._next) { if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) { @@ -50,15 +49,13 @@ public bool Add(TElement value) Resize(); } - int index = Count; + var index = Count; Count++; - - int bucket = hashCode % _buckets.Length; + var bucket = hashCode % _buckets.Length; _slots[index]._hashCode = hashCode; _slots[index]._value = value; _slots[index]._next = _buckets[bucket] - 1; _buckets[bucket] = index + 1; - return true; } @@ -68,11 +65,10 @@ public bool Remove(TElement value) #if DEBUG _haveRemoved = true; #endif - int hashCode = InternalGetHashCode(value); - int bucket = hashCode % _buckets.Length; - int last = -1; - - for (int i = _buckets[bucket] - 1; i >= 0; last = i, i = _slots[i]._next) + var hashCode = InternalGetHashCode(value); + var bucket = hashCode % _buckets.Length; + var last = -1; + for (var i = _buckets[bucket] - 1; i >= 0; last = i, i = _slots[i]._next) { if (_slots[i]._hashCode == hashCode && _comparer.Equals(_slots[i]._value, value)) { @@ -88,7 +84,6 @@ public bool Remove(TElement value) _slots[i]._hashCode = -1; _slots[i]._value = default; _slots[i]._next = -1; - return true; } } @@ -108,7 +103,6 @@ internal TElement[] ToArray() Debug.Assert(!_haveRemoved, "Optimized ToArray cannot be called if Remove has been called."); #endif var array = new TElement[Count]; - for (var i = 0; i != array.Length; ++i) { array[i] = _slots[i]._value; @@ -122,9 +116,8 @@ internal List ToList() #if DEBUG Debug.Assert(!_haveRemoved, "Optimized ToList cannot be called if Remove has been called."); #endif - int count = Count; + var count = Count; var list = new List(count); - for (var i = 0; i != count; ++i) { list.Add(_slots[i]._value); @@ -135,16 +128,13 @@ internal List ToList() private void Resize() { - int newSize = checked((Count * 2) + 1); + var newSize = checked((Count * 2) + 1); var newBuckets = new int[newSize]; var newSlots = new Slot[newSize]; - Array.Copy(_slots, 0, newSlots, 0, Count); - for (var i = 0; i < Count; i++) { - int bucket = newSlots[i]._hashCode % newSize; - + var bucket = newSlots[i]._hashCode % newSize; newSlots[i]._next = newBuckets[bucket] - 1; newBuckets[bucket] = i + 1; } From 7a73902877278d286e893309865414ac70398bc1 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 10:41:34 -0500 Subject: [PATCH 612/862] update extras --- Ix.NET/Source/global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index eca09e09aa..f438600dad 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "MSBuild.Sdk.Extras": "1.6.55" + "MSBuild.Sdk.Extras": "1.6.65" } } \ No newline at end of file From 2b33f10e163b44c33447ed637fce75e315fa00e0 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 14:36:48 -0500 Subject: [PATCH 613/862] Update tool versions --- Ix.NET/Source/Directory.build.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index 498dfc9dfe..1b565cfcd6 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -20,13 +20,13 @@ - + full - - + + From 71c561f165c82c59bd5bbd615169d8ea8d4e34fb Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 14:39:56 -0500 Subject: [PATCH 614/862] add support for C# 8 build --- Ix.NET/Source/Directory.build.props | 1 + Ix.NET/Source/Directory.build.targets | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index 1b565cfcd6..03ee3bfaab 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -17,6 +17,7 @@ true true latest + true diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index e43257ab08..8eb3acd3ea 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -11,6 +11,10 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION + + $(DefineConstants);CSHARP8 + + $(AssemblyName) ($(TargetFramework)) From 87f65f16863d46f14d16dde8281b7a71a5773537 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 1 Jan 2019 14:43:26 -0500 Subject: [PATCH 615/862] Use .NET Core 3.0 preview SDK to build --- Ix.NET/Source/global.json | 5 ++++- azure-pipelines.ix.yml | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index 2120c2f148..50c5a4d98e 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,5 +1,8 @@ { + "sdk": { + "version": "3.0.100-preview" + }, "msbuild-sdks": { - "MSBuild.Sdk.Extras": "1.6.65" + "MSBuild.Sdk.Extras": "2.0.0-preview.14" } } diff --git a/azure-pipelines.ix.yml b/azure-pipelines.ix.yml index d8a67164fa..17ff3be657 100644 --- a/azure-pipelines.ix.yml +++ b/azure-pipelines.ix.yml @@ -28,6 +28,10 @@ variables: BuildConfiguration: Release steps: +- task: DotNetCoreInstaller@0 + inputs: + version: '3.0.100-preview-009812' + - task: DotNetCoreCLI@2 inputs: command: custom From 369026d24e2f5a6ae6331e698fad86a4adfa1dbb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 21:45:46 -0800 Subject: [PATCH 616/862] Taming CancellationToken overload hell --- .../AsyncQueryableExTests.Generated.cs | 127 +- .../System/Linq/AsyncQueryableEx.Generated.cs | 178 +- .../System/Linq/AsyncQueryableEx.Generated.tt | 12 +- .../System/Linq/Operators/IsEmpty.cs | 20 +- .../System/Linq/Operators/Max.cs | 60 +- .../System/Linq/Operators/MaxBy.cs | 52 +- .../System/Linq/Operators/Min.cs | 60 +- .../System/Linq/Operators/MinBy.cs | 52 +- .../AsyncQueryableTests.Generated.cs | 4418 +++++--------- .../System/Linq/AsyncQueryable.Generated.cs | 5134 +++++------------ .../System/Linq/AsyncQueryable.Generated.tt | 12 +- .../System/Linq/Operators/Aggregate.cs | 82 +- .../System/Linq/Operators/All.cs | 26 +- .../System/Linq/Operators/Any.cs | 36 +- .../Linq/Operators/Average.Generated.cs | 360 +- .../Linq/Operators/Average.Generated.tt | 36 +- .../System/Linq/Operators/Contains.cs | 20 +- .../System/Linq/Operators/Count.cs | 36 +- .../System/Linq/Operators/ElementAt.cs | 72 +- .../Linq/Operators/ElementAtOrDefault.cs | 74 +- .../System/Linq/Operators/First.cs | 36 +- .../System/Linq/Operators/FirstOrDefault.cs | 36 +- .../System/Linq/Operators/ForEach.cs | 48 +- .../System/Linq/Operators/Last.cs | 36 +- .../System/Linq/Operators/LastOrDefault.cs | 36 +- .../System/Linq/Operators/LongCount.cs | 36 +- .../System/Linq/Operators/Max.cs | 36 +- .../System/Linq/Operators/Min.cs | 36 +- .../System/Linq/Operators/MinMax.Generated.cs | 720 +-- .../System/Linq/Operators/MinMax.Generated.tt | 36 +- .../System/Linq/Operators/SequenceEqual.cs | 24 +- .../System/Linq/Operators/Single.cs | 36 +- .../System/Linq/Operators/SingleOrDefault.cs | 36 +- .../System/Linq/Operators/Sum.Generated.cs | 360 +- .../System/Linq/Operators/Sum.Generated.tt | 36 +- .../System/Linq/Operators/ToArray.cs | 10 +- .../System/Linq/Operators/ToDictionary.cs | 112 +- .../System/Linq/Operators/ToHashSet.cs | 20 +- .../System/Linq/Operators/ToList.cs | 10 +- .../System/Linq/Operators/ToLookup.cs | 112 +- 40 files changed, 3061 insertions(+), 9618 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs index 74599713ff..1cccc6ab77 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.cs @@ -476,15 +476,6 @@ public void IgnoreElements1() [Fact] public void IsEmptyAsync1() - { - AssertEx.Throws(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryableEx.IsEmptyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void IsEmptyAsync2() { AssertEx.Throws(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -494,15 +485,6 @@ public void IsEmptyAsync2() [Fact] public void MaxAsync1() - { - AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - - var res = AsyncQueryableEx.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync2() { AssertEx.Throws(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); @@ -512,26 +494,6 @@ public void MaxAsync2() [Fact] public void MaxByAsync1() - { - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxByAsync2() - { - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxByAsync3() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -541,7 +503,7 @@ public void MaxByAsync3() } [Fact] - public void MaxByAsync4() + public void MaxByAsync2() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -551,7 +513,7 @@ public void MaxByAsync4() } [Fact] - public void MaxByAsync5() + public void MaxByAsync3() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -561,27 +523,7 @@ public void MaxByAsync5() } [Fact] - public void MaxByAsync6() - { - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxByAsync7() - { - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxByAsync8() + public void MaxByAsync4() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -591,7 +533,7 @@ public void MaxByAsync8() } [Fact] - public void MaxByAsync9() + public void MaxByAsync5() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -601,7 +543,7 @@ public void MaxByAsync9() } [Fact] - public void MaxByAsync10() + public void MaxByAsync6() { AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MaxByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -622,15 +564,6 @@ public void Merge1() [Fact] public void MinAsync1() - { - AssertEx.Throws(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), Comparer.Default), ane => ane.ParamName == "source"); - - var res = AsyncQueryableEx.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync2() { AssertEx.Throws(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); @@ -640,26 +573,6 @@ public void MinAsync2() [Fact] public void MinByAsync1() - { - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinByAsync2() - { - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinByAsync3() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -669,7 +582,7 @@ public void MinByAsync3() } [Fact] - public void MinByAsync4() + public void MinByAsync2() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -679,7 +592,7 @@ public void MinByAsync4() } [Fact] - public void MinByAsync5() + public void MinByAsync3() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -689,27 +602,7 @@ public void MinByAsync5() } [Fact] - public void MinByAsync6() - { - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinByAsync7() - { - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinByAsync8() + public void MinByAsync4() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -719,7 +612,7 @@ public void MinByAsync8() } [Fact] - public void MinByAsync9() + public void MinByAsync5() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -729,7 +622,7 @@ public void MinByAsync9() } [Fact] - public void MinByAsync10() + public void MinByAsync6() { AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryableEx.MinByAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 9f1517e03a..25ad89b71e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -598,19 +598,7 @@ public static IAsyncQueryable IgnoreElements(this IAsyncQuerya #endif } - public static Task IsEmptyAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task IsEmptyAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task IsEmptyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -622,19 +610,7 @@ public static Task IsEmptyAsync(this IAsyncQueryable sou #endif } - public static Task MaxAsync(this IAsyncQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -646,35 +622,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -688,7 +636,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -702,21 +650,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -730,21 +664,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -758,7 +678,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -772,7 +692,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -798,19 +718,7 @@ public static IAsyncQueryable Merge(this IAsyncQueryable MinAsync(this IAsyncQueryable source, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), default(IComparer))), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task MinAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -822,35 +730,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -864,7 +744,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -878,21 +758,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -906,21 +772,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer))), CancellationToken.None); -#endif - } - - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -934,7 +786,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -948,7 +800,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt index 117f7859a2..d820e47424 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -146,17 +146,25 @@ foreach (var m in typeof(AsyncEnumerableEx).GetMethods() } var isParams = false; + var lastParameterDefault = false; var parCount = m.GetParameters().Length; if (parCount != 0) { - if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) + var lastParam = m.GetParameters().Last(); + + if (lastParam.IsDefined(typeof(ParamArrayAttribute), true)) { isParams = true; } + + if (lastParam.ParameterType == typeof(CancellationToken)) + { + lastParameterDefault = true; + } } - var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name + (i == parCount - 1 && lastParameterDefault ? " = default" : ""))); var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index 836bfe2de4..4c541b2ae9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -10,25 +10,17 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task IsEmptyAsync(this IAsyncEnumerable source) + public static Task IsEmptyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return IsEmptyCore(source, CancellationToken.None); - } - - public static Task IsEmptyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return IsEmptyCore(source, cancellationToken); - } + return Core(); - private static async Task IsEmptyCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - return !await source.AnyAsync(cancellationToken).ConfigureAwait(false); + async Task Core() + { + return !await source.AnyAsync(cancellationToken).ConfigureAwait(false); + } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 2e2e49a537..9498edf181 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -10,53 +10,45 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task MaxAsync(this IAsyncEnumerable source, IComparer comparer) + public static Task MaxAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, comparer, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, comparer, cancellationToken); - } - - private static async Task MaxCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - if (comparer == null) - { - comparer = Comparer.Default; - } - - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw Error.NoElements(); + if (comparer == null) + { + comparer = Comparer.Default; + } - var max = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var cur = e.Current; + if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); + + var max = e.Current; - if (comparer.Compare(cur, max) > 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - max = cur; + var cur = e.Current; + + if (comparer.Compare(cur, max) > 0) + { + max = cur; + } } - } - return max; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return max; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index b351242334..5cc5134b0a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -10,17 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MaxByCore(source, keySelector, comparer: null, CancellationToken.None); - } - - public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,17 +20,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer: null, cancellationToken); } - public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MaxByCore(source, keySelector, comparer, CancellationToken.None); - } - - public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -50,17 +30,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer, cancellationToken); } - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MaxByCore(source, keySelector, comparer: null, CancellationToken.None); - } - - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,7 +41,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -82,17 +52,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab } #endif - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MaxByCore(source, keySelector, comparer, CancellationToken.None); - } - - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -103,7 +63,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 09337d7636..e3dfdc1581 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -10,53 +10,45 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task MinAsync(this IAsyncEnumerable source, IComparer comparer) + public static Task MinAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, comparer, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, comparer, cancellationToken); - } - - private static async Task MinCore(IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken) - { - if (comparer == null) - { - comparer = Comparer.Default; - } + return Core(); - var e = source.GetAsyncEnumerator(cancellationToken); - - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw Error.NoElements(); + if (comparer == null) + { + comparer = Comparer.Default; + } - var min = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var cur = e.Current; + if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); - if (comparer.Compare(cur, min) < 0) + var min = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) { - min = cur; + var cur = e.Current; + + if (comparer.Compare(cur, min) < 0) + { + min = cur; + } } - } - return min; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return min; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index b192cf6bf8..d932cd8772 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -10,17 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MinByCore(source, keySelector, comparer: null, CancellationToken.None); - } - - public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,17 +20,7 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer: null, cancellationToken); } - public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MinByCore(source, keySelector, comparer, CancellationToken.None); - } - - public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -50,17 +30,7 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer, cancellationToken); } - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MinByCore(source, keySelector, comparer: null, CancellationToken.None); - } - - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,7 +41,7 @@ public static Task> MinByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -82,17 +52,7 @@ public static Task> MinByAsync(this IAsyncEnumerab } #endif - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return MinByCore(source, keySelector, comparer, CancellationToken.None); - } - - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -103,7 +63,7 @@ public static Task> MinByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index 72eb747c02..af4c5b2e32 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -16,26 +16,6 @@ public class AsyncQueryableExTests { [Fact] public void AggregateAsync1() - { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AggregateAsync2() - { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AggregateAsync3() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -45,7 +25,7 @@ public void AggregateAsync3() } [Fact] - public void AggregateAsync4() + public void AggregateAsync2() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -55,7 +35,7 @@ public void AggregateAsync4() } [Fact] - public void AggregateAsync5() + public void AggregateAsync3() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -65,27 +45,7 @@ public void AggregateAsync5() } [Fact] - public void AggregateAsync6() - { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AggregateAsync7() - { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>)), ane => ane.ParamName == "accumulator"); - - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AggregateAsync8() + public void AggregateAsync4() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -95,7 +55,7 @@ public void AggregateAsync8() } [Fact] - public void AggregateAsync9() + public void AggregateAsync5() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -105,7 +65,7 @@ public void AggregateAsync9() } [Fact] - public void AggregateAsync10() + public void AggregateAsync6() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -115,29 +75,7 @@ public void AggregateAsync10() } [Fact] - public void AggregateAsync11() - { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AggregateAsync12() - { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AggregateAsync13() + public void AggregateAsync7() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -148,7 +86,7 @@ public void AggregateAsync13() } [Fact] - public void AggregateAsync14() + public void AggregateAsync8() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -159,7 +97,7 @@ public void AggregateAsync14() } [Fact] - public void AggregateAsync15() + public void AggregateAsync9() { AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); @@ -171,26 +109,6 @@ public void AggregateAsync15() [Fact] public void AllAsync1() - { - AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AllAsync2() - { - AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AllAsync3() { AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); @@ -200,7 +118,7 @@ public void AllAsync3() } [Fact] - public void AllAsync4() + public void AllAsync2() { AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); @@ -210,7 +128,7 @@ public void AllAsync4() } [Fact] - public void AllAsync5() + public void AllAsync3() { AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); @@ -221,15 +139,6 @@ public void AllAsync5() [Fact] public void AnyAsync1() - { - AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AnyAsync2() { AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -238,27 +147,7 @@ public void AnyAsync2() } [Fact] - public void AnyAsync3() - { - AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AnyAsync4() - { - AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AnyAsync5() + public void AnyAsync2() { AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); @@ -268,7 +157,7 @@ public void AnyAsync5() } [Fact] - public void AnyAsync6() + public void AnyAsync3() { AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); @@ -278,7 +167,7 @@ public void AnyAsync6() } [Fact] - public void AnyAsync7() + public void AnyAsync4() { AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); @@ -300,4197 +189,2710 @@ public void Append1() [Fact] public void AverageAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync3() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync4() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync5() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync6() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync7() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync8() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync9() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync10() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.AverageAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync11() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync12() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync13() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync14() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync15() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync16() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync17() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync18() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync19() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync20() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync21() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync22() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync23() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync24() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync25() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync26() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync27() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync28() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync29() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync30() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync31() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync32() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync33() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync34() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync35() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync36() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync37() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync38() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync39() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync40() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync41() + public void Cast1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Cast(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Cast(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync42() + public void Concat1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Concat(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync43() + public void ContainsAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync44() + public void ContainsAsync2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync45() + public void CountAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync46() + public void CountAsync2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync47() + public void CountAsync3() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync48() + public void CountAsync4() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync49() + public void DefaultIfEmpty1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync50() + public void DefaultIfEmpty2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync51() + public void Distinct1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync52() + public void Distinct2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync53() + public void ElementAtAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.ElementAtAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync54() + public void ElementAtOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ElementAtOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync55() + public void Except1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync56() + public void Except2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync57() + public void FirstAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync58() + public void FirstAsync2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync59() + public void FirstAsync3() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync60() + public void FirstAsync4() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync61() + public void FirstOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync62() + public void FirstOrDefaultAsync2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync63() + public void FirstOrDefaultAsync3() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync64() + public void FirstOrDefaultAsync4() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync65() + public void GroupBy1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync66() + public void GroupBy2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync67() + public void GroupBy3() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync68() + public void GroupBy4() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync69() + public void GroupBy5() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void AverageAsync70() + public void GroupBy6() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Cast1() + public void GroupBy7() { - AssertEx.Throws(() => AsyncQueryable.Cast(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.Cast(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Concat1() + public void GroupBy8() { - AssertEx.Throws(() => AsyncQueryable.Concat(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.Concat(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ContainsAsync1() + public void GroupBy9() { - AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ContainsAsync2() + public void GroupBy10() { - AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ContainsAsync3() + public void GroupBy11() { - AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ContainsAsync4() + public void GroupBy12() { - AssertEx.Throws(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), 1, EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.ContainsAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void CountAsync1() + public void GroupBy13() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void CountAsync2() + public void GroupBy14() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void CountAsync3() + public void GroupBy15() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void CountAsync4() + public void GroupBy16() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void CountAsync5() + public void GroupBy17() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void CountAsync6() + public void GroupBy18() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void CountAsync7() + public void GroupBy19() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void DefaultIfEmpty1() + public void GroupBy20() { - AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void DefaultIfEmpty2() + public void GroupBy21() { - AssertEx.Throws(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.DefaultIfEmpty(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Distinct1() + public void GroupBy22() { - AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Distinct2() + public void GroupBy23() { - AssertEx.Throws(() => AsyncQueryable.Distinct(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Distinct(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ElementAtAsync1() + public void GroupBy24() { - AssertEx.Throws(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.ElementAtAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ElementAtAsync2() + public void GroupJoin1() { - AssertEx.Throws(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.ElementAtAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ElementAtOrDefaultAsync1() + public void GroupJoin2() { - AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.ElementAtOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void ElementAtOrDefaultAsync2() + public void GroupJoin3() { - AssertEx.Throws(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), 1, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.ElementAtOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Except1() + public void GroupJoin4() { - AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Except2() + public void GroupJoin5() { - AssertEx.Throws(() => AsyncQueryable.Except(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Except(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void FirstAsync1() + public void GroupJoin6() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void FirstAsync2() + public void Intersect1() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void FirstAsync3() + public void Intersect2() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void FirstAsync4() + public void Join1() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void FirstAsync5() + public void Join2() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void FirstAsync6() + public void Join3() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void FirstAsync7() + public void Join4() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefaultAsync1() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefaultAsync2() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefaultAsync3() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefaultAsync4() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefaultAsync5() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefaultAsync6() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void FirstOrDefaultAsync7() - { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void GroupBy1() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy2() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy3() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy4() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy5() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy6() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy7() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy8() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy9() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy10() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy11() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy12() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy13() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy14() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy15() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy16() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy17() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy18() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy19() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy20() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy21() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy22() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy23() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupBy24() - { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin1() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin2() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin3() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin4() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin5() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void GroupJoin6() - { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Intersect1() - { - AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Intersect2() - { - AssertEx.Throws(() => AsyncQueryable.Intersect(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); - - var res = AsyncQueryable.Intersect(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Join1() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Join2() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Join3() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Join4() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Join5() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Join6() - { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void LastAsync1() - { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastAsync2() - { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastAsync3() - { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastAsync4() - { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastAsync5() - { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastAsync6() - { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastAsync7() - { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefaultAsync1() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefaultAsync2() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefaultAsync3() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefaultAsync4() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefaultAsync5() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefaultAsync6() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LastOrDefaultAsync7() - { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCountAsync1() - { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCountAsync2() - { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCountAsync3() - { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCountAsync4() - { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCountAsync5() - { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCountAsync6() - { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void LongCountAsync7() - { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync1() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync2() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync3() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync4() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync5() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync6() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync7() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync8() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync9() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync10() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync11() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync12() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync13() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync14() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync15() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync16() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync17() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync18() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync19() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync20() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync21() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync22() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync23() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync24() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync25() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync26() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync27() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync28() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync29() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync30() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync31() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync32() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync33() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync34() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync35() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync36() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync37() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync38() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync39() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync40() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync41() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync42() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync43() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync44() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync45() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync46() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync47() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync48() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync49() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync50() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync51() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync52() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync53() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync54() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync55() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync56() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync57() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync58() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync59() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync60() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync61() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync62() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync63() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync64() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync65() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync66() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync67() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync68() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync69() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync70() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync71() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync72() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync73() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync74() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync75() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync76() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MaxAsync77() - { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync1() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync2() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync3() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync4() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync5() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync6() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync7() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync8() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync9() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync10() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync11() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync12() + public void Join5() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void MinAsync13() + public void Join6() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.MinAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void MinAsync14() + public void LastAsync1() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync15() + public void LastAsync2() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync16() + public void LastAsync3() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync17() + public void LastAsync4() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync18() + public void LastOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync19() + public void LastOrDefaultAsync2() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync20() + public void LastOrDefaultAsync3() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync21() + public void LastOrDefaultAsync4() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); + var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync22() + public void LongCountAsync1() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync23() + public void LongCountAsync2() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync24() + public void LongCountAsync3() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync25() + public void LongCountAsync4() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync26() + public void MaxAsync1() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync27() + public void MaxAsync2() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); + var res = AsyncQueryable.MaxAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync28() + public void MaxAsync3() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync29() + public void MaxAsync4() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync30() + public void MaxAsync5() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync31() + public void MaxAsync6() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); + var res = AsyncQueryable.MaxAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync32() + public void MaxAsync7() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync33() + public void MaxAsync8() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync34() + public void MaxAsync9() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync35() + public void MaxAsync10() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.MaxAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync36() + public void MaxAsync11() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync37() + public void MaxAsync12() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync38() + public void MaxAsync13() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync39() + public void MaxAsync14() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync40() + public void MaxAsync15() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync41() + public void MaxAsync16() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync42() + public void MaxAsync17() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync43() + public void MaxAsync18() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync44() + public void MaxAsync19() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync45() + public void MaxAsync20() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync46() + public void MaxAsync21() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync47() + public void MaxAsync22() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync48() + public void MaxAsync23() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync49() + public void MaxAsync24() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync50() + public void MaxAsync25() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync51() + public void MaxAsync26() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync52() + public void MaxAsync27() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync53() + public void MaxAsync28() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync54() + public void MaxAsync29() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync55() + public void MaxAsync30() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync56() + public void MaxAsync31() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync57() + public void MaxAsync32() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync58() + public void MaxAsync33() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync59() + public void MaxAsync34() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync60() + public void MaxAsync35() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync61() + public void MaxAsync36() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync62() + public void MaxAsync37() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync63() + public void MaxAsync38() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync64() + public void MaxAsync39() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync65() + public void MaxAsync40() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync66() + public void MaxAsync41() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync67() + public void MaxAsync42() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync68() + public void MaxAsync43() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync69() + public void MaxAsync44() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync70() + public void MinAsync1() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync71() + public void MinAsync2() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync72() + public void MinAsync3() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync73() + public void MinAsync4() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MinAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync74() + public void MinAsync5() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync75() + public void MinAsync6() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync76() + public void MinAsync7() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync77() + public void MinAsync8() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OfType1() + public void MinAsync9() { - AssertEx.Throws(() => AsyncQueryable.OfType(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.OfType(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderBy1() + public void MinAsync10() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MinAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderBy2() + public void MinAsync11() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderBy3() + public void MinAsync12() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderBy4() + public void MinAsync13() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderBy5() + public void MinAsync14() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderByDescending1() + public void MinAsync15() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderByDescending2() + public void MinAsync16() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderByDescending3() + public void MinAsync17() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderByDescending4() + public void MinAsync18() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderByDescending5() + public void MinAsync19() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void OrderByDescending6() + public void MinAsync20() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Prepend1() + public void MinAsync21() { - AssertEx.Throws(() => AsyncQueryable.Prepend(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Prepend(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Reverse1() + public void MinAsync22() { - AssertEx.Throws(() => AsyncQueryable.Reverse(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Reverse(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Select1() + public void MinAsync23() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Select2() + public void MinAsync24() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Select3() + public void MinAsync25() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Select4() + public void MinAsync26() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Select5() + public void MinAsync27() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void Select6() + public void MinAsync28() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany1() + public void MinAsync29() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany2() + public void MinAsync30() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany3() + public void MinAsync31() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany4() + public void MinAsync32() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany5() + public void MinAsync33() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany6() + public void MinAsync34() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany7() + public void MinAsync35() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany8() + public void MinAsync36() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany9() + public void MinAsync37() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany10() + public void MinAsync38() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany11() + public void MinAsync39() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SelectMany12() + public void MinAsync40() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SequenceEqualAsync1() + public void MinAsync41() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SequenceEqualAsync2() + public void MinAsync42() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SequenceEqualAsync3() + public void MinAsync43() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SequenceEqualAsync4() + public void MinAsync44() { - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleAsync1() + public void OfType1() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OfType(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OfType(new object[] { default(object) }.ToAsyncEnumerable().AsAsyncQueryable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SingleAsync2() + public void OrderBy1() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); } [Fact] - public void SingleAsync3() + public void OrderBy2() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); } [Fact] - public void SingleAsync4() + public void OrderBy3() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] - public void SingleAsync5() + public void OrderBy4() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); } [Fact] - public void SingleAsync6() + public void OrderBy5() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] - public void SingleAsync7() + public void OrderBy6() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } [Fact] - public void SingleOrDefaultAsync1() + public void OrderByDescending1() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); } [Fact] - public void SingleOrDefaultAsync2() + public void OrderByDescending2() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); } [Fact] - public void SingleOrDefaultAsync3() + public void OrderByDescending3() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] - public void SingleOrDefaultAsync4() + public void OrderByDescending4() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); } [Fact] - public void SingleOrDefaultAsync5() + public void OrderByDescending5() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] - public void SingleOrDefaultAsync6() + public void OrderByDescending6() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } [Fact] - public void SingleOrDefaultAsync7() + public void Prepend1() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Prepend(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Prepend(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Skip1() + public void Reverse1() { - AssertEx.Throws(() => AsyncQueryable.Skip(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Reverse(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - var res = AsyncQueryable.Skip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var res = AsyncQueryable.Reverse(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipLast1() + public void Select1() { - AssertEx.Throws(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SkipLast(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile1() + public void Select2() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile2() + public void Select3() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile3() + public void Select4() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile4() + public void Select5() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile5() + public void Select6() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile6() + public void SelectMany1() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync1() + public void SelectMany2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync2() + public void SelectMany3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync3() + public void SelectMany4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync4() + public void SelectMany5() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync5() + public void SelectMany6() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync6() + public void SelectMany7() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SumAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync7() + public void SelectMany8() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SumAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync8() + public void SelectMany9() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SumAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync9() + public void SelectMany10() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync10() + public void SelectMany11() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync11() + public void SelectMany12() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync12() + public void SequenceEqualAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), CancellationToken.None), ane => ane.ParamName == "second"); - var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync13() + public void SequenceEqualAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "second"); - var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SequenceEqualAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync14() + public void SingleAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync15() + public void SingleAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync16() + public void SingleAsync3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync17() + public void SingleAsync4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync18() + public void SingleOrDefaultAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync19() + public void SingleOrDefaultAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => true, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync20() + public void SingleOrDefaultAsync3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync21() + public void SingleOrDefaultAsync4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync22() + public void Skip1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Skip(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.Skip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync23() + public void SkipLast1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), 1), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SkipLast(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync24() + public void SkipWhile1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync25() + public void SkipWhile2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync26() + public void SkipWhile3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync27() + public void SkipWhile4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync28() + public void SkipWhile5() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync29() + public void SkipWhile6() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double)); - AssertEx.SucceedOrFailProper(() => res.Wait()); + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SumAsync30() + public void SumAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync31() + public void SumAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal)); + var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync32() + public void SumAsync3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync33() + public void SumAsync4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync34() + public void SumAsync5() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync35() + public void SumAsync6() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable)); + var res = AsyncQueryable.SumAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync36() + public void SumAsync7() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync37() + public void SumAsync8() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.SumAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync38() + public void SumAsync9() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync39() + public void SumAsync10() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long)); + var res = AsyncQueryable.SumAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync40() + public void SumAsync11() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync41() + public void SumAsync12() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4500,7 +2902,7 @@ public void SumAsync41() } [Fact] - public void SumAsync42() + public void SumAsync13() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4510,7 +2912,7 @@ public void SumAsync42() } [Fact] - public void SumAsync43() + public void SumAsync14() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4520,7 +2922,7 @@ public void SumAsync43() } [Fact] - public void SumAsync44() + public void SumAsync15() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4530,7 +2932,7 @@ public void SumAsync44() } [Fact] - public void SumAsync45() + public void SumAsync16() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4540,7 +2942,7 @@ public void SumAsync45() } [Fact] - public void SumAsync46() + public void SumAsync17() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4550,7 +2952,7 @@ public void SumAsync46() } [Fact] - public void SumAsync47() + public void SumAsync18() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4560,7 +2962,7 @@ public void SumAsync47() } [Fact] - public void SumAsync48() + public void SumAsync19() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4570,7 +2972,7 @@ public void SumAsync48() } [Fact] - public void SumAsync49() + public void SumAsync20() { AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -4580,212 +2982,202 @@ public void SumAsync49() } [Fact] - public void SumAsync50() - { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void SumAsync51() + public void SumAsync21() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync52() + public void SumAsync22() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync53() + public void SumAsync23() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync54() + public void SumAsync24() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync55() + public void SumAsync25() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync56() + public void SumAsync26() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync57() + public void SumAsync27() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync58() + public void SumAsync28() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync59() + public void SumAsync29() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync60() + public void SumAsync30() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync61() + public void SumAsync31() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync62() + public void SumAsync32() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync63() + public void SumAsync33() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync64() + public void SumAsync34() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync65() + public void SumAsync35() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync66() + public void SumAsync36() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync67() + public void SumAsync37() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync68() + public void SumAsync38() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync69() + public void SumAsync39() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync70() + public void SumAsync40() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -4932,28 +3324,28 @@ public void ThenBy6() [Fact] public void ThenByDescending1() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); } [Fact] public void ThenByDescending2() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] public void ThenByDescending3() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); } [Fact] @@ -4985,15 +3377,6 @@ public void ThenByDescending6() [Fact] public void ToArrayAsync1() - { - AssertEx.Throws(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToArrayAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToArrayAsync2() { AssertEx.Throws(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -5003,26 +3386,6 @@ public void ToArrayAsync2() [Fact] public void ToDictionaryAsync1() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync2() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync3() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5032,7 +3395,7 @@ public void ToDictionaryAsync3() } [Fact] - public void ToDictionaryAsync4() + public void ToDictionaryAsync2() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5042,7 +3405,7 @@ public void ToDictionaryAsync4() } [Fact] - public void ToDictionaryAsync5() + public void ToDictionaryAsync3() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5052,27 +3415,17 @@ public void ToDictionaryAsync5() } [Fact] - public void ToDictionaryAsync6() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync7() + public void ToDictionaryAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync8() + public void ToDictionaryAsync5() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5082,7 +3435,7 @@ public void ToDictionaryAsync8() } [Fact] - public void ToDictionaryAsync9() + public void ToDictionaryAsync6() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5092,39 +3445,7 @@ public void ToDictionaryAsync9() } [Fact] - public void ToDictionaryAsync10() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync11() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync12() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync13() + public void ToDictionaryAsync7() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5135,7 +3456,7 @@ public void ToDictionaryAsync13() } [Fact] - public void ToDictionaryAsync14() + public void ToDictionaryAsync8() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5146,7 +3467,7 @@ public void ToDictionaryAsync14() } [Fact] - public void ToDictionaryAsync15() + public void ToDictionaryAsync9() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5157,29 +3478,7 @@ public void ToDictionaryAsync15() } [Fact] - public void ToDictionaryAsync16() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync17() - { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToDictionaryAsync18() + public void ToDictionaryAsync10() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5190,7 +3489,7 @@ public void ToDictionaryAsync18() } [Fact] - public void ToDictionaryAsync19() + public void ToDictionaryAsync11() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5201,7 +3500,7 @@ public void ToDictionaryAsync19() } [Fact] - public void ToDictionaryAsync20() + public void ToDictionaryAsync12() { AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5213,15 +3512,6 @@ public void ToDictionaryAsync20() [Fact] public void ToHashSetAsync1() - { - AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToHashSetAsync2() { AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -5230,16 +3520,7 @@ public void ToHashSetAsync2() } [Fact] - public void ToHashSetAsync3() - { - AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), EqualityComparer.Default), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToHashSetAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToHashSetAsync4() + public void ToHashSetAsync2() { AssertEx.Throws(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); @@ -5249,15 +3530,6 @@ public void ToHashSetAsync4() [Fact] public void ToListAsync1() - { - AssertEx.Throws(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable)), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.ToListAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable()); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToListAsync2() { AssertEx.Throws(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -5267,26 +3539,6 @@ public void ToListAsync2() [Fact] public void ToLookupAsync1() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync2() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync3() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5296,7 +3548,7 @@ public void ToLookupAsync3() } [Fact] - public void ToLookupAsync4() + public void ToLookupAsync2() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5306,7 +3558,7 @@ public void ToLookupAsync4() } [Fact] - public void ToLookupAsync5() + public void ToLookupAsync3() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5316,27 +3568,7 @@ public void ToLookupAsync5() } [Fact] - public void ToLookupAsync6() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync7() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync8() + public void ToLookupAsync4() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5346,7 +3578,7 @@ public void ToLookupAsync8() } [Fact] - public void ToLookupAsync9() + public void ToLookupAsync5() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5356,7 +3588,7 @@ public void ToLookupAsync9() } [Fact] - public void ToLookupAsync10() + public void ToLookupAsync6() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5366,29 +3598,7 @@ public void ToLookupAsync10() } [Fact] - public void ToLookupAsync11() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync12() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync13() + public void ToLookupAsync7() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5399,7 +3609,7 @@ public void ToLookupAsync13() } [Fact] - public void ToLookupAsync14() + public void ToLookupAsync8() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5410,7 +3620,7 @@ public void ToLookupAsync14() } [Fact] - public void ToLookupAsync15() + public void ToLookupAsync9() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5421,29 +3631,7 @@ public void ToLookupAsync15() } [Fact] - public void ToLookupAsync16() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync17() - { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void ToLookupAsync18() + public void ToLookupAsync10() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5454,7 +3642,7 @@ public void ToLookupAsync18() } [Fact] - public void ToLookupAsync19() + public void ToLookupAsync11() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); @@ -5465,7 +3653,7 @@ public void ToLookupAsync19() } [Fact] - public void ToLookupAsync20() + public void ToLookupAsync12() { AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 24cdbf4b2c..ad48fbf221 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -12,35 +12,7 @@ namespace System.Linq { public static partial class AsyncQueryable { - public static Task AggregateAsync(this IAsyncQueryable source, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); -#endif - } - - public static Task AggregateAsync(this IAsyncQueryable source, Expression>> accumulator) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator), CancellationToken.None); -#endif - } - - public static Task AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -54,7 +26,7 @@ public static Task AggregateAsync(this IAsyncQueryable AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -68,7 +40,7 @@ public static Task AggregateAsync(this IAsyncQueryable AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -82,35 +54,7 @@ public static Task AggregateAsync(this IAsyncQueryable AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); -#endif - } - - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator), CancellationToken.None); -#endif - } - - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -124,7 +68,7 @@ public static Task AggregateAsync(this IAsync #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -138,7 +82,7 @@ public static Task AggregateAsync(this IAsync #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -152,39 +96,7 @@ public static Task AggregateAsync(this IAsync #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); -#endif - } - - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (accumulator == null) - throw new ArgumentNullException(nameof(accumulator)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector), CancellationToken.None); -#endif - } - - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -200,7 +112,7 @@ public static Task AggregateAsync(this I #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -216,7 +128,7 @@ public static Task AggregateAsync(this I #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -232,35 +144,7 @@ public static Task AggregateAsync(this I #endif } - public static Task AllAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task AllAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -274,7 +158,7 @@ public static Task AllAsync(this IAsyncQueryable source, #endif } - public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -288,7 +172,7 @@ public static Task AllAsync(this IAsyncQueryable source, #endif } - public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -302,19 +186,7 @@ public static Task AllAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task AnyAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -326,35 +198,7 @@ public static Task AnyAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task AnyAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -368,7 +212,7 @@ public static Task AnyAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -382,7 +226,7 @@ public static Task AnyAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -408,247 +252,267 @@ public static IAsyncQueryable Append(this IAsyncQueryable AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source) + public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -656,13 +520,13 @@ public static Task AverageAsync(this IAsyncQueryable source, Cance throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -670,13 +534,13 @@ public static Task AverageAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -684,13 +548,13 @@ public static Task AverageAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -698,13 +562,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -712,13 +576,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -726,13 +590,13 @@ public static Task AverageAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -740,13 +604,13 @@ public static Task AverageAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -754,13 +618,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -768,13 +632,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -782,13 +646,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -796,13 +660,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -810,13 +674,13 @@ public static Task AverageAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -824,13 +688,13 @@ public static Task AverageAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -838,13 +702,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -852,13 +716,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -866,13 +730,13 @@ public static Task AverageAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -880,13 +744,13 @@ public static Task AverageAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -894,13 +758,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -908,13 +772,13 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector) + public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -922,3425 +786,1271 @@ public static Task AverageAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable Cast(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Cast(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable Concat(this IAsyncQueryable first, IAsyncEnumerable second) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Concat(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source, TSource defaultValue) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static IAsyncQueryable Distinct(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static IAsyncQueryable Distinct(this IAsyncQueryable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task ElementAtAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task ElementAtOrDefaultAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Cast(this IAsyncQueryable source) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Cast(default(IAsyncQueryable))), source.Expression)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable Concat(this IAsyncQueryable first, IAsyncEnumerable second) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Concat(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif - } - - public static Task ContainsAsync(this IAsyncQueryable source, TSource value) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource))), CancellationToken.None); -#endif - } - - public static Task ContainsAsync(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task CountAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task CountAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task CountAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task CountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif - } - - public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source, TSource defaultValue) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); -#endif - } - - public static IAsyncQueryable Distinct(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif - } - - public static IAsyncQueryable Distinct(this IAsyncQueryable source, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static Task ElementAtAsync(this IAsyncQueryable source, int index) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); -#endif - } - - public static Task ElementAtAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task ElementAtOrDefaultAsync(this IAsyncQueryable source, int index) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int))), CancellationToken.None); -#endif - } - - public static Task ElementAtOrDefaultAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif - } - - public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static Task FirstAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task FirstAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task FirstAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstOrDefaultAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task FirstOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif - } - - public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); - -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif - } - - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) - { - if (outer == null) - throw new ArgumentNullException(nameof(outer)); - if (inner == null) - throw new ArgumentNullException(nameof(inner)); - if (outerKeySelector == null) - throw new ArgumentNullException(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw new ArgumentNullException(nameof(innerKeySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); - -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif - } - - public static Task LastAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task LastAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LastAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task LastAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LastOrDefaultAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task LastOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LongCountAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task LongCountAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LongCountAsync(this IAsyncQueryable source, Expression> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); -#endif - } - - public static Task LongCountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (outer == null) + throw new ArgumentNullException(nameof(outer)); + if (inner == null) + throw new ArgumentNullException(nameof(inner)); + if (outerKeySelector == null) + throw new ArgumentNullException(nameof(outerKeySelector)); + if (innerKeySelector == null) + throw new ArgumentNullException(nameof(innerKeySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source) + public static Task LastAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LongCountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LongCountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4348,13 +2058,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4362,13 +2072,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4376,13 +2086,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4390,13 +2100,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4404,13 +2114,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4418,13 +2128,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4432,13 +2142,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4446,13 +2156,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4460,13 +2170,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4474,13 +2184,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4488,13 +2198,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4502,13 +2212,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4516,13 +2226,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4530,13 +2240,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4544,13 +2254,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4558,13 +2268,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4572,13 +2282,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4586,13 +2296,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4600,13 +2310,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4614,13 +2324,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4628,13 +2338,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4642,13 +2352,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4656,13 +2366,13 @@ public static Task MinAsync(this IAsyncQueryable sour throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4670,13 +2380,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4684,13 +2394,13 @@ public static Task MinAsync(this IAsyncQueryable sourc throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4698,13 +2408,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4712,13 +2422,13 @@ public static Task MinAsync(this IAsyncQueryable source throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4726,13 +2436,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4740,13 +2450,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4754,13 +2464,13 @@ public static Task MinAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4768,13 +2478,13 @@ public static Task MinAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector) + public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4782,13 +2492,13 @@ public static Task MinAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4796,231 +2506,215 @@ public static Task MinAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable OfType(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Reverse(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5028,13 +2722,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5042,13 +2736,83 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5056,13 +2820,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5070,13 +2834,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5084,13 +2848,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5098,13 +2862,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5112,13 +2876,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5126,13 +2890,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5140,13 +2904,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5154,13 +2918,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5168,13 +2932,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5182,981 +2946,999 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second)), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { - if (first == null) - throw new ArgumentNullException(nameof(first)); - if (second == null) - throw new ArgumentNullException(nameof(second)); + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SingleAsync(this IAsyncQueryable source) + public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SingleAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable OfType(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression> predicate) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate), CancellationToken.None); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (keySelector == null) + throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IAsyncQueryable Skip(this IAsyncQueryable source, int count) + public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Skip(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); #endif } - public static IAsyncQueryable SkipLast(this IAsyncQueryable source, int count) + public static IAsyncQueryable Reverse(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (predicate == null) - throw new ArgumentNullException(nameof(predicate)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static Task SumAsync(this IAsyncQueryable source) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) { - if (source == null) - throw new ArgumentNullException(nameof(source)); + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static Task SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable Skip(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Skip(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SkipLast(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (predicate == null) + throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector) + public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector), CancellationToken.None); + return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6170,7 +3952,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6184,7 +3966,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6198,7 +3980,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6212,7 +3994,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6226,7 +4008,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6240,7 +4022,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6254,7 +4036,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6268,7 +4050,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6282,7 +4064,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6296,7 +4078,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6310,7 +4092,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6324,7 +4106,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6338,7 +4120,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6352,7 +4134,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6366,7 +4148,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6380,7 +4162,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6394,7 +4176,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6408,7 +4190,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6422,7 +4204,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6436,7 +4218,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6450,7 +4232,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6464,7 +4246,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6478,7 +4260,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6492,7 +4274,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6506,7 +4288,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6520,7 +4302,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6534,7 +4316,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6548,7 +4330,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6562,7 +4344,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6852,19 +4634,7 @@ public static IOrderedAsyncQueryable ThenByDescending(th #endif } - public static Task ToArrayAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task ToArrayAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task ToArrayAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6876,35 +4646,7 @@ public static Task ToArrayAsync(this IAsyncQueryable> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6918,7 +4660,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6932,21 +4674,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6960,21 +4688,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -6988,7 +4702,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7002,7 +4716,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7016,39 +4730,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7064,7 +4746,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7080,23 +4762,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7112,23 +4778,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7144,7 +4794,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7160,7 +4810,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7176,19 +4826,7 @@ public static Task> ToDictionaryAsync> ToHashSetAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task> ToHashSetAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7200,19 +4838,7 @@ public static Task> ToHashSetAsync(this IAsyncQueryabl #endif } - public static Task> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7224,19 +4850,7 @@ public static Task> ToHashSetAsync(this IAsyncQueryabl #endif } - public static Task> ToListAsync(this IAsyncQueryable source) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable))), source.Expression), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None); -#endif - } - - public static Task> ToListAsync(this IAsyncQueryable source, CancellationToken cancellationToken) + public static Task> ToListAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7248,35 +4862,7 @@ public static Task> ToListAsync(this IAsyncQueryable> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7290,7 +4876,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7304,21 +4890,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7332,21 +4904,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7360,7 +4918,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7374,7 +4932,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7388,39 +4946,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7436,7 +4962,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7452,23 +4978,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7484,23 +4994,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (keySelector == null) - throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer))), CancellationToken.None); -#endif - } - - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7516,7 +5010,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -7532,7 +5026,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index 445847aa4f..e725cad53a 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -145,17 +145,25 @@ foreach (var m in typeof(AsyncEnumerable).GetMethods() } var isParams = false; + var lastParameterDefault = false; var parCount = m.GetParameters().Length; if (parCount != 0) { - if (m.GetParameters().Last().IsDefined(typeof(ParamArrayAttribute), true)) + var lastParam = m.GetParameters().Last(); + + if (lastParam.IsDefined(typeof(ParamArrayAttribute), true)) { isParams = true; } + + if (lastParam.ParameterType == typeof(CancellationToken)) + { + lastParameterDefault = true; + } } - var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name)); + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name + (i == parCount - 1 && lastParameterDefault ? " = default" : ""))); var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index b70c1775a6..2f7a4e72c2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -10,17 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AggregateAsync(this IAsyncEnumerable source, Func accumulator) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); - - return AggregateCore(source, accumulator, CancellationToken.None); - } - - public static Task AggregateAsync(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,17 +20,7 @@ public static Task AggregateAsync(this IAsyncEnumerable AggregateAsync(this IAsyncEnumerable source, Func> accumulator) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); - - return AggregateCore(source, accumulator, CancellationToken.None); - } - - public static Task AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +31,7 @@ public static Task AggregateAsync(this IAsyncEnumerable AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -62,17 +42,7 @@ public static Task AggregateAsync(this IAsyncEnumerable AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); - - return AggregateCore(source, seed, accumulator, x => x, CancellationToken.None); - } - - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -82,17 +52,7 @@ public static Task AggregateAsync(this IAsync return AggregateCore(source, seed, accumulator, x => x, cancellationToken); } - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); - - return AggregateCore(source, seed, accumulator, CancellationToken.None); - } - - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -103,7 +63,7 @@ public static Task AggregateAsync(this IAsync } #if !NO_DEEP_CANCELLATION - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,19 +74,7 @@ public static Task AggregateAsync(this IAsync } #endif - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); - } - - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,19 +86,7 @@ public static Task AggregateAsync(this I return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); } - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return AggregateCore(source, seed, accumulator, resultSelector, CancellationToken.None); - } - - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -163,7 +99,7 @@ public static Task AggregateAsync(this I } #if !NO_DEEP_CANCELLATION - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index cea2a2104c..9c86ad4eab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -10,17 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AllAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return AllCore(source, predicate, CancellationToken.None); - } - - public static Task AllAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,17 +20,7 @@ public static Task AllAsync(this IAsyncEnumerable source return AllCore(source, predicate, cancellationToken); } - public static Task AllAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return AllCore(source, predicate, CancellationToken.None); - } - - public static Task AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +31,7 @@ public static Task AllAsync(this IAsyncEnumerable source } #if !NO_DEEP_CANCELLATION - public static Task AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index eecd57d415..b711ac661e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AnyAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AnyCore(source, CancellationToken.None); - } - - public static Task AnyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return AnyCore(source, cancellationToken); } - public static Task AnyAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return AnyCore(source, predicate, CancellationToken.None); - } - - public static Task AnyAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return AnyCore(source, predicate, cancellationToken); } - public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return AnyCore(source, predicate, CancellationToken.None); - } - - public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task AnyAsync(this IAsyncEnumerable source } #if !NO_DEEP_CANCELLATION - public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 7937b617c8..21d1dadb29 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Cance return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -78,15 +50,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -94,17 +58,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,17 +68,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -135,7 +79,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -146,15 +90,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -162,17 +98,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -182,17 +108,7 @@ public static Task AverageAsync(this IAsyncEnumerable s return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -203,7 +119,7 @@ public static Task AverageAsync(this IAsyncEnumerable s } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -214,15 +130,7 @@ public static Task AverageAsync(this IAsyncEnumerable s } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -230,17 +138,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Ca return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -250,17 +148,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -271,7 +159,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -282,15 +170,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -298,17 +178,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -318,17 +188,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -339,7 +199,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -350,15 +210,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -366,17 +218,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -386,17 +228,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -407,7 +239,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -418,15 +250,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -434,17 +258,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -454,17 +268,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -475,7 +279,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -486,15 +290,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -502,17 +298,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -522,17 +308,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -543,7 +319,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -554,15 +330,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -570,17 +338,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -590,17 +348,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -611,7 +359,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -622,15 +370,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #endif - public static Task AverageAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -638,17 +378,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -658,17 +388,7 @@ public static Task AverageAsync(this IAsyncEnumerable return AverageCore(source, selector, cancellationToken); } - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -679,7 +399,7 @@ public static Task AverageAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index b7ebbf824c..7f90a3e67d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -35,15 +35,7 @@ foreach (var o in os) { var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; #> - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return AverageCore(source, CancellationToken.None); - } - - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,17 +43,7 @@ foreach (var o in os) return AverageCore(source, cancellationToken); } - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,17 +53,7 @@ foreach (var o in os) return AverageCore(source, selector, cancellationToken); } - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return AverageCore(source, selector, CancellationToken.None); - } - - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -92,7 +64,7 @@ foreach (var o in os) } #if !NO_DEEP_CANCELLATION - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 95addaf118..38b3783828 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ContainsAsync(this IAsyncEnumerable source, TSource value) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ContainsCore(source, value, CancellationToken.None); - } - - public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,15 +18,7 @@ public static Task ContainsAsync(this IAsyncEnumerable s return ContainsCore(source, value, cancellationToken); } - public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ContainsCore(source, value, comparer, CancellationToken.None); - } - - public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index e8c020054a..e340e84ed5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -11,15 +11,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task CountAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return CountCore(source, CancellationToken.None); - } - - public static Task CountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -27,17 +19,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return CountCore(source, cancellationToken); } - public static Task CountAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return CountCore(source, predicate, CancellationToken.None); - } - - public static Task CountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -47,17 +29,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return CountCore(source, predicate, cancellationToken); } - public static Task CountAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return CountCore(source, predicate, CancellationToken.None); - } - - public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -68,7 +40,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc } #if !NO_DEEP_CANCELLATION - public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 9944b3b1c7..b2d332bc30 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -10,64 +10,56 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ElementAtAsync(this IAsyncEnumerable source, int index) + public static Task ElementAtAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return ElementAtCore(source, index, CancellationToken.None); - } - - public static Task ElementAtAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ElementAtCore(source, index, cancellationToken); - } + return Core(); - private static async Task ElementAtCore(IAsyncEnumerable source, int index, CancellationToken cancellationToken) - { - if (source is IAsyncPartition p) + async Task Core() { - var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); - - if (first.HasValue) + if (source is IAsyncPartition p) { - return first.Value; - } - } - else - { - if (source is IList list) - { - return list[index]; - } + var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); - if (index >= 0) + if (first.HasValue) + { + return first.Value; + } + } + else { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source is IList list) + { + return list[index]; + } - try + if (index >= 0) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (index == 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - return e.Current; - } + if (index == 0) + { + return e.Current; + } - index--; + index--; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); } } - } - throw Error.ArgumentOutOfRange(nameof(index)); + throw Error.ArgumentOutOfRange(nameof(index)); + } } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 28b6f6a8b1..256dab42c1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -10,67 +10,59 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ElementAtOrDefaultAsync(this IAsyncEnumerable source, int index) + public static Task ElementAtOrDefaultAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return ElementAtOrDefaultCore(source, index, CancellationToken.None); - } - - public static Task ElementAtOrDefaultAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ElementAtOrDefaultCore(source, index, cancellationToken); - } + return Core(); - private static async Task ElementAtOrDefaultCore(IAsyncEnumerable source, int index, CancellationToken cancellationToken) - { - if (source is IAsyncPartition p) + async Task Core() { - var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); - - if (first.HasValue) + if (source is IAsyncPartition p) { - return first.Value; - } - } + var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); - if (index >= 0) - { - if (source is IList list) - { - if (index < list.Count) + if (first.HasValue) { - return list[index]; + return first.Value; } } - else - { - var e = source.GetAsyncEnumerator(cancellationToken); - try + if (index >= 0) + { + if (source is IList list) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + if (index < list.Count) { - if (index == 0) - { - return e.Current; - } - - index--; + return list[index]; } } - finally + else { - await e.DisposeAsync().ConfigureAwait(false); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (index == 0) + { + return e.Current; + } + + index--; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } - } - return default; + return default; + } } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 6ca57a3175..28bf63cec6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task FirstAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return FirstCore(source, CancellationToken.None); - } - - public static Task FirstAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return FirstCore(source, cancellationToken); } - public static Task FirstAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return FirstCore(source, predicate, CancellationToken.None); - } - - public static Task FirstAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return FirstCore(source, predicate, cancellationToken); } - public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return FirstCore(source, predicate, CancellationToken.None); - } - - public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task FirstAsync(this IAsyncEnumerable s } #if !NO_DEEP_CANCELLATION - public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index b516e800bb..9f95a252ba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task FirstOrDefaultAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return FirstOrDefaultCore(source, CancellationToken.None); - } - - public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return FirstOrDefaultCore(source, predicate, CancellationToken.None); - } - - public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return FirstOrDefaultCore(source, predicate, CancellationToken.None); - } - - public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 25f0a0b577..2ceda17786 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -17,17 +17,7 @@ public static partial class AsyncEnumerable // want to keep these methods, they may be a candidate for System.Interactive.Async if we consider them to be // non-standard (i.e. IEnumerable doesn't have a ForEach extension method either). - public static Task ForEachAsync(this IAsyncEnumerable source, Action action) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (action == null) - throw Error.ArgumentNull(nameof(action)); - - return ForEachAsyncCore(source, action, CancellationToken.None); - } - - public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -37,17 +27,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return ForEachAsyncCore(source, action, cancellationToken); } - public static Task ForEachAsync(this IAsyncEnumerable source, Action action) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (action == null) - throw Error.ArgumentNull(nameof(action)); - - return ForEachAsyncCore(source, action, CancellationToken.None); - } - - public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,17 +37,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return ForEachAsyncCore(source, action, cancellationToken); } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (action == null) - throw Error.ArgumentNull(nameof(action)); - - return ForEachAsyncCore(source, (x, ct) => action(x), CancellationToken.None); - } - - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -87,17 +57,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return ForEachAsyncCore(source, action, cancellationToken); } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (action == null) - throw Error.ArgumentNull(nameof(action)); - - return ForEachAsyncCore(source, (x, i, ct) => action(x, i), CancellationToken.None); - } - - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index aa56a914f7..f691be5223 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LastAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return LastCore(source, CancellationToken.None); - } - - public static Task LastAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task LastAsync(this IAsyncEnumerable so return LastCore(source, cancellationToken); } - public static Task LastAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return LastCore(source, predicate, CancellationToken.None); - } - - public static Task LastAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task LastAsync(this IAsyncEnumerable so return LastCore(source, predicate, cancellationToken); } - public static Task LastAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return LastCore(source, predicate, CancellationToken.None); - } - - public static Task LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task LastAsync(this IAsyncEnumerable so } #if !NO_DEEP_CANCELLATION - public static Task LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 93ac785c87..6230a67907 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LastOrDefaultAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return LastOrDefaultCore(source, CancellationToken.None); - } - - public static Task LastOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return LastOrDefaultCore(source, predicate, CancellationToken.None); - } - - public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return LastOrDefaultCore(source, predicate, CancellationToken.None); - } - - public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 8af207fe35..cbe6fb4172 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LongCountAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return LongCountCore(source, CancellationToken.None); - } - - public static Task LongCountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return LongCountCore(source, cancellationToken); } - public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return LongCountCore(source, predicate, CancellationToken.None); - } - - public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return LongCountCore(source, predicate, cancellationToken); } - public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return LongCountCore(source, predicate, CancellationToken.None); - } - - public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task LongCountAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 7d661d503c..dfa6cc8233 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task MaxAsync(this IAsyncEnumerable MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task MaxAsync(this IAsyncEnumerable MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index f30f106df3..d5520091f0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task MinAsync(this IAsyncEnumerable MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task MinAsync(this IAsyncEnumerable MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 851430cdf3..fc5f94d2fa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancellation return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -78,15 +50,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -94,17 +58,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,17 +68,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -135,7 +79,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -146,15 +90,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -162,17 +98,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancellati return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -182,17 +108,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -203,7 +119,7 @@ public static Task MaxAsync(this IAsyncEnumerable source } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -214,15 +130,7 @@ public static Task MaxAsync(this IAsyncEnumerable source } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -230,17 +138,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -250,17 +148,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -271,7 +159,7 @@ public static Task MaxAsync(this IAsyncEnumerable source } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -282,15 +170,7 @@ public static Task MaxAsync(this IAsyncEnumerable source } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -298,17 +178,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancella return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -318,17 +188,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -339,7 +199,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -350,15 +210,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -366,17 +218,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -386,17 +228,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -407,7 +239,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -418,15 +250,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -434,17 +258,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancel return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -454,17 +268,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -475,7 +279,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -486,15 +290,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -502,17 +298,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -522,17 +308,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -543,7 +319,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -554,15 +330,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -570,17 +338,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Canc return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -590,17 +348,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -611,7 +359,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -622,15 +370,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou } #endif - public static Task MaxAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MaxCore(source, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -638,17 +378,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return MaxCore(source, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -658,17 +388,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return MaxCore(source, selector, cancellationToken); } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MaxCore(source, selector, CancellationToken.None); - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -679,7 +399,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -690,15 +410,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -706,17 +418,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancellation return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -726,17 +428,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -747,7 +439,7 @@ public static Task MinAsync(this IAsyncEnumerable source, } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -758,15 +450,7 @@ public static Task MinAsync(this IAsyncEnumerable source, } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -774,17 +458,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -794,17 +468,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -815,7 +479,7 @@ public static Task MinAsync(this IAsyncEnumerable source, } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -826,15 +490,7 @@ public static Task MinAsync(this IAsyncEnumerable source, } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -842,17 +498,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancellati return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -862,17 +508,7 @@ public static Task MinAsync(this IAsyncEnumerable source return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -883,7 +519,7 @@ public static Task MinAsync(this IAsyncEnumerable source } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -894,15 +530,7 @@ public static Task MinAsync(this IAsyncEnumerable source } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -910,17 +538,7 @@ public static Task MinAsync(this IAsyncEnumerable source return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -930,17 +548,7 @@ public static Task MinAsync(this IAsyncEnumerable source return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -951,7 +559,7 @@ public static Task MinAsync(this IAsyncEnumerable source } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -962,15 +570,7 @@ public static Task MinAsync(this IAsyncEnumerable source } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -978,17 +578,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancella return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -998,17 +588,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1019,7 +599,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1030,15 +610,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1046,17 +618,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1066,17 +628,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1087,7 +639,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1098,15 +650,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1114,17 +658,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancel return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1134,17 +668,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1155,7 +679,7 @@ public static Task MinAsync(this IAsyncEnumerable sour } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1166,15 +690,7 @@ public static Task MinAsync(this IAsyncEnumerable sour } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1182,17 +698,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1202,17 +708,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1223,7 +719,7 @@ public static Task MinAsync(this IAsyncEnumerable sour } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1234,15 +730,7 @@ public static Task MinAsync(this IAsyncEnumerable sour } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1250,17 +738,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Canc return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1270,17 +748,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1291,7 +759,7 @@ public static Task MinAsync(this IAsyncEnumerable sou } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1302,15 +770,7 @@ public static Task MinAsync(this IAsyncEnumerable sou } #endif - public static Task MinAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return MinCore(source, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1318,17 +778,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return MinCore(source, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1338,17 +788,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return MinCore(source, selector, cancellationToken); } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return MinCore(source, selector, CancellationToken.None); - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1359,7 +799,7 @@ public static Task MinAsync(this IAsyncEnumerable sou } #if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 1361103dde..b9ba2df7b8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -22,15 +22,7 @@ foreach (var m in new[] { "Max", "Min" }) foreach (var t in new[] { "int", "int?", "long", "long?", "float", "float?", "double", "double?", "decimal", "decimal?" }) { #> - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return <#=m#>Core(source, CancellationToken.None); - } - - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -38,17 +30,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, cancellationToken); } - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return <#=m#>Core(source, selector, CancellationToken.None); - } - - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -58,17 +40,7 @@ foreach (var m in new[] { "Max", "Min" }) return <#=m#>Core(source, selector, cancellationToken); } - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return <#=m#>Core(source, selector, CancellationToken.None); - } - - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -79,7 +51,7 @@ foreach (var m in new[] { "Max", "Min" }) } #if !NO_DEEP_CANCELLATION - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 3d25d79fe2..915f0c5796 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -10,17 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second) - { - if (first == null) - throw Error.ArgumentNull(nameof(first)); - if (second == null) - throw Error.ArgumentNull(nameof(second)); - - return SequenceEqualCore(first, second, comparer: null, CancellationToken.None); - } - - public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -30,17 +20,7 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) - { - if (first == null) - throw Error.ArgumentNull(nameof(first)); - if (second == null) - throw Error.ArgumentNull(nameof(second)); - - return SequenceEqualCore(first, second, comparer, CancellationToken.None); - } - - public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (first == null) throw Error.ArgumentNull(nameof(first)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 3140d3a6a4..adfa80b1f2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SingleAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SingleCore(source, CancellationToken.None); - } - - public static Task SingleAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task SingleAsync(this IAsyncEnumerable return SingleCore(source, cancellationToken); } - public static Task SingleAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleCore(source, predicate, CancellationToken.None); - } - - public static Task SingleAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task SingleAsync(this IAsyncEnumerable return SingleCore(source, predicate, cancellationToken); } - public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleCore(source, predicate, CancellationToken.None); - } - - public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task SingleAsync(this IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index de507c35f6..54c3cd6d74 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SingleOrDefaultCore(source, CancellationToken.None); - } - - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< return SingleOrDefaultCore(source, cancellationToken); } - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleOrDefaultCore(source, predicate, CancellationToken.None); - } - - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< return SingleOrDefaultCore(source, predicate, cancellationToken); } - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleOrDefaultCore(source, predicate, CancellationToken.None); - } - - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< } #if !NO_DEEP_CANCELLATION - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 22eb5968c5..925da13ad1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,17 +18,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancellation return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -46,17 +28,7 @@ public static Task SumAsync(this IAsyncEnumerable source, return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -67,7 +39,7 @@ public static Task SumAsync(this IAsyncEnumerable source, } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -182,15 +154,7 @@ private static async Task SumCore(IAsyncEnumerable source } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -198,17 +162,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancellati return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -218,17 +172,7 @@ public static Task SumAsync(this IAsyncEnumerable source return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -239,7 +183,7 @@ public static Task SumAsync(this IAsyncEnumerable source } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -354,15 +298,7 @@ private static async Task SumCore(IAsyncEnumerable sourc } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -370,17 +306,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancella return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -390,17 +316,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -411,7 +327,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -514,15 +430,7 @@ private static async Task SumCore(IAsyncEnumerable sour } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -530,17 +438,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancel return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -550,17 +448,7 @@ public static Task SumAsync(this IAsyncEnumerable sour return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -571,7 +459,7 @@ public static Task SumAsync(this IAsyncEnumerable sour } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -674,15 +562,7 @@ private static async Task SumCore(IAsyncEnumerable sou } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -690,17 +570,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Canc return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -710,17 +580,7 @@ public static Task SumAsync(this IAsyncEnumerable sou return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -731,7 +591,7 @@ public static Task SumAsync(this IAsyncEnumerable sou } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -834,15 +694,7 @@ private static async Task SumCore(IAsyncEnumerable so } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -850,17 +702,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -870,17 +712,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -891,7 +723,7 @@ private static async Task SumCore(IAsyncEnumerable so } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1006,15 +838,7 @@ private static async Task SumCore(IAsyncEnumerable so } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1022,17 +846,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1042,17 +856,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1063,7 +867,7 @@ private static async Task SumCore(IAsyncEnumerable so } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1178,15 +982,7 @@ private static async Task SumCore(IAsyncEnumerable so } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1194,17 +990,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1214,17 +1000,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1235,7 +1011,7 @@ private static async Task SumCore(IAsyncEnumerable so } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1338,15 +1114,7 @@ private static async Task SumCore(IAsyncEnumerable so } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1354,17 +1122,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1374,17 +1132,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1395,7 +1143,7 @@ private static async Task SumCore(IAsyncEnumerable so } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1498,15 +1246,7 @@ private static async Task SumCore(IAsyncEnumerable so } #endif - public static Task SumAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1514,17 +1254,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1534,17 +1264,7 @@ private static async Task SumCore(IAsyncEnumerable so return SumCore(source, selector, cancellationToken); } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1555,7 +1275,7 @@ private static async Task SumCore(IAsyncEnumerable so } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 70af0128bb..5a0b6925ee 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -35,15 +35,7 @@ foreach (var o in os) { var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; #> - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, CancellationToken.None); - } - - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,17 +43,7 @@ foreach (var o in os) return SumCore(source, cancellationToken); } - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,17 +53,7 @@ foreach (var o in os) return SumCore(source, selector, cancellationToken); } - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, CancellationToken.None); - } - - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -92,7 +64,7 @@ foreach (var o in os) } #if !NO_DEEP_CANCELLATION - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs index afdfd94bfc..11d5152dbd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ToArrayAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ToArrayAsync(source, CancellationToken.None); - } - - public static Task ToArrayAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task ToArrayAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 822161b94e..ecd6156907 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -10,17 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,17 +20,7 @@ public static Task> ToDictionaryAsync(t return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); } - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToDictionaryCore(source, keySelector, x => new ValueTask(x), EqualityComparer.Default, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +31,7 @@ public static Task> ToDictionaryAsync(t } #if !NO_DEEP_CANCELLATION - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -62,17 +42,7 @@ public static Task> ToDictionaryAsync(t } #endif - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToDictionaryCore(source, keySelector, x => x, comparer, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -82,17 +52,7 @@ public static Task> ToDictionaryAsync(t return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); } - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -103,7 +63,7 @@ public static Task> ToDictionaryAsync(t } #if !NO_DEEP_CANCELLATION - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,19 +74,7 @@ public static Task> ToDictionaryAsync(t } #endif - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,19 +86,7 @@ public static Task> ToDictionaryAsync.Default, cancellationToken); } - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToDictionaryCore(source, keySelector, elementSelector, EqualityComparer.Default, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -163,7 +99,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -176,19 +112,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToDictionaryCore(source, keySelector, elementSelector, comparer, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -200,19 +124,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToDictionaryCore(source, keySelector, elementSelector, comparer, CancellationToken.None); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -225,7 +137,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 607aff12ae..c4872494a4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToHashSetAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ToHashSetCore(source, comparer: null, CancellationToken.None); - } - - public static Task> ToHashSetAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,15 +18,7 @@ public static Task> ToHashSetAsync(this IAsyncEnumerab return ToHashSetCore(source, comparer: null, cancellationToken); } - public static Task> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ToHashSetCore(source, comparer, CancellationToken.None); - } - - public static Task> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 85e9ded3ae..295d2c197c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -10,15 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToListAsync(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ToListCore(source, CancellationToken.None); - } - - public static Task> ToListAsync(this IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task> ToListAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index a871595572..9024076691 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -10,17 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToLookupCore(source, keySelector, x => x, comparer: null, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,17 +20,7 @@ public static Task> ToLookupAsync(this IAs return ToLookupCore(source, keySelector, x => x, comparer: null, cancellationToken); } - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer: null, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +31,7 @@ public static Task> ToLookupAsync(this IAs } #if !NO_DEEP_CANCELLATION - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -62,17 +42,7 @@ public static Task> ToLookupAsync(this IAs } #endif - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToLookupCore(source, keySelector, x => x, comparer, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -82,17 +52,7 @@ public static Task> ToLookupAsync(this IAs return ToLookupCore(source, keySelector, x => x, comparer, cancellationToken); } - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -103,7 +63,7 @@ public static Task> ToLookupAsync(this IAs } #if !NO_DEEP_CANCELLATION - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,19 +74,7 @@ public static Task> ToLookupAsync(this IAs } #endif - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToLookupCore(source, keySelector, elementSelector, comparer: null, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,19 +86,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToLookupCore(source, keySelector, elementSelector, comparer: null, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -163,7 +99,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -176,19 +112,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -200,19 +124,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToLookupCore(source, keySelector, elementSelector, comparer, CancellationToken.None); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -225,7 +137,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); From 15fb36bba0152fcde0e79a22cce8e548ecf7a738 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 22:08:45 -0800 Subject: [PATCH 617/862] Simplify code using local functions --- .../System/Linq/Operators/All.cs | 112 +++++---- .../System/Linq/Operators/Any.cs | 140 ++++++----- .../System/Linq/Operators/Contains.cs | 17 +- .../System/Linq/Operators/Count.cs | 151 ++++++------ .../System/Linq/Operators/First.cs | 63 +++-- .../System/Linq/Operators/FirstOrDefault.cs | 62 +++-- .../System/Linq/Operators/Last.cs | 62 +++-- .../System/Linq/Operators/LastOrDefault.cs | 62 +++-- .../System/Linq/Operators/LongCount.cs | 176 +++++++------- .../System/Linq/Operators/Single.cs | 222 +++++++++--------- .../System/Linq/Operators/SingleOrDefault.cs | 222 +++++++++--------- .../System/Linq/Operators/ToList.cs | 5 - 12 files changed, 629 insertions(+), 665 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 9c86ad4eab..30c26f45e1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -17,7 +17,27 @@ public static Task AllAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AllCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (!predicate(e.Current)) + return false; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return true; + } } public static Task AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) @@ -27,7 +47,27 @@ public static Task AllAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AllCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (!await predicate(e.Current).ConfigureAwait(false)) + return false; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return true; + } } #if !NO_DEEP_CANCELLATION @@ -38,69 +78,27 @@ public static Task AllAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AllCore(source, predicate, cancellationToken); - } -#endif + return Core(); - private static async Task AllCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - if (!predicate(e.Current)) - return false; - } - } - finally + async Task Core() { - await e.DisposeAsync().ConfigureAwait(false); - } - - return true; - } + var e = source.GetAsyncEnumerator(cancellationToken); - private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - if (!await predicate(e.Current).ConfigureAwait(false)) - return false; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (!await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + return false; + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return true; - } - -#if !NO_DEEP_CANCELLATION - private static async Task AllCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - if (!await predicate(e.Current, cancellationToken).ConfigureAwait(false)) - return false; + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return true; + return true; + } } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index b711ac661e..7aacbdab08 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -15,7 +15,21 @@ public static Task AnyAsync(this IAsyncEnumerable source if (source == null) throw Error.ArgumentNull(nameof(source)); - return AnyCore(source, cancellationToken); + return Core(); + + async Task Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + return await e.MoveNextAsync().ConfigureAwait(false); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AnyAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) @@ -25,7 +39,27 @@ public static Task AnyAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (predicate(e.Current)) + return true; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return false; + } } public static Task AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) @@ -35,7 +69,27 @@ public static Task AnyAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current).ConfigureAwait(false)) + return true; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return false; + } } #if !NO_DEEP_CANCELLATION @@ -46,83 +100,27 @@ public static Task AnyAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return AnyCore(source, predicate, cancellationToken); - } -#endif - - private static async Task AnyCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - return await e.MoveNextAsync().ConfigureAwait(false); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } + var e = source.GetAsyncEnumerator(cancellationToken); - private static async Task AnyCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - if (predicate(e.Current)) - return true; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + return true; + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return false; - } - - private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - if (await predicate(e.Current).ConfigureAwait(false)) - return true; + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return false; - } - -#if !NO_DEEP_CANCELLATION - private static async Task AnyCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) - return true; - } + return false; } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return false; } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 38b3783828..685dca3655 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -15,7 +15,12 @@ public static Task ContainsAsync(this IAsyncEnumerable s if (source == null) throw Error.ArgumentNull(nameof(source)); - return ContainsCore(source, value, cancellationToken); + if (source is ICollection collection) + { + return Task.FromResult(collection.Contains(value)); + } + + return ContainsCore(source, value, comparer: null, cancellationToken); } public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) @@ -26,16 +31,6 @@ public static Task ContainsAsync(this IAsyncEnumerable s return ContainsCore(source, value, comparer, cancellationToken); } - private static Task ContainsCore(IAsyncEnumerable source, TSource value, CancellationToken cancellationToken) - { - if (source is ICollection collection) - { - return Task.FromResult(collection.Contains(value)); - } - - return ContainsCore(source, value, comparer: null, cancellationToken); - } - private static async Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { var e = source.GetAsyncEnumerator(cancellationToken); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index e340e84ed5..9379a9f665 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -16,43 +16,6 @@ public static Task CountAsync(this IAsyncEnumerable sourc if (source == null) throw Error.ArgumentNull(nameof(source)); - return CountCore(source, cancellationToken); - } - - public static Task CountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return CountCore(source, predicate, cancellationToken); - } - - public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return CountCore(source, predicate, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return CountCore(source, predicate, cancellationToken); - } -#endif - - private static Task CountCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { switch (source) { case ICollection collection: @@ -90,86 +53,116 @@ async Task Core() } } - private static async Task CountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { - var count = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var count = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (predicate(e.Current)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - checked + if (predicate(e.Current)) { - count++; + checked + { + count++; + } } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return count; + return count; + } } - private static async Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var count = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var count = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (await predicate(e.Current).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - checked + if (await predicate(e.Current).ConfigureAwait(false)) { - count++; + checked + { + count++; + } } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return count; + return count; + } } #if !NO_DEEP_CANCELLATION - private static async Task CountCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var count = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var count = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - checked + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) { - count++; + checked + { + count++; + } } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return count; + return count; + } } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 28bf63cec6..6dd30f529c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -15,7 +15,14 @@ public static Task FirstAsync(this IAsyncEnumerable s if (source == null) throw Error.ArgumentNull(nameof(source)); - return FirstCore(source, cancellationToken); + return Core(); + + async Task Core() + { + var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : throw Error.NoElements(); + } } public static Task FirstAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) @@ -25,7 +32,14 @@ public static Task FirstAsync(this IAsyncEnumerable s if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return FirstCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : throw Error.NoElements(); + } } public static Task FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) @@ -35,7 +49,14 @@ public static Task FirstAsync(this IAsyncEnumerable s if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return FirstCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : throw Error.NoElements(); + } } #if !NO_DEEP_CANCELLATION @@ -46,38 +67,14 @@ public static Task FirstAsync(this IAsyncEnumerable s if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return FirstCore(source, predicate, cancellationToken); - } -#endif - - private static async Task FirstCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); - - return first.HasValue ? first.Value : throw Error.NoElements(); - } + return Core(); - private static async Task FirstCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - - return first.HasValue ? first.Value : throw Error.NoElements(); - } - - private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - - return first.HasValue ? first.Value : throw Error.NoElements(); - } - -#if !NO_DEEP_CANCELLATION - - private static async Task FirstCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + async Task Core() + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - return first.HasValue ? first.Value : throw Error.NoElements(); + return first.HasValue ? first.Value : throw Error.NoElements(); + } } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 9f95a252ba..5aea5e31bc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -15,7 +15,14 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core() + { + var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : default; + } } public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) @@ -25,7 +32,14 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core() + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : default; + } } public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) @@ -35,7 +49,14 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core() + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + + return first.HasValue ? first.Value : default; + } } #if !NO_DEEP_CANCELLATION @@ -46,37 +67,14 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable FirstOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); - - return first.HasValue ? first.Value : default; - } - - private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - - return first.HasValue ? first.Value : default; - } + return Core(); - private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - - return first.HasValue ? first.Value : default; - } - -#if !NO_DEEP_CANCELLATION - private static async Task FirstOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + async Task Core() + { + var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); - return first.HasValue ? first.Value : default; + return first.HasValue ? first.Value : default; + } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index f691be5223..101db9eef0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -15,7 +15,14 @@ public static Task LastAsync(this IAsyncEnumerable so if (source == null) throw Error.ArgumentNull(nameof(source)); - return LastCore(source, cancellationToken); + return Core(); + + async Task Core() + { + var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : throw Error.NoElements(); + } } public static Task LastAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) @@ -25,7 +32,14 @@ public static Task LastAsync(this IAsyncEnumerable so if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return LastCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : throw Error.NoElements(); + } } public static Task LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) @@ -35,7 +49,14 @@ public static Task LastAsync(this IAsyncEnumerable so if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return LastCore(source, predicate, cancellationToken); + return Core(); + + async Task Core() + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : throw Error.NoElements(); + } } #if !NO_DEEP_CANCELLATION @@ -46,37 +67,14 @@ public static Task LastAsync(this IAsyncEnumerable so if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return LastCore(source, predicate, cancellationToken); - } -#endif - - private static async Task LastCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); - - return last.HasValue ? last.Value : throw Error.NoElements(); - } - - private static async Task LastCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + return Core(); - return last.HasValue ? last.Value : throw Error.NoElements(); - } - - private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); - - return last.HasValue ? last.Value : throw Error.NoElements(); - } - -#if !NO_DEEP_CANCELLATION - private static async Task LastCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + async Task Core() + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); - return last.HasValue ? last.Value : throw Error.NoElements(); + return last.HasValue ? last.Value : throw Error.NoElements(); + } } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 6230a67907..b8b4592e75 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -15,7 +15,14 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core() + { + var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : default; + } } public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) @@ -25,7 +32,14 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core() + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : default; + } } public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) @@ -35,7 +49,14 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core() + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + + return last.HasValue ? last.Value : default; + } } #if !NO_DEEP_CANCELLATION @@ -46,37 +67,14 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable LastOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); - - return last.HasValue ? last.Value : default; - } - - private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); - - return last.HasValue ? last.Value : default; - } + return Core(); - private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); - - return last.HasValue ? last.Value : default; - } - -#if !NO_DEEP_CANCELLATION - private static async Task LastOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) - { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + async Task Core() + { + var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); - return last.HasValue ? last.Value : default; + return last.HasValue ? last.Value : default; + } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index cbe6fb4172..538810b584 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -15,145 +15,143 @@ public static Task LongCountAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return LongCountCore(source, cancellationToken); - } + return Core(); - public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); + async Task Core() + { + var count = 0L; - return LongCountCore(source, predicate, cancellationToken); - } + var e = source.GetAsyncEnumerator(cancellationToken); - public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + count++; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return LongCountCore(source, predicate, cancellationToken); + return count; + } } -#if !NO_DEEP_CANCELLATION - public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return LongCountCore(source, predicate, cancellationToken); - } -#endif + return Core(); - private static async Task LongCountCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var count = 0L; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - count++; - } - } - } - finally + async Task Core() { - await e.DisposeAsync().ConfigureAwait(false); - } - - return count; - } - - private static async Task LongCountCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) - { - var count = 0L; + var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - if (predicate(e.Current)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - checked + if (predicate(e.Current)) { - count++; + checked + { + count++; + } } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return count; + return count; + } } - private static async Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var count = 0L; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var count = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (await predicate(e.Current).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - checked + if (await predicate(e.Current).ConfigureAwait(false)) { - count++; + checked + { + count++; + } } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return count; + return count; + } } #if !NO_DEEP_CANCELLATION - private static async Task LongCountCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var count = 0L; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var count = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - checked + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) { - count++; + checked + { + count++; + } } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return count; + return count; + } } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index adfa80b1f2..3841f2a11c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -15,171 +15,169 @@ public static Task SingleAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return SingleCore(source, cancellationToken); - } - - public static Task SingleAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleCore(source, predicate, cancellationToken); - } - - public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleCore(source, predicate, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); + return Core(); - return SingleCore(source, predicate, cancellationToken); - } -#endif - - private static async Task SingleCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source is IList list) + async Task Core() { - switch (list.Count) + if (source is IList list) { - case 0: throw Error.NoElements(); - case 1: return list[0]; - } + switch (list.Count) + { + case 0: throw Error.NoElements(); + case 1: return list[0]; + } - throw Error.MoreThanOneElement(); - } + throw Error.MoreThanOneElement(); + } - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + try { - throw Error.NoElements(); - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } - var result = e.Current; - if (await e.MoveNextAsync().ConfigureAwait(false)) + var result = e.Current; + if (await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } + + return result; + } + finally { - throw Error.MoreThanOneElement(); + await e.DisposeAsync().ConfigureAwait(false); } - - return result; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); } } - private static async Task SingleCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - try + return Core(); + + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var result = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - if (predicate(result)) + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var result = e.Current; + + if (predicate(result)) { - if (predicate(e.Current)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - throw Error.MoreThanOneElement(); + if (predicate(e.Current)) + { + throw Error.MoreThanOneElement(); + } } - } - return result; + return result; + } } - } - throw Error.NoElements(); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + throw Error.NoElements(); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } - private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - try + return Core(); + + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var result = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - if (await predicate(result).ConfigureAwait(false)) + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var result = e.Current; + + if (await predicate(result).ConfigureAwait(false)) { - if (await predicate(e.Current).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - throw Error.MoreThanOneElement(); + if (await predicate(e.Current).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } } - } - return result; + return result; + } } - } - throw Error.NoElements(); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + throw Error.NoElements(); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } #if !NO_DEEP_CANCELLATION - private static async Task SingleCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var result = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - if (await predicate(result, cancellationToken).ConfigureAwait(false)) + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var result = e.Current; + + if (await predicate(result, cancellationToken).ConfigureAwait(false)) { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - throw Error.MoreThanOneElement(); + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } } - } - return result; + return result; + } } - } - throw Error.NoElements(); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + throw Error.NoElements(); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 54c3cd6d74..429acdbbea 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -15,172 +15,170 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< if (source == null) throw Error.ArgumentNull(nameof(source)); - return SingleOrDefaultCore(source, cancellationToken); - } - - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleOrDefaultCore(source, predicate, cancellationToken); - } - - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleOrDefaultCore(source, predicate, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (predicate == null) - throw Error.ArgumentNull(nameof(predicate)); - - return SingleOrDefaultCore(source, predicate, cancellationToken); - } -#endif + return Core(); - private static async Task SingleOrDefaultCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source is IList list) + async Task Core() { - switch (list.Count) + if (source is IList list) { - case 0: return default; - case 1: return list[0]; - } + switch (list.Count) + { + case 0: return default; + case 1: return list[0]; + } - throw Error.MoreThanOneElement(); - } + throw Error.MoreThanOneElement(); + } - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + try { - return default; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return default; + } - var result = e.Current; + var result = e.Current; - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return result; + } + } + finally { - return result; + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - throw Error.MoreThanOneElement(); + throw Error.MoreThanOneElement(); + } } - private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var result = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - if (predicate(result)) + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var result = e.Current; + + if (predicate(result)) { - if (predicate(e.Current)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - throw Error.MoreThanOneElement(); + if (predicate(e.Current)) + { + throw Error.MoreThanOneElement(); + } } - } - return result; + return result; + } } - } - return default; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return default; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } - private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); - try + return Core(); + + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var result = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - if (await predicate(result).ConfigureAwait(false)) + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var result = e.Current; + + if (await predicate(result).ConfigureAwait(false)) { - if (await predicate(e.Current).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - throw Error.MoreThanOneElement(); + if (await predicate(e.Current).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } } - } - return result; + return result; + } } - } - return default; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return default; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } #if !NO_DEEP_CANCELLATION - private static async Task SingleOrDefaultCore(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (predicate == null) + throw Error.ArgumentNull(nameof(predicate)); + + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var result = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - if (await predicate(result, cancellationToken).ConfigureAwait(false)) + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var result = e.Current; + + if (await predicate(result, cancellationToken).ConfigureAwait(false)) { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - throw Error.MoreThanOneElement(); + if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } } - } - return result; + return result; + } } - } - return default; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return default; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 295d2c197c..9a4f06007f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -15,11 +15,6 @@ public static Task> ToListAsync(this IAsyncEnumerable> ToListCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { if (source is IAsyncIListProvider listProvider) return listProvider.ToListAsync(cancellationToken).AsTask(); From 2ed38972f374202ffb53d335d0243f36dcaa86be Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 22:13:49 -0800 Subject: [PATCH 618/862] Use local functions in Sum --- .../System/Linq/Operators/Sum.Generated.cs | 1792 ++++++++--------- .../System/Linq/Operators/Sum.Generated.tt | 204 +- 2 files changed, 987 insertions(+), 1009 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 925da13ad1..6ce0001c46 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -15,7 +15,31 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancellation if (source == null) throw Error.ArgumentNull(nameof(source)); - return SumCore(source, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + sum += e.Current; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -25,7 +49,33 @@ public static Task SumAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -35,7 +85,33 @@ public static Task SumAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } #if !NO_DEEP_CANCELLATION @@ -46,548 +122,531 @@ public static Task SumAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + checked + { + sum += value; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } #endif - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { - var sum = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - checked + while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += e.Current; + checked + { + sum += e.Current; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { - var sum = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = selector(e.Current); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); - checked + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += value; + var value = selector(e.Current); + + checked + { + sum += value; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current).ConfigureAwait(false); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); - checked + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += value; + var value = await selector(e.Current).ConfigureAwait(false); + + checked + { + sum += value; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } #if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); - checked + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += value; + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + checked + { + sum += value; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } #endif - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return SumCore(source, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } #endif - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { - var sum = 0L; + if (source == null) + throw Error.ArgumentNull(nameof(source)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - checked + while (await e.MoveNextAsync().ConfigureAwait(false)) { sum += e.Current; } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { - var sum = 0L; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = selector(e.Current); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); - checked + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { + var value = selector(e.Current); + sum += value; } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0L; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current).ConfigureAwait(false); + var sum = 0.0; - checked + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { + var value = await selector(e.Current).ConfigureAwait(false); + sum += value; } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } #if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0L; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); - checked + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + sum += value; } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return sum; + return sum; + } } #endif - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return SumCore(source, cancellationToken); - } + return Core(); - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + async Task Core() + { + var sum = 0m; - return SumCore(source, selector, cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } + return Core(); -#if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } -#endif - - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var sum = 0.0f; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var sum = 0.0f; + var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); - sum += value; + sum += value; + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0.0f; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - var value = await selector(e.Current).ConfigureAwait(false); - - sum += value; + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; - } - -#if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0.0f; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - - sum += value; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return sum; } - - return sum; } -#endif - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } -#endif - - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var sum = 0.0; - - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - } - } - finally + async Task Core() { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var sum = 0.0; + var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); - sum += value; + sum += value; + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0.0; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - var value = await selector(e.Current).ConfigureAwait(false); - - sum += value; + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; - } - -#if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0.0; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - - sum += value; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return sum; } - - return sum; - } -#endif - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); } #if !NO_DEEP_CANCELLATION @@ -598,99 +657,30 @@ public static Task SumAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } -#endif - - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var sum = 0m; - - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + var sum = 0m; - return sum; - } + var e = source.GetAsyncEnumerator(cancellationToken); - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var sum = 0m; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - sum += value; + sum += value; + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0m; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - var value = await selector(e.Current).ConfigureAwait(false); - - sum += value; + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - -#if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0m; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - sum += value; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return sum; } - - return sum; } #endif @@ -699,550 +689,542 @@ private static async Task SumCore(IAsyncEnumerable so if (source == null) throw Error.ArgumentNull(nameof(source)); - return SumCore(source, cancellationToken); - } + return Core(); - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + async Task Core() + { + var sum = 0; - return SumCore(source, selector, cancellationToken); - } + var e = source.GetAsyncEnumerator(cancellationToken); - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + sum += e.Current.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return SumCore(source, selector, cancellationToken); + return sum; + } } -#if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } -#endif + return Core(); - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var sum = 0; + async Task Core() + { + var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - checked + while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += e.Current.GetValueOrDefault(); + var value = selector(e.Current); + + checked + { + sum += value.GetValueOrDefault(); + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var sum = 0; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - var value = selector(e.Current); - - checked - { - sum += value.GetValueOrDefault(); - } + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0; - - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current).ConfigureAwait(false); + return Core(); - checked - { - sum += value.GetValueOrDefault(); - } - } - } - finally + async Task Core() { - await e.DisposeAsync().ConfigureAwait(false); - } + var sum = 0; - return sum; - } + var e = source.GetAsyncEnumerator(cancellationToken); -#if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - - checked + while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += value.GetValueOrDefault(); + var value = await selector(e.Current).ConfigureAwait(false); + + checked + { + sum += value.GetValueOrDefault(); + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } -#endif - - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return SumCore(source, selector, cancellationToken); + return sum; + } } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } -#endif - - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var sum = 0L; + return Core(); - var e = source.GetAsyncEnumerator(cancellationToken); - - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - sum += e.Current.GetValueOrDefault(); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + var sum = 0; - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var sum = 0L; + var e = source.GetAsyncEnumerator(cancellationToken); - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var value = selector(e.Current); - - checked + while (await e.MoveNextAsync().ConfigureAwait(false)) { - sum += value.GetValueOrDefault(); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - return sum; - } - - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0L; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await selector(e.Current).ConfigureAwait(false); - - checked - { - sum += value.GetValueOrDefault(); + checked + { + sum += value.GetValueOrDefault(); + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } - -#if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var sum = 0L; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - - checked - { - sum += value.GetValueOrDefault(); - } + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #endif - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return SumCore(source, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } - - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } -#endif + return Core(); - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var sum = 0.0f; + async Task Core() + { + var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + sum += e.Current.GetValueOrDefault(); + } + } + } + finally { - sum += e.Current.GetValueOrDefault(); + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { - var sum = 0.0f; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); - sum += value.GetValueOrDefault(); + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0.0f; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); - sum += value.GetValueOrDefault(); + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0.0f; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0L; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - sum += value.GetValueOrDefault(); + checked + { + sum += value.GetValueOrDefault(); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #endif - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return SumCore(source, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } #if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); + return Core(); + + async Task Core() + { + var sum = 0.0f; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return sum; + } } #endif - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { - var sum = 0.0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current.GetValueOrDefault(); + } + } + finally { - sum += e.Current.GetValueOrDefault(); + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { - var sum = 0.0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); - sum += value.GetValueOrDefault(); + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0.0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); - sum += value.GetValueOrDefault(); + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0.0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0.0; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - sum += value.GetValueOrDefault(); + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #endif @@ -1251,130 +1233,128 @@ private static async Task SumCore(IAsyncEnumerable so if (source == null) throw Error.ArgumentNull(nameof(source)); - return SumCore(source, cancellationToken); - } + return Core(); - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + async Task Core() + { + var sum = 0m; - return SumCore(source, selector, cancellationToken); - } + var e = source.GetAsyncEnumerator(cancellationToken); - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return SumCore(source, selector, cancellationToken); + return sum; + } } -#if !NO_DEEP_CANCELLATION - public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return SumCore(source, selector, cancellationToken); - } -#endif - - private static async Task SumCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var sum = 0m; + return Core(); - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current.GetValueOrDefault(); - } - } - finally + async Task Core() { - await e.DisposeAsync().ConfigureAwait(false); - } - - return sum; - } + var sum = 0m; - private static async Task SumCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var sum = 0m; - - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); - sum += value.GetValueOrDefault(); + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0m; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); - sum += value.GetValueOrDefault(); + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #if !NO_DEEP_CANCELLATION - private static async Task SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = 0m; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = 0m; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - sum += value.GetValueOrDefault(); + sum += value.GetValueOrDefault(); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 5a0b6925ee..f169ca32cc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -40,194 +40,192 @@ foreach (var o in os) if (source == null) throw Error.ArgumentNull(nameof(source)); - return SumCore(source, cancellationToken); - } - - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } - - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + return Core(); - return SumCore(source, selector, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return SumCore(source, selector, cancellationToken); - } -#endif - - private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken) - { - var sum = <#=o.zero#>; + async Task<<#=o.type#>> Core() + { + var sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { <# if (o.@checked) { #> - checked - { - sum += e.Current<#=n#>; - } + checked + { + sum += e.Current<#=n#>; + } <# } else { #> - sum += e.Current<#=n#>; + sum += e.Current<#=n#>; <# } #> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { - var sum = <#=o.zero#>; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task<<#=o.type#>> Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = <#=o.zero#>; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = selector(e.Current); <# if (o.@checked) { #> - checked - { - sum += value<#=n#>; - } + checked + { + sum += value<#=n#>; + } <# } else { #> - sum += value<#=n#>; + sum += value<#=n#>; <# } #> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } - private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { - var sum = <#=o.zero#>; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task<<#=o.type#>> Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = <#=o.zero#>; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current).ConfigureAwait(false); <# if (o.@checked) { #> - checked - { - sum += value<#=n#>; - } + checked + { + sum += value<#=n#>; + } <# } else { #> - sum += value<#=n#>; + sum += value<#=n#>; <# } #> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #if !NO_DEEP_CANCELLATION - private static async Task<<#=o.type#>> SumCore(IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken) + public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { - var sum = <#=o.zero#>; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task<<#=o.type#>> Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var sum = <#=o.zero#>; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); <# if (o.@checked) { #> - checked - { - sum += value<#=n#>; - } + checked + { + sum += value<#=n#>; + } <# } else { #> - sum += value<#=n#>; + sum += value<#=n#>; <# } #> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return sum; + return sum; + } } #endif From 7e5f2aa2323f5809c8719a6054764ca0b32e4d94 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 22:23:44 -0800 Subject: [PATCH 619/862] Using local functions in Aggregate --- .../System/Linq/Operators/Aggregate.cs | 373 +++++++++--------- 1 file changed, 194 insertions(+), 179 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 2f7a4e72c2..df8df83043 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -17,7 +17,33 @@ public static Task AggregateAsync(this IAsyncEnumerable Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var acc = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = accumulator(acc, e.Current); + } + + return acc; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) @@ -27,7 +53,33 @@ public static Task AggregateAsync(this IAsyncEnumerable Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var acc = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current).ConfigureAwait(false); + } + + return acc; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #if !NO_DEEP_CANCELLATION @@ -38,7 +90,33 @@ public static Task AggregateAsync(this IAsyncEnumerable Core() + { + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + var acc = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + } + + return acc; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #endif @@ -49,254 +127,191 @@ public static Task AggregateAsync(this IAsync if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); - return AggregateCore(source, seed, accumulator, x => x, cancellationToken); - } + return Core(); - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); + async Task Core() + { + var acc = seed; - return AggregateCore(source, seed, accumulator, cancellationToken); - } + var e = source.GetAsyncEnumerator(cancellationToken); -#if !NO_DEEP_CANCELLATION - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = accumulator(acc, e.Current); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return AggregateCore(source, seed, accumulator, cancellationToken); + return acc; + } } -#endif - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken = default) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); - } + return Core(); - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (accumulator == null) - throw Error.ArgumentNull(nameof(accumulator)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); + async Task Core() + { + var acc = seed; + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } - return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); + return acc; + } } #if !NO_DEEP_CANCELLATION - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return AggregateCore(source, seed, accumulator, resultSelector, cancellationToken); - } -#endif - - private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken) - { - var acc = seed; - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = accumulator(acc, e.Current); - } - } - finally + async Task Core() { - await e.DisposeAsync().ConfigureAwait(false); - } + var acc = seed; - return resultSelector(acc); - } - - private static async Task AggregateCore(IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + try { - throw Error.NoElements(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + } } - - var acc = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - acc = accumulator(acc, e.Current); + await e.DisposeAsync().ConfigureAwait(false); } return acc; } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } } +#endif - private static async Task AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken = default) { - var acc = seed; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = await accumulator(acc, e.Current).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + var acc = seed; - return acc; - } + var e = source.GetAsyncEnumerator(cancellationToken); -#if !NO_DEEP_CANCELLATION - private static async Task AggregateCore(IAsyncEnumerable source, TResult seed, Func> accumulator, CancellationToken cancellationToken) - { - var acc = seed; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = accumulator(acc, e.Current); + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return acc; - } -#endif - - private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) - { - var acc = seed; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - acc = await accumulator(acc, e.Current).ConfigureAwait(false); + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return await resultSelector(acc).ConfigureAwait(false); + return resultSelector(acc); + } } -#if !NO_DEEP_CANCELLATION - private static async Task AggregateCore(IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { - var acc = seed; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); - } - } - finally + async Task Core() { - await e.DisposeAsync().ConfigureAwait(false); - } + var acc = seed; - return await resultSelector(acc, cancellationToken).ConfigureAwait(false); - } -#endif - - private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken); - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + try { - throw Error.NoElements(); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current).ConfigureAwait(false); + } } - - var acc = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - acc = await accumulator(acc, e.Current).ConfigureAwait(false); + await e.DisposeAsync().ConfigureAwait(false); } - return acc; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return await resultSelector(acc).ConfigureAwait(false); } } #if !NO_DEEP_CANCELLATION - private static async Task AggregateCore(IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) + public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { - var e = source.GetAsyncEnumerator(cancellationToken); + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (accumulator == null) + throw Error.ArgumentNull(nameof(accumulator)); + if (resultSelector == null) + throw Error.ArgumentNull(nameof(resultSelector)); + + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var acc = seed; - var acc = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - return acc; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + return await resultSelector(acc, cancellationToken).ConfigureAwait(false); } } #endif From d6171d53eee11926ad129f6d623b80e2de37276a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 22:29:07 -0800 Subject: [PATCH 620/862] Reduce loop bodies --- .../System/Linq/Operators/ToDictionary.cs | 8 ++++---- .../System.Linq.Async/System/Linq/Operators/ToHashSet.cs | 8 ++++---- .../System.Linq.Async/System/Linq/Operators/ToList.cs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index ecd6156907..a3e4085050 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -205,12 +205,12 @@ private static async Task> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { + var d = new Dictionary(comparer); + var e = source.GetAsyncEnumerator(cancellationToken); try { - var d = new Dictionary(comparer); - while (await e.MoveNextAsync().ConfigureAwait(false)) { var x = e.Current; @@ -220,13 +220,13 @@ private static async Task> ToDictionaryCore> ToHashSetAsync(this IAsyncEnumerab private static async Task> ToHashSetCore(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { + var set = new HashSet(comparer); + var e = source.GetAsyncEnumerator(cancellationToken); try { - var set = new HashSet(comparer); - while (await e.MoveNextAsync().ConfigureAwait(false)) { set.Add(e.Current); } - - return set; } finally { await e.DisposeAsync().ConfigureAwait(false); } + + return set; } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 9a4f06007f..f25b1e7be9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -22,23 +22,23 @@ public static Task> ToListAsync(this IAsyncEnumerable> Core() { + var list = new List(); + var e = source.GetAsyncEnumerator(cancellationToken); try { - var list = new List(); - while (await e.MoveNextAsync().ConfigureAwait(false)) { list.Add(e.Current); } - - return list; } finally { await e.DisposeAsync().ConfigureAwait(false); } + + return list; } } } From ae072e25a03260b57857d387dd8c7f0b2517c61d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 22:36:55 -0800 Subject: [PATCH 621/862] Reduce loop body in SingleOrDefault --- .../System/Linq/Operators/SingleOrDefault.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 429acdbbea..c7557242e1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -172,13 +172,13 @@ async Task Core() return result; } } - - return default; } finally { await e.DisposeAsync().ConfigureAwait(false); } + + return default; } } #endif From 02f43e94f7d274b8d2e3ad42b314e7859d307019 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 23:07:53 -0800 Subject: [PATCH 622/862] Smaller async state machines with default(T) == null check hoisted out (better JIT) --- .../System/Linq/Operators/Max.Generic.cs | 364 ++++++++++-------- .../System/Linq/Operators/Min.Generic.cs | 364 ++++++++++-------- 2 files changed, 424 insertions(+), 304 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs index 2682b9f608..3084dddcce 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs @@ -10,265 +10,325 @@ namespace System.Linq { public static partial class AsyncEnumerable { - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TSource); - if (value == null) + if (default(TSource) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = e.Current; - } - while (value == null); + value = e.Current; + } + while (value == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x != null && comparer.Compare(x, value) > 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = e.Current; + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = e.Current; - if (comparer.Compare(x, value) > 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = e.Current; + if (comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TResult); - if (value == null) + if (default(TResult) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = selector(e.Current); - } - while (value == null); + value = selector(e.Current); + } + while (value == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x != null && comparer.Compare(x, value) > 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = selector(e.Current); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = selector(e.Current); - if (comparer.Compare(x, value) > 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = selector(e.Current); + if (comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TResult); - if (value == null) + if (default(TResult) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = await selector(e.Current).ConfigureAwait(false); - } - while (value == null); + value = await selector(e.Current).ConfigureAwait(false); + } + while (value == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) > 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = await selector(e.Current).ConfigureAwait(false); - if (comparer.Compare(x, value) > 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current).ConfigureAwait(false); + if (comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } #if !NO_DEEP_CANCELLATION - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TResult); - if (value == null) + if (default(TResult) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (value == null); + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (value == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) > 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (comparer.Compare(x, value) > 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (comparer.Compare(x, value) > 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs index e7bf900793..13220cc602 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs @@ -10,265 +10,325 @@ namespace System.Linq { public static partial class AsyncEnumerable { - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) + private static Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TSource); - if (value == null) + if (default(TSource) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = e.Current; - } - while (value == null); + value = e.Current; + } + while (default(TSource) == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x != null && comparer.Compare(x, value) < 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = e.Current; + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = e.Current; - if (comparer.Compare(x, value) < 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = e.Current; + if (comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) + private static Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TResult); - if (value == null) + if (default(TResult) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = selector(e.Current); - } - while (value == null); + value = selector(e.Current); + } + while (default(TSource) == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x != null && comparer.Compare(x, value) < 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = selector(e.Current); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = selector(e.Current); - if (comparer.Compare(x, value) < 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = selector(e.Current); + if (comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TResult); - if (value == null) + if (default(TResult) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = await selector(e.Current).ConfigureAwait(false); - } - while (value == null); + value = await selector(e.Current).ConfigureAwait(false); + } + while (default(TSource) == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) < 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = await selector(e.Current).ConfigureAwait(false); - if (comparer.Compare(x, value) < 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current).ConfigureAwait(false); + if (comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } #if !NO_DEEP_CANCELLATION - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) + private static Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) { var comparer = Comparer.Default; - var value = default(TResult); - if (value == null) + if (default(TResult) == null) { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - do + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + do { - return value; - } + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (value == null); + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (default(TSource) == null); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) < 0) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + return Core(); - try + async Task Core() { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (comparer.Compare(x, value) < 0) + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (comparer.Compare(x, value) < 0) + { + value = x; + } } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; } } - - return value; } #endif } From e993d80482aaa2e7a73469799bd9552585bed33e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 3 Jan 2019 23:22:56 -0800 Subject: [PATCH 623/862] Inlining Max/Min code --- .../System/Linq/Operators/Max.Generic.cs | 335 ------------------ .../System/Linq/Operators/Max.cs | 308 +++++++++++++++- .../System/Linq/Operators/Min.Generic.cs | 335 ------------------ .../System/Linq/Operators/Min.cs | 308 +++++++++++++++- 4 files changed, 608 insertions(+), 678 deletions(-) delete mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs delete mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs deleted file mode 100644 index 3084dddcce..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Generic.cs +++ /dev/null @@ -1,335 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - private static Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TSource) == null) - { - return Core(); - - async Task Core() - { - var value = default(TSource); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (value == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x != null && comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TSource); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } - - private static Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TResult) == null) - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (value == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x != null && comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } - - private static Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TResult) == null) - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (value == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } - -#if !NO_DEEP_CANCELLATION - private static Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TResult) == null) - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (value == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (comparer.Compare(x, value) > 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } -#endif - } -} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index dfa6cc8233..6532c565dc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -15,7 +15,82 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + var comparer = Comparer.Default; + if (default(TSource) == null) + { + return Core(); + + async Task Core() + { + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -25,7 +100,82 @@ public static Task MaxAsync(this IAsyncEnumerable.Default; + if (default(TResult) == null) + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -35,7 +185,82 @@ public static Task MaxAsync(this IAsyncEnumerable.Default; + if (default(TResult) == null) + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } #if !NO_DEEP_CANCELLATION @@ -46,7 +271,82 @@ public static Task MaxAsync(this IAsyncEnumerable.Default; + if (default(TResult) == null) + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs deleted file mode 100644 index 13220cc602..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Generic.cs +++ /dev/null @@ -1,335 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - private static Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TSource) == null) - { - return Core(); - - async Task Core() - { - var value = default(TSource); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (default(TSource) == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x != null && comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TSource); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } - - private static Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TResult) == null) - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (default(TSource) == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x != null && comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } - - private static Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TResult) == null) - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (default(TSource) == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } - -#if !NO_DEEP_CANCELLATION - private static Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var comparer = Comparer.Default; - if (default(TResult) == null) - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (default(TSource) == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x != null && comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - else - { - return Core(); - - async Task Core() - { - var value = default(TResult); - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (comparer.Compare(x, value) < 0) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - } -#endif - } -} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index d5520091f0..e0ede973a4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -15,7 +15,82 @@ public static Task MinAsync(this IAsyncEnumerable sou if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + var comparer = Comparer.Default; + if (default(TSource) == null) + { + return Core(); + + async Task Core() + { + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TSource); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -25,7 +100,82 @@ public static Task MinAsync(this IAsyncEnumerable.Default; + if (default(TResult) == null) + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = selector(e.Current); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = selector(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = selector(e.Current); + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -35,7 +185,82 @@ public static Task MinAsync(this IAsyncEnumerable.Default; + if (default(TResult) == null) + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current).ConfigureAwait(false); + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } #if !NO_DEEP_CANCELLATION @@ -46,7 +271,82 @@ public static Task MinAsync(this IAsyncEnumerable.Default; + if (default(TResult) == null) + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + } + while (value == null); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } + else + { + return Core(); + + async Task Core() + { + var value = default(TResult); + + var e = source.GetAsyncEnumerator(cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } + } } #endif } From 0980e874303e389c095a871c08ad996816d425fe Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 4 Jan 2019 10:35:14 -0800 Subject: [PATCH 624/862] Avoiding heap-allocated closures --- .../System/Linq/Operators/Aggregate.cs | 90 +++--- .../System/Linq/Operators/All.cs | 24 +- .../System/Linq/Operators/Any.cs | 30 +- .../System/Linq/Operators/Count.cs | 30 +- .../System/Linq/Operators/ElementAt.cs | 23 +- .../Linq/Operators/ElementAtOrDefault.cs | 22 +- .../System/Linq/Operators/First.cs | 24 +- .../System/Linq/Operators/FirstOrDefault.cs | 30 +- .../System/Linq/Operators/Last.cs | 24 +- .../System/Linq/Operators/LastOrDefault.cs | 30 +- .../System/Linq/Operators/LongCount.cs | 30 +- .../System/Linq/Operators/Max.cs | 92 +++--- .../System/Linq/Operators/Min.cs | 92 +++--- .../System/Linq/Operators/SequenceEqual.cs | 10 +- .../System/Linq/Operators/Single.cs | 38 +-- .../System/Linq/Operators/SingleOrDefault.cs | 38 +-- .../System/Linq/Operators/Sum.Generated.cs | 300 +++++++++--------- .../System/Linq/Operators/ToEnumerable.cs | 6 +- .../System/Linq/Operators/ToList.cs | 6 +- 19 files changed, 483 insertions(+), 456 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index df8df83043..8d5fe7011c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -17,11 +17,11 @@ public static Task AggregateAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -34,7 +34,7 @@ async Task Core() while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = accumulator(acc, e.Current); + acc = _accumulator(acc, e.Current); } return acc; @@ -53,11 +53,11 @@ public static Task AggregateAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -70,7 +70,7 @@ async Task Core() while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = await accumulator(acc, e.Current).ConfigureAwait(false); + acc = await _accumulator(acc, e.Current).ConfigureAwait(false); } return acc; @@ -90,11 +90,11 @@ public static Task AggregateAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -107,7 +107,7 @@ async Task Core() while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false); } return acc; @@ -127,19 +127,19 @@ public static Task AggregateAsync(this IAsync if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); - return Core(); + return Core(source, seed, accumulator, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, CancellationToken _cancellationToken) { - var acc = seed; + var acc = _seed; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = accumulator(acc, e.Current); + acc = _accumulator(acc, e.Current); } } finally @@ -158,19 +158,19 @@ public static Task AggregateAsync(this IAsync if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); - return Core(); + return Core(source, seed, accumulator, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) { - var acc = seed; + var acc = _seed; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = await accumulator(acc, e.Current).ConfigureAwait(false); + acc = await _accumulator(acc, e.Current).ConfigureAwait(false); } } finally @@ -190,19 +190,19 @@ public static Task AggregateAsync(this IAsync if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); - return Core(); + return Core(source, seed, accumulator, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) { - var acc = seed; + var acc = _seed; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false); } } finally @@ -224,19 +224,19 @@ public static Task AggregateAsync(this I if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return Core(); + return Core(source, seed, accumulator, resultSelector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, Func _resultSelector, CancellationToken _cancellationToken) { - var acc = seed; + var acc = _seed; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = accumulator(acc, e.Current); + acc = _accumulator(acc, e.Current); } } finally @@ -244,7 +244,7 @@ async Task Core() await e.DisposeAsync().ConfigureAwait(false); } - return resultSelector(acc); + return _resultSelector(acc); } } @@ -257,19 +257,19 @@ public static Task AggregateAsync(this I if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return Core(); + return Core(source, seed, accumulator, resultSelector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) { - var acc = seed; + var acc = _seed; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = await accumulator(acc, e.Current).ConfigureAwait(false); + acc = await _accumulator(acc, e.Current).ConfigureAwait(false); } } finally @@ -277,7 +277,7 @@ async Task Core() await e.DisposeAsync().ConfigureAwait(false); } - return await resultSelector(acc).ConfigureAwait(false); + return await _resultSelector(acc).ConfigureAwait(false); } } @@ -291,19 +291,19 @@ public static Task AggregateAsync(this I if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); - return Core(); + return Core(source, seed, accumulator, resultSelector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) { - var acc = seed; + var acc = _seed; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - acc = await accumulator(acc, e.Current, cancellationToken).ConfigureAwait(false); + acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false); } } finally @@ -311,7 +311,7 @@ async Task Core() await e.DisposeAsync().ConfigureAwait(false); } - return await resultSelector(acc, cancellationToken).ConfigureAwait(false); + return await _resultSelector(acc, _cancellationToken).ConfigureAwait(false); } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 30c26f45e1..a98acb1c43 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -17,17 +17,17 @@ public static Task AllAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (!predicate(e.Current)) + if (!_predicate(e.Current)) return false; } } @@ -47,17 +47,17 @@ public static Task AllAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (!await predicate(e.Current).ConfigureAwait(false)) + if (!await _predicate(e.Current).ConfigureAwait(false)) return false; } } @@ -78,17 +78,17 @@ public static Task AllAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (!await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + if (!await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) return false; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 7aacbdab08..86c606f534 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -15,11 +15,11 @@ public static Task AnyAsync(this IAsyncEnumerable source if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -39,17 +39,17 @@ public static Task AnyAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (predicate(e.Current)) + if (_predicate(e.Current)) return true; } } @@ -69,17 +69,17 @@ public static Task AnyAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current).ConfigureAwait(false)) + if (await _predicate(e.Current).ConfigureAwait(false)) return true; } } @@ -100,17 +100,17 @@ public static Task AnyAsync(this IAsyncEnumerable source if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) return true; } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 9379a9f665..0edbbfad95 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -26,13 +26,13 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Task.FromResult(collection.Count); } - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -60,19 +60,19 @@ public static Task CountAsync(this IAsyncEnumerable sourc if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (predicate(e.Current)) + if (_predicate(e.Current)) { checked { @@ -97,19 +97,19 @@ public static Task CountAsync(this IAsyncEnumerable sourc if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current).ConfigureAwait(false)) + if (await _predicate(e.Current).ConfigureAwait(false)) { checked { @@ -135,19 +135,19 @@ public static Task CountAsync(this IAsyncEnumerable sourc if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) { checked { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index b2d332bc30..d2a953c82d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -15,13 +15,13 @@ public static Task ElementAtAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) { - if (source is IAsyncPartition p) + if (_source is IAsyncPartition p) { - var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); + var first = await p.TryGetElementAtAsync(_index, _cancellationToken).ConfigureAwait(false); if (first.HasValue) { @@ -30,25 +30,25 @@ async Task Core() } else { - if (source is IList list) + if (_source is IList list) { - return list[index]; + return list[_index]; } - if (index >= 0) + if (_index >= 0) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (index == 0) + if (_index == 0) { return e.Current; } - index--; + _index--; } } finally @@ -58,6 +58,9 @@ async Task Core() } } + // NB: Even though index is captured, no closure is created. + // The nameof expression is lowered to a literal prior to creating closures. + throw Error.ArgumentOutOfRange(nameof(index)); } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 256dab42c1..77b12625cb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -15,13 +15,13 @@ public static Task ElementAtOrDefaultAsync(this IAsyncEnumerab if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, index, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) { - if (source is IAsyncPartition p) + if (_source is IAsyncPartition p) { - var first = await p.TryGetElementAtAsync(index, cancellationToken).ConfigureAwait(false); + var first = await p.TryGetElementAtAsync(_index, _cancellationToken).ConfigureAwait(false); if (first.HasValue) { @@ -29,29 +29,29 @@ async Task Core() } } - if (index >= 0) + if (_index >= 0) { - if (source is IList list) + if (_source is IList list) { - if (index < list.Count) + if (_index < list.Count) { - return list[index]; + return list[_index]; } } else { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (index == 0) + if (_index == 0) { return e.Current; } - index--; + _index--; } } finally diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 6dd30f529c..12651d6ab5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -15,11 +15,11 @@ public static Task FirstAsync(this IAsyncEnumerable s if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } @@ -32,11 +32,11 @@ public static Task FirstAsync(this IAsyncEnumerable s if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } @@ -49,11 +49,11 @@ public static Task FirstAsync(this IAsyncEnumerable s if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } @@ -67,11 +67,11 @@ public static Task FirstAsync(this IAsyncEnumerable s if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : throw Error.NoElements(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 5aea5e31bc..9d43461ad2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -15,11 +15,11 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -32,11 +32,11 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -49,11 +49,11 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -67,11 +67,11 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var first = await TryGetFirst(source, predicate, cancellationToken).ConfigureAwait(false); + var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); return first.HasValue ? first.Value : default; } @@ -93,11 +93,11 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core() + async ValueTask> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 101db9eef0..f69bd1dc4d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -15,11 +15,11 @@ public static Task LastAsync(this IAsyncEnumerable so if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } @@ -32,11 +32,11 @@ public static Task LastAsync(this IAsyncEnumerable so if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } @@ -49,11 +49,11 @@ public static Task LastAsync(this IAsyncEnumerable so if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } @@ -67,11 +67,11 @@ public static Task LastAsync(this IAsyncEnumerable so if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : throw Error.NoElements(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index b8b4592e75..a537804578 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -15,11 +15,11 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -32,11 +32,11 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -49,11 +49,11 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -67,11 +67,11 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var last = await TryGetLast(source, predicate, cancellationToken).ConfigureAwait(false); + var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); return last.HasValue ? last.Value : default; } @@ -94,14 +94,14 @@ private static ValueTask> TryGetLast(IAsyncEnumerable> Core() + async ValueTask> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var last = default(TSource); var hasLast = false; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 538810b584..7c618bfb03 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -15,13 +15,13 @@ public static Task LongCountAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -49,19 +49,19 @@ public static Task LongCountAsync(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (predicate(e.Current)) + if (_predicate(e.Current)) { checked { @@ -86,19 +86,19 @@ public static Task LongCountAsync(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current).ConfigureAwait(false)) + if (await _predicate(e.Current).ConfigureAwait(false)) { checked { @@ -124,19 +124,19 @@ public static Task LongCountAsync(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) { checked { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 6532c565dc..7bb0dd6db5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -15,16 +15,17 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (source == null) throw Error.ArgumentNull(nameof(source)); - var comparer = Comparer.Default; if (default(TSource) == null) { - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TSource); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -58,13 +59,15 @@ async Task Core() } else { - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TSource); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -100,16 +103,17 @@ public static Task MaxAsync(this IAsyncEnumerable.Default; if (default(TResult) == null) { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -120,13 +124,13 @@ async Task Core() return value; } - value = selector(e.Current); + value = _selector(e.Current); } while (value == null); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + var x = _selector(e.Current); if (x != null && comparer.Compare(x, value) > 0) { value = x; @@ -143,13 +147,15 @@ async Task Core() } else { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -158,10 +164,10 @@ async Task Core() throw Error.NoElements(); } - value = selector(e.Current); + value = _selector(e.Current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + var x = _selector(e.Current); if (comparer.Compare(x, value) > 0) { value = x; @@ -185,16 +191,17 @@ public static Task MaxAsync(this IAsyncEnumerable.Default; if (default(TResult) == null) { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -205,13 +212,13 @@ async Task Core() return value; } - value = await selector(e.Current).ConfigureAwait(false); + value = await _selector(e.Current).ConfigureAwait(false); } while (value == null); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + var x = await _selector(e.Current).ConfigureAwait(false); if (x != null && comparer.Compare(x, value) > 0) { value = x; @@ -228,13 +235,15 @@ async Task Core() } else { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -243,10 +252,10 @@ async Task Core() throw Error.NoElements(); } - value = await selector(e.Current).ConfigureAwait(false); + value = await _selector(e.Current).ConfigureAwait(false); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + var x = await _selector(e.Current).ConfigureAwait(false); if (comparer.Compare(x, value) > 0) { value = x; @@ -271,16 +280,17 @@ public static Task MaxAsync(this IAsyncEnumerable.Default; if (default(TResult) == null) { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -291,13 +301,13 @@ async Task Core() return value; } - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } while (value == null); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (x != null && comparer.Compare(x, value) > 0) { value = x; @@ -314,13 +324,15 @@ async Task Core() } else { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -329,10 +341,10 @@ async Task Core() throw Error.NoElements(); } - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (comparer.Compare(x, value) > 0) { value = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index e0ede973a4..b16575768c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -15,16 +15,17 @@ public static Task MinAsync(this IAsyncEnumerable sou if (source == null) throw Error.ArgumentNull(nameof(source)); - var comparer = Comparer.Default; if (default(TSource) == null) { - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TSource); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -58,13 +59,15 @@ async Task Core() } else { - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TSource); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -100,16 +103,17 @@ public static Task MinAsync(this IAsyncEnumerable.Default; if (default(TResult) == null) { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -120,13 +124,13 @@ async Task Core() return value; } - value = selector(e.Current); + value = _selector(e.Current); } while (value == null); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + var x = _selector(e.Current); if (x != null && comparer.Compare(x, value) < 0) { value = x; @@ -143,13 +147,15 @@ async Task Core() } else { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -158,10 +164,10 @@ async Task Core() throw Error.NoElements(); } - value = selector(e.Current); + value = _selector(e.Current); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = selector(e.Current); + var x = _selector(e.Current); if (comparer.Compare(x, value) < 0) { value = x; @@ -185,16 +191,17 @@ public static Task MinAsync(this IAsyncEnumerable.Default; if (default(TResult) == null) { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -205,13 +212,13 @@ async Task Core() return value; } - value = await selector(e.Current).ConfigureAwait(false); + value = await _selector(e.Current).ConfigureAwait(false); } while (value == null); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + var x = await _selector(e.Current).ConfigureAwait(false); if (x != null && comparer.Compare(x, value) < 0) { value = x; @@ -228,13 +235,15 @@ async Task Core() } else { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -243,10 +252,10 @@ async Task Core() throw Error.NoElements(); } - value = await selector(e.Current).ConfigureAwait(false); + value = await _selector(e.Current).ConfigureAwait(false); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current).ConfigureAwait(false); + var x = await _selector(e.Current).ConfigureAwait(false); if (comparer.Compare(x, value) < 0) { value = x; @@ -271,16 +280,17 @@ public static Task MinAsync(this IAsyncEnumerable.Default; if (default(TResult) == null) { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -291,13 +301,13 @@ async Task Core() return value; } - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } while (value == null); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (x != null && comparer.Compare(x, value) < 0) { value = x; @@ -314,13 +324,15 @@ async Task Core() } else { - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { + var comparer = Comparer.Default; + var value = default(TResult); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -329,10 +341,10 @@ async Task Core() throw Error.NoElements(); } - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (comparer.Compare(x, value) < 0) { value = x; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 915f0c5796..76fcc264a9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -60,21 +60,21 @@ private static Task SequenceEqualCore(IAsyncEnumerable f } } - return Core(); + return Core(first, second, comparer, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { - var e1 = first.GetAsyncEnumerator(cancellationToken); + var e1 = _first.GetAsyncEnumerator(_cancellationToken); try { - var e2 = second.GetAsyncEnumerator(cancellationToken); + var e2 = _second.GetAsyncEnumerator(_cancellationToken); try { while (await e1.MoveNextAsync().ConfigureAwait(false)) { - if (!(await e2.MoveNextAsync().ConfigureAwait(false) && comparer.Equals(e1.Current, e2.Current))) + if (!(await e2.MoveNextAsync().ConfigureAwait(false) && _comparer.Equals(e1.Current, e2.Current))) { return false; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 3841f2a11c..c29de5ef09 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -15,11 +15,11 @@ public static Task SingleAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - if (source is IList list) + if (_source is IList list) { switch (list.Count) { @@ -30,7 +30,7 @@ async Task Core() throw Error.MoreThanOneElement(); } - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -61,11 +61,11 @@ public static Task SingleAsync(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -73,11 +73,11 @@ async Task Core() { var result = e.Current; - if (predicate(result)) + if (_predicate(result)) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (predicate(e.Current)) + if (_predicate(e.Current)) { throw Error.MoreThanOneElement(); } @@ -103,11 +103,11 @@ public static Task SingleAsync(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -115,11 +115,11 @@ async Task Core() { var result = e.Current; - if (await predicate(result).ConfigureAwait(false)) + if (await _predicate(result).ConfigureAwait(false)) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current).ConfigureAwait(false)) + if (await _predicate(e.Current).ConfigureAwait(false)) { throw Error.MoreThanOneElement(); } @@ -146,11 +146,11 @@ public static Task SingleAsync(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -158,11 +158,11 @@ async Task Core() { var result = e.Current; - if (await predicate(result, cancellationToken).ConfigureAwait(false)) + if (await _predicate(result, _cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) { throw Error.MoreThanOneElement(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index c7557242e1..4098335f4d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -15,11 +15,11 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - if (source is IList list) + if (_source is IList list) { switch (list.Count) { @@ -30,7 +30,7 @@ async Task Core() throw Error.MoreThanOneElement(); } - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -62,11 +62,11 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -74,11 +74,11 @@ async Task Core() { var result = e.Current; - if (predicate(result)) + if (_predicate(result)) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (predicate(e.Current)) + if (_predicate(e.Current)) { throw Error.MoreThanOneElement(); } @@ -104,11 +104,11 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -116,11 +116,11 @@ async Task Core() { var result = e.Current; - if (await predicate(result).ConfigureAwait(false)) + if (await _predicate(result).ConfigureAwait(false)) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current).ConfigureAwait(false)) + if (await _predicate(e.Current).ConfigureAwait(false)) { throw Error.MoreThanOneElement(); } @@ -147,11 +147,11 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); - return Core(); + return Core(source, predicate, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -159,11 +159,11 @@ async Task Core() { var result = e.Current; - if (await predicate(result, cancellationToken).ConfigureAwait(false)) + if (await _predicate(result, _cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync().ConfigureAwait(false)) { - if (await predicate(e.Current, cancellationToken).ConfigureAwait(false)) + if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) { throw Error.MoreThanOneElement(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 6ce0001c46..2cd9c007d3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -15,13 +15,13 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancellation if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -49,19 +49,19 @@ public static Task SumAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); checked { @@ -85,19 +85,19 @@ public static Task SumAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); checked { @@ -122,19 +122,19 @@ public static Task SumAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); checked { @@ -157,13 +157,13 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancellati if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -191,19 +191,19 @@ public static Task SumAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); checked { @@ -227,19 +227,19 @@ public static Task SumAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); checked { @@ -264,19 +264,19 @@ public static Task SumAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); checked { @@ -299,13 +299,13 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancella if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -330,19 +330,19 @@ public static Task SumAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); sum += value; } @@ -363,19 +363,19 @@ public static Task SumAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); sum += value; } @@ -397,19 +397,19 @@ public static Task SumAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); sum += value; } @@ -429,13 +429,13 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancel if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -460,19 +460,19 @@ public static Task SumAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); sum += value; } @@ -493,19 +493,19 @@ public static Task SumAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); sum += value; } @@ -527,19 +527,19 @@ public static Task SumAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); sum += value; } @@ -559,13 +559,13 @@ public static Task SumAsync(this IAsyncEnumerable source, Canc if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -590,19 +590,19 @@ public static Task SumAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); sum += value; } @@ -623,19 +623,19 @@ public static Task SumAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); sum += value; } @@ -657,19 +657,19 @@ public static Task SumAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); sum += value; } @@ -689,13 +689,13 @@ async Task Core() if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -723,19 +723,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); checked { @@ -759,19 +759,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); checked { @@ -796,19 +796,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); checked { @@ -831,13 +831,13 @@ async Task Core() if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -865,19 +865,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); checked { @@ -901,19 +901,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); checked { @@ -938,19 +938,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); checked { @@ -973,13 +973,13 @@ async Task Core() if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -1004,19 +1004,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1037,19 +1037,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1071,19 +1071,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1103,13 +1103,13 @@ async Task Core() if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -1134,19 +1134,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1167,19 +1167,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1201,19 +1201,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1233,13 +1233,13 @@ async Task Core() if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -1264,19 +1264,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); sum += value.GetValueOrDefault(); } @@ -1297,19 +1297,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); sum += value.GetValueOrDefault(); } @@ -1331,19 +1331,19 @@ async Task Core() if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task Core() + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); sum += value.GetValueOrDefault(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs index 1c7c7e65dc..2d84b9b945 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToEnumerable.cs @@ -17,11 +17,11 @@ public static IEnumerable ToEnumerable(this IAsyncEnumerable Core() + IEnumerable Core(IAsyncEnumerable _source) { - var e = source.GetAsyncEnumerator(default); + var e = _source.GetAsyncEnumerator(default); try { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index f25b1e7be9..af653fd549 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -18,13 +18,13 @@ public static Task> ToListAsync(this IAsyncEnumerable listProvider) return listProvider.ToListAsync(cancellationToken).AsTask(); - return Core(); + return Core(source, cancellationToken); - async Task> Core() + async Task> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var list = new List(); - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { From 5227c484292d7af364d19490336fa13ef2ced1c8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 4 Jan 2019 10:42:39 -0800 Subject: [PATCH 625/862] Refactor Where/Select optimizations --- .../System/Linq/Operators/Select.Opt.cs | 31 +++++++++++++++++++ .../System/Linq/Operators/Select.cs | 17 ---------- .../System/Linq/Operators/Where.Opt.cs | 31 +++++++++++++++++++ .../System/Linq/Operators/Where.cs | 17 ---------- 4 files changed, 62 insertions(+), 34 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs new file mode 100644 index 0000000000..604f7cb18a --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private static Func CombineSelectors(Func selector1, Func selector2) + { + return x => selector2(selector1(x)); + } + + private static Func> CombineSelectors(Func> selector1, Func> selector2) + { + return async x => await selector2(await selector1(x).ConfigureAwait(false)).ConfigureAwait(false); + } + +#if !NO_DEEP_CANCELLATION + private static Func> CombineSelectors(Func> selector1, Func> selector2) + { + return async (x, ct) => await selector2(await selector1(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false); + } +#endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index baaa8edf6c..7dc71b79c6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -99,23 +99,6 @@ public static IAsyncEnumerable Select(this IAsyncEnum } #endif - private static Func CombineSelectors(Func selector1, Func selector2) - { - return x => selector2(selector1(x)); - } - - private static Func> CombineSelectors(Func> selector1, Func> selector2) - { - return async x => await selector2(await selector1(x).ConfigureAwait(false)).ConfigureAwait(false); - } - -#if !NO_DEEP_CANCELLATION - private static Func> CombineSelectors(Func> selector1, Func> selector2) - { - return async (x, ct) => await selector2(await selector1(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false); - } -#endif - internal sealed class SelectEnumerableAsyncIterator : AsyncIterator { private readonly Func _selector; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs new file mode 100644 index 0000000000..5e544f268b --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private static Func CombinePredicates(Func predicate1, Func predicate2) + { + return x => predicate1(x) && predicate2(x); + } + + private static Func> CombinePredicates(Func> predicate1, Func> predicate2) + { + return async x => await predicate1(x).ConfigureAwait(false) && await predicate2(x).ConfigureAwait(false); + } + +#if !NO_DEEP_CANCELLATION + private static Func> CombinePredicates(Func> predicate1, Func> predicate2) + { + return async (x, ct) => await predicate1(x, ct).ConfigureAwait(false) && await predicate2(x, ct).ConfigureAwait(false); + } +#endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 3d5af66827..c0d170a65d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -93,23 +93,6 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable CombinePredicates(Func predicate1, Func predicate2) - { - return x => predicate1(x) && predicate2(x); - } - - private static Func> CombinePredicates(Func> predicate1, Func> predicate2) - { - return async x => await predicate1(x).ConfigureAwait(false) && await predicate2(x).ConfigureAwait(false); - } - -#if !NO_DEEP_CANCELLATION - private static Func> CombinePredicates(Func> predicate1, Func> predicate2) - { - return async (x, ct) => await predicate1(x, ct).ConfigureAwait(false) && await predicate2(x, ct).ConfigureAwait(false); - } -#endif - internal sealed class WhereEnumerableAsyncIterator : AsyncIterator { private readonly Func _predicate; From 89ed66a36d09816ae9aa6d2f27d306284641bc66 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 4 Jan 2019 10:43:04 -0800 Subject: [PATCH 626/862] Updated code generation for Sum to avoid closures --- .../System/Linq/Operators/Sum.Generated.tt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index f169ca32cc..b94eaae990 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -40,13 +40,13 @@ foreach (var o in os) if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task<<#=o.type#>> Core() + async Task<<#=o.type#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -87,19 +87,19 @@ else if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task<<#=o.type#>> Core() + async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = selector(e.Current); + var value = _selector(e.Current); <# if (o.@checked) @@ -136,19 +136,19 @@ else if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task<<#=o.type#>> Core() + async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current).ConfigureAwait(false); + var value = await _selector(e.Current).ConfigureAwait(false); <# if (o.@checked) @@ -186,19 +186,19 @@ else if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return Core(); + return Core(source, selector, cancellationToken); - async Task<<#=o.type#>> Core() + async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var value = await selector(e.Current, cancellationToken).ConfigureAwait(false); + var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); <# if (o.@checked) From be5d8bb43808bd93fc00c5301d7b30f55e8744fe Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 4 Jan 2019 11:23:15 -0800 Subject: [PATCH 627/862] Enabling optimizations for combining N predicates --- .../System/Linq/Operators/Select.Opt.cs | 2 - .../Linq/Operators/Where.Opt.Generated.cs | 231 ++++++++++++++++++ .../Linq/Operators/Where.Opt.Generated.tt | 168 +++++++++++++ .../System/Linq/Operators/Where.Opt.cs | 143 ++++++++++- 4 files changed, 537 insertions(+), 7 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs index 604f7cb18a..fc3dff4d82 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Collections.Generic; -using System.Diagnostics; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.cs new file mode 100644 index 0000000000..0c5bc74bcd --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.cs @@ -0,0 +1,231 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private sealed class CombinedPredicates2 : ICombinedPredicates + { + private readonly Func _predicate1; + private readonly Func _predicate2; + + public CombinedPredicates2(Func predicate1, Func predicate2) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + } + + public ICombinedPredicates And(Func predicate) => + new CombinedPredicates3( + _predicate1, + _predicate2, + predicate + ); + + public bool Invoke(TSource x) => _predicate1(x) && _predicate2(x); + } + + private sealed class CombinedPredicates3 : ICombinedPredicates + { + private readonly Func _predicate1; + private readonly Func _predicate2; + private readonly Func _predicate3; + + public CombinedPredicates3(Func predicate1, Func predicate2, Func predicate3) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + _predicate3 = predicate3; + } + + public ICombinedPredicates And(Func predicate) => + new CombinedPredicates4( + _predicate1, + _predicate2, + _predicate3, + predicate + ); + + public bool Invoke(TSource x) => _predicate1(x) && _predicate2(x) && _predicate3(x); + } + + private sealed class CombinedPredicates4 : ICombinedPredicates + { + private readonly Func _predicate1; + private readonly Func _predicate2; + private readonly Func _predicate3; + private readonly Func _predicate4; + + public CombinedPredicates4(Func predicate1, Func predicate2, Func predicate3, Func predicate4) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + _predicate3 = predicate3; + _predicate4 = predicate4; + } + + public ICombinedPredicates And(Func predicate) => + new CombinedPredicatesN( + _predicate1, + _predicate2, + _predicate3, + _predicate4, + predicate + ); + + public bool Invoke(TSource x) => _predicate1(x) && _predicate2(x) && _predicate3(x) && _predicate4(x); + } + + private sealed class CombinedAsyncPredicates2 : ICombinedAsyncPredicates + { + private readonly Func> _predicate1; + private readonly Func> _predicate2; + + public CombinedAsyncPredicates2(Func> predicate1, Func> predicate2) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + } + + public ICombinedAsyncPredicates And(Func> predicate) => + new CombinedAsyncPredicates3( + _predicate1, + _predicate2, + predicate + ); + + public async ValueTask Invoke(TSource x) => await _predicate1(x).ConfigureAwait(false) && await _predicate2(x).ConfigureAwait(false); + } + + private sealed class CombinedAsyncPredicates3 : ICombinedAsyncPredicates + { + private readonly Func> _predicate1; + private readonly Func> _predicate2; + private readonly Func> _predicate3; + + public CombinedAsyncPredicates3(Func> predicate1, Func> predicate2, Func> predicate3) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + _predicate3 = predicate3; + } + + public ICombinedAsyncPredicates And(Func> predicate) => + new CombinedAsyncPredicates4( + _predicate1, + _predicate2, + _predicate3, + predicate + ); + + public async ValueTask Invoke(TSource x) => await _predicate1(x).ConfigureAwait(false) && await _predicate2(x).ConfigureAwait(false) && await _predicate3(x).ConfigureAwait(false); + } + + private sealed class CombinedAsyncPredicates4 : ICombinedAsyncPredicates + { + private readonly Func> _predicate1; + private readonly Func> _predicate2; + private readonly Func> _predicate3; + private readonly Func> _predicate4; + + public CombinedAsyncPredicates4(Func> predicate1, Func> predicate2, Func> predicate3, Func> predicate4) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + _predicate3 = predicate3; + _predicate4 = predicate4; + } + + public ICombinedAsyncPredicates And(Func> predicate) => + new CombinedAsyncPredicatesN( + _predicate1, + _predicate2, + _predicate3, + _predicate4, + predicate + ); + + public async ValueTask Invoke(TSource x) => await _predicate1(x).ConfigureAwait(false) && await _predicate2(x).ConfigureAwait(false) && await _predicate3(x).ConfigureAwait(false) && await _predicate4(x).ConfigureAwait(false); + } + +#if !NO_DEEP_CANCELLATION + private sealed class CombinedAsyncPredicatesWithCancellation2 : ICombinedAsyncPredicatesWithCancellation + { + private readonly Func> _predicate1; + private readonly Func> _predicate2; + + public CombinedAsyncPredicatesWithCancellation2(Func> predicate1, Func> predicate2) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + } + + public ICombinedAsyncPredicatesWithCancellation And(Func> predicate) => + new CombinedAsyncPredicatesWithCancellation3( + _predicate1, + _predicate2, + predicate + ); + + public async ValueTask Invoke(TSource x, CancellationToken ct) => await _predicate1(x, ct).ConfigureAwait(false) && await _predicate2(x, ct).ConfigureAwait(false); + } + + private sealed class CombinedAsyncPredicatesWithCancellation3 : ICombinedAsyncPredicatesWithCancellation + { + private readonly Func> _predicate1; + private readonly Func> _predicate2; + private readonly Func> _predicate3; + + public CombinedAsyncPredicatesWithCancellation3(Func> predicate1, Func> predicate2, Func> predicate3) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + _predicate3 = predicate3; + } + + public ICombinedAsyncPredicatesWithCancellation And(Func> predicate) => + new CombinedAsyncPredicatesWithCancellation4( + _predicate1, + _predicate2, + _predicate3, + predicate + ); + + public async ValueTask Invoke(TSource x, CancellationToken ct) => await _predicate1(x, ct).ConfigureAwait(false) && await _predicate2(x, ct).ConfigureAwait(false) && await _predicate3(x, ct).ConfigureAwait(false); + } + + private sealed class CombinedAsyncPredicatesWithCancellation4 : ICombinedAsyncPredicatesWithCancellation + { + private readonly Func> _predicate1; + private readonly Func> _predicate2; + private readonly Func> _predicate3; + private readonly Func> _predicate4; + + public CombinedAsyncPredicatesWithCancellation4(Func> predicate1, Func> predicate2, Func> predicate3, Func> predicate4) + { + _predicate1 = predicate1; + _predicate2 = predicate2; + _predicate3 = predicate3; + _predicate4 = predicate4; + } + + public ICombinedAsyncPredicatesWithCancellation And(Func> predicate) => + new CombinedAsyncPredicatesWithCancellationN( + _predicate1, + _predicate2, + _predicate3, + _predicate4, + predicate + ); + + public async ValueTask Invoke(TSource x, CancellationToken ct) => await _predicate1(x, ct).ConfigureAwait(false) && await _predicate2(x, ct).ConfigureAwait(false) && await _predicate3(x, ct).ConfigureAwait(false) && await _predicate4(x, ct).ConfigureAwait(false); + } + +#endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.tt new file mode 100644 index 0000000000..39745e2b3a --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.Generated.tt @@ -0,0 +1,168 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# +int maxCombine = 4; +#> +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { +<# +for (var i = 2; i <= maxCombine; i++) +{ + var applyAll = string.Join(" && ", Enumerable.Range(1, i).Select(j => "_predicate" + j + "(x)")); + var allPreds = string.Join(", ", Enumerable.Range(1, i).Select(j => "Func predicate" + j)); +#> + private sealed class CombinedPredicates<#=i#> : ICombinedPredicates + { +<# +for (var j = 1; j <= i; j++) +{ +#> + private readonly Func _predicate<#=j#>; +<# +} +#> + + public CombinedPredicates<#=i#>(<#=allPreds#>) + { +<# +for (var j = 1; j <= i; j++) +{ +#> + _predicate<#=j#> = predicate<#=j#>; +<# +} +#> + } + + public ICombinedPredicates And(Func predicate) => + new CombinedPredicates<#=i == maxCombine ? "N" : (i + 1).ToString()#>( +<# +for (var j = 1; j <= i; j++) +{ +#> + _predicate<#=j#>, +<# +} +#> + predicate + ); + + public bool Invoke(TSource x) => <#=applyAll#>; + } + +<# +} +#> +<# +for (var i = 2; i <= maxCombine; i++) +{ + var applyAll = string.Join(" && ", Enumerable.Range(1, i).Select(j => "await _predicate" + j + "(x).ConfigureAwait(false)")); + var allPreds = string.Join(", ", Enumerable.Range(1, i).Select(j => "Func> predicate" + j)); +#> + private sealed class CombinedAsyncPredicates<#=i#> : ICombinedAsyncPredicates + { +<# +for (var j = 1; j <= i; j++) +{ +#> + private readonly Func> _predicate<#=j#>; +<# +} +#> + + public CombinedAsyncPredicates<#=i#>(<#=allPreds#>) + { +<# +for (var j = 1; j <= i; j++) +{ +#> + _predicate<#=j#> = predicate<#=j#>; +<# +} +#> + } + + public ICombinedAsyncPredicates And(Func> predicate) => + new CombinedAsyncPredicates<#=i == maxCombine ? "N" : (i + 1).ToString()#>( +<# +for (var j = 1; j <= i; j++) +{ +#> + _predicate<#=j#>, +<# +} +#> + predicate + ); + + public async ValueTask Invoke(TSource x) => <#=applyAll#>; + } + +<# +} +#> +#if !NO_DEEP_CANCELLATION +<# +for (var i = 2; i <= maxCombine; i++) +{ + var applyAll = string.Join(" && ", Enumerable.Range(1, i).Select(j => "await _predicate" + j + "(x, ct).ConfigureAwait(false)")); + var allPreds = string.Join(", ", Enumerable.Range(1, i).Select(j => "Func> predicate" + j)); +#> + private sealed class CombinedAsyncPredicatesWithCancellation<#=i#> : ICombinedAsyncPredicatesWithCancellation + { +<# +for (var j = 1; j <= i; j++) +{ +#> + private readonly Func> _predicate<#=j#>; +<# +} +#> + + public CombinedAsyncPredicatesWithCancellation<#=i#>(<#=allPreds#>) + { +<# +for (var j = 1; j <= i; j++) +{ +#> + _predicate<#=j#> = predicate<#=j#>; +<# +} +#> + } + + public ICombinedAsyncPredicatesWithCancellation And(Func> predicate) => + new CombinedAsyncPredicatesWithCancellation<#=i == maxCombine ? "N" : (i + 1).ToString()#>( +<# +for (var j = 1; j <= i; j++) +{ +#> + _predicate<#=j#>, +<# +} +#> + predicate + ); + + public async ValueTask Invoke(TSource x, CancellationToken ct) => <#=applyAll#>; + } + +<# +} +#> +#endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs index 5e544f268b..3880cbfa86 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.Opt.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -using System.Collections.Generic; -using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -13,18 +11,153 @@ public static partial class AsyncEnumerable { private static Func CombinePredicates(Func predicate1, Func predicate2) { - return x => predicate1(x) && predicate2(x); + if (predicate1.Target is ICombinedPredicates c) + { + return c.And(predicate2).Invoke; + } + else + { + return new CombinedPredicates2(predicate1, predicate2).Invoke; + } + } + + private interface ICombinedPredicates + { + ICombinedPredicates And(Func predicate); + bool Invoke(TSource x); + } + + private sealed class CombinedPredicatesN : ICombinedPredicates + { + private readonly Func[] _predicates; + + public CombinedPredicatesN(params Func[] predicates) + { + _predicates = predicates; + } + + public ICombinedPredicates And(Func predicate) + { + var predicates = new Func[_predicates.Length + 1]; + Array.Copy(_predicates, predicates, _predicates.Length); + predicates[_predicates.Length] = predicate; + + return new CombinedPredicatesN(predicates); + } + + public bool Invoke(TSource x) + { + foreach (var predicate in _predicates) + { + if (!predicate(x)) + { + return false; + } + } + + return true; + } } private static Func> CombinePredicates(Func> predicate1, Func> predicate2) { - return async x => await predicate1(x).ConfigureAwait(false) && await predicate2(x).ConfigureAwait(false); + if (predicate1.Target is ICombinedAsyncPredicates c) + { + return c.And(predicate2).Invoke; + } + else + { + return new CombinedAsyncPredicates2(predicate1, predicate2).Invoke; + } + } + + private interface ICombinedAsyncPredicates + { + ICombinedAsyncPredicates And(Func> predicate); + ValueTask Invoke(TSource x); + } + + private sealed class CombinedAsyncPredicatesN : ICombinedAsyncPredicates + { + private readonly Func>[] _predicates; + + public CombinedAsyncPredicatesN(params Func>[] predicates) + { + _predicates = predicates; + } + + public ICombinedAsyncPredicates And(Func> predicate) + { + var predicates = new Func>[_predicates.Length + 1]; + Array.Copy(_predicates, predicates, _predicates.Length); + predicates[_predicates.Length] = predicate; + + return new CombinedAsyncPredicatesN(predicates); + } + + public async ValueTask Invoke(TSource x) + { + foreach (var predicate in _predicates) + { + if (!await predicate(x).ConfigureAwait(false)) + { + return false; + } + } + + return true; + } } #if !NO_DEEP_CANCELLATION private static Func> CombinePredicates(Func> predicate1, Func> predicate2) { - return async (x, ct) => await predicate1(x, ct).ConfigureAwait(false) && await predicate2(x, ct).ConfigureAwait(false); + if (predicate1.Target is ICombinedAsyncPredicatesWithCancellation c) + { + return c.And(predicate2).Invoke; + } + else + { + return new CombinedAsyncPredicatesWithCancellation2(predicate1, predicate2).Invoke; + } + } + + private interface ICombinedAsyncPredicatesWithCancellation + { + ICombinedAsyncPredicatesWithCancellation And(Func> predicate); + ValueTask Invoke(TSource x, CancellationToken ct); + } + + private sealed class CombinedAsyncPredicatesWithCancellationN : ICombinedAsyncPredicatesWithCancellation + { + private readonly Func>[] _predicates; + + public CombinedAsyncPredicatesWithCancellationN(params Func>[] predicates) + { + _predicates = predicates; + } + + public ICombinedAsyncPredicatesWithCancellation And(Func> predicate) + { + var predicates = new Func>[_predicates.Length + 1]; + Array.Copy(_predicates, predicates, _predicates.Length); + predicates[_predicates.Length] = predicate; + + return new CombinedAsyncPredicatesWithCancellationN(predicates); + } + + public async ValueTask Invoke(TSource x, CancellationToken ct) + { + foreach (var predicate in _predicates) + { + if (!await predicate(x, ct).ConfigureAwait(false)) + { + return false; + } + } + + return true; + } } #endif } From 2b0cd8e161cbea52ad39ea3680ac1836711dde32 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 4 Jan 2019 12:00:32 -0800 Subject: [PATCH 628/862] Enabling optimizations for combining N selectors --- .../Linq/Operators/Select.Opt.Generated.cs | 213 ++++++++++++++++ .../Linq/Operators/Select.Opt.Generated.tt | 228 ++++++++++++++++++ .../System/Linq/Operators/Select.Opt.cs | 45 +++- 3 files changed, 483 insertions(+), 3 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.cs new file mode 100644 index 0000000000..48299b2778 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.cs @@ -0,0 +1,213 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { + private sealed class CombinedSelectors2 : ICombinedSelectors + { + private readonly Func _selector1; + private readonly Func _selector2; + + public CombinedSelectors2(Func selector1, Func selector2) + { + _selector1 = selector1; + _selector2 = selector2; + } + + public ICombinedSelectors Combine(Func selector) => + new CombinedSelectors3( + _selector1, + _selector2, + selector + ); + + public TResult Invoke(TSource x) => _selector2(_selector1(x)); + } + + private sealed class CombinedSelectors3 : ICombinedSelectors + { + private readonly Func _selector1; + private readonly Func _selector2; + private readonly Func _selector3; + + public CombinedSelectors3(Func selector1, Func selector2, Func selector3) + { + _selector1 = selector1; + _selector2 = selector2; + _selector3 = selector3; + } + + public ICombinedSelectors Combine(Func selector) => + new CombinedSelectors4( + _selector1, + _selector2, + _selector3, + selector + ); + + public TResult Invoke(TSource x) => _selector3(_selector2(_selector1(x))); + } + + private sealed class CombinedSelectors4 : ICombinedSelectors + { + private readonly Func _selector1; + private readonly Func _selector2; + private readonly Func _selector3; + private readonly Func _selector4; + + public CombinedSelectors4(Func selector1, Func selector2, Func selector3, Func selector4) + { + _selector1 = selector1; + _selector2 = selector2; + _selector3 = selector3; + _selector4 = selector4; + } + + public ICombinedSelectors Combine(Func selector) => + new CombinedSelectors2(this.Invoke, selector); + + public TResult Invoke(TSource x) => _selector4(_selector3(_selector2(_selector1(x)))); + } + + private sealed class CombinedAsyncSelectors2 : ICombinedAsyncSelectors + { + private readonly Func> _selector1; + private readonly Func> _selector2; + + public CombinedAsyncSelectors2(Func> selector1, Func> selector2) + { + _selector1 = selector1; + _selector2 = selector2; + } + + public ICombinedAsyncSelectors Combine(Func> selector) => + new CombinedAsyncSelectors3( + _selector1, + _selector2, + selector + ); + + public async ValueTask Invoke(TSource x) => await _selector2(await _selector1(x).ConfigureAwait(false)).ConfigureAwait(false); + } + + private sealed class CombinedAsyncSelectors3 : ICombinedAsyncSelectors + { + private readonly Func> _selector1; + private readonly Func> _selector2; + private readonly Func> _selector3; + + public CombinedAsyncSelectors3(Func> selector1, Func> selector2, Func> selector3) + { + _selector1 = selector1; + _selector2 = selector2; + _selector3 = selector3; + } + + public ICombinedAsyncSelectors Combine(Func> selector) => + new CombinedAsyncSelectors4( + _selector1, + _selector2, + _selector3, + selector + ); + + public async ValueTask Invoke(TSource x) => await _selector3(await _selector2(await _selector1(x).ConfigureAwait(false)).ConfigureAwait(false)).ConfigureAwait(false); + } + + private sealed class CombinedAsyncSelectors4 : ICombinedAsyncSelectors + { + private readonly Func> _selector1; + private readonly Func> _selector2; + private readonly Func> _selector3; + private readonly Func> _selector4; + + public CombinedAsyncSelectors4(Func> selector1, Func> selector2, Func> selector3, Func> selector4) + { + _selector1 = selector1; + _selector2 = selector2; + _selector3 = selector3; + _selector4 = selector4; + } + + public ICombinedAsyncSelectors Combine(Func> selector) => + new CombinedAsyncSelectors2(this.Invoke, selector); + + public async ValueTask Invoke(TSource x) => await _selector4(await _selector3(await _selector2(await _selector1(x).ConfigureAwait(false)).ConfigureAwait(false)).ConfigureAwait(false)).ConfigureAwait(false); + } + +#if !NO_DEEP_CANCELLATION + private sealed class CombinedAsyncSelectorsWithCancellation2 : ICombinedAsyncSelectorsWithCancellation + { + private readonly Func> _selector1; + private readonly Func> _selector2; + + public CombinedAsyncSelectorsWithCancellation2(Func> selector1, Func> selector2) + { + _selector1 = selector1; + _selector2 = selector2; + } + + public ICombinedAsyncSelectorsWithCancellation Combine(Func> selector) => + new CombinedAsyncSelectorsWithCancellation3( + _selector1, + _selector2, + selector + ); + + public async ValueTask Invoke(TSource x, CancellationToken ct) => await _selector2(await _selector1(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false); + } + + private sealed class CombinedAsyncSelectorsWithCancellation3 : ICombinedAsyncSelectorsWithCancellation + { + private readonly Func> _selector1; + private readonly Func> _selector2; + private readonly Func> _selector3; + + public CombinedAsyncSelectorsWithCancellation3(Func> selector1, Func> selector2, Func> selector3) + { + _selector1 = selector1; + _selector2 = selector2; + _selector3 = selector3; + } + + public ICombinedAsyncSelectorsWithCancellation Combine(Func> selector) => + new CombinedAsyncSelectorsWithCancellation4( + _selector1, + _selector2, + _selector3, + selector + ); + + public async ValueTask Invoke(TSource x, CancellationToken ct) => await _selector3(await _selector2(await _selector1(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false), ct).ConfigureAwait(false); + } + + private sealed class CombinedAsyncSelectorsWithCancellation4 : ICombinedAsyncSelectorsWithCancellation + { + private readonly Func> _selector1; + private readonly Func> _selector2; + private readonly Func> _selector3; + private readonly Func> _selector4; + + public CombinedAsyncSelectorsWithCancellation4(Func> selector1, Func> selector2, Func> selector3, Func> selector4) + { + _selector1 = selector1; + _selector2 = selector2; + _selector3 = selector3; + _selector4 = selector4; + } + + public ICombinedAsyncSelectorsWithCancellation Combine(Func> selector) => + new CombinedAsyncSelectorsWithCancellation2(this.Invoke, selector); + + public async ValueTask Invoke(TSource x, CancellationToken ct) => await _selector4(await _selector3(await _selector2(await _selector1(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false), ct).ConfigureAwait(false), ct).ConfigureAwait(false); + } + +#endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.tt new file mode 100644 index 0000000000..3acdc4f3a7 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.Generated.tt @@ -0,0 +1,228 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# +int maxCombine = 4; +#> +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class AsyncEnumerable + { +<# +for (var i = 2; i <= maxCombine; i++) +{ + Func getInputType = j => j == 1 ? "TSource" : "TMiddle" + (j - 1); + Func getOutputType = j => j == i ? "TResult" : "TMiddle" + j; + Func getSelectorType = j => "Func<" + getInputType(j) + ", " + getOutputType(j) + ">"; + + var types = string.Join(", ", Enumerable.Range(1, i - 1).Select(j => "TMiddle" + j)); + var allSelectors = string.Join(", ", Enumerable.Range(1, i).Select(j => getSelectorType(j) + " selector" + j)); + + var applyAll = Enumerable.Range(1, i).Reverse().Aggregate("", (s, j) => s + "_selector" + j + "(") + "x" + new string(')', i); +#> + private sealed class CombinedSelectors<#=i#>, TResult> : ICombinedSelectors + { +<# +for (var j = 1; j <= i; j++) +{ + var type = getSelectorType(j); +#> + private readonly <#=type#> _selector<#=j#>; +<# +} +#> + + public CombinedSelectors<#=i#>(<#=allSelectors#>) + { +<# +for (var j = 1; j <= i; j++) +{ +#> + _selector<#=j#> = selector<#=j#>; +<# +} +#> + } + + public ICombinedSelectors Combine(Func selector) => +<# +if (i == maxCombine) +{ +#> + new CombinedSelectors2(this.Invoke, selector); +<# +} +else +{ +#> + new CombinedSelectors<#=i + 1#>, TResult, TNewResult>( +<# +for (var j = 1; j <= i; j++) +{ +#> + _selector<#=j#>, +<# +} +#> + selector + ); +<# +} +#> + + public TResult Invoke(TSource x) => <#=applyAll#>; + } + +<# +} +#> +<# +for (var i = 2; i <= maxCombine; i++) +{ + Func getInputType = j => j == 1 ? "TSource" : "TMiddle" + (j - 1); + Func getOutputType = j => "ValueTask<" + (j == i ? "TResult" : "TMiddle" + j) + ">"; + Func getSelectorType = j => "Func<" + getInputType(j) + ", " + getOutputType(j) + ">"; + + var types = string.Join(", ", Enumerable.Range(1, i - 1).Select(j => "TMiddle" + j)); + var allSelectors = string.Join(", ", Enumerable.Range(1, i).Select(j => getSelectorType(j) + " selector" + j)); + + var applyAll = Enumerable.Range(1, i).Reverse().Aggregate("", (s, j) => s + "await _selector" + j + "(") + "x" + string.Join("", Enumerable.Repeat(").ConfigureAwait(false)", i)); +#> + private sealed class CombinedAsyncSelectors<#=i#>, TResult> : ICombinedAsyncSelectors + { +<# +for (var j = 1; j <= i; j++) +{ + var type = getSelectorType(j); +#> + private readonly <#=type#> _selector<#=j#>; +<# +} +#> + + public CombinedAsyncSelectors<#=i#>(<#=allSelectors#>) + { +<# +for (var j = 1; j <= i; j++) +{ +#> + _selector<#=j#> = selector<#=j#>; +<# +} +#> + } + + public ICombinedAsyncSelectors Combine(Func> selector) => +<# +if (i == maxCombine) +{ +#> + new CombinedAsyncSelectors2(this.Invoke, selector); +<# +} +else +{ +#> + new CombinedAsyncSelectors<#=i + 1#>, TResult, TNewResult>( +<# +for (var j = 1; j <= i; j++) +{ +#> + _selector<#=j#>, +<# +} +#> + selector + ); +<# +} +#> + + public async ValueTask Invoke(TSource x) => <#=applyAll#>; + } + +<# +} +#> +#if !NO_DEEP_CANCELLATION +<# +for (var i = 2; i <= maxCombine; i++) +{ + Func getInputType = j => j == 1 ? "TSource" : "TMiddle" + (j - 1); + Func getOutputType = j => "ValueTask<" + (j == i ? "TResult" : "TMiddle" + j) + ">"; + Func getSelectorType = j => "Func<" + getInputType(j) + ", CancellationToken, " + getOutputType(j) + ">"; + + var types = string.Join(", ", Enumerable.Range(1, i - 1).Select(j => "TMiddle" + j)); + var allSelectors = string.Join(", ", Enumerable.Range(1, i).Select(j => getSelectorType(j) + " selector" + j)); + + var applyAll = Enumerable.Range(1, i).Reverse().Aggregate("", (s, j) => s + "await _selector" + j + "(") + "x" + string.Join("", Enumerable.Repeat(", ct).ConfigureAwait(false)", i)); +#> + private sealed class CombinedAsyncSelectorsWithCancellation<#=i#>, TResult> : ICombinedAsyncSelectorsWithCancellation + { +<# +for (var j = 1; j <= i; j++) +{ + var type = getSelectorType(j); +#> + private readonly <#=type#> _selector<#=j#>; +<# +} +#> + + public CombinedAsyncSelectorsWithCancellation<#=i#>(<#=allSelectors#>) + { +<# +for (var j = 1; j <= i; j++) +{ +#> + _selector<#=j#> = selector<#=j#>; +<# +} +#> + } + + public ICombinedAsyncSelectorsWithCancellation Combine(Func> selector) => +<# +if (i == maxCombine) +{ +#> + new CombinedAsyncSelectorsWithCancellation2(this.Invoke, selector); +<# +} +else +{ +#> + new CombinedAsyncSelectorsWithCancellation<#=i + 1#>, TResult, TNewResult>( +<# +for (var j = 1; j <= i; j++) +{ +#> + _selector<#=j#>, +<# +} +#> + selector + ); +<# +} +#> + + public async ValueTask Invoke(TSource x, CancellationToken ct) => <#=applyAll#>; + } + +<# +} +#> +#endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs index fc3dff4d82..9bf83a9afd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.Opt.cs @@ -11,18 +11,57 @@ public static partial class AsyncEnumerable { private static Func CombineSelectors(Func selector1, Func selector2) { - return x => selector2(selector1(x)); + if (selector1.Target is ICombinedSelectors c) + { + return c.Combine(selector2).Invoke; + } + else + { + return new CombinedSelectors2(selector1, selector2).Invoke; + } + } + + private interface ICombinedSelectors + { + ICombinedSelectors Combine(Func selector); + TResult Invoke(TSource x); } private static Func> CombineSelectors(Func> selector1, Func> selector2) { - return async x => await selector2(await selector1(x).ConfigureAwait(false)).ConfigureAwait(false); + if (selector1.Target is ICombinedAsyncSelectors c) + { + return c.Combine(selector2).Invoke; + } + else + { + return new CombinedAsyncSelectors2(selector1, selector2).Invoke; + } + } + + private interface ICombinedAsyncSelectors + { + ICombinedAsyncSelectors Combine(Func> selector); + ValueTask Invoke(TSource x); } #if !NO_DEEP_CANCELLATION private static Func> CombineSelectors(Func> selector1, Func> selector2) { - return async (x, ct) => await selector2(await selector1(x, ct).ConfigureAwait(false), ct).ConfigureAwait(false); + if (selector1.Target is ICombinedAsyncSelectorsWithCancellation c) + { + return c.Combine(selector2).Invoke; + } + else + { + return new CombinedAsyncSelectorsWithCancellation2(selector1, selector2).Invoke; + } + } + + private interface ICombinedAsyncSelectorsWithCancellation + { + ICombinedAsyncSelectorsWithCancellation Combine(Func> selector); + ValueTask Invoke(TSource x, CancellationToken ct); } #endif } From dc2706c7ad35ffc2f033fbaf096689f546f165e9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 7 Jan 2019 20:45:28 -0800 Subject: [PATCH 629/862] Code-gen for Average. --- .../System.Linq.Async.csproj | 31 + .../Linq/Operators/Average.Generated.cs | 1442 ++++++++++++++++- .../Linq/Operators/Average.Generated.tt | 346 +++- .../System/Linq/Operators/Average.cs | 1357 ---------------- 4 files changed, 1762 insertions(+), 1414 deletions(-) delete mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 72ae7239e9..cacafc0c9a 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -4,6 +4,19 @@ net45;net46;netstandard1.4;netstandard2.0 + + + True + True + Select.Opt.Generated.tt + + + True + True + Where.Opt.Generated.tt + + + @@ -19,11 +32,21 @@ True True + + True + True + Select.Opt.Generated.tt + Sum.Generated.tt True True + + True + True + Where.Opt.Generated.tt + @@ -35,10 +58,18 @@ MinMax.Generated.cs TextTemplatingFileGenerator + + TextTemplatingFileGenerator + Select.Opt.Generated.cs + Sum.Generated.cs TextTemplatingFileGenerator + + TextTemplatingFileGenerator + Where.Opt.Generated.cs + diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 21d1dadb29..1dabfed05e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -1,6 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. +// See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Threading; @@ -15,7 +15,37 @@ public static Task AverageAsync(this IAsyncEnumerable source, Cance if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -25,7 +55,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += _selector(e.Current); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -35,7 +95,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #if !NO_DEEP_CANCELLATION @@ -46,7 +136,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #endif @@ -55,7 +175,37 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -65,7 +215,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += _selector(e.Current); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -75,7 +255,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #if !NO_DEEP_CANCELLATION @@ -86,7 +296,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #endif @@ -95,7 +335,37 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + ++count; + } + } + + return (float)(sum / count); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -105,7 +375,37 @@ public static Task AverageAsync(this IAsyncEnumerable s if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += _selector(e.Current); + ++count; + } + } + + return (float)(sum / count); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -115,7 +415,37 @@ public static Task AverageAsync(this IAsyncEnumerable s if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (float)(sum / count); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #if !NO_DEEP_CANCELLATION @@ -126,7 +456,37 @@ public static Task AverageAsync(this IAsyncEnumerable s if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (float)(sum / count); + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #endif @@ -135,7 +495,37 @@ public static Task AverageAsync(this IAsyncEnumerable source, Ca if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -145,7 +535,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += _selector(e.Current); + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -155,7 +575,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #if !NO_DEEP_CANCELLATION @@ -166,7 +616,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #endif @@ -175,7 +655,37 @@ public static Task AverageAsync(this IAsyncEnumerable source, if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + decimal sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -185,7 +695,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + decimal sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += _selector(e.Current); + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -195,7 +735,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + decimal sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #if !NO_DEEP_CANCELLATION @@ -206,7 +776,37 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + decimal sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + } } #endif @@ -215,7 +815,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -225,7 +863,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = _selector(e.Current); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -235,7 +911,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #if !NO_DEEP_CANCELLATION @@ -246,7 +960,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #endif @@ -255,7 +1007,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -265,7 +1055,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = _selector(e.Current); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -275,7 +1103,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #if !NO_DEEP_CANCELLATION @@ -286,7 +1152,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #endif @@ -295,7 +1199,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -305,7 +1247,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = _selector(e.Current); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -315,7 +1295,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #if !NO_DEEP_CANCELLATION @@ -326,7 +1344,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #endif @@ -335,7 +1391,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -345,7 +1439,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = _selector(e.Current); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -355,7 +1487,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #if !NO_DEEP_CANCELLATION @@ -366,7 +1536,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #endif @@ -375,7 +1583,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -385,7 +1631,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = _selector(e.Current); + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -395,7 +1679,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #if !NO_DEEP_CANCELLATION @@ -406,7 +1728,45 @@ public static Task AverageAsync(this IAsyncEnumerable if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; + } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 7f90a3e67d..8eb068ccd5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -6,7 +6,7 @@ <#@ output extension=".cs" #> // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. +// See the LICENSE file in the project root for more information. using System.Collections.Generic; using System.Threading; @@ -19,28 +19,114 @@ namespace System.Linq <# var os = new[] { - new { type = "int", res = "double" }, - new { type = "long", res = "double" }, - new { type = "float", res = "float" }, - new { type = "double", res = "double" }, - new { type = "decimal", res = "decimal" }, - new { type = "int?", res = "double?" }, - new { type = "long?", res = "double?" }, - new { type = "float?", res = "float?" }, - new { type = "double?", res = "double?" }, - new { type = "decimal?", res = "decimal?" }, + new { type = "int", res = "double", sum = "long" }, + new { type = "long", res = "double", sum = "long" }, + new { type = "float", res = "float", sum = "double" }, + new { type = "double", res = "double", sum = "double" }, + new { type = "decimal", res = "decimal", sum = "decimal" }, + new { type = "int?", res = "double?", sum = "long" }, + new { type = "long?", res = "double?", sum = "long" }, + new { type = "float?", res = "float?", sum = "double" }, + new { type = "double?", res = "double?", sum = "double" }, + new { type = "decimal?", res = "decimal?", sum = "decimal" }, }; foreach (var o in os) { - var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; + var isNullable = o.type.EndsWith("?"); + var t = o.type.TrimEnd('?'); + + string res = ""; + + if (t == "int" || t == "long") + res = "(double)sum / count"; + else if (t == "double" || t == "decimal") + res = "sum / count"; + else if (t == "float") + res = "(float)(sum / count)"; #> public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return AverageCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task<<#=o.res#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) + { +<# +if (isNullable) +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; +<# +} +else +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += e.Current; + ++count; + } + } + + return <#=res#>; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +<# +} +#> + } } public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -50,7 +136,83 @@ foreach (var o in os) if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { +<# +if (isNullable) +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = _selector(e.Current); + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; +<# +} +else +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += _selector(e.Current); + ++count; + } + } + + return <#=res#>; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +<# +} +#> + } } public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) @@ -60,7 +222,83 @@ foreach (var o in os) if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + { +<# +if (isNullable) +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; +<# +} +else +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return <#=res#>; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +<# +} +#> + } } #if !NO_DEEP_CANCELLATION @@ -71,7 +309,83 @@ foreach (var o in os) if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return AverageCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + { +<# +if (isNullable) +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return null; +<# +} +else +{ +#> + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return <#=res#>; + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +<# +} +#> + } } #endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs deleted file mode 100644 index 76c20af694..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.cs +++ /dev/null @@ -1,1357 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - private static async Task AverageCore(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - long sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - long sum = selector(e.Current); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += selector(e.Current); - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - long sum = await selector(e.Current).ConfigureAwait(false); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current).ConfigureAwait(false); - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - long sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = e.Current; - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = selector(e.Current); - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = selector(e.Current); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += selector(e.Current); - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = await selector(e.Current).ConfigureAwait(false); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current).ConfigureAwait(false); - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); - ++count; - } - } - - return (double)sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = e.Current; - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = selector(e.Current); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = e.Current; - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - // There is an opportunity to short-circuit here, in that if e.Current is - // ever NaN then the result will always be NaN. Assuming that this case is - // rare enough that not checking is the better approach generally. - sum += e.Current; - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = selector(e.Current); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - // There is an opportunity to short-circuit here, in that if e.Current is - // ever NaN then the result will always be NaN. Assuming that this case is - // rare enough that not checking is the better approach generally. - sum += selector(e.Current); - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = await selector(e.Current).ConfigureAwait(false); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - // There is an opportunity to short-circuit here, in that if e.Current is - // ever NaN then the result will always be NaN. Assuming that this case is - // rare enough that not checking is the better approach generally. - sum += await selector(e.Current).ConfigureAwait(false); - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - // There is an opportunity to short-circuit here, in that if e.Current is - // ever NaN then the result will always be NaN. Assuming that this case is - // rare enough that not checking is the better approach generally. - sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = e.Current; - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = selector(e.Current); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - double sum = e.Current; - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - - return (float)(sum / count); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - double sum = selector(e.Current); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += selector(e.Current); - ++count; - } - - return (float)(sum / count); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - double sum = await selector(e.Current).ConfigureAwait(false); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current).ConfigureAwait(false); - ++count; - } - - return (float)(sum / count); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - double sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); - ++count; - } - - return (float)(sum / count); - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = e.Current; - if (v.HasValue) - { - double sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (float)(sum / count); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = selector(e.Current); - if (v.HasValue) - { - double sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (float)(sum / count); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - double sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (float)(sum / count); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - double sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (float)(sum / count); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = e.Current; - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = selector(e.Current); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += selector(e.Current); - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = await selector(e.Current).ConfigureAwait(false); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current).ConfigureAwait(false); - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var sum = await selector(e.Current, cancellationToken).ConfigureAwait(false); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await selector(e.Current, cancellationToken).ConfigureAwait(false); - ++count; - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - } -#endif - - private static async Task AverageCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = e.Current; - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = selector(e.Current); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } - -#if !NO_DEEP_CANCELLATION - private static async Task AverageCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - var sum = v.GetValueOrDefault(); - long count = 1; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - - return sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return null; - } -#endif - } -} From 8d10432be7672ef89934aa1a224fafd924104183 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 7 Jan 2019 22:21:52 -0800 Subject: [PATCH 630/862] Generate code for Min and Max. --- .../System/Linq/Operators/Max.Primitive.cs | 1827 -------- .../System/Linq/Operators/Min.Primitive.cs | 1579 ------- .../System/Linq/Operators/MinMax.Generated.cs | 4072 ++++++++++++++++- .../System/Linq/Operators/MinMax.Generated.tt | 551 ++- 4 files changed, 4505 insertions(+), 3524 deletions(-) delete mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs delete mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs deleted file mode 100644 index cce4651d80..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.Primitive.cs +++ /dev/null @@ -1,1827 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive - // or mostly-positive integer values are quite common in real-world - // uses, it's only been done in this direction for int? and long?. - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - // As described in a comment on Min(IAsyncEnumerable) NaN is ordered - // less than all other values. We need to do explicit checks to ensure this, but - // once we've found a value that is not NaN we need no longer worry about it, - // so first loop until such a value is found (or not, as the case may be). - while (double.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (double.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = e.Current; - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (float.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (float.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = e.Current; - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive - // or mostly-positive integer values are quite common in real-world - // uses, it's only been done in this direction for int? and long?. - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (float.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (float.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = selector(e.Current); - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - - // As described in a comment on Min(IAsyncEnumerable) NaN is ordered - // less than all other values. We need to do explicit checks to ensure this, but - // once we've found a value that is not NaN we need no longer worry about it, - // so first loop until such a value is found (or not, as the case may be). - while (double.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (double.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = selector(e.Current); - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive - // or mostly-positive integer values are quite common in real-world - // uses, it's only been done in this direction for int? and long?. - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (float.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (float.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = await selector(e.Current).ConfigureAwait(false); - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - - // As described in a comment on Min(IAsyncEnumerable) NaN is ordered - // less than all other values. We need to do explicit checks to ensure this, but - // once we've found a value that is not NaN we need no longer worry about it, - // so first loop until such a value is found (or not, as the case may be). - while (double.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (double.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = await selector(e.Current).ConfigureAwait(false); - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - -#if !NO_DEEP_CANCELLATION - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive - // or mostly-positive integer values are quite common in real-world - // uses, it's only been done in this direction for int? and long?. - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (float.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (float.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - - // As described in a comment on Min(IAsyncEnumerable) NaN is ordered - // less than all other values. We need to do explicit checks to ensure this, but - // once we've found a value that is not NaN we need no longer worry about it, - // so first loop until such a value is found (or not, as the case may be). - while (double.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (double.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MaxCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } -#endif - } -} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs deleted file mode 100644 index bf21c3aca0..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.Primitive.cs +++ /dev/null @@ -1,1579 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - else if (float.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (float.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - else if (double.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (double.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x < value) - { - value = x; - } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - else if (float.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (float.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x < value) - { - value = x; - } - else if (double.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (double.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = selector(e.Current); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func selector, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = selector(e.Current); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = selector(e.Current); - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - else if (float.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (float.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else if (double.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (double.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - -#if !NO_DEEP_CANCELLATION - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - int? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - long? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - else if (float.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - float? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (float.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else if (double.IsNaN(x)) - { - return x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - double? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else if (double.IsNaN(x)) - { - return cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal value; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await selector(e.Current, cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - - private static async Task MinCore(IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) - { - decimal? value = null; - - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await selector(e.Current, cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await selector(e.Current, cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - if (cur.HasValue && x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } -#endif - } -} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index fc5f94d2fa..5a40147684 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -15,7 +15,39 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancellation if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -25,7 +57,39 @@ public static Task MaxAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -35,7 +99,39 @@ public static Task MaxAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -46,16 +142,119 @@ public static Task MaxAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -65,7 +264,78 @@ public static Task MaxAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -75,7 +345,78 @@ public static Task MaxAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -86,16 +427,119 @@ public static Task MaxAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -105,7 +549,39 @@ public static Task MaxAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -115,7 +591,39 @@ public static Task MaxAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -126,16 +634,119 @@ public static Task MaxAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -145,7 +756,78 @@ public static Task MaxAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -155,7 +837,78 @@ public static Task MaxAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -166,16 +919,134 @@ public static Task MaxAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -185,7 +1056,54 @@ public static Task MaxAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -195,7 +1113,54 @@ public static Task MaxAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -206,16 +1171,130 @@ public static Task MaxAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = e.Current; + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -225,7 +1304,74 @@ public static Task MaxAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = _selector(e.Current); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -235,7 +1381,74 @@ public static Task MaxAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await _selector(e.Current).ConfigureAwait(false); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -246,16 +1459,130 @@ public static Task MaxAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -265,7 +1592,54 @@ public static Task MaxAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -275,7 +1649,54 @@ public static Task MaxAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -286,16 +1707,130 @@ public static Task MaxAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = e.Current; + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -305,7 +1840,74 @@ public static Task MaxAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = _selector(e.Current); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -315,7 +1917,74 @@ public static Task MaxAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await _selector(e.Current).ConfigureAwait(false); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -326,16 +1995,115 @@ public static Task MaxAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -345,7 +2113,39 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -355,7 +2155,39 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -366,16 +2198,93 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MaxCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -385,7 +2294,52 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -395,7 +2349,52 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -406,16 +2405,93 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MaxCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -425,7 +2501,39 @@ public static Task MinAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -435,7 +2543,39 @@ public static Task MinAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -446,16 +2586,95 @@ public static Task MinAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -465,7 +2684,54 @@ public static Task MinAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -475,7 +2741,54 @@ public static Task MinAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -486,16 +2799,95 @@ public static Task MinAsync(this IAsyncEnumerable source, if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -505,7 +2897,39 @@ public static Task MinAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -515,7 +2939,39 @@ public static Task MinAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -526,16 +2982,95 @@ public static Task MinAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -545,7 +3080,54 @@ public static Task MinAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -555,7 +3137,54 @@ public static Task MinAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -566,16 +3195,111 @@ public static Task MinAsync(this IAsyncEnumerable source if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -585,7 +3309,55 @@ public static Task MinAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -595,7 +3367,55 @@ public static Task MinAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -606,16 +3426,127 @@ public static Task MinAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -625,7 +3556,70 @@ public static Task MinAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -635,7 +3629,70 @@ public static Task MinAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -646,16 +3703,127 @@ public static Task MinAsync(this IAsyncEnumerable sourc if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -665,7 +3833,55 @@ public static Task MinAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -675,7 +3891,55 @@ public static Task MinAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -686,16 +3950,127 @@ public static Task MinAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -705,7 +4080,70 @@ public static Task MinAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -715,7 +4153,70 @@ public static Task MinAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -726,16 +4227,111 @@ public static Task MinAsync(this IAsyncEnumerable sour if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -745,7 +4341,39 @@ public static Task MinAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -755,7 +4383,39 @@ public static Task MinAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -766,16 +4426,93 @@ public static Task MinAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return MinCore(source, cancellationToken); + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) @@ -785,7 +4522,52 @@ public static Task MinAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) @@ -795,7 +4577,52 @@ public static Task MinAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } #if !NO_DEEP_CANCELLATION @@ -806,9 +4633,54 @@ public static Task MinAsync(this IAsyncEnumerable sou if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return MinCore(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; + } } -#endif +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index b9ba2df7b8..12bd58c361 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -19,49 +19,564 @@ namespace System.Linq <# foreach (var m in new[] { "Max", "Min" }) { + var comparison = m == "Max" ? ">" : "<"; + foreach (var t in new[] { "int", "int?", "long", "long?", "float", "float?", "double", "double?", "decimal", "decimal?" }) { + var isFloatingPoint = t.StartsWith("float") || t.StartsWith("double"); + var isInteger = t.StartsWith("int") || t.StartsWith("long"); + var isNullable = t.EndsWith("?"); + var shortCircuit = t.StartsWith("decimal"); #> public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return <#=m#>Core(source, cancellationToken); - } + return Core(source, cancellationToken); - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + async Task<<#=t#>> Core(IAsyncEnumerable<<#=t#>> _source, CancellationToken _cancellationToken) + { +<# + if (!isNullable) { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); +#> + <#=t#> value; - return <#=m#>Core(source, selector, cancellationToken); - } + var e = _source.GetAsyncEnumerator(_cancellationToken); - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + +<# + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t#>.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + +<# + } +#> + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x <#=comparison#> value) + { + value = x; + } +<# + if (isFloatingPoint && m == "Min") + { +#> + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t#>.IsNaN(x)) + { + return x; + } + } +<# + } +#> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; +<# + } + else { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); +#> + <#=t#> value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); - return <#=m#>Core(source, selector, cancellationToken); +<# + if (isInteger && m == "Max") + { +#> + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } +<# + } + else if (isFloatingPoint && m == "Min") + { +#> + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t.TrimEnd('?')#>.IsNaN(x)) + { + return cur; + } + } + } + } +<# + } + else + { + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t.TrimEnd('?')#>.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = e.Current; + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + +<# + } +#> + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + +<# + if (shortCircuit) + { +#> + if (cur.HasValue && x <#=comparison#> valueVal) +<# + } + else + { +#> + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) +<# + } +#> + { + valueVal = x; + value = cur; + } + } +<# + } +#> + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; +<# } +#> + } + } + +<# +foreach (var overload in new[] { + new { selector = "Func", invoke = "_selector(e.Current)" }, + new { selector = "Func>", invoke = "await _selector(e.Current).ConfigureAwait(false)" }, + new { selector = "Func>", invoke = "await _selector(e.Current, _cancellationToken).ConfigureAwait(false)" }, +}) +{ + var isDeepCancellation = overload.selector.Contains("CancellationToken"); + if (isDeepCancellation) + { +#> #if !NO_DEEP_CANCELLATION - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) +<# + } +#> + public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, <#=overload.selector#> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (selector == null) throw Error.ArgumentNull(nameof(selector)); - return <#=m#>Core(source, selector, cancellationToken); + return Core(source, selector, cancellationToken); + + async Task<<#=t#>> Core(IAsyncEnumerable _source, <#=overload.selector#> _selector, CancellationToken _cancellationToken) + { +<# + if (!isNullable) + { +#> + <#=t#> value; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = <#=overload.invoke#>; + +<# + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t#>.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = <#=overload.invoke#>; + } + +<# + } +#> + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = <#=overload.invoke#>; + if (x <#=comparison#> value) + { + value = x; + } +<# + if (isFloatingPoint && m == "Min") + { +#> + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t#>.IsNaN(x)) + { + return x; + } + } +<# + } +#> + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; +<# } -#endif + else + { +#> + <#=t#> value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = <#=overload.invoke#>; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + +<# + if (isInteger && m == "Max") + { +#> + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = <#=overload.invoke#>; + var x = cur.GetValueOrDefault(); + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = <#=overload.invoke#>; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } +<# + } + else if (isFloatingPoint && m == "Min") + { +#> + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = <#=overload.invoke#>; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t.TrimEnd('?')#>.IsNaN(x)) + { + return cur; + } + } + } + } +<# + } + else + { + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t.TrimEnd('?')#>.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + var cur = <#=overload.invoke#>; + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + +<# + } +#> + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = <#=overload.invoke#>; + var x = cur.GetValueOrDefault(); + +<# + if (shortCircuit) + { +#> + if (cur.HasValue && x <#=comparison#> valueVal) +<# + } + else + { +#> + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) +<# + } +#> + { + valueVal = x; + value = cur; + } + } +<# + } +#> + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } + + return value; +<# + } +#> + } + } + +<# + if (isDeepCancellation) + { +#> +#endif +<# + } +} +#> <# } } From 5faed346a83bf919ad9d93b05b863f0d7d5f5bb3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:41:25 -0800 Subject: [PATCH 631/862] Use C# 8.0 in Aggregate. --- .../System/Linq/Operators/Aggregate.cs | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 8d5fe7011c..5f8e104a58 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -21,6 +21,24 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + var acc = e.Current; + + while (await e.MoveNextAsync()) + { + acc = _accumulator(acc, e.Current); + } + + return acc; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -43,6 +61,7 @@ async Task Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + var acc = e.Current; + + while (await e.MoveNextAsync()) + { + acc = await _accumulator(acc, e.Current).ConfigureAwait(false); + } + + return acc; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -79,6 +116,7 @@ async Task Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + var acc = e.Current; + + while (await e.MoveNextAsync()) + { + acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false); + } + + return acc; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -116,6 +172,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, TAccumulate _see { var acc = _seed; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + acc = _accumulator(acc, item); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -146,6 +209,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { await e.DisposeAsync().ConfigureAwait(false); } +#endif return acc; } @@ -164,6 +228,12 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { var acc = _seed; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + acc = await _accumulator(acc, item).ConfigureAwait(false); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -177,6 +247,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { await e.DisposeAsync().ConfigureAwait(false); } +#endif return acc; } @@ -196,6 +267,12 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { var acc = _seed; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -209,6 +286,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { await e.DisposeAsync().ConfigureAwait(false); } +#endif return acc; } @@ -230,6 +308,12 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { var acc = _seed; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + acc = _accumulator(acc, item); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -243,6 +327,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { await e.DisposeAsync().ConfigureAwait(false); } +#endif return _resultSelector(acc); } @@ -263,6 +348,12 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { var acc = _seed; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + acc = await _accumulator(acc, item).ConfigureAwait(false); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -276,6 +367,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { await e.DisposeAsync().ConfigureAwait(false); } +#endif return await _resultSelector(acc).ConfigureAwait(false); } @@ -297,6 +389,12 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { var acc = _seed; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -310,6 +408,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { await e.DisposeAsync().ConfigureAwait(false); } +#endif return await _resultSelector(acc, _cancellationToken).ConfigureAwait(false); } From a14f42f8d499620e1c6b4ea1a786448982169ef0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:42:24 -0800 Subject: [PATCH 632/862] Use C# 8.0 in All and Any. --- .../System/Linq/Operators/All.cs | 32 ++++++++++++++++ .../System/Linq/Operators/Any.cs | 37 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index a98acb1c43..7d08cce8a9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -21,6 +21,15 @@ public static Task AllAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (!_predicate(item)) + { + return false; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -35,6 +44,7 @@ async Task Core(IAsyncEnumerable _source, Func _pr { await e.DisposeAsync().ConfigureAwait(false); } +#endif return true; } @@ -51,6 +61,16 @@ public static Task AllAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (!await _predicate(item).ConfigureAwait(false)) + { + return false; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -65,6 +85,7 @@ async Task Core(IAsyncEnumerable _source, Func AllAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (!await _predicate(item, _cancellationToken).ConfigureAwait(false)) + { + return false; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -96,6 +127,7 @@ async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + return await e.MoveNextAsync(); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -29,6 +35,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _canc { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -43,6 +50,15 @@ public static Task AnyAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (_predicate(item)) + { + return true; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -57,6 +73,7 @@ async Task Core(IAsyncEnumerable _source, Func _pr { await e.DisposeAsync().ConfigureAwait(false); } +#endif return false; } @@ -73,6 +90,15 @@ public static Task AnyAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (await _predicate(item).ConfigureAwait(false)) + { + return true; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -87,6 +113,7 @@ async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) + { + return true; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -118,6 +154,7 @@ async Task Core(IAsyncEnumerable _source, Func Date: Wed, 9 Jan 2019 20:43:16 -0800 Subject: [PATCH 633/862] Use C# 8.0 in Count and LongCount. --- .../System/Linq/Operators/Count.cs | 49 +++++++++++++++++++ .../System/Linq/Operators/LongCount.cs | 49 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 0edbbfad95..c03f464bd9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -32,6 +32,15 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { var count = 0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + checked + { + count++; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -48,6 +57,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { await e.DisposeAsync().ConfigureAwait(false); } +#endif return count; } @@ -66,6 +76,18 @@ async Task Core(IAsyncEnumerable _source, Func _pre { var count = 0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (_predicate(item)) + { + checked + { + count++; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -85,6 +107,7 @@ async Task Core(IAsyncEnumerable _source, Func _pre { await e.DisposeAsync().ConfigureAwait(false); } +#endif return count; } @@ -103,6 +126,18 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _canc { var count = 0L; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + checked + { + count++; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -37,6 +46,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _canc { await e.DisposeAsync().ConfigureAwait(false); } +#endif return count; } @@ -55,6 +65,18 @@ async Task Core(IAsyncEnumerable _source, Func _pr { var count = 0L; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (_predicate(item)) + { + checked + { + count++; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -74,6 +96,7 @@ async Task Core(IAsyncEnumerable _source, Func _pr { await e.DisposeAsync().ConfigureAwait(false); } +#endif return count; } @@ -92,6 +115,18 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Date: Wed, 9 Jan 2019 20:43:49 -0800 Subject: [PATCH 634/862] Use C# 8.0 in Contains. --- .../System/Linq/Operators/Contains.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 685dca3655..3edafc6bab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -33,6 +33,31 @@ public static Task ContainsAsync(this IAsyncEnumerable s private static async Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + // + // See https://github.com/dotnet/corefx/pull/25097 for the optimization here. + // + if (comparer == null) + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (EqualityComparer.Default.Equals(item, value)) + { + return true; + } + } + } + else + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (comparer.Equals(item, value)) + { + return true; + } + } + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -65,6 +90,7 @@ private static async Task ContainsCore(IAsyncEnumerable { await e.DisposeAsync().ConfigureAwait(false); } +#endif return false; } From e86510b734dd0ac5885c7ff4cd51f07d8d590cdc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:44:16 -0800 Subject: [PATCH 635/862] Proper configuration to pick up C# 8.0. --- Ix.NET/Source/Directory.build.props | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index 03ee3bfaab..b6289202bb 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -24,7 +24,12 @@ full - + + + + 8.0 + + From f931420e89ef3cfcc23941a299166dd5d37cc599 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:45:27 -0800 Subject: [PATCH 636/862] Use C# 8.0 in ForEach. --- .../System/Linq/Operators/ForEach.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 2ceda17786..43f1fd3c49 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -79,6 +79,12 @@ public static Task ForEachAsync(this IAsyncEnumerable source, private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + action(item); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -92,10 +98,17 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { await e.DisposeAsync().ConfigureAwait(false); } +#endif } private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + await action(item, cancellationToken).ConfigureAwait(false); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -109,12 +122,19 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { await e.DisposeAsync().ConfigureAwait(false); } +#endif } private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) { var index = 0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + action(item, checked(index++)); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -128,12 +148,19 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { await e.DisposeAsync().ConfigureAwait(false); } +#endif } private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { var index = 0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + await action(item, checked(index++), cancellationToken).ConfigureAwait(false); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -147,6 +174,7 @@ private static async Task ForEachAsyncCore(IAsyncEnumerable so { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } } From 3e63666486b5cd449399a122028d28e761e313d2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:46:41 -0800 Subject: [PATCH 637/862] Use C# 8.0 in ElementAt. --- .../System/Linq/Operators/ElementAt.cs | 12 ++++++++++++ .../System/Linq/Operators/ElementAtOrDefault.cs | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index d2a953c82d..8449c7e3bf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -37,6 +37,17 @@ async Task Core(IAsyncEnumerable _source, int _index, Cancella if (_index >= 0) { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (_index == 0) + { + return item; + } + + _index--; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -55,6 +66,7 @@ async Task Core(IAsyncEnumerable _source, int _index, Cancella { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 77b12625cb..acbec37b33 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -40,6 +40,17 @@ async Task Core(IAsyncEnumerable _source, int _index, Cancella } else { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + if (_index == 0) + { + return item; + } + + _index--; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -58,6 +69,7 @@ async Task Core(IAsyncEnumerable _source, int _index, Cancella { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } From 7cf8fb5a3bb6b0a06cd7e2129e2aa76eb24607b6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:47:06 -0800 Subject: [PATCH 638/862] Use C# 8.0 in ToList. --- .../System.Linq.Async/System/Linq/Operators/ToList.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index af653fd549..0b64dfa6fb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -24,6 +24,12 @@ async Task> Core(IAsyncEnumerable _source, CancellationTo { var list = new List(); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + list.Add(item); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -37,6 +43,7 @@ async Task> Core(IAsyncEnumerable _source, CancellationTo { await e.DisposeAsync().ConfigureAwait(false); } +#endif return list; } From 8a41d158642d463bdd3804c50ca66f2905b2bfd3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:47:28 -0800 Subject: [PATCH 639/862] Use C# 8.0 in ToHashSet. --- .../System.Linq.Async/System/Linq/Operators/ToHashSet.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index f1d129d030..2988902e2f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -30,6 +30,12 @@ private static async Task> ToHashSetCore(IAsyncEnumera { var set = new HashSet(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + set.Add(item); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -43,6 +49,7 @@ private static async Task> ToHashSetCore(IAsyncEnumera { await e.DisposeAsync().ConfigureAwait(false); } +#endif return set; } From 1640ce2daeb1aa745d5f737ec35d7b4f7ce56a20 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:49:54 -0800 Subject: [PATCH 640/862] Use C# 8.0 in ToDictionary. --- .../System/Linq/Operators/ToDictionary.cs | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index a3e4085050..677bf700cd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -152,12 +152,21 @@ public static Task> ToDictionaryAsync> ToDictionaryCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { + var d = new Dictionary(comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = keySelector(item); + var value = elementSelector(item); + + d.Add(key, value); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try { - var d = new Dictionary(comparer); - while (await e.MoveNextAsync().ConfigureAwait(false)) { var x = e.Current; @@ -167,23 +176,33 @@ private static async Task> ToDictionaryCore> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { + var d = new Dictionary(comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item).ConfigureAwait(false); + var value = await elementSelector(item).ConfigureAwait(false); + + d.Add(key, value); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try { - var d = new Dictionary(comparer); - while (await e.MoveNextAsync().ConfigureAwait(false)) { var x = e.Current; @@ -193,13 +212,14 @@ private static async Task> ToDictionaryCore> ToDictionaryCore(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item, cancellationToken).ConfigureAwait(false); + var value = await elementSelector(item, cancellationToken).ConfigureAwait(false); + + d.Add(key, value); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -225,6 +254,7 @@ private static async Task> ToDictionaryCore Date: Wed, 9 Jan 2019 20:51:08 -0800 Subject: [PATCH 641/862] Use C# 8.0 in Single. --- .../System/Linq/Operators/Single.cs | 100 ++++++++++++++++-- .../System/Linq/Operators/SingleOrDefault.cs | 94 +++++++++++++++- 2 files changed, 184 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index c29de5ef09..be89b31d05 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -30,6 +30,24 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c throw Error.MoreThanOneElement(); } +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + var result = e.Current; + + if (await e.MoveNextAsync()) + { + throw Error.MoreThanOneElement(); + } + + return result; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -51,6 +69,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -65,6 +84,28 @@ public static Task SingleAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var result = e.Current; + + if (_predicate(result)) + { + while (await e.MoveNextAsync()) + { + if (_predicate(e.Current)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -86,13 +127,14 @@ async Task Core(IAsyncEnumerable _source, Func return result; } } - - throw Error.NoElements(); } finally { await e.DisposeAsync().ConfigureAwait(false); } +#endif + + throw Error.NoElements(); } } @@ -107,6 +149,28 @@ public static Task SingleAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var result = e.Current; + + if (await _predicate(result).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + if (await _predicate(e.Current).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -128,13 +192,14 @@ async Task Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var result = e.Current; + + if (await _predicate(result, _cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -171,13 +258,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _c throw Error.MoreThanOneElement(); } +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + return default; + } + + var result = e.Current; + + if (!await e.MoveNextAsync()) + { + return result; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -50,6 +66,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif throw Error.MoreThanOneElement(); } @@ -66,6 +83,28 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var result = e.Current; + + if (_predicate(result)) + { + while (await e.MoveNextAsync()) + { + if (_predicate(e.Current)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -87,13 +126,14 @@ async Task Core(IAsyncEnumerable _source, Func return result; } } - - return default; } finally { await e.DisposeAsync().ConfigureAwait(false); } +#endif + + return default; } } @@ -108,6 +148,28 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var result = e.Current; + + if (await _predicate(result).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + if (await _predicate(e.Current).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -129,13 +191,14 @@ async Task Core(IAsyncEnumerable _source, Func SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var result = e.Current; + + if (await _predicate(result, _cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + if (await _predicate(e.Current, _cancellationToken).ConfigureAwait(false)) + { + throw Error.MoreThanOneElement(); + } + } + + return result; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -177,6 +262,7 @@ async Task Core(IAsyncEnumerable _source, Func Date: Wed, 9 Jan 2019 20:51:40 -0800 Subject: [PATCH 642/862] Use C# 8.0 in First. --- .../System/Linq/Operators/FirstOrDefault.cs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 9d43461ad2..9fa6713de9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -97,6 +97,15 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (await e.MoveNextAsync()) + { + return new Maybe(e.Current); + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -110,6 +119,7 @@ async ValueTask> Core(IAsyncEnumerable _source, Cancella { await e.DisposeAsync().ConfigureAwait(false); } +#endif return new Maybe(); } @@ -120,6 +130,20 @@ async ValueTask> Core(IAsyncEnumerable _source, Cancella private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var value = e.Current; + + if (predicate(value)) + { + return new Maybe(value); + } + } + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -138,12 +162,27 @@ private static async Task> TryGetFirst(IAsyncEnumerable< { await e.DisposeAsync().ConfigureAwait(false); } +#endif return new Maybe(); } private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var value = e.Current; + + if (await predicate(value).ConfigureAwait(false)) + { + return new Maybe(value); + } + } + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -162,6 +201,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< { await e.DisposeAsync().ConfigureAwait(false); } +#endif return new Maybe(); } @@ -169,6 +209,20 @@ private static async Task> TryGetFirst(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var value = e.Current; + + if (await predicate(value, cancellationToken).ConfigureAwait(false)) + { + return new Maybe(value); + } + } + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -187,6 +241,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< { await e.DisposeAsync().ConfigureAwait(false); } +#endif return new Maybe(); } From ddaf9b991f7dcd2f651adea736c1979e0af0fdf4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:52:24 -0800 Subject: [PATCH 643/862] Use C# 8.0 in Last. --- .../System/Linq/Operators/LastOrDefault.cs | 62 +++++++++++++------ 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index a537804578..da1283bff2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -101,6 +101,13 @@ async ValueTask> Core(IAsyncEnumerable _source, Cancella var last = default(TSource); var hasLast = false; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + hasLast = true; + last = item; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -115,6 +122,7 @@ async ValueTask> Core(IAsyncEnumerable _source, Cancella { await e.DisposeAsync().ConfigureAwait(false); } +#endif return hasLast ? new Maybe(last) : new Maybe(); } @@ -128,6 +136,16 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable(last); - } - - return new Maybe(); + return hasLast ? new Maybe(last) : new Maybe(); } private static async Task> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) @@ -161,6 +175,16 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable(last); - } - - return new Maybe(); + return hasLast ? new Maybe(last) : new Maybe(); } #if !NO_DEEP_CANCELLATION @@ -195,6 +215,16 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable(last); - } - - return new Maybe(); + return hasLast ? new Maybe(last) : new Maybe(); } #endif } From d4eea91c4f9cfcf298cd2682081d0da3861460bb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:52:50 -0800 Subject: [PATCH 644/862] Use C# 8.0 in SequenceEqual. --- .../System/Linq/Operators/SequenceEqual.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 76fcc264a9..1df272adb6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -64,6 +64,23 @@ private static Task SequenceEqualCore(IAsyncEnumerable f async Task Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e1 = _first.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + await using (var e2 = _second.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e1.MoveNextAsync()) + { + if (!(await e2.MoveNextAsync() && _comparer.Equals(e1.Current, e2.Current))) + { + return false; + } + } + + return !await e2.MoveNextAsync(); + } + } +#else var e1 = _first.GetAsyncEnumerator(_cancellationToken); try @@ -91,6 +108,7 @@ async Task Core(IAsyncEnumerable _first, IAsyncEnumerable Date: Wed, 9 Jan 2019 20:53:24 -0800 Subject: [PATCH 645/862] Use C# 8.0 in Union. --- .../System.Linq.Async/System/Linq/Operators/Union.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index aa3cb5cfba..f2d2af6ac0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -174,6 +174,12 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in enumerable.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + set.Add(item); + } +#else var e = enumerable.GetAsyncEnumerator(cancellationToken); try @@ -187,6 +193,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } From c6da267eef1aa96f4b99ea13b2623996c375ea9e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:56:56 -0800 Subject: [PATCH 646/862] Remove duplicate accesses to Current in Lookup. --- .../System/Linq/Operators/Lookup.cs | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index c99f96414e..5b67251e02 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -97,10 +97,12 @@ internal static async Task> CreateAsync(IAsyncEn { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = keySelector(enu.Current); + var item = enu.Current; + + var key = keySelector(item); var group = lookup.GetGrouping(key, create: true); - var element = elementSelector(enu.Current); + var element = elementSelector(item); group.Add(element); } } @@ -125,8 +127,10 @@ internal static async Task> CreateAsync(IAsyncEnumerable< { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = keySelector(enu.Current); - lookup.GetGrouping(key, create: true).Add(enu.Current); + var item = enu.Current; + + var key = keySelector(item); + lookup.GetGrouping(key, create: true).Add(item); } } finally @@ -147,10 +151,12 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = keySelector(enu.Current); + var item = enu.Current; + + var key = keySelector(item); if (key != null) { - lookup.GetGrouping(key, create: true).Add(enu.Current); + lookup.GetGrouping(key, create: true).Add(item); } } } @@ -389,10 +395,12 @@ internal static async Task> CreateAsync( { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current).ConfigureAwait(false); + var item = enu.Current; + + var key = await keySelector(item).ConfigureAwait(false); var group = lookup.GetGrouping(key, create: true); - var element = await elementSelector(enu.Current).ConfigureAwait(false); + var element = await elementSelector(item).ConfigureAwait(false); group.Add(element); } } @@ -419,10 +427,12 @@ internal static async Task> CreateAsync( { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + var item = enu.Current; + + var key = await keySelector(item, cancellationToken).ConfigureAwait(false); var group = lookup.GetGrouping(key, create: true); - var element = await elementSelector(enu.Current, cancellationToken).ConfigureAwait(false); + var element = await elementSelector(item, cancellationToken).ConfigureAwait(false); group.Add(element); } } @@ -448,8 +458,10 @@ internal static async Task> CreateAsync(IAsyncEnu { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current).ConfigureAwait(false); - lookup.GetGrouping(key, create: true).Add(enu.Current); + var item = enu.Current; + + var key = await keySelector(item).ConfigureAwait(false); + lookup.GetGrouping(key, create: true).Add(item); } } finally @@ -474,8 +486,10 @@ internal static async Task> CreateAsync(IAsyncEnu { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); - lookup.GetGrouping(key, create: true).Add(enu.Current); + var item = enu.Current; + + var key = await keySelector(item, cancellationToken).ConfigureAwait(false); + lookup.GetGrouping(key, create: true).Add(item); } } finally @@ -497,10 +511,12 @@ internal static async Task> CreateForJoinAsync(IA { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current).ConfigureAwait(false); + var item = enu.Current; + + var key = await keySelector(item).ConfigureAwait(false); if (key != null) { - lookup.GetGrouping(key, create: true).Add(enu.Current); + lookup.GetGrouping(key, create: true).Add(item); } } } @@ -523,10 +539,12 @@ internal static async Task> CreateForJoinAsync(IA { while (await enu.MoveNextAsync().ConfigureAwait(false)) { - var key = await keySelector(enu.Current, cancellationToken).ConfigureAwait(false); + var item = enu.Current; + + var key = await keySelector(item, cancellationToken).ConfigureAwait(false); if (key != null) { - lookup.GetGrouping(key, create: true).Add(enu.Current); + lookup.GetGrouping(key, create: true).Add(item); } } } From 971f38e22dbf2103094ff0ce08b2d33aa45bd288 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:58:05 -0800 Subject: [PATCH 647/862] Use C# 8.0 in Lookup. --- .../System/Linq/Operators/Lookup.cs | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs index 5b67251e02..14869355e2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Lookup.cs @@ -91,6 +91,16 @@ internal static async Task> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = keySelector(item); + var group = lookup.GetGrouping(key, create: true); + + var element = elementSelector(item); + group.Add(element); + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -110,6 +120,7 @@ internal static async Task> CreateAsync(IAsyncEn { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -121,6 +132,13 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = keySelector(item); + lookup.GetGrouping(key, create: true).Add(item); + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -137,6 +155,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -145,6 +164,16 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { var lookup = new Lookup(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = keySelector(item); + if (key != null) + { + lookup.GetGrouping(key, create: true).Add(item); + } + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -164,6 +193,7 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -389,6 +419,16 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item).ConfigureAwait(false); + var group = lookup.GetGrouping(key, create: true); + + var element = await elementSelector(item).ConfigureAwait(false); + group.Add(element); + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -408,6 +448,7 @@ internal static async Task> CreateAsync( { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -421,6 +462,16 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item, cancellationToken).ConfigureAwait(false); + var group = lookup.GetGrouping(key, create: true); + + var element = await elementSelector(item, cancellationToken).ConfigureAwait(false); + group.Add(element); + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -440,6 +491,7 @@ internal static async Task> CreateAsync( { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -452,6 +504,13 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item).ConfigureAwait(false); + lookup.GetGrouping(key, create: true).Add(item); + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -468,6 +527,7 @@ internal static async Task> CreateAsync(IAsyncEnu { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -480,6 +540,13 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item, cancellationToken).ConfigureAwait(false); + lookup.GetGrouping(key, create: true).Add(item); + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -496,6 +563,7 @@ internal static async Task> CreateAsync(IAsyncEnu { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -505,6 +573,16 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item).ConfigureAwait(false); + if (key != null) + { + lookup.GetGrouping(key, create: true).Add(item); + } + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -524,6 +602,7 @@ internal static async Task> CreateForJoinAsync(IA { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } @@ -533,6 +612,16 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = await keySelector(item, cancellationToken).ConfigureAwait(false); + if (key != null) + { + lookup.GetGrouping(key, create: true).Add(item); + } + } +#else var enu = source.GetAsyncEnumerator(cancellationToken); try @@ -552,6 +641,7 @@ internal static async Task> CreateForJoinAsync(IA { await enu.DisposeAsync().ConfigureAwait(false); } +#endif return lookup; } From dd907ead48bb9a47f0af0d699c6de580a84969c1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:58:28 -0800 Subject: [PATCH 648/862] Use C# 8.0 in Concat. --- .../System.Linq.Async/System/Linq/Operators/Concat.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 97aee1ba56..1afb89ea08 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -84,6 +84,12 @@ public async ValueTask> ToListAsync(CancellationToken cancellation break; } +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + list.Add(item); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -97,6 +103,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { await e.DisposeAsync().ConfigureAwait(false); } +#endif } return list; From b1e58d21482f6636712f53bc338d8078f02e8f32 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 20:59:16 -0800 Subject: [PATCH 649/862] Use C# 8.0 in AsyncEnumerableHelpers. --- .../System/Linq/AsyncEnumerableHelpers.cs | 65 +++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 97ab453312..f753e9b6fa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -44,6 +44,55 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } else { +#if CSHARP8 + await using (var en = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (await en.MoveNextAsync()) + { + const int DefaultCapacity = 4; + var arr = new T[DefaultCapacity]; + arr[0] = en.Current; + var count = 1; + + while (await en.MoveNextAsync()) + { + if (count == arr.Length) + { + // MaxArrayLength is defined in Array.MaxArrayLength and in gchelpers in CoreCLR. + // It represents the maximum number of elements that can be in an array where + // the size of the element is greater than one byte; a separate, slightly larger constant, + // is used when the size of the element is one. + const int MaxArrayLength = 0x7FEFFFFF; + + // This is the same growth logic as in List: + // If the array is currently empty, we make it a default size. Otherwise, we attempt to + // double the size of the array. Doubling will overflow once the size of the array reaches + // 2^30, since doubling to 2^31 is 1 larger than Int32.MaxValue. In that case, we instead + // constrain the length to be MaxArrayLength (this overflow check works because of the + // cast to uint). Because a slightly larger constant is used when T is one byte in size, we + // could then end up in a situation where arr.Length is MaxArrayLength or slightly larger, such + // that we constrain newLength to be MaxArrayLength but the needed number of elements is actually + // larger than that. For that case, we then ensure that the newLength is large enough to hold + // the desired capacity. This does mean that in the very rare case where we've grown to such a + // large size, each new element added after MaxArrayLength will end up doing a resize. + var newLength = count << 1; + if ((uint)newLength > MaxArrayLength) + { + newLength = MaxArrayLength <= count ? count + 1 : MaxArrayLength; + } + + Array.Resize(ref arr, newLength); + } + + arr[count++] = en.Current; + } + + result.Length = count; + result.Array = arr; + return result; + } + } +#else var en = source.GetAsyncEnumerator(cancellationToken); try @@ -97,6 +146,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE { await en.DisposeAsync().ConfigureAwait(false); } +#endif } result.Length = 0; @@ -110,23 +160,30 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE internal static async Task> ToSet(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) { + var set = new Set(comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (T item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + set.Add(item); + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try { - var set = new Set(comparer); - while (await e.MoveNextAsync().ConfigureAwait(false)) { set.Add(e.Current); } - - return set; } finally { await e.DisposeAsync().ConfigureAwait(false); } +#endif + + return set; } internal struct ArrayWithLength From 4ab51fea0c95dd3c63c5ca90f59e52a72e46ca73 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:01:16 -0800 Subject: [PATCH 650/862] Use C# 8.0 in generic Min and Max. --- .../System/Linq/Operators/Max.cs | 190 ++++++++++++++++++ .../System/Linq/Operators/Min.cs | 190 ++++++++++++++++++ 2 files changed, 380 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 7bb0dd6db5..71d0f001cb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -25,6 +25,31 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c var value = default(TSource); +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (value == null); + + while (await e.MoveNextAsync()) + { + var x = e.Current; + + if (x != null && comparer.Compare(x, value) > 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -53,6 +78,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -67,6 +93,26 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c var value = default(TSource); +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (comparer.Compare(x, value) > 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -90,6 +136,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -113,6 +160,31 @@ async Task Core(IAsyncEnumerable _source, Func 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -141,6 +213,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -178,6 +271,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -229,6 +348,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -266,6 +407,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -318,6 +485,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -355,6 +544,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _c var value = default(TSource); +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (value == null); + + while (await e.MoveNextAsync()) + { + var x = e.Current; + + if (x != null && comparer.Compare(x, value) < 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -53,6 +78,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -67,6 +93,27 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c var value = default(TSource); +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + + if (comparer.Compare(x, value) < 0) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -90,6 +137,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -113,6 +161,31 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Date: Wed, 9 Jan 2019 21:01:52 -0800 Subject: [PATCH 651/862] Use C# 8.0 in Append and Prepend. --- .../System/Linq/Operators/AppendPrepend.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 40b3d635ec..b7a97c2aa2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -206,6 +206,13 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + array[index] = item; + ++index; + } +#else var en = _source.GetAsyncEnumerator(cancellationToken); try @@ -220,6 +227,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel { await en.DisposeAsync().ConfigureAwait(false); } +#endif } if (_appending) @@ -243,6 +251,12 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(_item); } +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + list.Add(item); + } +#else var en = _source.GetAsyncEnumerator(cancellationToken); try @@ -256,6 +270,7 @@ public override async ValueTask> ToListAsync(CancellationToken can { await en.DisposeAsync().ConfigureAwait(false); } +#endif if (_appending) { @@ -413,6 +428,13 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + array[index] = item; + ++index; + } +#else var en = _source.GetAsyncEnumerator(cancellationToken); try @@ -427,6 +449,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel { await en.DisposeAsync().ConfigureAwait(false); } +#endif } index = array.Length; @@ -448,6 +471,12 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(n.Item); } +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + list.Add(item); + } +#else var en = _source.GetAsyncEnumerator(cancellationToken); try @@ -461,6 +490,7 @@ public override async ValueTask> ToListAsync(CancellationToken can { await en.DisposeAsync().ConfigureAwait(false); } +#endif if (_appended != null) { From b138e06b0aae61c1ca585e0e143a742b101afe4b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:02:45 -0800 Subject: [PATCH 652/862] Use C# 8.0 in primitive Min and Max. --- .../System/Linq/Operators/MinMax.Generated.cs | 5472 +++++++++++++---- .../System/Linq/Operators/MinMax.Generated.tt | 446 ++ 2 files changed, 4678 insertions(+), 1240 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 5a40147684..5bec54aa2d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -21,6 +21,26 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancellat { int value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -45,6 +65,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancellat { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -63,6 +84,26 @@ async Task Core(IAsyncEnumerable _source, Func _sele { int value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync()) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -87,6 +128,7 @@ async Task Core(IAsyncEnumerable _source, Func _sele { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -105,6 +147,26 @@ async Task Core(IAsyncEnumerable _source, Func value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -129,6 +191,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -172,6 +255,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -252,6 +395,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync()) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync()) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -333,6 +536,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -414,6 +677,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { - long value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#endif + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + long value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); } value = e.Current; @@ -537,6 +881,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancell { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -555,6 +900,26 @@ async Task Core(IAsyncEnumerable _source, Func _se { long value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync()) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -579,6 +944,7 @@ async Task Core(IAsyncEnumerable _source, Func _se { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -597,6 +963,26 @@ async Task Core(IAsyncEnumerable _source, Func value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -621,6 +1007,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -664,6 +1071,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -744,6 +1211,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - long? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -856,7 +1302,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) @@ -889,7 +1335,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -921,24 +1367,23 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + value = await _selector(e.Current).ConfigureAwait(false); } while (!value.HasValue); @@ -955,9 +1400,9 @@ async Task Core(IAsyncEnumerable _source, Func valueVal) @@ -969,9 +1414,9 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } + finally + { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } -#endif - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + long? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } + while (!value.HasValue); - value = e.Current; + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. - while (float.IsNaN(value)) + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { if (!await e.MoveNextAsync().ConfigureAwait(false)) { return value; } - value = e.Current; + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } + while (!value.HasValue); - while (await e.MoveNextAsync().ConfigureAwait(false)) + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + if (valueVal >= 0) { - var x = e.Current; - if (x > value) + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) + { + valueVal = x; + value = cur; + } } } } @@ -1044,34 +1635,33 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) +#endif + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float value; - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = _selector(e.Current); + value = e.Current; // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no @@ -1080,45 +1670,24 @@ async Task Core(IAsyncEnumerable _source, Func _ while (float.IsNaN(value)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = _selector(e.Current); + value = e.Current; } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = _selector(e.Current); + var x = e.Current; if (x > value) { value = x; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - float value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1128,7 +1697,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) { value = x; @@ -1158,13 +1727,13 @@ async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1173,20 +1742,19 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float value; - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + value = _selector(e.Current); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no @@ -1195,96 +1763,149 @@ async Task Core(IAsyncEnumerable _source, Func value) { value = x; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x > value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif return value; } } -#endif - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + float value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync()) { return value; } - value = e.Current; + value = await _selector(e.Current).ConfigureAwait(false); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(valueVal)) + while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) { return value; } - var cur = e.Current; - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + value = await _selector(e.Current).ConfigureAwait(false); } while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } @@ -1292,12 +1913,14 @@ async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1306,62 +1929,77 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + float value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync()) { return value; } - value = _selector(e.Current); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(valueVal)) + while (float.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) { return value; } - var cur = _selector(e.Current); - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } @@ -1369,38 +2007,37 @@ async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float? value = null; - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + value = e.Current; } while (!value.HasValue); @@ -1415,12 +2052,12 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - float? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1478,7 +2093,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - double value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + float? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); - } + if (!await e.MoveNextAsync()) + { + return value; + } - value = e.Current; + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (double.IsNaN(value)) + while (float.IsNaN(valueVal)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = e.Current; + var cur = _selector(e.Current); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = e.Current; - if (x > value) + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - double value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); } + while (!value.HasValue); - value = _selector(e.Current); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (double.IsNaN(value)) + while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) { return value; } - value = _selector(e.Current); + var cur = _selector(e.Current); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = _selector(e.Current); - if (x > value) + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } @@ -1637,12 +2272,13 @@ async Task Core(IAsyncEnumerable _source, Func { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1651,100 +2287,117 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + float? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); } + while (!value.HasValue); - value = await _selector(e.Current).ConfigureAwait(false); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (double.IsNaN(value)) + while (float.IsNaN(valueVal)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + var cur = await _selector(e.Current).ConfigureAwait(false); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x > value) + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - -#if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - double value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); } + while (!value.HasValue); - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (double.IsNaN(value)) + while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) { return value; } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var cur = await _selector(e.Current).ConfigureAwait(false); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x > value) + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } @@ -1752,37 +2405,39 @@ async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + float? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = e.Current; + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } while (!value.HasValue); @@ -1795,14 +2450,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - double? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1859,7 +2493,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - double? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); + } + + value = e.Current; + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + value = e.Current; } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x > value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (double.IsNaN(valueVal)) + while (double.IsNaN(value)) { if (!await e.MoveNextAsync().ConfigureAwait(false)) { return value; } - var cur = await _selector(e.Current).ConfigureAwait(false); - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + value = e.Current; } while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + var x = e.Current; + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } @@ -1982,13 +2631,13 @@ async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1997,86 +2646,45 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - double? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = _selector(e.Current); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (double.IsNaN(valueVal)) + while (double.IsNaN(value)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + value = _selector(e.Current); } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + var x = _selector(e.Current); + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - -#endif - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { - decimal value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -2086,11 +2694,26 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c throw Error.NoElements(); } - value = e.Current; + value = _selector(e.Current); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + var x = _selector(e.Current); if (x > value) { value = x; @@ -2101,12 +2724,13 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2115,52 +2739,45 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - decimal value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = _selector(e.Current); + value = await _selector(e.Current).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) { - var x = _selector(e.Current); + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); if (x > value) { value = x; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - decimal value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -2172,6 +2789,21 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2200,22 +2833,36 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - decimal value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { throw Error.NoElements(); } value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + + while (await e.MoveNextAsync()) { var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (x > value) @@ -2224,36 +2871,72 @@ async Task Core(IAsyncEnumerable _source, Func value) + { + value = x; + } + } + } + finally + { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } #endif - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - decimal? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } @@ -2266,40 +2949,41 @@ async Task Core(IAsyncEnumerable _source, Func valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { valueVal = x; value = cur; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - decimal? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -2313,7 +2997,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { valueVal = x; value = cur; @@ -2337,12 +3043,13 @@ async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2351,24 +3058,23 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - decimal? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + value = _selector(e.Current); } while (!value.HasValue); @@ -2376,41 +3082,41 @@ async Task Core(IAsyncEnumerable _source, Func valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { valueVal = x; value = cur; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - -#if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - decimal? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -2424,7 +3130,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { valueVal = x; value = cur; @@ -2448,167 +3176,132 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - int value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); } + while (!value.HasValue); - value = e.Current; + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); - while (await e.MoveNextAsync().ConfigureAwait(false)) + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(valueVal)) { - var x = e.Current; - if (x < value) + if (!await e.MoveNextAsync()) { - value = x; + return value; } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - int value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + var cur = await _selector(e.Current).ConfigureAwait(false); - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } - value = _selector(e.Current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = _selector(e.Current); - if (x < value) + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - int value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) + if (!await e.MoveNextAsync().ConfigureAwait(false)) { - value = x; + return value; } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - return value; - } - } + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); -#if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); - return Core(source, selector, cancellationToken); + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - int value; + while (double.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } - var e = _source.GetAsyncEnumerator(_cancellationToken); + var cur = await _selector(e.Current).ConfigureAwait(false); - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x < value) + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } @@ -2616,37 +3309,39 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - int? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + double? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = e.Current; + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } while (!value.HasValue); @@ -2654,42 +3349,41 @@ async Task Core(IAsyncEnumerable _source, Func valueVal) { valueVal = x; value = cur; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - int? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -2703,7 +3397,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) { valueVal = x; value = cur; @@ -2729,114 +3443,61 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - int? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + decimal value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) + var x = e.Current; + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - -#if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - int? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync().ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = e.Current; while (await e.MoveNextAsync().ConfigureAwait(false)) { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) + var x = e.Current; + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } @@ -2844,65 +3505,45 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - long value; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + decimal value; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = e.Current; + value = _selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = e.Current; - if (x < value) + var x = _selector(e.Current); + if (x > value) { value = x; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - long value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -2917,7 +3558,7 @@ async Task Core(IAsyncEnumerable _source, Func _se while (await e.MoveNextAsync().ConfigureAwait(false)) { var x = _selector(e.Current); - if (x < value) + if (x > value) { value = x; } @@ -2927,12 +3568,13 @@ async Task Core(IAsyncEnumerable _source, Func _se { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2941,10 +3583,30 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - long value; + decimal value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -2959,7 +3621,7 @@ async Task Core(IAsyncEnumerable _source, Func value) { value = x; } @@ -2969,13 +3631,14 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2984,10 +3647,30 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - long value; + decimal value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3002,7 +3685,7 @@ async Task Core(IAsyncEnumerable _source, Func value) { value = x; } @@ -3012,23 +3695,57 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - long? value = null; + decimal? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3055,9 +3772,7 @@ async Task Core(IAsyncEnumerable _source, Func valueVal) { valueVal = x; value = cur; @@ -3068,12 +3783,13 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3082,19 +3798,18 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - long? value = null; - - var e = _source.GetAsyncEnumerator(_cancellationToken); + decimal? value = null; - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } @@ -3107,42 +3822,19 @@ async Task Core(IAsyncEnumerable _source, Func valueVal) { valueVal = x; value = cur; } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - long? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3156,7 +3848,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) { valueVal = x; value = cur; @@ -3182,13 +3872,13 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3197,10 +3887,133 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - long? value = null; + decimal? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + if (cur.HasValue && x > valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3227,9 +4040,7 @@ async Task Core(IAsyncEnumerable _source, Func valueVal) { valueVal = x; value = cur; @@ -3240,23 +4051,44 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - float value; + int value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3275,34 +4107,19 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { value = x; } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } } } finally { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3311,10 +4128,30 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - float value; + int value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + while (await e.MoveNextAsync()) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3333,34 +4170,19 @@ async Task Core(IAsyncEnumerable _source, Func _ { value = x; } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } } } finally { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3369,10 +4191,30 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float value; + int value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3391,35 +4233,20 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3428,10 +4255,30 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float value; + int value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3450,45 +4297,65 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - float? value = null; + int? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3513,30 +4380,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3558,10 +4410,45 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - float? value = null; + int? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3586,30 +4473,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3631,10 +4503,45 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float? value = null; + int? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3659,30 +4566,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3705,10 +4597,45 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float? value = null; + int? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3733,29 +4660,1611 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + long value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + long value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync()) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + long? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + long? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) + { + valueVal = x; + value = cur; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + float value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + float value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync()) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + float? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + float? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = _selector(e.Current); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = _selector(e.Current); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); if (x < valueVal) { - valueVal = x; - value = cur; + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + double value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); - if (float.IsNaN(x)) - { - return cur; - } + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = e.Current; + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; } } } @@ -3764,23 +6273,156 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync()) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + throw Error.NoElements(); + } + + value = _selector(e.Current); + + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var x = _selector(e.Current); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } #endif - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3790,11 +6432,70 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _can throw Error.NoElements(); } - value = e.Current; + value = await _selector(e.Current).ConfigureAwait(false); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = e.Current; + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) + { + value = x; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return x; + } + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double value; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (x < value) { value = x; @@ -3817,28 +6518,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _can } } } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - double value; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -3848,11 +6528,11 @@ async Task Core(IAsyncEnumerable _source, Func throw Error.NoElements(); } - value = _selector(e.Current); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = _selector(e.Current); + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (x < value) { value = x; @@ -3879,56 +6559,122 @@ async Task Core(IAsyncEnumerable _source, Func { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - double value; + double? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + if (double.IsNaN(x)) + { + return cur; + } + } + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = e.Current; } + while (!value.HasValue); - value = await _selector(e.Current).ConfigureAwait(false); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else + var cur = e.Current; + if (cur.HasValue) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) + var x = cur.GetValueOrDefault(); + if (x < valueVal) { - return x; + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return cur; + } } } } @@ -3937,13 +6683,13 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3952,42 +6698,108 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - double value; + double? value = null; + +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = _selector(e.Current); + } + while (!value.HasValue); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) + { + var cur = _selector(e.Current); + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x < valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return cur; + } + } + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync().ConfigureAwait(false)) + { + return value; + } + + value = _selector(e.Current); } + while (!value.HasValue); - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync().ConfigureAwait(false)) { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else + var cur = _selector(e.Current); + if (cur.HasValue) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) + var x = cur.GetValueOrDefault(); + if (x < valueVal) { - return x; + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (double.IsNaN(x)) + { + return cur; + } } } } @@ -3996,37 +6808,38 @@ async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = e.Current; + value = await _selector(e.Current).ConfigureAwait(false); } while (!value.HasValue); @@ -4034,9 +6847,9 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - double? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -4099,7 +6891,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4155,24 +6949,23 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } while (!value.HasValue); @@ -4180,9 +6973,9 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - double? value = null; - +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -4288,6 +7059,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _c { decimal value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x < value) + { + value = x; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -4329,6 +7121,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; } @@ -4347,6 +7140,26 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func <#=t#> value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = e.Current; + +<# + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t#>.IsNaN(value)) + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + +<# + } +#> + while (await e.MoveNextAsync()) + { + var x = e.Current; + if (x <#=comparison#> value) + { + value = x; + } +<# + if (isFloatingPoint && m == "Min") + { +#> + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t#>.IsNaN(x)) + { + return x; + } + } +<# + } +#> + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -112,6 +177,7 @@ foreach (var m in new[] { "Max", "Min" }) { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; <# @@ -121,6 +187,162 @@ foreach (var m in new[] { "Max", "Min" }) #> <#=t#> value = null; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + +<# + if (isInteger && m == "Max") + { +#> + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } +<# + } + else if (isFloatingPoint && m == "Min") + { +#> + while (await e.MoveNextAsync()) + { + var cur = e.Current; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t.TrimEnd('?')#>.IsNaN(x)) + { + return cur; + } + } + } + } +<# + } + else + { + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t.TrimEnd('?')#>.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync()) + { + return value; + } + + var cur = e.Current; + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + +<# + } +#> + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var x = cur.GetValueOrDefault(); + +<# + if (shortCircuit) + { +#> + if (cur.HasValue && x <#=comparison#> valueVal) +<# + } + else + { +#> + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) +<# + } +#> + { + valueVal = x; + value = cur; + } + } +<# + } +#> + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -281,6 +503,7 @@ foreach (var m in new[] { "Max", "Min" }) { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; <# @@ -322,6 +545,71 @@ foreach (var overload in new[] { #> <#=t#> value; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = <#=overload.invoke#>; + +<# + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t#>.IsNaN(value)) + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = <#=overload.invoke#>; + } + +<# + } +#> + while (await e.MoveNextAsync()) + { + var x = <#=overload.invoke#>; + if (x <#=comparison#> value) + { + value = x; + } +<# + if (isFloatingPoint && m == "Min") + { +#> + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t#>.IsNaN(x)) + { + return x; + } + } +<# + } +#> + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -391,6 +679,7 @@ foreach (var overload in new[] { { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; <# @@ -400,6 +689,162 @@ foreach (var overload in new[] { #> <#=t#> value = null; +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) + { + return value; + } + + value = <#=overload.invoke#>; + } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + +<# + if (isInteger && m == "Max") + { +#> + if (valueVal >= 0) + { + // We can fast-path this case where we know HasValue will + // never affect the outcome, without constantly checking + // if we're in such a state. Similar fast-paths could + // be done for other cases, but as all-positive or mostly- + // positive integer values are quite common in real-world + // uses, it's only been done for int? and long?. + + while (await e.MoveNextAsync()) + { + var cur = <#=overload.invoke#>; + var x = cur.GetValueOrDefault(); + + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } + else + { + while (await e.MoveNextAsync()) + { + var cur = <#=overload.invoke#>; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + } + } +<# + } + else if (isFloatingPoint && m == "Min") + { +#> + while (await e.MoveNextAsync()) + { + var cur = <#=overload.invoke#>; + if (cur.HasValue) + { + var x = cur.GetValueOrDefault(); + if (x <#=comparison#> valueVal) + { + valueVal = x; + value = cur; + } + else + { + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (<#=t.TrimEnd('?')#>.IsNaN(x)) + { + return cur; + } + } + } + } +<# + } + else + { + if (isFloatingPoint && m == "Max") + { +#> + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (<#=t.TrimEnd('?')#>.IsNaN(valueVal)) + { + if (!await e.MoveNextAsync()) + { + return value; + } + + var cur = <#=overload.invoke#>; + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } + } + +<# + } +#> + while (await e.MoveNextAsync()) + { + var cur = <#=overload.invoke#>; + var x = cur.GetValueOrDefault(); + +<# + if (shortCircuit) + { +#> + if (cur.HasValue && x <#=comparison#> valueVal) +<# + } + else + { +#> + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x <#=comparison#> valueVal) +<# + } +#> + { + valueVal = x; + value = cur; + } + } +<# + } +#> + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -560,6 +1005,7 @@ foreach (var overload in new[] { { await e.DisposeAsync().ConfigureAwait(false); } +#endif return value; <# From 76ebc9b0490c78ee78b71689f57daae0a1c05006 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:07:29 -0800 Subject: [PATCH 653/862] Use C# 8.0 in OrderedAsyncEnumerable. --- .../Linq/Operators/OrderedAsyncEnumerable.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index a835be929e..ca7678714b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -265,6 +265,33 @@ private ValueTask SortedMap(TElement[] elements, int count, int minIndexI public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { +#if CSHARP8 + await using (IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + return new Maybe(); + } + + TElement value = e.Current; + + AsyncCachingComparer comparer = GetComparer(); + + await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + TElement x = e.Current; + + if (await comparer.Compare(x, cacheLower: true, cancellationToken).ConfigureAwait(false) < 0) + { + value = x; + } + } + + return new Maybe(value); + } +#else IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken); try @@ -296,10 +323,38 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance { await e.DisposeAsync().ConfigureAwait(false); } +#endif } public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { +#if CSHARP8 + await using (IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + return new Maybe(); + } + + TElement value = e.Current; + + AsyncCachingComparer comparer = GetComparer(); + + await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + TElement current = e.Current; + + if (await comparer.Compare(current, cacheLower: false, cancellationToken).ConfigureAwait(false) >= 0) + { + value = current; + } + } + + return new Maybe(value); + } +#else IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken); try @@ -331,6 +386,7 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel { await e.DisposeAsync().ConfigureAwait(false); } +#endif } internal async ValueTask> TryGetLastAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) From ccd9a44c0b2eb32c7346152dd4344a65c0d3cb23 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:08:57 -0800 Subject: [PATCH 654/862] Obey to repo's code style for OrderedAsyncEnumerable. --- .../Linq/Operators/OrderedAsyncEnumerable.cs | 138 +++++++++--------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index ca7678714b..412d56f6a2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -84,9 +84,9 @@ public override async ValueTask DisposeAsync() public async ValueTask ToArrayAsync(CancellationToken cancellationToken) { - AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + var elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); - int count = elements.Length; + var count = elements.Length; if (count == 0) { @@ -97,13 +97,13 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTo #endif } - TElement[] array = elements.Array; + var array = elements.Array; - int[] map = await SortedMap(array, count, cancellationToken).ConfigureAwait(false); + var map = await SortedMap(array, count, cancellationToken).ConfigureAwait(false); var result = new TElement[count]; - for (int i = 0; i < result.Length; i++) + for (var i = 0; i < result.Length; i++) { result[i] = array[map[i]]; } @@ -113,9 +113,9 @@ public async ValueTask ToArrayAsync(CancellationToken cancellationTo internal async ValueTask ToArrayAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) { - AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + var elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); - int count = elements.Length; + var count = elements.Length; if (count <= minIndexInclusive) { @@ -131,22 +131,22 @@ internal async ValueTask ToArrayAsync(int minIndexInclusive, int max maxIndexInclusive = count - 1; } - TElement[] array = elements.Array; + var array = elements.Array; if (minIndexInclusive == maxIndexInclusive) { - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + var sorter = GetAsyncEnumerableSorter(cancellationToken); - TElement element = await sorter.ElementAt(array, count, minIndexInclusive).ConfigureAwait(false); + var element = await sorter.ElementAt(array, count, minIndexInclusive).ConfigureAwait(false); return new TElement[] { element }; } - int[] map = await SortedMap(array, count, minIndexInclusive, maxIndexInclusive, cancellationToken).ConfigureAwait(false); + var map = await SortedMap(array, count, minIndexInclusive, maxIndexInclusive, cancellationToken).ConfigureAwait(false); var result = new TElement[maxIndexInclusive - minIndexInclusive + 1]; - for (int i = 0; minIndexInclusive <= maxIndexInclusive; i++) + for (var i = 0; minIndexInclusive <= maxIndexInclusive; i++) { result[i] = array[map[minIndexInclusive++]]; } @@ -156,22 +156,22 @@ internal async ValueTask ToArrayAsync(int minIndexInclusive, int max public async ValueTask> ToListAsync(CancellationToken cancellationToken) { - AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + var elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); - int count = elements.Length; + var count = elements.Length; if (count == 0) { return new List(capacity: 0); } - TElement[] array = elements.Array; + var array = elements.Array; - int[] map = await SortedMap(array, count, cancellationToken).ConfigureAwait(false); + var map = await SortedMap(array, count, cancellationToken).ConfigureAwait(false); var result = new List(count); - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { result.Add(array[map[i]]); } @@ -181,9 +181,9 @@ public async ValueTask> ToListAsync(CancellationToken cancellatio internal async ValueTask> ToListAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) { - AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + var elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); - int count = elements.Length; + var count = elements.Length; if (count <= minIndexInclusive) { @@ -195,18 +195,18 @@ internal async ValueTask> ToListAsync(int minIndexInclusive, int maxIndexInclusive = count - 1; } - TElement[] array = elements.Array; + var array = elements.Array; if (minIndexInclusive == maxIndexInclusive) { - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + var sorter = GetAsyncEnumerableSorter(cancellationToken); - TElement element = await sorter.ElementAt(array, count, minIndexInclusive).ConfigureAwait(false); + var element = await sorter.ElementAt(array, count, minIndexInclusive).ConfigureAwait(false); return new List(1) { element }; } - int[] map = await SortedMap(array, count, minIndexInclusive, maxIndexInclusive, cancellationToken).ConfigureAwait(false); + var map = await SortedMap(array, count, minIndexInclusive, maxIndexInclusive, cancellationToken).ConfigureAwait(false); var list = new List(maxIndexInclusive - minIndexInclusive + 1); @@ -222,7 +222,7 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca { if (_source is IAsyncIListProvider listProv) { - int count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); } return !onlyIfCheap || _source is ICollection || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) : -1; @@ -230,7 +230,7 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca internal async ValueTask GetCountAsync(int minIndexInclusive, int maxIndexInclusive, bool onlyIfCheap, CancellationToken cancellationToken) { - int count = await GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + var count = await GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); if (count <= 0) { @@ -247,14 +247,14 @@ internal async ValueTask GetCountAsync(int minIndexInclusive, int maxIndexI private ValueTask SortedMap(TElement[] elements, int count, CancellationToken cancellationToken) { - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + var sorter = GetAsyncEnumerableSorter(cancellationToken); return sorter.Sort(elements, count); } private ValueTask SortedMap(TElement[] elements, int count, int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) { - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + var sorter = GetAsyncEnumerableSorter(cancellationToken); return sorter.Sort(elements, count, minIndexInclusive, maxIndexInclusive); } @@ -273,15 +273,15 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance return new Maybe(); } - TElement value = e.Current; + var value = e.Current; - AsyncCachingComparer comparer = GetComparer(); + var comparer = GetComparer(); await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync()) { - TElement x = e.Current; + var x = e.Current; if (await comparer.Compare(x, cacheLower: true, cancellationToken).ConfigureAwait(false) < 0) { @@ -336,15 +336,15 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel return new Maybe(); } - TElement value = e.Current; + var value = e.Current; - AsyncCachingComparer comparer = GetComparer(); + var comparer = GetComparer(); await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync()) { - TElement current = e.Current; + var current = e.Current; if (await comparer.Compare(current, cacheLower: false, cancellationToken).ConfigureAwait(false) >= 0) { @@ -391,22 +391,22 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel internal async ValueTask> TryGetLastAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) { - AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + var elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); - int count = elements.Length; + var count = elements.Length; if (minIndexInclusive >= count) { return new Maybe(); } - TElement[] array = elements.Array; + var array = elements.Array; TElement last; if (maxIndexInclusive < count - 1) { - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + var sorter = GetAsyncEnumerableSorter(cancellationToken); last = await sorter.ElementAt(array, count, maxIndexInclusive).ConfigureAwait(false); } @@ -420,15 +420,15 @@ internal async ValueTask> TryGetLastAsync(int minIndexInclusive, private async ValueTask Last(TElement[] items, int count, CancellationToken cancellationToken) { - TElement value = items[0]; + var value = items[0]; - AsyncCachingComparer comparer = GetComparer(); + var comparer = GetComparer(); await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); - for (int i = 1; i != count; ++i) + for (var i = 1; i != count; ++i) { - TElement x = items[i]; + var x = items[i]; if (await comparer.Compare(x, cacheLower: false, cancellationToken).ConfigureAwait(false) >= 0) { @@ -456,15 +456,15 @@ public ValueTask> TryGetElementAtAsync(int index, CancellationTo async ValueTask> Core() { - AsyncEnumerableHelpers.ArrayWithLength elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); + var elements = await AsyncEnumerableHelpers.ToArrayWithLength(_source, cancellationToken).ConfigureAwait(false); - int count = elements.Length; + var count = elements.Length; if (index < count) { - AsyncEnumerableSorter sorter = GetAsyncEnumerableSorter(cancellationToken); + var sorter = GetAsyncEnumerableSorter(cancellationToken); - TElement element = await sorter.ElementAt(elements.Array, count, index).ConfigureAwait(false); + var element = await sorter.ElementAt(elements.Array, count, index).ConfigureAwait(false); return new Maybe(element); } @@ -622,7 +622,7 @@ internal abstract class AsyncEnumerableSorter public async ValueTask Sort(TElement[] elements, int count) { - int[] map = await ComputeMap(elements, count).ConfigureAwait(false); + var map = await ComputeMap(elements, count).ConfigureAwait(false); QuickSort(map, 0, count - 1); @@ -631,7 +631,7 @@ public async ValueTask Sort(TElement[] elements, int count) public async ValueTask Sort(TElement[] elements, int count, int minIndexInclusive, int maxIndexInclusive) { - int[] map = await ComputeMap(elements, count).ConfigureAwait(false); + var map = await ComputeMap(elements, count).ConfigureAwait(false); PartialQuickSort(map, 0, count - 1, minIndexInclusive, maxIndexInclusive); @@ -640,7 +640,7 @@ public async ValueTask Sort(TElement[] elements, int count, int minIndexI public async ValueTask ElementAt(TElement[] elements, int count, int index) { - int[] map = await ComputeMap(elements, count).ConfigureAwait(false); + var map = await ComputeMap(elements, count).ConfigureAwait(false); return index == 0 ? elements[Min(map, count)] : @@ -686,7 +686,7 @@ public AsyncEnumerableSorterBase(IComparer comparer, bool descending, Asyn internal sealed override int CompareAnyKeys(int index1, int index2) { - int c = _comparer.Compare(_keys[index1], _keys[index2]); + var c = _comparer.Compare(_keys[index1], _keys[index2]); if (c == 0) { @@ -765,9 +765,9 @@ protected override void PartialQuickSort(int[] map, int left, int right, int min { do { - int i = left; - int j = right; - int x = map[i + ((j - i) >> 1)]; + var i = left; + var j = right; + var x = map[i + ((j - i) >> 1)]; do { while (i < map.Length && CompareKeys(x, map[i]) > 0) @@ -787,7 +787,7 @@ protected override void PartialQuickSort(int[] map, int left, int right, int min if (i < j) { - int temp = map[i]; + var temp = map[i]; map[i] = map[j]; map[j] = temp; } @@ -1015,7 +1015,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella public IAsyncPartition Skip(int count) { - int minIndex = unchecked(_minIndexInclusive + count); + var minIndex = unchecked(_minIndexInclusive + count); if (unchecked((uint)minIndex > (uint)_maxIndexInclusive)) { @@ -1027,7 +1027,7 @@ public IAsyncPartition Skip(int count) public IAsyncPartition Take(int count) { - int maxIndex = unchecked(_minIndexInclusive + count - 1); + var maxIndex = unchecked(_minIndexInclusive + count - 1); if (unchecked((uint)maxIndex >= (uint)_maxIndexInclusive)) { @@ -1076,7 +1076,7 @@ protected override async ValueTask MoveNextCore() _minIndexIterator = _minIndexInclusive; _maxIndexIterator = _maxIndexInclusive; - int count = _buffer.Length; + var count = _buffer.Length; if (count > _minIndexIterator) { @@ -1085,7 +1085,7 @@ protected override async ValueTask MoveNextCore() _maxIndexIterator = count - 1; } - AsyncEnumerableSorter sorter = _source.GetAsyncEnumerableSorter(_cancellationToken); + var sorter = _source.GetAsyncEnumerableSorter(_cancellationToken); if (_minIndexIterator == _maxIndexIterator) { @@ -1155,9 +1155,9 @@ public AsyncCachingComparer(Func keySelector, IComparer co internal override ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) { - TKey newKey = _keySelector(element); + var newKey = _keySelector(element); - int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + var cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); if (cacheLower == cmp < 0) { @@ -1187,9 +1187,9 @@ public AsyncCachingComparerWithChild(Func keySelector, IComparer internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) { - TKey newKey = _keySelector(element); + var newKey = _keySelector(element); - int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + var cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); if (cmp == 0) { @@ -1230,9 +1230,9 @@ public AsyncCachingComparerWithTask(Func> keySelector, internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) { - TKey newKey = await _keySelector(element).ConfigureAwait(false); + var newKey = await _keySelector(element).ConfigureAwait(false); - int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + var cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); if (cacheLower == cmp < 0) { @@ -1260,9 +1260,9 @@ public AsyncCachingComparerWithTaskAndChild(Func> keyS internal override async ValueTask Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) { - TKey newKey = await _keySelector(element).ConfigureAwait(false); + var newKey = await _keySelector(element).ConfigureAwait(false); - int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + var cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); if (cmp == 0) { @@ -1304,9 +1304,9 @@ public AsyncCachingComparerWithTaskAndCancellation(Func Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) { - TKey newKey = await _keySelector(element, cancellationToken).ConfigureAwait(false); + var newKey = await _keySelector(element, cancellationToken).ConfigureAwait(false); - int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + var cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); if (cacheLower == cmp < 0) { @@ -1334,9 +1334,9 @@ public AsyncCachingComparerWithTaskAndCancellationAndChild(Func Compare(TElement element, bool cacheLower, CancellationToken cancellationToken) { - TKey newKey = await _keySelector(element, cancellationToken).ConfigureAwait(false); + var newKey = await _keySelector(element, cancellationToken).ConfigureAwait(false); - int cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); + var cmp = _descending ? _comparer.Compare(_lastKey, newKey) : _comparer.Compare(newKey, _lastKey); if (cmp == 0) { From 6c7a784426a8ada66f55b0d286a07be0ec9de933 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:09:50 -0800 Subject: [PATCH 655/862] Use C# 8.0 in Sum. --- .../System/Linq/Operators/Sum.Generated.cs | 388 ++++++++++++++++++ .../System/Linq/Operators/Sum.Generated.tt | 98 +++++ 2 files changed, 486 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 2cd9c007d3..b477882cde 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -21,6 +21,15 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancellat { var sum = 0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (int value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + checked + { + sum += value; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -37,6 +46,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancellat { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -55,6 +65,17 @@ async Task Core(IAsyncEnumerable _source, Func _sele { var sum = 0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var value = _selector(item); + + checked + { + sum += value; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -73,6 +94,7 @@ async Task Core(IAsyncEnumerable _source, Func _sele { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -91,6 +113,17 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancell { var sum = 0L; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (long value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + checked + { + sum += value; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -179,6 +234,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancell { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -197,6 +253,17 @@ async Task Core(IAsyncEnumerable _source, Func _se { var sum = 0L; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var value = _selector(item); + + checked + { + sum += value; + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -215,6 +282,7 @@ async Task Core(IAsyncEnumerable _source, Func _se { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -233,6 +301,17 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cance { var sum = 0.0f; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (float value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + sum += value; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -318,6 +416,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -336,6 +435,14 @@ async Task Core(IAsyncEnumerable _source, Func _ { var sum = 0.0f; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var value = _selector(item); + + sum += value; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -351,6 +458,7 @@ async Task Core(IAsyncEnumerable _source, Func _ { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -369,6 +477,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _can { var sum = 0.0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (double value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + sum += value; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -448,6 +580,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _can { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -466,6 +599,14 @@ async Task Core(IAsyncEnumerable _source, Func { var sum = 0.0; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var value = _selector(item); + + sum += value; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -481,6 +622,7 @@ async Task Core(IAsyncEnumerable _source, Func { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -499,6 +641,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _c { var sum = 0m; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (decimal value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + sum += value; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -578,6 +744,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -596,6 +763,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (<#=o.type#> value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { +<# +if (o.@checked) +{ +#> + checked + { + sum += value<#=n#>; + } +<# +} +else +{ +#> + sum += value<#=n#>; +<# +} +#> + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -75,6 +97,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -93,6 +116,30 @@ else { var sum = <#=o.zero#>; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var value = _selector(item); + +<# +if (o.@checked) +{ +#> + checked + { + sum += value<#=n#>; + } +<# +} +else +{ +#> + sum += value<#=n#>; +<# +} +#> + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -124,6 +171,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -142,6 +190,30 @@ else { var sum = <#=o.zero#>; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var value = await _selector(item).ConfigureAwait(false); + +<# +if (o.@checked) +{ +#> + checked + { + sum += value<#=n#>; + } +<# +} +else +{ +#> + sum += value<#=n#>; +<# +} +#> + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -173,6 +245,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } @@ -192,6 +265,30 @@ else { var sum = <#=o.zero#>; +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var value = await _selector(item, _cancellationToken).ConfigureAwait(false); + +<# +if (o.@checked) +{ +#> + checked + { + sum += value<#=n#>; + } +<# +} +else +{ +#> + sum += value<#=n#>; +<# +} +#> + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -223,6 +320,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif return sum; } From c70c1e5d2ca408af2d5e499b9bccd5a98e51d342 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:10:30 -0800 Subject: [PATCH 656/862] Use C# 8.0 in Average. --- .../Linq/Operators/Average.Generated.cs | 1110 ++++++++++++++++- .../Linq/Operators/Average.Generated.tt | 208 +++ 2 files changed, 1283 insertions(+), 35 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 1dabfed05e..8d5854ed8a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -19,6 +19,28 @@ public static Task AverageAsync(this IAsyncEnumerable source, Cance async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += e.Current; + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -45,6 +67,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancel { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -59,6 +82,28 @@ public static Task AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += _selector(e.Current); + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -85,6 +130,7 @@ async Task Core(IAsyncEnumerable _source, Func _s { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -99,6 +145,28 @@ public static Task AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -125,6 +193,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -166,6 +257,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Canc async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += e.Current; + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -205,6 +319,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -219,6 +334,28 @@ public static Task AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += _selector(e.Current); + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -245,6 +382,7 @@ async Task Core(IAsyncEnumerable _source, Func _ { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -259,6 +397,28 @@ public static Task AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -285,6 +445,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + long sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (double)sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -326,6 +509,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Canc async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += e.Current; + ++count; + } + } + + return (float)(sum / count); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -365,6 +571,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -379,6 +586,28 @@ public static Task AverageAsync(this IAsyncEnumerable s async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += _selector(e.Current); + ++count; + } + } + + return (float)(sum / count); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -405,6 +634,7 @@ async Task Core(IAsyncEnumerable _source, Func _ { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -419,6 +649,28 @@ public static Task AverageAsync(this IAsyncEnumerable s async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return (float)(sum / count); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -445,6 +697,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable s async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return (float)(sum / count); + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -486,6 +761,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Ca async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += e.Current; + ++count; + } + } + + return sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -525,6 +823,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _can { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -539,6 +838,28 @@ public static Task AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += _selector(e.Current); + ++count; + } + } + + return sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -565,6 +886,7 @@ async Task Core(IAsyncEnumerable _source, Func { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -579,11 +901,33 @@ public static Task AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + if (!await e.MoveNextAsync().ConfigureAwait(false)) { throw Error.NoElements(); } @@ -605,6 +949,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + double sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -646,6 +1013,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + decimal sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += e.Current; + ++count; + } + } + + return sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -685,6 +1075,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } @@ -699,6 +1090,28 @@ public static Task AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + decimal sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += _selector(e.Current); + ++count; + } + } + + return sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -725,6 +1138,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + decimal sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -765,6 +1201,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + decimal sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return sum / count; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -806,6 +1265,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = e.Current; + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -851,6 +1339,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = _selector(e.Current); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -899,6 +1416,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -947,6 +1493,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -996,6 +1571,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = e.Current; + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1043,6 +1647,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = _selector(e.Current); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1091,6 +1724,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1139,6 +1801,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + long sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (double)sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1188,6 +1879,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = e.Current; + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var v = e.Current; + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return null; + } + } + + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = _selector(e.Current); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try { while (await e.MoveNextAsync().ConfigureAwait(false)) { - var v = e.Current; + var v = _selector(e.Current); if (v.HasValue) { double sum = v.GetValueOrDefault(); @@ -1218,7 +2015,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1249,24 +2047,23 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var v = _selector(e.Current); + var v = await _selector(e.Current).ConfigureAwait(false); if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; checked { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - v = _selector(e.Current); + v = await _selector(e.Current).ConfigureAwait(false); if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1279,26 +2076,7 @@ async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1331,6 +2109,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return (float)(sum / count); + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1380,6 +2187,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = e.Current; + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1427,6 +2263,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = _selector(e.Current); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1475,6 +2340,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1523,6 +2417,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + double sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1572,6 +2495,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = e.Current; + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1619,6 +2571,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = _selector(e.Current); + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1667,6 +2648,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1715,6 +2725,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + decimal sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return sum / count; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -1764,6 +2803,7 @@ async Task Core(IAsyncEnumerable _source, Func +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = e.Current; + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = e.Current; + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -90,6 +118,7 @@ if (isNullable) { await e.DisposeAsync().ConfigureAwait(false); } +#endif return null; <# @@ -97,6 +126,28 @@ if (isNullable) else { #> +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = e.Current; + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += e.Current; + ++count; + } + } + + return <#=res#>; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -123,6 +174,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif <# } #> @@ -144,6 +196,34 @@ else if (isNullable) { #> +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = _selector(e.Current); + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = _selector(e.Current); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -176,6 +256,7 @@ if (isNullable) { await e.DisposeAsync().ConfigureAwait(false); } +#endif return null; <# @@ -183,6 +264,28 @@ if (isNullable) else { #> +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = _selector(e.Current); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += _selector(e.Current); + ++count; + } + } + + return <#=res#>; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -209,6 +312,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif <# } #> @@ -230,6 +334,34 @@ else if (isNullable) { #> +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -262,6 +394,7 @@ if (isNullable) { await e.DisposeAsync().ConfigureAwait(false); } +#endif return null; <# @@ -269,6 +402,28 @@ if (isNullable) else { #> +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = await _selector(e.Current).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current).ConfigureAwait(false); + ++count; + } + } + + return <#=res#>; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -295,6 +450,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif <# } #> @@ -317,6 +473,34 @@ else if (isNullable) { #> +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + <#=o.sum#> sum = v.GetValueOrDefault(); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (v.HasValue) + { + sum += v.GetValueOrDefault(); + ++count; + } + } + } + + return <#=res#>; + } + } + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -349,6 +533,7 @@ if (isNullable) { await e.DisposeAsync().ConfigureAwait(false); } +#endif return null; <# @@ -356,6 +541,28 @@ if (isNullable) else { #> +#if CSHARP8 + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + <#=o.sum#> sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + long count = 1; + checked + { + while (await e.MoveNextAsync()) + { + sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + ++count; + } + } + + return <#=res#>; + } +#else var e = _source.GetAsyncEnumerator(_cancellationToken); try @@ -382,6 +589,7 @@ else { await e.DisposeAsync().ConfigureAwait(false); } +#endif <# } #> From e07db0620262d048aa8d210e1e9d1ae13059eb69 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:11:11 -0800 Subject: [PATCH 657/862] Use C# 8.0 in Ix. --- .../System/Linq/Operators/Max.cs | 22 +++++ .../System/Linq/Operators/Min.cs | 22 +++++ .../System/Linq/Operators/MinBy.cs | 90 +++++++++++++++++++ 3 files changed, 134 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 9498edf181..83637f60ba 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -24,6 +24,27 @@ async Task Core() comparer = Comparer.Default; } +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + throw Error.NoElements(); + + var max = e.Current; + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + + if (comparer.Compare(cur, max) > 0) + { + max = cur; + } + } + + return max; + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -49,6 +70,7 @@ async Task Core() { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index e3dfdc1581..88a1153ad8 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -24,6 +24,27 @@ async Task Core() comparer = Comparer.Default; } +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + throw Error.NoElements(); + + var min = e.Current; + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + + if (comparer.Compare(cur, min) < 0) + { + min = cur; + } + } + + return min; + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -49,6 +70,7 @@ async Task Core() { await e.DisposeAsync().ConfigureAwait(false); } +#endif } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index d932cd8772..10ae55c7f4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -110,6 +110,35 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + throw Error.NoElements(); + + var current = e.Current; + var resKey = keySelector(current); + result.Add(current); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var key = keySelector(cur); + + var cmp = compare(key, resKey); + + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -143,6 +172,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { await e.DisposeAsync().ConfigureAwait(false); } +#endif return result; } @@ -151,6 +181,35 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + throw Error.NoElements(); + + var current = e.Current; + var resKey = await keySelector(current).ConfigureAwait(false); + result.Add(current); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var key = await keySelector(cur).ConfigureAwait(false); + + var cmp = compare(key, resKey); + + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -184,6 +243,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { await e.DisposeAsync().ConfigureAwait(false); } +#endif return result; } @@ -193,6 +253,35 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); +#if CSHARP8 + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + throw Error.NoElements(); + + var current = e.Current; + var resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); + result.Add(current); + + while (await e.MoveNextAsync()) + { + var cur = e.Current; + var key = await keySelector(cur, cancellationToken).ConfigureAwait(false); + + var cmp = compare(key, resKey); + + if (cmp == 0) + { + result.Add(cur); + } + else if (cmp > 0) + { + result = new List { cur }; + resKey = key; + } + } + } +#else var e = source.GetAsyncEnumerator(cancellationToken); try @@ -226,6 +315,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { await e.DisposeAsync().ConfigureAwait(false); } +#endif return result; } From b2cc797263eccaa3f0620398bcc2ce095a397794 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:18:17 -0800 Subject: [PATCH 658/862] Reduce code duplication in Distinct. --- .../System.Linq.Async/System/Linq/Operators/Distinct.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs index fb201adb70..e98179a813 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Distinct.cs @@ -11,13 +11,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Distinct(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return new DistinctAsyncIterator(source, comparer: null); - } + public static IAsyncEnumerable Distinct(this IAsyncEnumerable source) => Distinct(source, comparer: null); public static IAsyncEnumerable Distinct(this IAsyncEnumerable source, IEqualityComparer comparer) { From fb6c7d19f57cce90c2b307f114ac62d04e944b0e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:18:54 -0800 Subject: [PATCH 659/862] Moving optimization in Contains to size of async code. --- .../System/Linq/Operators/Contains.cs | 105 +++++++++--------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 3edafc6bab..2c9be7c17e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -10,89 +10,90 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - if (source is ICollection collection) - { - return Task.FromResult(collection.Contains(value)); - } - - return ContainsCore(source, value, comparer: null, cancellationToken); - } + public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken = default) => + source is ICollection collection ? Task.FromResult(collection.Contains(value)) : + ContainsAsync(source, value, comparer: null, cancellationToken); public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return ContainsCore(source, value, comparer, cancellationToken); - } - - private static async Task ContainsCore(IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken) - { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' // // See https://github.com/dotnet/corefx/pull/25097 for the optimization here. // if (comparer == null) { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + return Core(source, value, cancellationToken); + + async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { - if (EqualityComparer.Default.Equals(item, value)) +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { - return true; + if (EqualityComparer.Default.Equals(item, _value)) + { + return true; + } } - } - } - else - { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) - { - if (comparer.Equals(item, value)) +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try { - return true; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + if (EqualityComparer.Default.Equals(e.Current, _value)) + { + return true; + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } +#endif + + return false; } } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try + else { - // - // See https://github.com/dotnet/corefx/pull/25097 for the optimization here. - // - if (comparer == null) + return Core(source, value, comparer, cancellationToken); + + async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { - while (await e.MoveNextAsync().ConfigureAwait(false)) +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { - if (EqualityComparer.Default.Equals(e.Current, value)) + if (_comparer.Equals(item, _value)) { return true; } } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try { - if (comparer.Equals(e.Current, value)) + while (await e.MoveNextAsync().ConfigureAwait(false)) { - return true; + if (_comparer.Equals(e.Current, _value)) + { + return true; + } } } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } #endif - return false; + return false; + } + } } } } From 05360aba29fbd98f45d3e9918521621b5c417227 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:22:54 -0800 Subject: [PATCH 660/862] Reduce code in Except, Intersect, and Union. --- .../System/Linq/Operators/Except.cs | 12 ++---------- .../System/Linq/Operators/Intersect.cs | 12 ++---------- .../System/Linq/Operators/Union.cs | 16 ++-------------- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 9b69ba5da0..53dbaa7eb7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -4,22 +4,14 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Except(this IAsyncEnumerable first, IAsyncEnumerable second) - { - if (first == null) - throw Error.ArgumentNull(nameof(first)); - if (second == null) - throw Error.ArgumentNull(nameof(second)); - - return new ExceptAsyncIterator(first, second, comparer: null); - } + public static IAsyncEnumerable Except(this IAsyncEnumerable first, IAsyncEnumerable second) => + Except(first, second, comparer: null); public static IAsyncEnumerable Except(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 799648659f..80a7118008 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -4,22 +4,14 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second) - { - if (first == null) - throw Error.ArgumentNull(nameof(first)); - if (second == null) - throw Error.ArgumentNull(nameof(second)); - - return new IntersectAsyncIterator(first, second, comparer: null); - } + public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second) => + Intersect(first, second, comparer: null); public static IAsyncEnumerable Intersect(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index f2d2af6ac0..b0370a8161 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -11,15 +11,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second) - { - if (first == null) - throw Error.ArgumentNull(nameof(first)); - if (second == null) - throw Error.ArgumentNull(nameof(second)); - - return UnionCore(first, second, comparer: null); - } + public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second) => + Union(first, second, comparer: null); public static IAsyncEnumerable Union(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) { @@ -28,11 +21,6 @@ public static IAsyncEnumerable Union(this IAsyncEnumerable UnionCore(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer) - { return first is UnionAsyncIterator union && AreEqualityComparersEqual(comparer, union._comparer) ? union.Union(second) : new UnionAsyncIterator2(first, second, comparer); } From fab4165c01c1ac7e22d13e3f1855f5ec7960eff6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:24:23 -0800 Subject: [PATCH 661/862] Reduce code in DefaultIfEmpty. --- .../System/Linq/Operators/DefaultIfEmpty.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs index 8a1ca757c2..090bde8543 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/DefaultIfEmpty.cs @@ -12,13 +12,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return new DefaultIfEmptyAsyncIterator(source, default); - } + public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source) => + DefaultIfEmpty(source, default); public static IAsyncEnumerable DefaultIfEmpty(this IAsyncEnumerable source, TSource defaultValue) { From d109962f8f68b421e8c1b3c8f5f6bd2d4f8a8284 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:25:29 -0800 Subject: [PATCH 662/862] Reduce code in SequenceEqual. --- .../System/Linq/Operators/SequenceEqual.cs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 1df272adb6..a4c07bae5e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -10,15 +10,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) - { - if (first == null) - throw Error.ArgumentNull(nameof(first)); - if (second == null) - throw Error.ArgumentNull(nameof(second)); - - return SequenceEqualCore(first, second, comparer: null, cancellationToken); - } + public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) => + SequenceEqual(first, second, comparer: null, cancellationToken); public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -27,11 +20,6 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable SequenceEqualCore(IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken) - { if (comparer == null) { comparer = EqualityComparer.Default; From db5992d579410f447be2a9a2af6853f8f391fcea Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:29:49 -0800 Subject: [PATCH 663/862] Remove unused using. --- .../Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index fd6daac5be..d15ad9e837 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using System.Threading.Tasks; namespace System.Linq From 043997b2e7972432c041a6193676b6f49b5f24fc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:39:24 -0800 Subject: [PATCH 664/862] Fix typo. --- .../Source/System.Linq.Async/System/Linq/Operators/Grouping.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs index 8638b34218..4ba525187f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Grouping.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Threading; -// Note: The type here has to be internal as System.Linq has it's own public copy we're not using +// Note: The type here has to be internal as System.Linq has its own public copy we're not using. namespace System.Linq.Internal { From 19a364f9a85fed1b4b5a946e231fa401abdeb521 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:40:56 -0800 Subject: [PATCH 665/862] Reduce code in GroupBy. --- .../System/Linq/Operators/GroupBy.cs | 303 ++++-------------- 1 file changed, 60 insertions(+), 243 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index c224cc0352..232509c350 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -11,220 +11,70 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new GroupedAsyncEnumerable(source, keySelector, comparer: null); - } - - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new GroupedAsyncEnumerable(source, keySelector, comparer); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) => + GroupedAsyncEnumerable(source, keySelector, comparer: null); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) => + new GroupedAsyncEnumerable(source, keySelector, comparer); - return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer: null); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => + new GroupedAsyncEnumerableWithTask(source, keySelector, comparer: null); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => + new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); #endif - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => + new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => + new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer); #endif - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer: null); - } - - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector) => + new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer: null); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) => + new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); - return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer: null); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer: null); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); #endif - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => + new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer); - } + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => + new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer); #endif - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer: null); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector) => + new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) => + new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - return new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - } - - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => + new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => + new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); #endif - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => + new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => + new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer); #endif public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) @@ -327,13 +177,9 @@ private sealed class GroupedResultAsyncEnumerable : Asyn public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(resultSelector != null); - - _source = source; - _keySelector = keySelector; - _resultSelector = resultSelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector)); _comparer = comparer; } @@ -420,13 +266,9 @@ private sealed class GroupedResultAsyncEnumerableWithTask source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(resultSelector != null); - - _source = source; - _keySelector = keySelector; - _resultSelector = resultSelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector)); _comparer = comparer; } @@ -514,13 +356,9 @@ private sealed class GroupedResultAsyncEnumerableWithTaskAndCancellation source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(resultSelector != null); - - _source = source; - _keySelector = keySelector; - _resultSelector = resultSelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector)); _comparer = comparer; } @@ -608,13 +446,9 @@ private sealed class GroupedAsyncEnumerable : AsyncIter public GroupedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(elementSelector != null); - - _source = source; - _keySelector = keySelector; - _elementSelector = elementSelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector)); _comparer = comparer; } @@ -701,13 +535,9 @@ private sealed class GroupedAsyncEnumerableWithTask : A public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(elementSelector != null); - - _source = source; - _keySelector = keySelector; - _elementSelector = elementSelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector)); _comparer = comparer; } @@ -795,13 +625,9 @@ private sealed class GroupedAsyncEnumerableWithTaskAndCancellation source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - Debug.Assert(elementSelector != null); - - _source = source; - _keySelector = keySelector; - _elementSelector = elementSelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector)); _comparer = comparer; } @@ -888,11 +714,8 @@ private sealed class GroupedAsyncEnumerable : AsyncIterator source, Func keySelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - - _source = source; - _keySelector = keySelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); _comparer = comparer; } @@ -978,11 +801,8 @@ private sealed class GroupedAsyncEnumerableWithTask : AsyncIterat public GroupedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - - _source = source; - _keySelector = keySelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); _comparer = comparer; } @@ -1069,11 +889,8 @@ private sealed class GroupedAsyncEnumerableWithTaskAndCancellation source, Func> keySelector, IEqualityComparer comparer) { - Debug.Assert(source != null); - Debug.Assert(keySelector != null); - - _source = source; - _keySelector = keySelector; + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); _comparer = comparer; } From 4f97781307e5938752e7c92455860612da906b80 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:45:07 -0800 Subject: [PATCH 666/862] Fix SequenceEqual chaining. --- .../System.Linq.Async/System/Linq/Operators/SequenceEqual.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index a4c07bae5e..58a43defef 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -11,7 +11,7 @@ namespace System.Linq public static partial class AsyncEnumerable { public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) => - SequenceEqual(first, second, comparer: null, cancellationToken); + SequenceEqualAsync(first, second, comparer: null, cancellationToken); public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) { From 85a9111e33109397da47bebe3b241d4fdf3e9355 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:45:41 -0800 Subject: [PATCH 667/862] Tweak local function signatures in Contains. --- .../System.Linq.Async/System/Linq/Operators/Contains.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 2c9be7c17e..d6e9805bd7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -26,7 +26,7 @@ public static Task ContainsAsync(this IAsyncEnumerable s { return Core(source, value, cancellationToken); - async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) { #if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -62,7 +62,7 @@ async Task Core(IAsyncEnumerable _source, TSource _value { return Core(source, value, comparer, cancellationToken); - async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) + async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { #if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) From 780694dd9a2a8f4d2d0e4708510327e9d92d31d1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:46:01 -0800 Subject: [PATCH 668/862] Add missing new. --- .../Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 232509c350..1d84c8399b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -12,7 +12,7 @@ namespace System.Linq public static partial class AsyncEnumerable { public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector) => - GroupedAsyncEnumerable(source, keySelector, comparer: null); + new GroupedAsyncEnumerable(source, keySelector, comparer: null); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerable(source, keySelector, comparer); From 59802a7891d5e70d6bff5c1a46effde711b19c97 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:52:33 -0800 Subject: [PATCH 669/862] Reduce code in GroupJoin. --- .../System/Linq/Operators/GroupJoin.cs | 55 +++---------------- 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 6d8ee96a12..1e4447080c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -10,21 +10,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector) - { - if (outer == null) - throw Error.ArgumentNull(nameof(outer)); - if (inner == null) - throw Error.ArgumentNull(nameof(inner)); - if (outerKeySelector == null) - throw Error.ArgumentNull(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw Error.ArgumentNull(nameof(innerKeySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - } + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector) => + GroupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func, TResult> resultSelector, IEqualityComparer comparer) { @@ -42,39 +29,8 @@ public static IAsyncEnumerable GroupJoin return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) - { - if (outer == null) - throw Error.ArgumentNull(nameof(outer)); - if (inner == null) - throw Error.ArgumentNull(nameof(inner)); - if (outerKeySelector == null) - throw Error.ArgumentNull(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw Error.ArgumentNull(nameof(innerKeySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - } - -#if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) - { - if (outer == null) - throw Error.ArgumentNull(nameof(outer)); - if (inner == null) - throw Error.ArgumentNull(nameof(inner)); - if (outerKeySelector == null) - throw Error.ArgumentNull(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw Error.ArgumentNull(nameof(innerKeySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new GroupJoinAsyncEnumerableWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - } -#endif + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => + GroupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { @@ -93,6 +49,9 @@ public static IAsyncEnumerable GroupJoin } #if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => + GroupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) { if (outer == null) From e16dff76d6f5a18dc18fcda7d29c8841f571d2e9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 21:52:42 -0800 Subject: [PATCH 670/862] Reduce code in Join. --- .../System/Linq/Operators/Join.cs | 55 +++---------------- 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 3a883d6941..4fe17e9f17 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -11,21 +11,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) - { - if (outer == null) - throw Error.ArgumentNull(nameof(outer)); - if (inner == null) - throw Error.ArgumentNull(nameof(inner)); - if (outerKeySelector == null) - throw Error.ArgumentNull(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw Error.ArgumentNull(nameof(innerKeySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - } + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) => + Join(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector, IEqualityComparer comparer) { @@ -43,39 +30,8 @@ public static IAsyncEnumerable Join(this return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) - { - if (outer == null) - throw Error.ArgumentNull(nameof(outer)); - if (inner == null) - throw Error.ArgumentNull(nameof(inner)); - if (outerKeySelector == null) - throw Error.ArgumentNull(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw Error.ArgumentNull(nameof(innerKeySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - } - -#if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) - { - if (outer == null) - throw Error.ArgumentNull(nameof(outer)); - if (inner == null) - throw Error.ArgumentNull(nameof(inner)); - if (outerKeySelector == null) - throw Error.ArgumentNull(nameof(outerKeySelector)); - if (innerKeySelector == null) - throw Error.ArgumentNull(nameof(innerKeySelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return new JoinAsyncIteratorWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - } -#endif + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + Join(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { @@ -94,6 +50,9 @@ public static IAsyncEnumerable Join(this } #if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + Join(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) From 7f90a101019dc13f233e7dbae3bdeff6bf86778c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 22:00:20 -0800 Subject: [PATCH 671/862] Reduce code in OrderBy. --- .../System/Linq/Operators/OrderBy.cs | 156 +++--------------- .../Linq/Operators/OrderedAsyncEnumerable.cs | 17 +- 2 files changed, 28 insertions(+), 145 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index 8f8ca393af..eff7657af9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -10,140 +10,54 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: false, parent: null); - } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) => + new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: false, parent: null); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: false, parent: null); - } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => + new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: false, parent: null); - } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => + new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: false, parent: null); #endif - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); - } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => + new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); - } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: false, parent: null); - } + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: false, parent: null); #endif - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: true, parent: null); - } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) => + new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: true, parent: null); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: true, parent: null); - } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => + new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: true, parent: null); - } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => + new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: true, parent: null); #endif - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); - } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => + new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); - } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: true, parent: null); - } + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: true, parent: null); #endif public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: false); } @@ -152,8 +66,6 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer: default(IComparer), descending: false); } @@ -163,8 +75,6 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: false); } @@ -174,8 +84,6 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } @@ -184,8 +92,6 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } @@ -195,8 +101,6 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } @@ -206,8 +110,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: true); } @@ -216,8 +118,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer: default(IComparer), descending: true); } @@ -227,8 +127,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: true); } @@ -238,8 +136,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } @@ -248,8 +144,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } @@ -259,8 +153,6 @@ public static IOrderedAsyncEnumerable ThenByDescending(t { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 412d56f6a2..e3a3d6ed83 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -4,7 +4,6 @@ using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -22,9 +21,7 @@ internal abstract class OrderedAsyncEnumerable : AsyncIterator source) { - Debug.Assert(source != null); - - _source = source; + _source = source ?? throw Error.ArgumentNull(nameof(source)); } IOrderedAsyncEnumerable IOrderedAsyncEnumerable.CreateOrderedEnumerable(Func keySelector, IComparer comparer, bool descending) @@ -487,9 +484,7 @@ internal sealed class OrderedAsyncEnumerable : OrderedAsyncEnume public OrderedAsyncEnumerable(IAsyncEnumerable source, Func keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) : base(source) { - Debug.Assert(keySelector != null); - - _keySelector = keySelector; + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); _comparer = comparer ?? Comparer.Default; _descending = descending; _parent = parent; @@ -532,9 +527,7 @@ internal sealed class OrderedAsyncEnumerableWithTask : OrderedAs public OrderedAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) : base(source) { - Debug.Assert(keySelector != null); - - _keySelector = keySelector; + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); _comparer = comparer ?? Comparer.Default; _descending = descending; _parent = parent; @@ -578,9 +571,7 @@ internal sealed class OrderedAsyncEnumerableWithTaskAndCancellation source, Func> keySelector, IComparer comparer, bool descending, OrderedAsyncEnumerable parent) : base(source) { - Debug.Assert(keySelector != null); - - _keySelector = keySelector; + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); _comparer = comparer ?? Comparer.Default; _descending = descending; _parent = parent; From fb3b6f40e4de15f223ffa5fc738c8c93ccd6fe90 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 22:02:40 -0800 Subject: [PATCH 672/862] Reduce code in ToHashSet. --- .../System/Linq/Operators/ToHashSet.cs | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 2988902e2f..879b1f00ff 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -10,48 +10,43 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToHashSetAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return ToHashSetCore(source, comparer: null, cancellationToken); - } + public static Task> ToHashSetAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) => + ToHashSetAsync(source, comparer: null, cancellationToken); public static Task> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - return ToHashSetCore(source, comparer, cancellationToken); - } + return Core(source, comparer, cancellationToken); - private static async Task> ToHashSetCore(IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken) - { - var set = new HashSet(comparer); + async Task> Core(IAsyncEnumerable _source, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + var set = new HashSet(_comparer); #if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) - { - set.Add(item); - } + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + set.Add(item); + } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - set.Add(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + set.Add(e.Current); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } #endif - return set; + return set; + } } } } From 533971331549393c72f5f794f3b120711b661c1f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 22:20:13 -0800 Subject: [PATCH 673/862] Use null for default comparer in ToDictionary. --- .../System/Linq/Operators/ToDictionary.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 677bf700cd..2a73508411 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -17,7 +17,7 @@ public static Task> ToDictionaryAsync(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => x, EqualityComparer.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, x => x, comparer: null, cancellationToken); } public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) @@ -27,7 +27,7 @@ public static Task> ToDictionaryAsync(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => new ValueTask(x), EqualityComparer.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer: null, cancellationToken); } #if !NO_DEEP_CANCELLATION @@ -38,7 +38,7 @@ public static Task> ToDictionaryAsync(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), EqualityComparer.Default, cancellationToken); + return ToDictionaryCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer: null, cancellationToken); } #endif @@ -83,7 +83,7 @@ public static Task> ToDictionaryAsync.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) @@ -95,7 +95,7 @@ public static Task> ToDictionaryAsync.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } #if !NO_DEEP_CANCELLATION @@ -108,7 +108,7 @@ public static Task> ToDictionaryAsync.Default, cancellationToken); + return ToDictionaryCore(source, keySelector, elementSelector, comparer: null, cancellationToken); } #endif From 7878c5b3492e119128fca5128474d309e8797ba4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 9 Jan 2019 22:25:58 -0800 Subject: [PATCH 674/862] Reducing code in ToDictionary. --- .../System/Linq/Operators/ToDictionary.cs | 84 ++++--------------- 1 file changed, 16 insertions(+), 68 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 2a73508411..f50bf82de8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -10,37 +10,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToDictionaryCore(source, keySelector, x => x, comparer: null, cancellationToken); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer: null, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToDictionaryCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer: null, cancellationToken); - } -#endif + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) => + ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -52,6 +23,9 @@ public static Task> ToDictionaryAsync(t return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); } + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -63,6 +37,9 @@ public static Task> ToDictionaryAsync(t } #if !NO_DEEP_CANCELLATION + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -74,43 +51,8 @@ public static Task> ToDictionaryAsync(t } #endif - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToDictionaryCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - } - - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToDictionaryCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToDictionaryCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - } -#endif + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => + ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -124,6 +66,9 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -137,6 +82,9 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) From f76294ee94918c991e41e6f991d83a7aa5082353 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 10 Jan 2019 10:11:48 -0800 Subject: [PATCH 675/862] Reducing code in ToLookup. --- .../System/Linq/Operators/ToLookup.cs | 84 ++++--------------- 1 file changed, 16 insertions(+), 68 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 9024076691..2ea63e20b9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -10,37 +10,8 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToLookupCore(source, keySelector, x => x, comparer: null, cancellationToken); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer: null, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - - return ToLookupCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer: null, cancellationToken); - } -#endif + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) => + ToLookupAsync(source, keySelector, comparer: null, cancellationToken); public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -52,6 +23,9 @@ public static Task> ToLookupAsync(this IAs return ToLookupCore(source, keySelector, x => x, comparer, cancellationToken); } + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToLookupAsync(source, keySelector, comparer:null, cancellationToken); + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -63,6 +37,9 @@ public static Task> ToLookupAsync(this IAs } #if !NO_DEEP_CANCELLATION + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToLookupAsync(source, keySelector, comparer: null, cancellationToken); + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -74,43 +51,8 @@ public static Task> ToLookupAsync(this IAs } #endif - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - } - - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - } - -#if !NO_DEEP_CANCELLATION - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - - return ToLookupCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - } -#endif + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => + ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -124,6 +66,9 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -137,6 +82,9 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) From beaa2d76432f166ce8ddf49cd7054e0f3d56b208 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 10 Jan 2019 10:28:40 -0800 Subject: [PATCH 676/862] Better forwarding of ToLookup to underlying implementations. --- .../System/Linq/Operators/ToLookup.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 2ea63e20b9..27a963a576 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -20,7 +20,7 @@ public static Task> ToLookupAsync(this IAs if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => x, comparer, cancellationToken); + return ToLookupCore(source, keySelector, comparer, cancellationToken); } public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => @@ -38,7 +38,7 @@ public static Task> ToLookupAsync(this IAs #if !NO_DEEP_CANCELLATION public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToLookupAsync(source, keySelector, comparer: null, cancellationToken); + ToLookupAsync(source, keySelector, comparer: null, cancellationToken); public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -52,7 +52,7 @@ public static Task> ToLookupAsync(this IAs #endif public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => - ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -83,7 +83,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -98,6 +98,11 @@ public static Task> ToLookupAsync> ToLookupCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + return await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + } + private static async Task> ToLookupCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { return await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); From 0d5c58baa0ca59dc011da8e0232b3593ccbed8bc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 10 Jan 2019 10:37:13 -0800 Subject: [PATCH 677/862] More proper forwarding to ToLookup. --- .../System/Linq/Operators/ToLookup.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 27a963a576..d290e4f82f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -33,7 +33,7 @@ public static Task> ToLookupAsync(this IAs if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); + return ToLookupCore(source, keySelector, comparer, cancellationToken); } #if !NO_DEEP_CANCELLATION @@ -47,7 +47,7 @@ public static Task> ToLookupAsync(this IAs if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer, cancellationToken); + return ToLookupCore(source, keySelector, comparer, cancellationToken); } #endif @@ -113,7 +113,17 @@ private static async Task> ToLookupCore.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); } + private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + } + #if !NO_DEEP_CANCELLATION + private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); + } + private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) { return await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); From a948fa217319f9980952c522afdda58cc66af196 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 10 Jan 2019 10:42:25 -0800 Subject: [PATCH 678/862] Use local functions to ToLookup. --- .../System/Linq/Operators/ToLookup.cs | 72 +++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index d290e4f82f..9def25502d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -20,7 +20,12 @@ public static Task> ToLookupAsync(this IAs if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, comparer, cancellationToken); + return Core(source, keySelector, comparer, cancellationToken); + + async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + return await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); + } } public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => @@ -33,7 +38,12 @@ public static Task> ToLookupAsync(this IAs if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, comparer, cancellationToken); + return Core(source, keySelector, comparer, cancellationToken); + + async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); + } } #if !NO_DEEP_CANCELLATION @@ -47,7 +57,12 @@ public static Task> ToLookupAsync(this IAs if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToLookupCore(source, keySelector, comparer, cancellationToken); + return Core(source, keySelector, comparer, cancellationToken); + + async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); + } } #endif @@ -63,7 +78,12 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + return await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); + } } public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => @@ -78,7 +98,12 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); + } } #if !NO_DEEP_CANCELLATION @@ -94,39 +119,12 @@ public static Task> ToLookupAsync> ToLookupCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - return await Internal.Lookup.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - } - - private static async Task> ToLookupCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - return await Internal.Lookup.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); - } - - private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - return await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); - } - - private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - return await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - } - -#if !NO_DEEP_CANCELLATION - private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - return await Internal.LookupWithTask.CreateAsync(source, keySelector, comparer, cancellationToken).ConfigureAwait(false); - } + return Core(source, keySelector, elementSelector, comparer, cancellationToken); - private static async Task> ToLookupCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - return await Internal.LookupWithTask.CreateAsync(source, keySelector, elementSelector, comparer, cancellationToken).ConfigureAwait(false); + async Task> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); + } } #endif } From 8cefa656f8ea200268b1425a3a896e7105ebb27b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 10 Jan 2019 10:56:59 -0800 Subject: [PATCH 679/862] Adding optimized implementations of ToDictionary. --- .../System/Linq/Operators/ToDictionary.cs | 304 ++++++++++++------ 1 file changed, 202 insertions(+), 102 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index f50bf82de8..606f1c984e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -11,7 +11,7 @@ namespace System.Linq public static partial class AsyncEnumerable { public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) => - ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); + ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -20,7 +20,41 @@ public static Task> ToDictionaryAsync(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => x, comparer, cancellationToken); + return Core(source, keySelector, comparer, cancellationToken); + + async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + var d = new Dictionary(_comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var key = _keySelector(item); + + d.Add(key, item); + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var item = e.Current; + + var key = _keySelector(item); + + d.Add(key, item); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return d; + } } public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => @@ -33,12 +67,46 @@ public static Task> ToDictionaryAsync(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, keySelector, x => new ValueTask(x), comparer, cancellationToken); + return Core(source, keySelector, comparer, cancellationToken); + + async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + var d = new Dictionary(_comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var key = await _keySelector(item).ConfigureAwait(false); + + d.Add(key, item); + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var item = e.Current; + + var key = await _keySelector(item).ConfigureAwait(false); + + d.Add(key, item); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return d; + } } #if !NO_DEEP_CANCELLATION public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); + ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -47,12 +115,46 @@ public static Task> ToDictionaryAsync(t if (keySelector == null) throw Error.ArgumentNull(nameof(keySelector)); - return ToDictionaryCore(source, x => keySelector(x, cancellationToken), x => new ValueTask(x), comparer, cancellationToken); + return Core(source, keySelector, comparer, cancellationToken); + + async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + var d = new Dictionary(_comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + + d.Add(key, item); + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var item = e.Current; + + var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + + d.Add(key, item); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return d; + } } #endif public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => - ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { @@ -63,7 +165,43 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + var d = new Dictionary(_comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var key = _keySelector(item); + var value = _elementSelector(item); + + d.Add(key, value); + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var item = e.Current; + + var key = _keySelector(item); + var value = _elementSelector(item); + + d.Add(key, value); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return d; + } } public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => @@ -78,7 +216,43 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + { + var d = new Dictionary(_comparer); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var key = await _keySelector(item).ConfigureAwait(false); + var value = await _elementSelector(item).ConfigureAwait(false); + + d.Add(key, value); + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var item = e.Current; + + var key = await _keySelector(item).ConfigureAwait(false); + var value = await _elementSelector(item).ConfigureAwait(false); + + d.Add(key, value); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return d; + } } #if !NO_DEEP_CANCELLATION @@ -94,117 +268,43 @@ public static Task> ToDictionaryAsync> ToDictionaryCore(IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - var d = new Dictionary(comparer); + return Core(source, keySelector, elementSelector, comparer, cancellationToken); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + async Task> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { - var key = keySelector(item); - var value = elementSelector(item); + var d = new Dictionary(_comparer); - d.Add(key, value); - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { - var x = e.Current; - - var key = keySelector(x); - var value = elementSelector(x); + var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + var value = await _elementSelector(item, _cancellationToken).ConfigureAwait(false); d.Add(key, value); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return d; - } - - private static async Task> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - var d = new Dictionary(comparer); - -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) - { - var key = await keySelector(item).ConfigureAwait(false); - var value = await elementSelector(item).ConfigureAwait(false); - - d.Add(key, value); - } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - var x = e.Current; + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var item = e.Current; - var key = await keySelector(x).ConfigureAwait(false); - var value = await elementSelector(x).ConfigureAwait(false); + var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); + var value = await _elementSelector(item, _cancellationToken).ConfigureAwait(false); - d.Add(key, value); + d.Add(key, value); + } } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return d; - } - -#if !NO_DEEP_CANCELLATION - private static async Task> ToDictionaryCore(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) - { - var d = new Dictionary(comparer); - -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) - { - var key = await keySelector(item, cancellationToken).ConfigureAwait(false); - var value = await elementSelector(item, cancellationToken).ConfigureAwait(false); - - d.Add(key, value); - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + finally { - var x = e.Current; - - var key = await keySelector(x, cancellationToken).ConfigureAwait(false); - var value = await elementSelector(x, cancellationToken).ConfigureAwait(false); - - d.Add(key, value); + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } #endif - return d; + return d; + } } #endif } From 578bb662de4789a84f6f36818622db05732d1f06 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 10 Jan 2019 11:11:33 -0800 Subject: [PATCH 680/862] Optimize ForEach implementations. --- .../System/Linq/Operators/ForEach.cs | 233 +++++++++++------- 1 file changed, 139 insertions(+), 94 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 43f1fd3c49..4fd046b939 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -24,157 +24,202 @@ public static Task ForEachAsync(this IAsyncEnumerable source, if (action == null) throw Error.ArgumentNull(nameof(action)); - return ForEachAsyncCore(source, action, cancellationToken); - } + return Core(source, action, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (action == null) - throw Error.ArgumentNull(nameof(action)); + async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) + { +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + _action(item); + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); - return ForEachAsyncCore(source, action, cancellationToken); + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + _action(e.Current); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + } } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) + public static Task ForEachAsync(this IAsyncEnumerable source, Action action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (action == null) throw Error.ArgumentNull(nameof(action)); - return ForEachAsyncCore(source, (x, ct) => action(x), cancellationToken); - } - - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (action == null) - throw Error.ArgumentNull(nameof(action)); + return Core(source, action, cancellationToken); - return ForEachAsyncCore(source, action, cancellationToken); - } + async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) + { + var index = 0; - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (action == null) - throw Error.ArgumentNull(nameof(action)); +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + _action(item, checked(index++)); + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); - return ForEachAsyncCore(source, (x, i, ct) => action(x, i), cancellationToken); + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + _action(e.Current, checked(index++)); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + } } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (action == null) throw Error.ArgumentNull(nameof(action)); - return ForEachAsyncCore(source, action, cancellationToken); - } + return Core(source, action, cancellationToken); - private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) - { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { - action(item); - } +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + await _action(item).ConfigureAwait(false); + } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - action(e.Current); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + await _action(e.Current).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } #endif + } } - private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + return Core(source, action, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { - await action(item, cancellationToken).ConfigureAwait(false); - } +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + await _action(item, _cancellationToken).ConfigureAwait(false); + } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - await action(e.Current, cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + await _action(e.Current, _cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } #endif + } } - private static async Task ForEachAsyncCore(IAsyncEnumerable source, Action action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { - var index = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (action == null) + throw Error.ArgumentNull(nameof(action)); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + return Core(source, action, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { - action(item, checked(index++)); - } + var index = 0; + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + await _action(item, checked(index++)).ConfigureAwait(false); + } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - action(e.Current, checked(index++)); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + await _action(e.Current, checked(index++)).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } #endif + } } - private static async Task ForEachAsyncCore(IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { - var index = 0; + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (action == null) + throw Error.ArgumentNull(nameof(action)); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + return Core(source, action, cancellationToken); + + async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { - await action(item, checked(index++), cancellationToken).ConfigureAwait(false); - } + var index = 0; + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + await _action(item, checked(index++), _cancellationToken).ConfigureAwait(false); + } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) + try { - await action(e.Current, checked(index++), cancellationToken).ConfigureAwait(false); + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + await _action(e.Current, checked(index++), _cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } #endif + } } } } From 7d459c9d859d6edc043ff3faf54f690699dc3cc2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 10 Jan 2019 21:38:14 -0800 Subject: [PATCH 681/862] Implementing more overloads of GroupBy. --- .../System/Linq/Operators/GroupBy.cs | 398 +++++++++++++----- 1 file changed, 299 insertions(+), 99 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 1d84c8399b..4fa54a5c7b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -20,15 +19,13 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func> keySelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer: null); -#if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => - new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); -#endif - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); #if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => + new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer); #endif @@ -42,15 +39,13 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer: null); -#if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => - new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); -#endif - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); #if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer); #endif @@ -64,105 +59,35 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); -#if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => - new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); -#endif - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => + new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer); #endif - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return source.GroupBy(keySelector, elementSelector, comparer: null).Select(g => resultSelector(g.Key, g)); - } - - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector) => + new GroupedResultAsyncEnumerable(source, keySelector, elementSelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return source.GroupBy(keySelector, elementSelector, comparer: null).Select(g => resultSelector(g.Key, g)); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) => + new GroupedResultAsyncEnumerable(source, keySelector, elementSelector, resultSelector, comparer); -#if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return source.GroupBy(keySelector, elementSelector, comparer: null).Select((g, ct) => resultSelector(g.Key, g, ct)); - } -#endif + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => + new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return source.GroupBy(keySelector, elementSelector, comparer).Select(g => resultSelector(g.Key, g)); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => + new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (keySelector == null) - throw Error.ArgumentNull(nameof(keySelector)); - if (elementSelector == null) - throw Error.ArgumentNull(nameof(elementSelector)); - if (resultSelector == null) - throw Error.ArgumentNull(nameof(resultSelector)); - - return source.GroupBy(keySelector, elementSelector, comparer).Select((g, ct) => resultSelector(g.Key, g, ct)); - } + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => + new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer: null); + + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => + new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer); #endif private sealed class GroupedResultAsyncEnumerable : AsyncIterator, IAsyncIListProvider @@ -295,7 +220,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); + _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -385,7 +310,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); + _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -434,6 +359,281 @@ async ValueTask Core() } #endif + private sealed class GroupedResultAsyncEnumerable : AsyncIterator, IAsyncIListProvider + { + private readonly IAsyncEnumerable _source; + private readonly Func _keySelector; + private readonly Func _elementSelector; + private readonly Func, TResult> _resultSelector; + private readonly IEqualityComparer _comparer; + + private Internal.Lookup _lookup; + private IEnumerator _enumerator; + + public GroupedResultAsyncEnumerable(IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) + { + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector)); + _resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector)); + _comparer = comparer; + } + + public override AsyncIteratorBase Clone() + { + return new GroupedResultAsyncEnumerable(_source, _keySelector, _elementSelector, _resultSelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + _enumerator.Dispose(); + _enumerator = null; + _lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _lookup = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); + _enumerator = _lookup.ApplyResultSelector(_resultSelector).GetEnumerator(); + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (_enumerator.MoveNext()) + { + _current = _enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return l.ToArray(_resultSelector); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return l.ToList(_resultSelector); + } + + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return new ValueTask(-1); + } + + return Core(); + + async ValueTask Core() + { + var l = await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + } + + private sealed class GroupedResultAsyncEnumerableWithTask : AsyncIterator, IAsyncIListProvider + { + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly Func> _elementSelector; + private readonly Func, ValueTask> _resultSelector; + private readonly IEqualityComparer _comparer; + + private Internal.LookupWithTask _lookup; + private IAsyncEnumerator _enumerator; + + public GroupedResultAsyncEnumerableWithTask(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) + { + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector)); + _resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector)); + _comparer = comparer; + } + + public override AsyncIteratorBase Clone() + { + return new GroupedResultAsyncEnumerableWithTask(_source, _keySelector, _elementSelector, _resultSelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); + _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArray(_resultSelector).ConfigureAwait(false); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToList(_resultSelector).ConfigureAwait(false); + } + + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return new ValueTask(-1); + } + + return Core(); + + async ValueTask Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + } + +#if !NO_DEEP_CANCELLATION + private sealed class GroupedResultAsyncEnumerableWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider + { + private readonly IAsyncEnumerable _source; + private readonly Func> _keySelector; + private readonly Func> _elementSelector; + private readonly Func, CancellationToken, ValueTask> _resultSelector; + private readonly IEqualityComparer _comparer; + + private Internal.LookupWithTask _lookup; + private IAsyncEnumerator _enumerator; + + public GroupedResultAsyncEnumerableWithTaskAndCancellation(IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) + { + _source = source ?? throw Error.ArgumentNull(nameof(source)); + _keySelector = keySelector ?? throw Error.ArgumentNull(nameof(keySelector)); + _elementSelector = elementSelector ?? throw Error.ArgumentNull(nameof(elementSelector)); + _resultSelector = resultSelector ?? throw Error.ArgumentNull(nameof(resultSelector)); + _comparer = comparer; + } + + public override AsyncIteratorBase Clone() + { + return new GroupedResultAsyncEnumerableWithTaskAndCancellation(_source, _keySelector, _elementSelector, _resultSelector, _comparer); + } + + public override async ValueTask DisposeAsync() + { + if (_enumerator != null) + { + await _enumerator.DisposeAsync().ConfigureAwait(false); + _enumerator = null; + _lookup = null; + } + + await base.DisposeAsync().ConfigureAwait(false); + } + + protected override async ValueTask MoveNextCore() + { + switch (_state) + { + case AsyncIteratorState.Allocated: + _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); + _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _state = AsyncIteratorState.Iterating; + goto case AsyncIteratorState.Iterating; + + case AsyncIteratorState.Iterating: + if (await _enumerator.MoveNextAsync().ConfigureAwait(false)) + { + _current = _enumerator.Current; + return true; + } + + await DisposeAsync().ConfigureAwait(false); + break; + } + + return false; + } + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToArray(_resultSelector, cancellationToken).ConfigureAwait(false); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + return await l.ToList(_resultSelector, cancellationToken).ConfigureAwait(false); + } + + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return new ValueTask(-1); + } + + return Core(); + + async ValueTask Core() + { + var l = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, cancellationToken).ConfigureAwait(false); + + return l.Count; + } + } + } +#endif + private sealed class GroupedAsyncEnumerable : AsyncIterator>, IAsyncIListProvider> { private readonly IAsyncEnumerable _source; From af84c58c2970e486ebd6a57bac7939ea4175e7f1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:46:28 -0800 Subject: [PATCH 682/862] Use async iterators for Zip. --- .../System/Linq/Operators/Zip.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 51bcf94c69..17d9580d58 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -20,7 +20,25 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + await using (var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) + { + yield return selector(e1.Current, e2.Current); + } + } + } + } +#else return new ZipAsyncIterator(first, second, selector); +#endif } public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) @@ -32,7 +50,25 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + await using (var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) + { + yield return await selector(e1.Current, e2.Current).ConfigureAwait(false); + } + } + } + } +#else return new ZipAsyncIteratorWithTask(first, second, selector); +#endif } #if !NO_DEEP_CANCELLATION @@ -45,10 +81,29 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + await using (var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) + { + yield return await selector(e1.Current, e2.Current, cancellationToken).ConfigureAwait(false); + } + } + } + } +#else return new ZipAsyncIteratorWithTaskAndCancellation(first, second, selector); +#endif } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class ZipAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _first; @@ -265,6 +320,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From 620478334d20c3b257c4afafa3bc923309504cd9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:46:53 -0800 Subject: [PATCH 683/862] Use async iterators for indexed Where overloads. --- .../System/Linq/Operators/Where.cs | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index c0d170a65d..991268728d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -34,7 +34,29 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + if (predicate(element, index)) + { + yield return element; + } + } + } +#else return new WhereEnumerableWithIndexAsyncIterator(source, predicate); +#endif } public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) @@ -78,7 +100,29 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + if (await predicate(element, index).ConfigureAwait(false)) + { + yield return element; + } + } + } +#else return new WhereEnumerableWithIndexAsyncIteratorWithTask(source, predicate); +#endif } #if !NO_DEEP_CANCELLATION @@ -89,7 +133,29 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + if (await predicate(element, index, cancellationToken).ConfigureAwait(false)) + { + yield return element; + } + } + } +#else return new WhereEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); +#endif } #endif @@ -162,6 +228,7 @@ protected override async ValueTask MoveNextCore() } } +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class WhereEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -229,6 +296,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif internal sealed class WhereEnumerableAsyncIteratorWithTask : AsyncIterator { @@ -360,6 +428,7 @@ protected override async ValueTask MoveNextCore() } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; @@ -496,6 +565,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif private sealed class WhereSelectEnumerableAsyncIterator : AsyncIterator From 6d298c9c85a3690a67d258d3daaf45bdbbece68e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:47:26 -0800 Subject: [PATCH 684/862] Use async iterators for indexed Select overloads. --- .../System/Linq/Operators/Select.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 7dc71b79c6..00b1a2c33f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -36,7 +36,26 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + yield return selector(element, index); + } + } +#else return new SelectEnumerableWithIndexAsyncIterator(source, selector); +#endif } public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) @@ -84,7 +103,26 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + yield return await selector(element, index).ConfigureAwait(false); + } + } +#else return new SelectEnumerableWithIndexAsyncIteratorWithTask(source, selector); +#endif } #if !NO_DEEP_CANCELLATION @@ -95,7 +133,26 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + yield return await selector(element, index, cancellationToken).ConfigureAwait(false); + } + } +#else return new SelectEnumerableWithIndexAsyncIteratorWithTaskAndCancellation(source, selector); +#endif } #endif @@ -160,6 +217,7 @@ protected override async ValueTask MoveNextCore() } } +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SelectEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _selector; @@ -223,6 +281,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif internal sealed class SelectIListIterator : AsyncIterator, IAsyncIListProvider { @@ -464,6 +523,7 @@ protected override async ValueTask MoveNextCore() } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _selector; @@ -592,6 +652,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif // NB: LINQ to Objects implements IPartition for this. However, it seems incorrect to do so in a trivial From 59984d24fdcfb43ed1e0de4b23539a322bb21cc8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:47:42 -0800 Subject: [PATCH 685/862] Use async iterators for SkipLast. --- .../System/Linq/Operators/SkipLast.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index d15ad9e837..c4bf6c9605 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -27,9 +27,40 @@ public static IAsyncEnumerable SkipLast(this IAsyncEnumerable< count = 0; } +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var queue = new Queue(); + + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + if (queue.Count == count) + { + do + { + yield return queue.Dequeue(); + queue.Enqueue(e.Current); + } + while (await e.MoveNextAsync()); + break; + } + else + { + queue.Enqueue(e.Current); + } + } + } + } +#else return new SkipLastAsyncIterator(source, count); +#endif } +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SkipLastAsyncIterator : AsyncIterator { private readonly int _count; @@ -97,5 +128,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 64a37ef68d8b2036b3416b2bbd10d9eb6ed92f67 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:47:51 -0800 Subject: [PATCH 686/862] Use async iterators for TakeLast. --- .../System/Linq/Operators/TakeLast.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 794e51af8a..f687ed0a2d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -20,9 +20,55 @@ public static IAsyncEnumerable TakeLast(this IAsyncEnumerable< return Empty(); } +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + Queue queue; + + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + queue = new Queue(); + queue.Enqueue(e.Current); + + while (await e.MoveNextAsync()) + { + if (queue.Count < count) + { + queue.Enqueue(e.Current); + } + else + { + do + { + queue.Dequeue(); + queue.Enqueue(e.Current); + } + while (await e.MoveNextAsync()); + break; + } + } + } + + Debug.Assert(queue.Count <= count); + do + { + yield return queue.Dequeue(); + } + while (queue.Count > 0); + } +#else return new TakeLastAsyncIterator(source, count); +#endif } +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class TakeLastAsyncIterator : AsyncIterator { private readonly int _count; @@ -115,5 +161,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 998fbc2827d6dd8b506fbd46e9f344694a3bd545 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:48:25 -0800 Subject: [PATCH 687/862] Use async iterators for TakeWhile. --- .../System/Linq/Operators/TakeWhile.cs | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 6e2c81005e..ccf05ae02f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -18,7 +18,24 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (!predicate(element)) + { + break; + } + + yield return element; + } + } +#else return new TakeWhileAsyncIterator(source, predicate); +#endif } public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func predicate) @@ -28,7 +45,31 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + if (!predicate(element, index)) + { + break; + } + + yield return element; + } + } +#else return new TakeWhileWithIndexAsyncIterator(source, predicate); +#endif } public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) @@ -38,7 +79,24 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (!await predicate(element).ConfigureAwait(false)) + { + break; + } + + yield return element; + } + } +#else return new TakeWhileAsyncIteratorWithTask(source, predicate); +#endif } #if !NO_DEEP_CANCELLATION @@ -49,7 +107,24 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (!await predicate(element, cancellationToken).ConfigureAwait(false)) + { + break; + } + + yield return element; + } + } +#else return new TakeWhileAsyncIteratorWithTaskAndCancellation(source, predicate); +#endif } #endif @@ -60,7 +135,31 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + if (!await predicate(element, index).ConfigureAwait(false)) + { + break; + } + + yield return element; + } + } +#else return new TakeWhileWithIndexAsyncIteratorWithTask(source, predicate); +#endif } #if !NO_DEEP_CANCELLATION @@ -71,10 +170,35 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + if (!await predicate(element, index, cancellationToken).ConfigureAwait(false)) + { + break; + } + + yield return element; + } + } +#else return new TakeWhileWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); +#endif } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class TakeWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -477,6 +601,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From 2274c02dafe3f53bd4e97c5c0c8c98ae8c796a1d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:48:39 -0800 Subject: [PATCH 688/862] Use async iterators for SkipWhile. --- .../System/Linq/Operators/SkipWhile.cs | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 51d2eeb081..8972767dd1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -18,7 +18,34 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var element = e.Current; + + if (!predicate(element)) + { + yield return element; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + + yield break; + } + } + } + } +#else return new SkipWhileAsyncIterator(source, predicate); +#endif } public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func predicate) @@ -28,7 +55,41 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + var index = -1; + + while (await e.MoveNextAsync()) + { + checked + { + index++; + } + + var element = e.Current; + + if (!predicate(element, index)) + { + yield return element; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + + yield break; + } + } + } + } +#else return new SkipWhileWithIndexAsyncIterator(source, predicate); +#endif } public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) @@ -38,7 +99,34 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var element = e.Current; + + if (!await predicate(element).ConfigureAwait(false)) + { + yield return element; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + + yield break; + } + } + } + } +#else return new SkipWhileAsyncIteratorWithTask(source, predicate); +#endif } #if !NO_DEEP_CANCELLATION @@ -49,7 +137,34 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (await e.MoveNextAsync()) + { + var element = e.Current; + + if (!await predicate(element, cancellationToken).ConfigureAwait(false)) + { + yield return element; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + + yield break; + } + } + } + } +#else return new SkipWhileAsyncIteratorWithTaskAndCancellation(source, predicate); +#endif } #endif @@ -60,7 +175,41 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + var index = -1; + + while (await e.MoveNextAsync()) + { + checked + { + index++; + } + + var element = e.Current; + + if (!await predicate(element, index).ConfigureAwait(false)) + { + yield return element; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + + yield break; + } + } + } + } +#else return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); +#endif } #if !NO_DEEP_CANCELLATION @@ -71,10 +220,45 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + var index = -1; + + while (await e.MoveNextAsync()) + { + checked + { + index++; + } + + var element = e.Current; + + if (!await predicate(element, index, cancellationToken).ConfigureAwait(false)) + { + yield return element; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + + yield break; + } + } + } + } +#else return new SkipWhileWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); +#endif } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SkipWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -557,6 +741,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From b63320e979e38422af3e41b3c4c9d1a66decf73d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:49:02 -0800 Subject: [PATCH 689/862] Use async iterators for various SelectMany overloads. --- .../System/Linq/Operators/SelectMany.cs | 197 ++++++++++++++++++ Ix.NET/Source/global.json | 3 - 2 files changed, 197 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index d7d14031f1..1de6760d0b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -50,7 +50,31 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + int index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + var inner = selector(element, index); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return subElement; + } + } + } +#else return new SelectManyWithIndexAsyncIterator(source, selector); +#endif } public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) @@ -60,7 +84,31 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + int index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + var inner = selector(element, index); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return subElement; + } + } + } +#else return new SelectManyWithIndexAsyncIteratorWithTask(source, selector); +#endif } #if !NO_DEEP_CANCELLATION @@ -71,7 +119,31 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + int index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + var inner = await selector(element, index, cancellationToken).ConfigureAwait(false); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return subElement; + } + } + } +#else return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(source, selector); +#endif } #endif @@ -84,7 +156,24 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) + { + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var inner = selector(element); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return resultSelector(element, subElement); + } + } + } +#else return new SelectManyAsyncIterator(source, selector, resultSelector); +#endif } public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) @@ -96,7 +185,24 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) + { + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var inner = await selector(element).ConfigureAwait(false); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return await resultSelector(element, subElement).ConfigureAwait(false); + } + } + } +#else return new SelectManyAsyncIteratorWithTask(source, selector, resultSelector); +#endif } #if !NO_DEEP_CANCELLATION @@ -109,7 +215,24 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) + { + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var inner = await selector(element, cancellationToken).ConfigureAwait(false); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return await resultSelector(element, subElement, cancellationToken).ConfigureAwait(false); + } + } + } +#else return new SelectManyAsyncIteratorWithTaskAndCancellation(source, selector, resultSelector); +#endif } #endif @@ -122,7 +245,31 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) + { + int index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + var inner = selector(element, index); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return resultSelector(element, subElement); + } + } + } +#else return new SelectManyWithIndexAsyncIterator(source, selector, resultSelector); +#endif } public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) @@ -134,7 +281,31 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) + { + int index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + var inner = await selector(element, index).ConfigureAwait(false); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return await resultSelector(element, subElement).ConfigureAwait(false); + } + } + } +#else return new SelectManyWithIndexAsyncIteratorWithTask(source, selector, resultSelector); +#endif } #if !NO_DEEP_CANCELLATION @@ -147,7 +318,31 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) + { + int index = -1; + + await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + checked + { + index++; + } + + var inner = await selector(element, index, cancellationToken).ConfigureAwait(false); + + await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return await resultSelector(element, subElement, cancellationToken).ConfigureAwait(false); + } + } + } +#else return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(source, selector, resultSelector); +#endif } #endif @@ -426,6 +621,7 @@ protected override async ValueTask MoveNextCore() } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SelectManyAsyncIterator : AsyncIterator { private const int State_Source = 1; @@ -1336,6 +1532,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index 50c5a4d98e..443c4bfae8 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,7 +1,4 @@ { - "sdk": { - "version": "3.0.100-preview" - }, "msbuild-sdks": { "MSBuild.Sdk.Extras": "2.0.0-preview.14" } From 1b093d6d3be18e07f92982ba7fbce86d65e25449 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 09:57:53 -0800 Subject: [PATCH 690/862] Fix collectionSelector parameter name in SelectMany. --- .../System/Linq/AsyncQueryable.Generated.cs | 60 +++++++++---------- .../System/Linq/Operators/SelectMany.cs | 60 +++++++++---------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index ad48fbf221..1356b0810d 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -3478,99 +3478,99 @@ public static IAsyncQueryable SelectMany(this IAsyncQ #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector, Expression> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector, Expression>> resultSelector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, selector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 1de6760d0b..ba43a3c1ba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -147,12 +147,12 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> collectionSelector, Func resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + if (collectionSelector == null) + throw Error.ArgumentNull(nameof(collectionSelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); @@ -163,7 +163,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { - var inner = selector(element); + var inner = collectionSelector(element); await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) { @@ -172,16 +172,16 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } #else - return new SelectManyAsyncIterator(source, selector, resultSelector); + return new SelectManyAsyncIterator(source, collectionSelector, resultSelector); #endif } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + if (collectionSelector == null) + throw Error.ArgumentNull(nameof(collectionSelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); @@ -192,7 +192,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { - var inner = await selector(element).ConfigureAwait(false); + var inner = await collectionSelector(element).ConfigureAwait(false); await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) { @@ -201,17 +201,17 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } #else - return new SelectManyAsyncIteratorWithTask(source, selector, resultSelector); + return new SelectManyAsyncIteratorWithTask(source, collectionSelector, resultSelector); #endif } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + if (collectionSelector == null) + throw Error.ArgumentNull(nameof(collectionSelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); @@ -222,7 +222,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { await foreach (var element in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { - var inner = await selector(element, cancellationToken).ConfigureAwait(false); + var inner = await collectionSelector(element, cancellationToken).ConfigureAwait(false); await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) { @@ -231,17 +231,17 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } #else - return new SelectManyAsyncIteratorWithTaskAndCancellation(source, selector, resultSelector); + return new SelectManyAsyncIteratorWithTaskAndCancellation(source, collectionSelector, resultSelector); #endif } #endif - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> selector, Func resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func> collectionSelector, Func resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + if (collectionSelector == null) + throw Error.ArgumentNull(nameof(collectionSelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); @@ -259,7 +259,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) index++; } - var inner = selector(element, index); + var inner = collectionSelector(element, index); await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) { @@ -268,16 +268,16 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } #else - return new SelectManyWithIndexAsyncIterator(source, selector, resultSelector); + return new SelectManyWithIndexAsyncIterator(source, collectionSelector, resultSelector); #endif } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + if (collectionSelector == null) + throw Error.ArgumentNull(nameof(collectionSelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); @@ -295,7 +295,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) index++; } - var inner = await selector(element, index).ConfigureAwait(false); + var inner = await collectionSelector(element, index).ConfigureAwait(false); await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) { @@ -304,17 +304,17 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } #else - return new SelectManyWithIndexAsyncIteratorWithTask(source, selector, resultSelector); + return new SelectManyWithIndexAsyncIteratorWithTask(source, collectionSelector, resultSelector); #endif } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector, Func> resultSelector) + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); + if (collectionSelector == null) + throw Error.ArgumentNull(nameof(collectionSelector)); if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); @@ -332,7 +332,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) index++; } - var inner = await selector(element, index, cancellationToken).ConfigureAwait(false); + var inner = await collectionSelector(element, index, cancellationToken).ConfigureAwait(false); await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) { @@ -341,7 +341,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } #else - return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(source, selector, resultSelector); + return new SelectManyWithIndexAsyncIteratorWithTaskAndCancellation(source, collectionSelector, resultSelector); #endif } #endif From 090adf7d2216f5fe41c816aa8c490f210254fac6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 11:39:00 -0800 Subject: [PATCH 691/862] Fix #if condition. --- .../Source/System.Linq.Async/System/Linq/Operators/Select.cs | 4 ++-- .../System.Linq.Async/System/Linq/Operators/SkipLast.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/SkipWhile.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/TakeLast.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/TakeWhile.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/Where.cs | 4 ++-- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index 00b1a2c33f..b92909f450 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -217,7 +217,7 @@ protected override async ValueTask MoveNextCore() } } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class SelectEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _selector; @@ -523,7 +523,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _selector; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index c4bf6c9605..7d92505cc2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -60,7 +60,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class SkipLastAsyncIterator : AsyncIterator { private readonly int _count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 8972767dd1..c888e04048 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -258,7 +258,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class SkipWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index f687ed0a2d..8eb27366d4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -68,7 +68,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class TakeLastAsyncIterator : AsyncIterator { private readonly int _count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index ccf05ae02f..9ac3e3e53a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -198,7 +198,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class TakeWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 991268728d..7a3ab2c64a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -228,7 +228,7 @@ protected override async ValueTask MoveNextCore() } } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class WhereEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -428,7 +428,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 17d9580d58..d378b8d476 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -103,7 +103,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class ZipAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _first; From 9d30984de23aa65b3d123edf4036aa7047ee18b0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 11:47:52 -0800 Subject: [PATCH 692/862] Use async iterators for Except. --- .../System/Linq/Operators/Except.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 53dbaa7eb7..6c457122b0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -20,9 +20,32 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var set = new Set(comparer); + + await foreach (var element in second.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + set.Add(element); + } + + await foreach (var element in first.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (set.Add(element)) + { + yield return element; + } + } + } +#else return new ExceptAsyncIterator(first, second, comparer); +#endif } +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class ExceptAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; @@ -100,5 +123,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 41efe2944dcfc97bc641179b2c8b9c8e02eea11b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 11:48:00 -0800 Subject: [PATCH 693/862] Use async iterators for Intersect. --- .../System/Linq/Operators/Intersect.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 80a7118008..4505fb7d1d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -20,9 +20,32 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable if (second == null) throw Error.ArgumentNull(nameof(second)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR + return Create(Core); + + async IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var set = new Set(comparer); + + await foreach (var element in second.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + set.Add(element); + } + + await foreach (var element in first.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (set.Remove(element)) + { + yield return element; + } + } + } +#else return new IntersectAsyncIterator(first, second, comparer); +#endif } +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class IntersectAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; @@ -101,5 +124,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 9056d39084422ced422ffeddee43ae48646f3a21 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 11:53:35 -0800 Subject: [PATCH 694/862] Use enumerators for iterators at the moment. --- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/Intersect.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 6c457122b0..85602ad1d2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -23,7 +23,7 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable Core(CancellationToken cancellationToken) + async IAsyncEnumerator Core(CancellationToken cancellationToken) { var set = new Set(comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 4505fb7d1d..3ec0168353 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -23,7 +23,7 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable #if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR return Create(Core); - async IAsyncEnumerable Core(CancellationToken cancellationToken) + async IAsyncEnumerator Core(CancellationToken cancellationToken) { var set = new Set(comparer); From 3f91f9f9686a54589b79e88d0e6b42b803f45505 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 11 Jan 2019 12:02:26 -0800 Subject: [PATCH 695/862] Add link to pull request. --- Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs | 2 +- .../Source/System.Linq.Async/System/Linq/Operators/Intersect.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 85602ad1d2..d35f9fff1c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable Core(CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 3ec0168353..489799d5b9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable if (second == null) throw Error.ArgumentNull(nameof(second)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) From 1449b9663df65062877b89294dde00200624ab40 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 17:43:53 -0800 Subject: [PATCH 696/862] Iterator-based implementation of GroupJoin and Join. --- .../System/Linq/Operators/GroupJoin.cs | 71 +++++++++++ .../System/Linq/Operators/Join.cs | 119 ++++++++++++++++++ 2 files changed, 190 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 1e4447080c..c94508a24d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -26,7 +26,30 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (await e.MoveNextAsync()) + { + var lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + + do + { + var item = e.Current; + var outerKey = outerKeySelector(item); + yield return resultSelector(item, lookup[outerKey]); + } + while (await e.MoveNextAsync()); + } + } + } +#else return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); +#endif } public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => @@ -45,7 +68,30 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (await e.MoveNextAsync()) + { + var lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + + do + { + var item = e.Current; + var outerKey = await outerKeySelector(item).ConfigureAwait(false); + yield return await resultSelector(item, lookup[outerKey]).ConfigureAwait(false); + } + while (await e.MoveNextAsync()); + } + } + } +#else return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); +#endif } #if !NO_DEEP_CANCELLATION @@ -65,10 +111,34 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (await e.MoveNextAsync()) + { + var lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + + do + { + var item = e.Current; + var outerKey = await outerKeySelector(item, cancellationToken).ConfigureAwait(false); + yield return await resultSelector(item, lookup[outerKey], cancellationToken).ConfigureAwait(false); + } + while (await e.MoveNextAsync()); + } + } + } +#else return new GroupJoinAsyncEnumerableWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); +#endif } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class GroupJoinAsyncEnumerable : IAsyncEnumerable { private readonly IEqualityComparer _comparer; @@ -363,6 +433,7 @@ public async ValueTask MoveNextAsync() public ValueTask DisposeAsync() => _outer.DisposeAsync(); } } +#endif #endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 4fe17e9f17..c1f2a28c23 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -27,7 +27,46 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (await e.MoveNextAsync()) + { + var lookup = await Internal.Lookup.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + + if (lookup.Count != 0) + { + do + { + var item = e.Current; + + var outerKey = outerKeySelector(item); + + var g = lookup.GetGrouping(outerKey, create: false); + + if (g != null) + { + var count = g._count; + var elements = g._elements; + + for (var i = 0; i != count; ++i) + { + yield return resultSelector(item, elements[i]); + } + } + } + while (await e.MoveNextAsync()); + } + } + } + } +#else return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); +#endif } public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => @@ -46,7 +85,46 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (await e.MoveNextAsync()) + { + var lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + + if (lookup.Count != 0) + { + do + { + var item = e.Current; + + var outerKey = await outerKeySelector(item).ConfigureAwait(false); + + var g = lookup.GetGrouping(outerKey, create: false); + + if (g != null) + { + var count = g._count; + var elements = g._elements; + + for (var i = 0; i != count; ++i) + { + yield return await resultSelector(item, elements[i]).ConfigureAwait(false); + } + } + } + while (await e.MoveNextAsync()); + } + } + } + } +#else return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); +#endif } #if !NO_DEEP_CANCELLATION @@ -66,10 +144,50 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); +#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (await e.MoveNextAsync()) + { + var lookup = await Internal.LookupWithTask.CreateForJoinAsync(inner, innerKeySelector, comparer, cancellationToken).ConfigureAwait(false); + + if (lookup.Count != 0) + { + do + { + var item = e.Current; + + var outerKey = await outerKeySelector(item, cancellationToken).ConfigureAwait(false); + + var g = lookup.GetGrouping(outerKey, create: false); + + if (g != null) + { + var count = g._count; + var elements = g._elements; + + for (var i = 0; i != count; ++i) + { + yield return await resultSelector(item, elements[i], cancellationToken).ConfigureAwait(false); + } + } + } + while (await e.MoveNextAsync()); + } + } + } + } +#else return new JoinAsyncIteratorWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); +#endif } #endif +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class JoinAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _outer; @@ -451,6 +569,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From 5cddc62b531842eb0113042ef2b16e28e8d362df Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 17:46:13 -0800 Subject: [PATCH 697/862] SelectMany can implement IAsyncIListProvider. --- .../System/Linq/Operators/SelectMany.cs | 271 +++++++++++++++++- .../System/Linq/Operators/Utilities.cs | 63 ++++ 2 files changed, 330 insertions(+), 4 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index ba43a3c1ba..116b4a6cdb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -346,7 +346,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif - private sealed class SelectManyAsyncIterator : AsyncIterator + private sealed class SelectManyAsyncIterator : AsyncIterator, IAsyncIListProvider { private const int State_Source = 1; private const int State_Result = 2; @@ -389,6 +389,91 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return new ValueTask(-1); + } + + return Core(cancellationToken); + + async ValueTask Core(CancellationToken _cancellationToken) + { + var count = 0; + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + checked + { + count += await _selector(element).CountAsync().ConfigureAwait(false); + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + checked + { + count += await _selector(e.Current).CountAsync().ConfigureAwait(false); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return count; + } + } + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + // REVIEW: Substitute for SparseArrayBuilder logic once we have access to that. + + var list = await ToListAsync(cancellationToken).ConfigureAwait(false); + + return list.ToArray(); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var list = new List(); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var items = _selector(element); + + await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); + } +#else + var e = _source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var items = _selector(e.Current); + + await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return list; + } + protected override async ValueTask MoveNextCore() { switch (_state) @@ -437,7 +522,7 @@ protected override async ValueTask MoveNextCore() } } - private sealed class SelectManyAsyncIteratorWithTask : AsyncIterator + private sealed class SelectManyAsyncIteratorWithTask : AsyncIterator, IAsyncIListProvider { private const int State_Source = 1; private const int State_Result = 2; @@ -480,6 +565,95 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return new ValueTask(-1); + } + + return Core(cancellationToken); + + async ValueTask Core(CancellationToken _cancellationToken) + { + var count = 0; + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var items = await _selector(element).ConfigureAwait(false); + + checked + { + count += await items.CountAsync().ConfigureAwait(false); + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var items = await _selector(e.Current).ConfigureAwait(false); + + checked + { + count += await items.CountAsync().ConfigureAwait(false); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return count; + } + } + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + // REVIEW: Substitute for SparseArrayBuilder logic once we have access to that. + + var list = await ToListAsync(cancellationToken).ConfigureAwait(false); + + return list.ToArray(); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var list = new List(); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var items = await _selector(element).ConfigureAwait(false); + + await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); + } +#else + var e = _source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var items = await _selector(e.Current).ConfigureAwait(false); + + await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return list; + } + protected override async ValueTask MoveNextCore() { switch (_state) @@ -529,7 +703,7 @@ protected override async ValueTask MoveNextCore() } #if !NO_DEEP_CANCELLATION - private sealed class SelectManyAsyncIteratorWithTaskAndCancellation : AsyncIterator + private sealed class SelectManyAsyncIteratorWithTaskAndCancellation : AsyncIterator, IAsyncIListProvider { private const int State_Source = 1; private const int State_Result = 2; @@ -572,6 +746,95 @@ public override async ValueTask DisposeAsync() await base.DisposeAsync().ConfigureAwait(false); } + public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancellationToken) + { + if (onlyIfCheap) + { + return new ValueTask(-1); + } + + return Core(cancellationToken); + + async ValueTask Core(CancellationToken _cancellationToken) + { + var count = 0; + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + { + var items = await _selector(element, _cancellationToken).ConfigureAwait(false); + + checked + { + count += await items.CountAsync().ConfigureAwait(false); + } + } +#else + var e = _source.GetAsyncEnumerator(_cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var items = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + checked + { + count += await items.CountAsync().ConfigureAwait(false); + } + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return count; + } + } + + public async ValueTask ToArrayAsync(CancellationToken cancellationToken) + { + // REVIEW: Substitute for SparseArrayBuilder logic once we have access to that. + + var list = await ToListAsync(cancellationToken).ConfigureAwait(false); + + return list.ToArray(); + } + + public async ValueTask> ToListAsync(CancellationToken cancellationToken) + { + var list = new List(); + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + var items = await _selector(element, cancellationToken).ConfigureAwait(false); + + await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); + } +#else + var e = _source.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + var items = await _selector(e.Current, cancellationToken).ConfigureAwait(false); + + await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + + return list; + } + protected override async ValueTask MoveNextCore() { switch (_state) @@ -621,7 +884,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) private sealed class SelectManyAsyncIterator : AsyncIterator { private const int State_Source = 1; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs new file mode 100644 index 0000000000..994c1f1920 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + internal static class Utilities + { + public static async ValueTask AddRangeAsync(this List list, IAsyncEnumerable collection, CancellationToken cancellationToken) + { + if (collection is IEnumerable enumerable) + { + list.AddRange(enumerable); + return; + } + + if (collection is IAsyncIListProvider listProvider) + { + var count = await listProvider.GetCountAsync(onlyIfCheap: true, cancellationToken).ConfigureAwait(false); + + if (count == 0) + { + return; + } + + if (count > 0) + { + var newCount = list.Count + count; + + if (list.Capacity < newCount) + { + list.Capacity = newCount; + } + } + } + +#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' + await foreach (var item in collection.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + list.Add(item); + } +#else + var e = collection.GetAsyncEnumerator(cancellationToken); + + try + { + while (await e.MoveNextAsync().ConfigureAwait(false)) + { + list.Add(e.Current); + } + } + finally + { + await e.DisposeAsync().ConfigureAwait(false); + } +#endif + } + } +} From ac470e6889b6c12d054c2de83719c7f2a5072eab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 17:51:10 -0800 Subject: [PATCH 698/862] Remove ASYNC_ITERATOR_CAN_RETURN_AETOR; this is now supported in the latest preview. --- .../System/Linq/Operators/Except.cs | 4 ++-- .../System/Linq/Operators/GroupJoin.cs | 8 ++++---- .../System/Linq/Operators/Intersect.cs | 4 ++-- .../System/Linq/Operators/Join.cs | 8 ++++---- .../System/Linq/Operators/Select.cs | 10 +++++----- .../System/Linq/Operators/SelectMany.cs | 20 +++++++++---------- .../System/Linq/Operators/SkipLast.cs | 4 ++-- .../System/Linq/Operators/SkipWhile.cs | 14 ++++++------- .../System/Linq/Operators/TakeLast.cs | 4 ++-- .../System/Linq/Operators/TakeWhile.cs | 14 ++++++------- .../System/Linq/Operators/Where.cs | 10 +++++----- .../System/Linq/Operators/Zip.cs | 8 ++++---- 12 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index d35f9fff1c..05e5bf28c5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -45,7 +45,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class ExceptAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index c94508a24d..dfeb2e57cb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -26,7 +26,7 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -68,7 +68,7 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -111,7 +111,7 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -138,7 +138,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class GroupJoinAsyncEnumerable : IAsyncEnumerable { private readonly IEqualityComparer _comparer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 489799d5b9..060e7dbfc4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable if (second == null) throw Error.ArgumentNull(nameof(second)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -45,7 +45,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class IntersectAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index c1f2a28c23..0a5f862761 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -27,7 +27,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -85,7 +85,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -144,7 +144,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -187,7 +187,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class JoinAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _outer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index b92909f450..d0119f1200 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -36,7 +36,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -103,7 +103,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -133,7 +133,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -217,7 +217,7 @@ protected override async ValueTask MoveNextCore() } } -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SelectEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _selector; @@ -523,7 +523,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _selector; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 116b4a6cdb..3b11f80b36 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -50,7 +50,7 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -84,7 +84,7 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -119,7 +119,7 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -156,7 +156,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -185,7 +185,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -215,7 +215,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -245,7 +245,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -281,7 +281,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -318,7 +318,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -884,7 +884,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SelectManyAsyncIterator : AsyncIterator { private const int State_Source = 1; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 7d92505cc2..b1c17fe029 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -27,7 +27,7 @@ public static IAsyncEnumerable SkipLast(this IAsyncEnumerable< count = 0; } -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -60,7 +60,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SkipLastAsyncIterator : AsyncIterator { private readonly int _count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index c888e04048..0cc660c4c4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -55,7 +55,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -99,7 +99,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -137,7 +137,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -175,7 +175,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -220,7 +220,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -258,7 +258,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class SkipWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 8eb27366d4..357d6f97f8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable TakeLast(this IAsyncEnumerable< return Empty(); } -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -68,7 +68,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class TakeLastAsyncIterator : AsyncIterator { private readonly int _count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 9ac3e3e53a..dd1ae27fad 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -45,7 +45,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -79,7 +79,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -107,7 +107,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -135,7 +135,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -170,7 +170,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -198,7 +198,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class TakeWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 7a3ab2c64a..ea73f39276 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -34,7 +34,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -100,7 +100,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -133,7 +133,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -228,7 +228,7 @@ protected override async ValueTask MoveNextCore() } } -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class WhereEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -428,7 +428,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index d378b8d476..32ffccf57c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -50,7 +50,7 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -81,7 +81,7 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR // https://github.com/dotnet/roslyn/pull/31114 +#if CSHARP8 && USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -103,7 +103,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR && ASYNC_ITERATOR_CAN_RETURN_AETOR) +#if !(CSHARP8 && USE_ASYNC_ITERATOR) private sealed class ZipAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _first; From e11f6aed52724a40231bd27b006789447272dcba Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 18:45:09 -0800 Subject: [PATCH 699/862] Fix USE_ASYNC_ITERATOR build. --- .../System.Linq.Async/System/Linq/Operators/Except.cs | 1 + .../System.Linq.Async/System/Linq/Operators/GroupJoin.cs | 6 +++--- .../System.Linq.Async/System/Linq/Operators/Intersect.cs | 1 + .../System.Linq.Async/System/Linq/Operators/SelectMany.cs | 2 +- .../System.Linq.Async/System/Linq/Operators/SkipLast.cs | 1 + .../System.Linq.Async/System/Linq/Operators/TakeLast.cs | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 05e5bf28c5..457dbc922e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index dfeb2e57cb..b4ee5cf584 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -41,7 +41,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var item = e.Current; var outerKey = outerKeySelector(item); - yield return resultSelector(item, lookup[outerKey]); + yield return resultSelector(item, lookup[outerKey].ToAsyncEnumerable()); } while (await e.MoveNextAsync()); } @@ -83,7 +83,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var item = e.Current; var outerKey = await outerKeySelector(item).ConfigureAwait(false); - yield return await resultSelector(item, lookup[outerKey]).ConfigureAwait(false); + yield return await resultSelector(item, lookup[outerKey].ToAsyncEnumerable()).ConfigureAwait(false); } while (await e.MoveNextAsync()); } @@ -126,7 +126,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var item = e.Current; var outerKey = await outerKeySelector(item, cancellationToken).ConfigureAwait(false); - yield return await resultSelector(item, lookup[outerKey], cancellationToken).ConfigureAwait(false); + yield return await resultSelector(item, lookup[outerKey].ToAsyncEnumerable(), cancellationToken).ConfigureAwait(false); } while (await e.MoveNextAsync()); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 060e7dbfc4..28d372dca3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 3b11f80b36..c48f7e0108 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -98,7 +98,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) index++; } - var inner = selector(element, index); + var inner = await selector(element, index).ConfigureAwait(false); await foreach (var subElement in inner.WithCancellation(cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index b1c17fe029..6364baf5ea 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 357d6f97f8..509570cee7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq From e576f233031b56afd381c008cfd16e38f3d5d4c9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 18:55:22 -0800 Subject: [PATCH 700/862] Remove AETOR_HAS_CT checks. CancellationToken is now supported on the interface. --- .../System/Linq/AsyncEnumerableHelpers.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 12 +-- .../System/Linq/Operators/All.cs | 6 +- .../System/Linq/Operators/Any.cs | 6 +- .../System/Linq/Operators/AppendPrepend.cs | 8 +- .../System/Linq/Operators/Concat.cs | 2 +- .../System/Linq/Operators/Contains.cs | 4 +- .../System/Linq/Operators/Count.cs | 8 +- .../System/Linq/Operators/ElementAt.cs | 2 +- .../Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/ForEach.cs | 12 +-- .../System/Linq/Operators/LastOrDefault.cs | 8 +- .../System/Linq/Operators/LongCount.cs | 8 +- .../System/Linq/Operators/Lookup.cs | 18 ++--- .../System/Linq/Operators/SelectMany.cs | 12 +-- .../System/Linq/Operators/Sum.Generated.cs | 80 +++++++++---------- .../System/Linq/Operators/ToDictionary.cs | 12 +-- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/Union.cs | 2 +- .../System/Linq/Operators/Utilities.cs | 2 +- 21 files changed, 105 insertions(+), 105 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index f753e9b6fa..e701307bcd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -162,7 +162,7 @@ internal static async Task> ToSet(IAsyncEnumerable source, IEqualit { var set = new Set(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (T item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 5f8e104a58..44e144acc0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -190,7 +190,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { var acc = _seed; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); @@ -228,7 +228,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { var acc = _seed; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); @@ -267,7 +267,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _see { var acc = _seed; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); @@ -308,7 +308,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { var acc = _seed; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); @@ -348,7 +348,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { var acc = _seed; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); @@ -389,7 +389,7 @@ async Task Core(IAsyncEnumerable _source, TAccumulate _seed, F { var acc = _seed; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 7d08cce8a9..19db08b694 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -21,7 +21,7 @@ public static Task AllAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!_predicate(item)) @@ -61,7 +61,7 @@ public static Task AllAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { @@ -103,7 +103,7 @@ public static Task AllAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 0e6ca0c56b..29e7cc06df 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -50,7 +50,7 @@ public static Task AnyAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_predicate(item)) @@ -90,7 +90,7 @@ public static Task AnyAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item).ConfigureAwait(false)) @@ -131,7 +131,7 @@ public static Task AnyAsync(this IAsyncEnumerable source async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index b7a97c2aa2..1478971b10 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -206,7 +206,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; @@ -251,7 +251,7 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(_item); } -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); @@ -428,7 +428,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; @@ -471,7 +471,7 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(n.Item); } -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 1afb89ea08..6dba7e4fb6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -84,7 +84,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation break; } -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index d6e9805bd7..324ca50d49 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -28,7 +28,7 @@ public static Task ContainsAsync(this IAsyncEnumerable s async Task Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (EqualityComparer.Default.Equals(item, _value)) @@ -64,7 +64,7 @@ async Task Core(IAsyncEnumerable _source, TSource _value, Cancell async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_comparer.Equals(item, _value)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index c03f464bd9..473d8cdffc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -32,7 +32,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cance { var count = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -76,7 +76,7 @@ async Task Core(IAsyncEnumerable _source, Func _pre { var count = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_predicate(item)) @@ -126,7 +126,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, int _index, Cancella if (_index >= 0) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index acbec37b33..8cbb0f2535 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -40,7 +40,7 @@ async Task Core(IAsyncEnumerable _source, int _index, Cancella } else { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 4fd046b939..f33a5d1332 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -28,7 +28,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item); @@ -64,7 +64,7 @@ async Task Core(IAsyncEnumerable _source, Action _action, { var index = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item, checked(index++)); @@ -98,7 +98,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item).ConfigureAwait(false); @@ -127,7 +127,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item, _cancellationToken).ConfigureAwait(false); @@ -163,7 +163,7 @@ async Task Core(IAsyncEnumerable _source, Func _act { var index = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item, checked(index++)).ConfigureAwait(false); @@ -199,7 +199,7 @@ async Task Core(IAsyncEnumerable _source, Func> Core(IAsyncEnumerable _source, Cancella var last = default(TSource); var hasLast = false; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { hasLast = true; @@ -136,7 +136,7 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable Core(IAsyncEnumerable _source, CancellationToken _canc { var count = 0L; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -65,7 +65,7 @@ async Task Core(IAsyncEnumerable _source, Func _pr { var count = 0L; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_predicate(item)) @@ -115,7 +115,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -132,7 +132,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -164,7 +164,7 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { var lookup = new Lookup(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -419,7 +419,7 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -462,7 +462,7 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); @@ -504,7 +504,7 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -540,7 +540,7 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); @@ -573,7 +573,7 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -612,7 +612,7 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index c48f7e0108..2e9b44fd43 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -402,7 +402,7 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -446,7 +446,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = _selector(element); @@ -578,7 +578,7 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var items = await _selector(element).ConfigureAwait(false); @@ -626,7 +626,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = await _selector(element).ConfigureAwait(false); @@ -759,7 +759,7 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var items = await _selector(element, _cancellationToken).ConfigureAwait(false); @@ -807,7 +807,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = await _selector(element, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index b477882cde..9e9a1ff98c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -21,7 +21,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _cancellat { var sum = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (int value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -65,7 +65,7 @@ async Task Core(IAsyncEnumerable _source, Func _sele { var sum = 0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = _selector(item); @@ -113,7 +113,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancell { var sum = 0L; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (long value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -253,7 +253,7 @@ async Task Core(IAsyncEnumerable _source, Func _se { var sum = 0L; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = _selector(item); @@ -301,7 +301,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cance { var sum = 0.0f; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (float value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; @@ -435,7 +435,7 @@ async Task Core(IAsyncEnumerable _source, Func _ { var sum = 0.0f; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = _selector(item); @@ -477,7 +477,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _can { var sum = 0.0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (double value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; @@ -599,7 +599,7 @@ async Task Core(IAsyncEnumerable _source, Func { var sum = 0.0; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = _selector(item); @@ -641,7 +641,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _c { var sum = 0m; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (decimal value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; @@ -763,7 +763,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> Core(IAsyncEnumerable _source, Fu { var d = new Dictionary(_comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); @@ -73,7 +73,7 @@ async Task> Core(IAsyncEnumerable _source, Fu { var d = new Dictionary(_comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); @@ -121,7 +121,7 @@ async Task> Core(IAsyncEnumerable _source, Fu { var d = new Dictionary(_comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); @@ -171,7 +171,7 @@ async Task> Core(IAsyncEnumerable _source, F { var d = new Dictionary(_comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); @@ -222,7 +222,7 @@ async Task> Core(IAsyncEnumerable _source, F { var d = new Dictionary(_comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); @@ -274,7 +274,7 @@ async Task> Core(IAsyncEnumerable _source, F { var d = new Dictionary(_comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 879b1f00ff..a2d739c1df 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -24,7 +24,7 @@ async Task> Core(IAsyncEnumerable _source, IEqualityCo { var set = new HashSet(_comparer); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { set.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 0b64dfa6fb..f31e285985 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -24,7 +24,7 @@ async Task> Core(IAsyncEnumerable _source, CancellationTo { var list = new List(); -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { list.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index b0370a8161..6507a2875e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -162,7 +162,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in enumerable.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs index 994c1f1920..414e0a406e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs @@ -38,7 +38,7 @@ public static async ValueTask AddRangeAsync(this List list, IAsyncEnumerab } } -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (var item in collection.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); From 43c78bfaf2dfd65038e11e476ae50126f5ca02a8 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 20:44:09 -0800 Subject: [PATCH 701/862] Fix two warnings. --- .../System/Linq/AsyncEnumerableRewriter.cs | 2 +- .../System/Linq/Operators/OrderedAsyncEnumerable.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs index fa691301b6..1a17a634b1 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs @@ -69,7 +69,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node) return Expression.Call(obj, node.Method, args); } - var method = default(MethodInfo); + MethodInfo method; // // Find a corresponding method in the non-expression world, e.g. rewriting from diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index e3a3d6ed83..e7cf30286e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -220,6 +220,8 @@ public async ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken ca if (_source is IAsyncIListProvider listProv) { var count = await listProv.GetCountAsync(onlyIfCheap, cancellationToken).ConfigureAwait(false); + + return count; } return !onlyIfCheap || _source is ICollection || _source is ICollection ? await _source.CountAsync(cancellationToken).ConfigureAwait(false) : -1; From 5be9b8416e3b7b8b85454d260d8ab2cc56b0b10e Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 20:50:55 -0800 Subject: [PATCH 702/862] Fix AsyncQueryable tests. --- .../AsyncQueryableTests.Generated.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index af4c5b2e32..99cee2c1ed 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -2539,7 +2539,7 @@ public void SelectMany6() public void SelectMany7() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "collectionSelector"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); @@ -2551,7 +2551,7 @@ public void SelectMany7() public void SelectMany8() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); @@ -2563,7 +2563,7 @@ public void SelectMany8() public void SelectMany9() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); @@ -2575,7 +2575,7 @@ public void SelectMany9() public void SelectMany10() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "collectionSelector"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); @@ -2587,7 +2587,7 @@ public void SelectMany10() public void SelectMany11() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); @@ -2599,7 +2599,7 @@ public void SelectMany11() public void SelectMany12() { AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); @@ -3788,4 +3788,4 @@ public void Zip3() } } -} \ No newline at end of file +} From eddf1ea0bcbbfc38e5563d12a2651ddeb3c77143 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 21:09:42 -0800 Subject: [PATCH 703/862] Using configured enumerator rather than interface. --- .../System/Linq/Operators/OrderedAsyncEnumerable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index e7cf30286e..634e24a5db 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -265,7 +265,7 @@ private ValueTask SortedMap(TElement[] elements, int count, int minIndexI public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { #if CSHARP8 - await using (IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + await using (var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) { @@ -328,7 +328,7 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { #if CSHARP8 - await using (IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + await using (var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) { From b27038cdfa9ef3961ec6ee1e6b57cf50cfb8bbe7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 21:09:56 -0800 Subject: [PATCH 704/862] Move to BCL implementation of ConfigureAwait and WithCancellation. --- .../Linq/AsyncEnumerable.WithCancellation.cs | 77 ----------------- .../ConfiguredCancelableAsyncEnumerable.cs | 86 +++++++++++++++++++ .../Tasks/AsyncEnumerableExtensions.cs | 85 ++++++------------ 3 files changed, 110 insertions(+), 138 deletions(-) delete mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs deleted file mode 100644 index 339f865f67..0000000000 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.WithCancellation.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncEnumerable - { - // REVIEW: [LDM-2018-11-28] Should return type be a struct or just the interface type? Should this live in the System.Linq namespace or in System.Collections.Generic? - - public static WithCancellationTokenAsyncEnumerable WithCancellation(this IAsyncEnumerable source, CancellationToken cancellationToken) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return new WithCancellationTokenAsyncEnumerable(source, cancellationToken); - } - - // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait. - // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. - - public readonly struct WithCancellationTokenAsyncEnumerable : IAsyncEnumerable - { - private readonly IAsyncEnumerable _source; - private readonly CancellationToken _cancellationToken; - - public WithCancellationTokenAsyncEnumerable(IAsyncEnumerable source, CancellationToken cancellationToken) - { - _source = source; - _cancellationToken = cancellationToken; - } - - // REVIEW: Should we simply ignore the second cancellation token or should we link the two? - // REVIEW: [LDM-2018-11-28] Should we have eager cancellation here too? - - public WithCancellationAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - { - CancellationToken token; - - if (cancellationToken == default) - { - token = _cancellationToken; - } - else if (_cancellationToken == default) - { - token = cancellationToken; - } - else - { - token = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken, cancellationToken).Token; - } - - return new WithCancellationAsyncEnumerator(_source.GetAsyncEnumerator(token)); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - => GetAsyncEnumerator(cancellationToken); - - public readonly struct WithCancellationAsyncEnumerator : IAsyncEnumerator - { - private readonly IAsyncEnumerator _enumerator; - - public WithCancellationAsyncEnumerator(IAsyncEnumerator enumerator) => _enumerator = enumerator; - - public T Current => _enumerator.Current; - - public ValueTask DisposeAsync() => _enumerator.DisposeAsync(); - - public ValueTask MoveNextAsync() => _enumerator.MoveNextAsync(); - } - } - } -} diff --git a/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs new file mode 100644 index 0000000000..5db327f2e5 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs @@ -0,0 +1,86 @@ +#if !BCL_HAS_CONFIGUREAWAIT // https://github.com/dotnet/coreclr/pull/21939 + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Runtime.CompilerServices +{ + /// Provides an awaitable async enumerable that enables cancelable iteration and configured awaits. + [StructLayout(LayoutKind.Auto)] + public readonly struct ConfiguredCancelableAsyncEnumerable + { + private readonly IAsyncEnumerable _enumerable; + private readonly CancellationToken _cancellationToken; + private readonly bool _continueOnCapturedContext; + + internal ConfiguredCancelableAsyncEnumerable(IAsyncEnumerable enumerable, bool continueOnCapturedContext, CancellationToken cancellationToken) + { + _enumerable = enumerable; + _continueOnCapturedContext = continueOnCapturedContext; + _cancellationToken = cancellationToken; + } + + /// Configures how awaits on the tasks returned from an async iteration will be performed. + /// Whether to capture and marshal back to the current context. + /// The configured enumerable. + /// This will replace any previous value set by for this iteration. + public ConfiguredCancelableAsyncEnumerable ConfigureAwait(bool continueOnCapturedContext) => + new ConfiguredCancelableAsyncEnumerable(_enumerable, continueOnCapturedContext, _cancellationToken); + + /// Sets the to be passed to when iterating. + /// The to use. + /// The configured enumerable. + /// This will replace any previous set by for this iteration. + public ConfiguredCancelableAsyncEnumerable WithCancellation(CancellationToken cancellationToken) => + new ConfiguredCancelableAsyncEnumerable(_enumerable, _continueOnCapturedContext, cancellationToken); + + public Enumerator GetAsyncEnumerator() => + // as with other "configured" awaitable-related type in CompilerServices, we don't null check to defend against + // misuse like `default(ConfiguredCancelableAsyncEnumerable).GetAsyncEnumerator()`, which will null ref by design. + new Enumerator(_enumerable.GetAsyncEnumerator(_cancellationToken), _continueOnCapturedContext); + + /// Provides an awaitable async enumerator that enables cancelable iteration and configured awaits. + [StructLayout(LayoutKind.Auto)] + public readonly struct Enumerator : IAsyncDisposable // Workaround for https://github.com/dotnet/csharplang/blob/master/meetings/2019/LDM-2019-01-16.md + { + private readonly IAsyncEnumerator _enumerator; + private readonly bool _continueOnCapturedContext; + + internal Enumerator(IAsyncEnumerator enumerator, bool continueOnCapturedContext) + { + _enumerator = enumerator; + _continueOnCapturedContext = continueOnCapturedContext; + } + + /// Advances the enumerator asynchronously to the next element of the collection. + /// + /// A that will complete with a result of true + /// if the enumerator was successfully advanced to the next element, or false if the enumerator has + /// passed the end of the collection. + /// + public ConfiguredValueTaskAwaitable MoveNextAsync() => + _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); + + /// Gets the element in the collection at the current position of the enumerator. + public T Current => _enumerator.Current; + + /// + /// Performs application-defined tasks associated with freeing, releasing, or + /// resetting unmanaged resources asynchronously. + /// + public ConfiguredValueTaskAwaitable DisposeAsync() => + _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); + + async ValueTask IAsyncDisposable.DisposeAsync() => + await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); + } + } +} + +#endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index 67b53355c9..4982783c87 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -9,71 +9,34 @@ namespace System.Threading.Tasks { public static class AsyncEnumerableExtensions { - public static ConfiguredAsyncEnumerable ConfigureAwait(this IAsyncEnumerable enumerable, bool continueOnCapturedContext) - { - if (enumerable == null) - throw Error.ArgumentNull(nameof(enumerable)); - - return new ConfiguredAsyncEnumerable(enumerable, continueOnCapturedContext); - } - - public static ConfiguredAsyncEnumerable.ConfiguredAsyncEnumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) +#if !BCL_HAS_CONFIGUREAWAIT // https://github.com/dotnet/coreclr/pull/21939 + + /// Configures how awaits on the tasks returned from an async iteration will be performed. + /// The type of the objects being iterated. + /// The source enumerable being iterated. + /// Whether to capture and marshal back to the current context. + /// The configured enumerable. + public static ConfiguredCancelableAsyncEnumerable ConfigureAwait( + this IAsyncEnumerable source, bool continueOnCapturedContext) => + new ConfiguredCancelableAsyncEnumerable(source, continueOnCapturedContext, cancellationToken: default); + + /// Sets the to be passed to when iterating. + /// The type of the objects being iterated. + /// The source enumerable being iterated. + /// The to use. + /// The configured enumerable. + public static ConfiguredCancelableAsyncEnumerable WithCancellation( + this IAsyncEnumerable source, CancellationToken cancellationToken) => + new ConfiguredCancelableAsyncEnumerable(source, continueOnCapturedContext: true, cancellationToken); + +#endif + + public static ConfiguredCancelableAsyncEnumerable.Enumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) { if (enumerator == null) throw Error.ArgumentNull(nameof(enumerator)); - return new ConfiguredAsyncEnumerable.ConfiguredAsyncEnumerator(enumerator, continueOnCapturedContext); - } - - // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation. - // We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing. - - public readonly struct ConfiguredAsyncEnumerable : IAsyncEnumerable - { - private readonly IAsyncEnumerable _enumerable; - private readonly bool _continueOnCapturedContext; - - internal ConfiguredAsyncEnumerable(IAsyncEnumerable enumerable, bool continueOnCapturedContext) - { - _enumerable = enumerable; - _continueOnCapturedContext = continueOnCapturedContext; - } - - public ConfiguredAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); // NB: [LDM-2018-11-28] Equivalent to async iterator behavior. - - return new ConfiguredAsyncEnumerator(_enumerable.GetAsyncEnumerator(cancellationToken), _continueOnCapturedContext); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) => - GetAsyncEnumerator(cancellationToken); - - public readonly struct ConfiguredAsyncEnumerator : IAsyncEnumerator - { - private readonly IAsyncEnumerator _enumerator; - private readonly bool _continueOnCapturedContext; - - internal ConfiguredAsyncEnumerator(IAsyncEnumerator enumerator, bool continueOnCapturedContext) - { - _enumerator = enumerator; - _continueOnCapturedContext = continueOnCapturedContext; - } - - public ConfiguredValueTaskAwaitable MoveNextAsync() => - _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); - - public T Current => _enumerator.Current; - - public ConfiguredValueTaskAwaitable DisposeAsync() => - _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - - async ValueTask IAsyncEnumerator.MoveNextAsync() => - await _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); - - async ValueTask IAsyncDisposable.DisposeAsync() => - await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - } + return new ConfiguredCancelableAsyncEnumerable.Enumerator(enumerator, continueOnCapturedContext); } } } From fab0a0e40b099365ebaed28a6fe2459ce05610b0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 21:23:37 -0800 Subject: [PATCH 705/862] Clean up props and targets. --- Ix.NET/Source/Directory.build.props | 2 +- Ix.NET/Source/Directory.build.targets | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index b6289202bb..d4cd606485 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -34,7 +34,7 @@ - + diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 8eb3acd3ea..f21c3c6672 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -1,5 +1,5 @@ - - + + $(DefineConstants);NO_ARRAY_EMPTY;NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION @@ -14,9 +14,9 @@ $(DefineConstants);CSHARP8 - + $(AssemblyName) ($(TargetFramework)) - \ No newline at end of file + From 3e66377b6ccffaaed50a19eded301c8ca1013618 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 21:42:50 -0800 Subject: [PATCH 706/862] Remove AETOR_HAS_CT from tt file. --- .../System/Linq/Operators/Sum.Generated.tt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 27f8c3bd52..adc76674ea 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -46,7 +46,7 @@ foreach (var o in os) { var sum = <#=o.zero#>; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (<#=o.type#> value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { <# @@ -116,7 +116,7 @@ else { var sum = <#=o.zero#>; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = _selector(item); @@ -190,7 +190,7 @@ else { var sum = <#=o.zero#>; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = await _selector(item).ConfigureAwait(false); @@ -265,7 +265,7 @@ else { var sum = <#=o.zero#>; -#if CSHARP8 && AETOR_HAS_CT // CS0656 Missing compiler required member 'System.Collections.Generic.IAsyncEnumerable`1.GetAsyncEnumerator' +#if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = await _selector(item, _cancellationToken).ConfigureAwait(false); From 645aa551dc9908b7fcc011b445cff7cc4de14fb1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 21:48:04 -0800 Subject: [PATCH 707/862] Use static local functions. --- .../System/Linq/Operators/Aggregate.cs | 18 +- .../System/Linq/Operators/All.cs | 6 +- .../System/Linq/Operators/Any.cs | 8 +- .../Linq/Operators/Average.Generated.cs | 80 ++++----- .../Linq/Operators/Average.Generated.tt | 8 +- .../System/Linq/Operators/Contains.cs | 4 +- .../System/Linq/Operators/Count.cs | 8 +- .../System/Linq/Operators/ElementAt.cs | 2 +- .../Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/First.cs | 8 +- .../System/Linq/Operators/FirstOrDefault.cs | 10 +- .../System/Linq/Operators/ForEach.cs | 12 +- .../System/Linq/Operators/Last.cs | 8 +- .../System/Linq/Operators/LastOrDefault.cs | 10 +- .../System/Linq/Operators/LongCount.cs | 8 +- .../System/Linq/Operators/Max.cs | 16 +- .../System/Linq/Operators/Min.cs | 16 +- .../System/Linq/Operators/MinMax.Generated.cs | 160 +++++++++--------- .../System/Linq/Operators/MinMax.Generated.tt | 4 +- .../System/Linq/Operators/SequenceEqual.cs | 2 +- .../System/Linq/Operators/Single.cs | 8 +- .../System/Linq/Operators/Sum.Generated.cs | 80 ++++----- .../System/Linq/Operators/Sum.Generated.tt | 8 +- .../System/Linq/Operators/ToDictionary.cs | 14 +- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/ToLookup.cs | 10 +- 27 files changed, 257 insertions(+), 257 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 44e144acc0..c439a804df 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -19,7 +19,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -74,7 +74,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -130,7 +130,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -186,7 +186,7 @@ public static Task AggregateAsync(this IAsync return Core(source, seed, accumulator, cancellationToken); - async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, CancellationToken _cancellationToken) { var acc = _seed; @@ -224,7 +224,7 @@ public static Task AggregateAsync(this IAsync return Core(source, seed, accumulator, cancellationToken); - async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) { var acc = _seed; @@ -263,7 +263,7 @@ public static Task AggregateAsync(this IAsync return Core(source, seed, accumulator, cancellationToken); - async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) { var acc = _seed; @@ -304,7 +304,7 @@ public static Task AggregateAsync(this I return Core(source, seed, accumulator, resultSelector, cancellationToken); - async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, Func _resultSelector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, Func _resultSelector, CancellationToken _cancellationToken) { var acc = _seed; @@ -344,7 +344,7 @@ public static Task AggregateAsync(this I return Core(source, seed, accumulator, resultSelector, cancellationToken); - async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) { var acc = _seed; @@ -385,7 +385,7 @@ public static Task AggregateAsync(this I return Core(source, seed, accumulator, resultSelector, cancellationToken); - async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) { var acc = _seed; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 19db08b694..3bf77ecfdd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -19,7 +19,7 @@ public static Task AllAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -59,7 +59,7 @@ public static Task AllAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { #if CSHARP8 @@ -101,7 +101,7 @@ public static Task AllAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { #if CSHARP8 diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 29e7cc06df..0207bac92d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -17,7 +17,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -48,7 +48,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -88,7 +88,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -129,7 +129,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 8d5854ed8a..31839ce92d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -17,7 +17,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Cance return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -80,7 +80,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -143,7 +143,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -207,7 +207,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -269,7 +269,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -332,7 +332,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -395,7 +395,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -459,7 +459,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -521,7 +521,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -584,7 +584,7 @@ public static Task AverageAsync(this IAsyncEnumerable s return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -647,7 +647,7 @@ public static Task AverageAsync(this IAsyncEnumerable s return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -711,7 +711,7 @@ public static Task AverageAsync(this IAsyncEnumerable s return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -773,7 +773,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Ca return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -836,7 +836,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -899,7 +899,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -963,7 +963,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1025,7 +1025,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1088,7 +1088,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1151,7 +1151,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1215,7 +1215,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1277,7 +1277,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1354,7 +1354,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1431,7 +1431,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1509,7 +1509,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1585,7 +1585,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1662,7 +1662,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1739,7 +1739,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1817,7 +1817,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1893,7 +1893,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -1970,7 +1970,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2047,7 +2047,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2125,7 +2125,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2201,7 +2201,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2278,7 +2278,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2355,7 +2355,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2433,7 +2433,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2509,7 +2509,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2586,7 +2586,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2663,7 +2663,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -2741,7 +2741,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 27c40680dc..66739ac079 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -52,7 +52,7 @@ foreach (var o in os) return Core(source, cancellationToken); - async Task<<#=o.res#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) + static async Task<<#=o.res#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) { <# if (isNullable) @@ -190,7 +190,7 @@ else return Core(source, selector, cancellationToken); - async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { <# if (isNullable) @@ -328,7 +328,7 @@ else return Core(source, selector, cancellationToken); - async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { <# if (isNullable) @@ -467,7 +467,7 @@ else return Core(source, selector, cancellationToken); - async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { <# if (isNullable) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 324ca50d49..74c3cc438f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -26,7 +26,7 @@ public static Task ContainsAsync(this IAsyncEnumerable s { return Core(source, value, cancellationToken); - async Task Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -62,7 +62,7 @@ async Task Core(IAsyncEnumerable _source, TSource _value, Cancell { return Core(source, value, comparer, cancellationToken); - async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 473d8cdffc..7e7cb16079 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -28,7 +28,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var count = 0; @@ -72,7 +72,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var count = 0; @@ -122,7 +122,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0; @@ -173,7 +173,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index dde64306aa..ec7034632a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -17,7 +17,7 @@ public static Task ElementAtAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) { if (_source is IAsyncPartition p) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 8cbb0f2535..c069229e20 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -17,7 +17,7 @@ public static Task ElementAtOrDefaultAsync(this IAsyncEnumerab return Core(source, index, cancellationToken); - async Task Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) { if (_source is IAsyncPartition p) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 12651d6ab5..0a562aaba3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -17,7 +17,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _cancellationToken).ConfigureAwait(false); @@ -34,7 +34,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -51,7 +51,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -69,7 +69,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 9fa6713de9..cc9324b80d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -17,7 +17,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _cancellationToken).ConfigureAwait(false); @@ -34,7 +34,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -51,7 +51,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -69,7 +69,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -95,7 +95,7 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index f33a5d1332..70527b0709 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -26,7 +26,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return Core(source, action, cancellationToken); - async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -60,7 +60,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return Core(source, action, cancellationToken); - async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) { var index = 0; @@ -96,7 +96,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return Core(source, action, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -125,7 +125,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, { return Core(source, action, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { #if CSHARP8 await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) @@ -159,7 +159,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return Core(source, action, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { var index = 0; @@ -195,7 +195,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, return Core(source, action, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { var index = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index f69bd1dc4d..e1a4328388 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -17,7 +17,7 @@ public static Task LastAsync(this IAsyncEnumerable so return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _cancellationToken).ConfigureAwait(false); @@ -34,7 +34,7 @@ public static Task LastAsync(this IAsyncEnumerable so return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -51,7 +51,7 @@ public static Task LastAsync(this IAsyncEnumerable so return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -69,7 +69,7 @@ public static Task LastAsync(this IAsyncEnumerable so return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index abb0dcf3f3..63a77dd787 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -17,7 +17,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _cancellationToken).ConfigureAwait(false); @@ -34,7 +34,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -51,7 +51,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -69,7 +69,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -96,7 +96,7 @@ private static ValueTask> TryGetLast(IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var last = default(TSource); var hasLast = false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 79a43bcf0d..3d99c2b124 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -17,7 +17,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var count = 0L; @@ -61,7 +61,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var count = 0L; @@ -111,7 +111,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0L; @@ -162,7 +162,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0L; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 71d0f001cb..ed4039bfe5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -19,7 +19,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou { return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -87,7 +87,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -154,7 +154,7 @@ public static Task MaxAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -222,7 +222,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -289,7 +289,7 @@ public static Task MaxAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -357,7 +357,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -426,7 +426,7 @@ public static Task MaxAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -494,7 +494,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index f402004a35..9f276264e9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -19,7 +19,7 @@ public static Task MinAsync(this IAsyncEnumerable sou { return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -87,7 +87,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c { return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -155,7 +155,7 @@ public static Task MinAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -223,7 +223,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -291,7 +291,7 @@ public static Task MinAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -359,7 +359,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -428,7 +428,7 @@ public static Task MinAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -496,7 +496,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 5bec54aa2d..f81565d7dd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -17,7 +17,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancellation return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int value; @@ -80,7 +80,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int value; @@ -143,7 +143,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -207,7 +207,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -269,7 +269,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int? value = null; @@ -410,7 +410,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int? value = null; @@ -551,7 +551,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -693,7 +693,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -833,7 +833,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancellati return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long value; @@ -896,7 +896,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long value; @@ -959,7 +959,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -1023,7 +1023,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -1085,7 +1085,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long? value = null; @@ -1226,7 +1226,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long? value = null; @@ -1367,7 +1367,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -1509,7 +1509,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -1649,7 +1649,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancella return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float value; @@ -1742,7 +1742,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float value; @@ -1835,7 +1835,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -1929,7 +1929,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -2021,7 +2021,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float? value = null; @@ -2154,7 +2154,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float? value = null; @@ -2287,7 +2287,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -2421,7 +2421,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -2553,7 +2553,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Cancel return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double value; @@ -2646,7 +2646,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double value; @@ -2739,7 +2739,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -2833,7 +2833,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -2925,7 +2925,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double? value = null; @@ -3058,7 +3058,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double? value = null; @@ -3191,7 +3191,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -3325,7 +3325,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -3457,7 +3457,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, Canc return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal value; @@ -3520,7 +3520,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal value; @@ -3583,7 +3583,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -3647,7 +3647,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -3709,7 +3709,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal? value = null; @@ -3798,7 +3798,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -3887,7 +3887,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -3977,7 +3977,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -4065,7 +4065,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancellation return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int value; @@ -4128,7 +4128,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int value; @@ -4191,7 +4191,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -4255,7 +4255,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -4317,7 +4317,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int? value = null; @@ -4410,7 +4410,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int? value = null; @@ -4503,7 +4503,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -4597,7 +4597,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -4689,7 +4689,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancellati return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long value; @@ -4752,7 +4752,7 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long value; @@ -4815,7 +4815,7 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -4879,7 +4879,7 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -4941,7 +4941,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long? value = null; @@ -5034,7 +5034,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long? value = null; @@ -5127,7 +5127,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -5221,7 +5221,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -5313,7 +5313,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancella return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float value; @@ -5408,7 +5408,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float value; @@ -5503,7 +5503,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -5599,7 +5599,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -5693,7 +5693,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float? value = null; @@ -5818,7 +5818,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float? value = null; @@ -5943,7 +5943,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -6069,7 +6069,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -6193,7 +6193,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Cancel return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double value; @@ -6288,7 +6288,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double value; @@ -6383,7 +6383,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -6479,7 +6479,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -6573,7 +6573,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double? value = null; @@ -6698,7 +6698,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double? value = null; @@ -6823,7 +6823,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -6949,7 +6949,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -7073,7 +7073,7 @@ public static Task MinAsync(this IAsyncEnumerable source, Canc return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal value; @@ -7136,7 +7136,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal value; @@ -7199,7 +7199,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -7263,7 +7263,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -7325,7 +7325,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal? value = null; @@ -7414,7 +7414,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -7503,7 +7503,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -7593,7 +7593,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 22394217ef..f025d86f4b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -35,7 +35,7 @@ foreach (var m in new[] { "Max", "Min" }) return Core(source, cancellationToken); - async Task<<#=t#>> Core(IAsyncEnumerable<<#=t#>> _source, CancellationToken _cancellationToken) + static async Task<<#=t#>> Core(IAsyncEnumerable<<#=t#>> _source, CancellationToken _cancellationToken) { <# if (!isNullable) @@ -537,7 +537,7 @@ foreach (var overload in new[] { return Core(source, selector, cancellationToken); - async Task<<#=t#>> Core(IAsyncEnumerable _source, <#=overload.selector#> _selector, CancellationToken _cancellationToken) + static async Task<<#=t#>> Core(IAsyncEnumerable _source, <#=overload.selector#> _selector, CancellationToken _cancellationToken) { <# if (!isNullable) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 58a43defef..fbdefc6afa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -50,7 +50,7 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e1 = _first.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index be89b31d05..2529d512b2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -17,7 +17,7 @@ public static Task SingleAsync(this IAsyncEnumerable return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { if (_source is IList list) { @@ -82,7 +82,7 @@ public static Task SingleAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -147,7 +147,7 @@ public static Task SingleAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) @@ -213,7 +213,7 @@ public static Task SingleAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { #if CSHARP8 await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 9e9a1ff98c..0cc7ee8a6e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -17,7 +17,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancellation return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0; @@ -61,7 +61,7 @@ public static Task SumAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -109,7 +109,7 @@ public static Task SumAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -158,7 +158,7 @@ public static Task SumAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -205,7 +205,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancellati return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0L; @@ -249,7 +249,7 @@ public static Task SumAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -297,7 +297,7 @@ public static Task SumAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -346,7 +346,7 @@ public static Task SumAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -393,7 +393,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancella return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -431,7 +431,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -473,7 +473,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -516,7 +516,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -557,7 +557,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Cancel return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0; @@ -595,7 +595,7 @@ public static Task SumAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -637,7 +637,7 @@ public static Task SumAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -680,7 +680,7 @@ public static Task SumAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -721,7 +721,7 @@ public static Task SumAsync(this IAsyncEnumerable source, Canc return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0m; @@ -759,7 +759,7 @@ public static Task SumAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -801,7 +801,7 @@ public static Task SumAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -844,7 +844,7 @@ public static Task SumAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -885,7 +885,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0; @@ -929,7 +929,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -977,7 +977,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -1026,7 +1026,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -1073,7 +1073,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0L; @@ -1117,7 +1117,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -1165,7 +1165,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -1214,7 +1214,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -1261,7 +1261,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -1299,7 +1299,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -1341,7 +1341,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -1384,7 +1384,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -1425,7 +1425,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0; @@ -1463,7 +1463,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -1505,7 +1505,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -1548,7 +1548,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -1589,7 +1589,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0m; @@ -1627,7 +1627,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -1669,7 +1669,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -1712,7 +1712,7 @@ async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index adc76674ea..6065222de1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -42,7 +42,7 @@ foreach (var o in os) return Core(source, cancellationToken); - async Task<<#=o.type#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) + static async Task<<#=o.type#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; @@ -112,7 +112,7 @@ else return Core(source, selector, cancellationToken); - async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; @@ -186,7 +186,7 @@ else return Core(source, selector, cancellationToken); - async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; @@ -261,7 +261,7 @@ else return Core(source, selector, cancellationToken); - async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index b8fa445451..be56090fb2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -22,12 +22,12 @@ public static Task> ToDictionaryAsync(t return Core(source, keySelector, comparer, cancellationToken); - async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); #if CSHARP8 - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); @@ -69,7 +69,7 @@ public static Task> ToDictionaryAsync(t return Core(source, keySelector, comparer, cancellationToken); - async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -117,7 +117,7 @@ public static Task> ToDictionaryAsync(t return Core(source, keySelector, comparer, cancellationToken); - async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -167,7 +167,7 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -218,7 +218,7 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -270,7 +270,7 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index a2d739c1df..441265f71e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -20,7 +20,7 @@ public static Task> ToHashSetAsync(this IAsyncEnumerab return Core(source, comparer, cancellationToken); - async Task> Core(IAsyncEnumerable _source, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var set = new HashSet(_comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index f31e285985..8d45438d22 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -20,7 +20,7 @@ public static Task> ToListAsync(this IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var list = new List(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 9def25502d..92fa34606c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -22,7 +22,7 @@ public static Task> ToLookupAsync(this IAs return Core(source, keySelector, comparer, cancellationToken); - async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); } @@ -59,7 +59,7 @@ public static Task> ToLookupAsync(this IAs return Core(source, keySelector, comparer, cancellationToken); - async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); } @@ -80,7 +80,7 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); } @@ -100,7 +100,7 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); } @@ -121,7 +121,7 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); } From ca0a8b53b4ba9fbfbd2c501b887f224b574d541d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 22:07:28 -0800 Subject: [PATCH 708/862] Change CSHARP8 for USE_* checks. Enable C# 8.0 for all builds. --- Ix.NET/Source/Directory.build.props | 9 +- Ix.NET/Source/Directory.build.targets | 5 +- Ix.NET/Source/Playground/Program.cs | 16 +- .../System/Linq/Operators/Max.cs | 2 +- .../System/Linq/Operators/Min.cs | 2 +- .../System/Linq/Operators/MinBy.cs | 6 +- .../System/Linq/AsyncEnumerableHelpers.cs | 4 +- .../System/Linq/Operators/Aggregate.cs | 18 +- .../System/Linq/Operators/All.cs | 8 +- .../System/Linq/Operators/Any.cs | 8 +- .../System/Linq/Operators/AppendPrepend.cs | 8 +- .../Linq/Operators/Average.Generated.cs | 80 ++++----- .../Linq/Operators/Average.Generated.tt | 16 +- .../System/Linq/Operators/Concat.cs | 2 +- .../System/Linq/Operators/Contains.cs | 4 +- .../System/Linq/Operators/Count.cs | 8 +- .../System/Linq/Operators/ElementAt.cs | 2 +- .../Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/Except.cs | 4 +- .../System/Linq/Operators/FirstOrDefault.cs | 8 +- .../System/Linq/Operators/ForEach.cs | 12 +- .../System/Linq/Operators/GroupJoin.cs | 8 +- .../System/Linq/Operators/Intersect.cs | 4 +- .../System/Linq/Operators/Join.cs | 8 +- .../System/Linq/Operators/LastOrDefault.cs | 8 +- .../System/Linq/Operators/LongCount.cs | 8 +- .../System/Linq/Operators/Lookup.cs | 18 +- .../System/Linq/Operators/Max.cs | 16 +- .../System/Linq/Operators/Min.cs | 16 +- .../System/Linq/Operators/MinMax.Generated.cs | 160 +++++++++--------- .../System/Linq/Operators/MinMax.Generated.tt | 8 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 4 +- .../System/Linq/Operators/Select.cs | 10 +- .../System/Linq/Operators/SelectMany.cs | 32 ++-- .../System/Linq/Operators/SequenceEqual.cs | 2 +- .../System/Linq/Operators/Single.cs | 8 +- .../System/Linq/Operators/SingleOrDefault.cs | 8 +- .../System/Linq/Operators/SkipLast.cs | 4 +- .../System/Linq/Operators/SkipWhile.cs | 14 +- .../System/Linq/Operators/Sum.Generated.cs | 80 ++++----- .../System/Linq/Operators/Sum.Generated.tt | 8 +- .../System/Linq/Operators/TakeLast.cs | 4 +- .../System/Linq/Operators/TakeWhile.cs | 14 +- .../System/Linq/Operators/ToDictionary.cs | 12 +- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/Union.cs | 2 +- .../System/Linq/Operators/Utilities.cs | 2 +- .../System/Linq/Operators/Where.cs | 10 +- .../System/Linq/Operators/Zip.cs | 8 +- 50 files changed, 349 insertions(+), 355 deletions(-) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index d4cd606485..ceaef7610b 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -16,8 +16,8 @@ embedded true true - latest - true + + 8.0 @@ -25,11 +25,6 @@ full - - - 8.0 - - diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index f21c3c6672..a3ddc67947 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -11,8 +11,9 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION - - $(DefineConstants);CSHARP8 + + + $(DefineConstants);USE_AWAIT_FOREACH;USE_AWAIT_USING diff --git a/Ix.NET/Source/Playground/Program.cs b/Ix.NET/Source/Playground/Program.cs index 4c5b0bd3a8..7c001fec0f 100644 --- a/Ix.NET/Source/Playground/Program.cs +++ b/Ix.NET/Source/Playground/Program.cs @@ -78,8 +78,8 @@ static async Task AsyncLinq() var xs = new List { 1, 2, 3 }; var ys = xs.ToAsyncEnumerable().Where(x => x % 2 == 0); -#if CSHARP8 - foreach await (var y in ys) +#if USE_AWAIT_FOREACH + await foreach (var y in ys) { Console.WriteLine(y); } @@ -108,8 +108,8 @@ static async Task AsyncLinqQueryable() var xs = new List { 1, 2, 3 }.AsQueryable(); var ys = xs.ToAsyncEnumerable().Where(x => x % 2 == 0); -#if CSHARP8 - foreach await (var y in ys) +#if USE_AWAIT_FOREACH + await foreach (var y in ys) { Console.WriteLine(y); } @@ -138,8 +138,8 @@ static async Task AsyncIx() var xs = new List { 1, 2, 3 }; var ys = xs.ToAsyncEnumerable().Distinct(x => x % 2); -#if CSHARP8 - foreach await (var y in ys) +#if USE_AWAIT_FOREACH + await foreach (var y in ys) { Console.WriteLine(y); } @@ -157,8 +157,8 @@ static async Task AsyncIxQueryable() var xs = new List { 1, 2, 3 }.AsQueryable(); var ys = xs.ToAsyncEnumerable().Distinct(x => x % 2); -#if CSHARP8 - foreach await (var y in ys) +#if USE_AWAIT_FOREACH + await foreach (var y in ys) { Console.WriteLine(y); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 83637f60ba..d95f3260a5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -24,7 +24,7 @@ async Task Core() comparer = Comparer.Default; } -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 88a1153ad8..1d5e16e0b9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -24,7 +24,7 @@ async Task Core() comparer = Comparer.Default; } -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 10ae55c7f4..bc34c1f2d0 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -110,7 +110,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -181,7 +181,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -253,7 +253,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index e701307bcd..7e6804b3d7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -44,7 +44,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } else { -#if CSHARP8 +#if USE_AWAIT_USING await using (var en = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (await en.MoveNextAsync()) @@ -162,7 +162,7 @@ internal static async Task> ToSet(IAsyncEnumerable source, IEqualit { var set = new Set(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (T item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index c439a804df..306118535e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -21,7 +21,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -76,7 +76,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -132,7 +132,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -190,7 +190,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumula { var acc = _seed; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); @@ -228,7 +228,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumula { var acc = _seed; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); @@ -267,7 +267,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumula { var acc = _seed; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); @@ -308,7 +308,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ { var acc = _seed; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); @@ -348,7 +348,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ { var acc = _seed; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); @@ -389,7 +389,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ { var acc = _seed; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 3bf77ecfdd..797b3ddade 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -21,7 +21,7 @@ public static Task AllAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!_predicate(item)) @@ -61,8 +61,7 @@ public static Task AllAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 - +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!await _predicate(item).ConfigureAwait(false)) @@ -103,8 +102,7 @@ public static Task AllAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 - +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!await _predicate(item, _cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 0207bac92d..472ff7f6ad 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -19,7 +19,7 @@ public static Task AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { return await e.MoveNextAsync(); @@ -50,7 +50,7 @@ public static Task AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_predicate(item)) @@ -90,7 +90,7 @@ public static Task AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item).ConfigureAwait(false)) @@ -131,7 +131,7 @@ public static Task AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index 1478971b10..6f839613e2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -206,7 +206,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; @@ -251,7 +251,7 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(_item); } -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); @@ -428,7 +428,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; @@ -471,7 +471,7 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(n.Item); } -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 31839ce92d..6b5d54e7fd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -19,7 +19,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Cance static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -82,7 +82,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -145,7 +145,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -209,7 +209,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -271,7 +271,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -334,7 +334,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -397,7 +397,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -461,7 +461,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -523,7 +523,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -586,7 +586,7 @@ public static Task AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -649,7 +649,7 @@ public static Task AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -713,7 +713,7 @@ public static Task AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -775,7 +775,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Ca static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -838,7 +838,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -901,7 +901,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -965,7 +965,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -1027,7 +1027,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -1090,7 +1090,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -1153,7 +1153,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -1217,7 +1217,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -1279,7 +1279,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1356,7 +1356,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1433,7 +1433,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1511,7 +1511,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1587,7 +1587,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1664,7 +1664,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1741,7 +1741,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1819,7 +1819,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1895,7 +1895,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -1972,7 +1972,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2049,7 +2049,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2127,7 +2127,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2203,7 +2203,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2280,7 +2280,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2357,7 +2357,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2435,7 +2435,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2511,7 +2511,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2588,7 +2588,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2665,7 +2665,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -2743,7 +2743,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 66739ac079..68c0d1d3f8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -58,7 +58,7 @@ foreach (var o in os) if (isNullable) { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -126,7 +126,7 @@ if (isNullable) else { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -196,7 +196,7 @@ else if (isNullable) { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -264,7 +264,7 @@ if (isNullable) else { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -334,7 +334,7 @@ else if (isNullable) { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -402,7 +402,7 @@ if (isNullable) else { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -473,7 +473,7 @@ else if (isNullable) { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -541,7 +541,7 @@ if (isNullable) else { #> -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index 6dba7e4fb6..ea93d3b6fb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -84,7 +84,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation break; } -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 74c3cc438f..cb835ca9d1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -28,7 +28,7 @@ public static Task ContainsAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (EqualityComparer.Default.Equals(item, _value)) @@ -64,7 +64,7 @@ static async Task Core(IAsyncEnumerable _source, TSource _value, static async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_comparer.Equals(item, _value)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 7e7cb16079..0f753b0fe8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -32,7 +32,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken { var count = 0; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -76,7 +76,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, int _index, C if (_index >= 0) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index c069229e20..f289b89bbf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -40,7 +40,7 @@ static async Task Core(IAsyncEnumerable _source, int _index, C } else { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs index 457dbc922e..e006c481b3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Except.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable Except(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -46,7 +46,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class ExceptAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index cc9324b80d..12c9a3581d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -97,7 +97,7 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (await e.MoveNextAsync()) @@ -130,7 +130,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, C private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -169,7 +169,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -209,7 +209,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 70527b0709..f695f2cfaf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -28,7 +28,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item); @@ -64,7 +64,7 @@ static async Task Core(IAsyncEnumerable _source, Action _ { var index = 0; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item, checked(index++)); @@ -98,7 +98,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item).ConfigureAwait(false); @@ -127,7 +127,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item, _cancellationToken).ConfigureAwait(false); @@ -163,7 +163,7 @@ static async Task Core(IAsyncEnumerable _source, Func _source, Func GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -68,7 +68,7 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -111,7 +111,7 @@ public static IAsyncEnumerable GroupJoin if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -138,7 +138,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class GroupJoinAsyncEnumerable : IAsyncEnumerable { private readonly IEqualityComparer _comparer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs index 28d372dca3..2a2a6dd149 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Intersect.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable Intersect(this IAsyncEnumerable if (second == null) throw Error.ArgumentNull(nameof(second)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -46,7 +46,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class IntersectAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 0a5f862761..e5af5c9e0c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -27,7 +27,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -85,7 +85,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -144,7 +144,7 @@ public static IAsyncEnumerable Join(this if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -187,7 +187,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class JoinAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _outer; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 63a77dd787..4161e7cde5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -101,7 +101,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, C var last = default(TSource); var hasLast = false; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { hasLast = true; @@ -136,7 +136,7 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable Core(IAsyncEnumerable _source, CancellationToke { var count = 0L; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -65,7 +65,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -132,7 +132,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -164,7 +164,7 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { var lookup = new Lookup(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -419,7 +419,7 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -462,7 +462,7 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); @@ -504,7 +504,7 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -540,7 +540,7 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); @@ -573,7 +573,7 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -612,7 +612,7 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index ed4039bfe5..b6b032c498 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -25,7 +25,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { do @@ -93,7 +93,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -160,7 +160,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { do @@ -93,7 +93,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -161,7 +161,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ca { int value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -84,7 +84,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ { long value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -900,7 +900,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken { float value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -1746,7 +1746,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok { double value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -2650,7 +2650,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT { decimal value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -3524,7 +3524,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ca { int value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -4132,7 +4132,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ { long value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -4756,7 +4756,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken { float value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -5412,7 +5412,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok { double value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -6292,7 +6292,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT { decimal value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -7140,7 +7140,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func <#=t#> value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -187,7 +187,7 @@ foreach (var m in new[] { "Max", "Min" }) #> <#=t#> value = null; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) @@ -545,7 +545,7 @@ foreach (var overload in new[] { #> <#=t#> value; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -689,7 +689,7 @@ foreach (var overload in new[] { #> <#=t#> value = null; -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 634e24a5db..f7861a780e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -264,7 +264,7 @@ private ValueTask SortedMap(TElement[] elements, int count, int minIndexI public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -327,7 +327,7 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index d0119f1200..e803a90024 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -36,7 +36,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -103,7 +103,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -133,7 +133,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -217,7 +217,7 @@ protected override async ValueTask MoveNextCore() } } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class SelectEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _selector; @@ -523,7 +523,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class SelectEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _selector; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 2e9b44fd43..4f6bf7fb72 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -50,7 +50,7 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -84,7 +84,7 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -119,7 +119,7 @@ public static IAsyncEnumerable SelectMany(this IAsync if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -156,7 +156,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -185,7 +185,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -215,7 +215,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -245,7 +245,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -281,7 +281,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -318,7 +318,7 @@ public static IAsyncEnumerable SelectMany Core(CancellationToken cancellationToken) @@ -402,7 +402,7 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -446,7 +446,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = _selector(element); @@ -578,7 +578,7 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var items = await _selector(element).ConfigureAwait(false); @@ -626,7 +626,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = await _selector(element).ConfigureAwait(false); @@ -759,7 +759,7 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var items = await _selector(element, _cancellationToken).ConfigureAwait(false); @@ -807,7 +807,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = await _selector(element, cancellationToken).ConfigureAwait(false); @@ -884,7 +884,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class SelectManyAsyncIterator : AsyncIterator { private const int State_Source = 1; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index fbdefc6afa..f5c75f23e5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -52,7 +52,7 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e1 = _first.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { await using (var e2 = _second.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 2529d512b2..b31bcf1397 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -30,7 +30,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT throw Error.MoreThanOneElement(); } -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -84,7 +84,7 @@ public static Task SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -149,7 +149,7 @@ public static Task SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -215,7 +215,7 @@ public static Task SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index 4a00fa7b91..1a30666947 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -30,7 +30,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c throw Error.MoreThanOneElement(); } -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) @@ -83,7 +83,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -148,7 +148,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) @@ -214,7 +214,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if CSHARP8 +#if USE_AWAIT_USING await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { while (await e.MoveNextAsync()) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index 6364baf5ea..cc0e45a5a4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -28,7 +28,7 @@ public static IAsyncEnumerable SkipLast(this IAsyncEnumerable< count = 0; } -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -61,7 +61,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class SkipLastAsyncIterator : AsyncIterator { private readonly int _count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 0cc660c4c4..87141b0810 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -55,7 +55,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -99,7 +99,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -137,7 +137,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -175,7 +175,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -220,7 +220,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -258,7 +258,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class SkipWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 0cc7ee8a6e..a0c82d78cd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -21,7 +21,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca { var sum = 0; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (int value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -65,7 +65,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ { var sum = 0L; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (long value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -253,7 +253,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken { var sum = 0.0f; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (float value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; @@ -435,7 +435,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok { var sum = 0.0; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (double value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; @@ -599,7 +599,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT { var sum = 0m; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (decimal value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; @@ -763,7 +763,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (<#=o.type#> value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { <# @@ -116,7 +116,7 @@ else { var sum = <#=o.zero#>; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = _selector(item); @@ -190,7 +190,7 @@ else { var sum = <#=o.zero#>; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = await _selector(item).ConfigureAwait(false); @@ -265,7 +265,7 @@ else { var sum = <#=o.zero#>; -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = await _selector(item, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 509570cee7..56865d6141 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable TakeLast(this IAsyncEnumerable< return Empty(); } -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -69,7 +69,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class TakeLastAsyncIterator : AsyncIterator { private readonly int _count; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index dd1ae27fad..0d42a841fb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -18,7 +18,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -45,7 +45,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -79,7 +79,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -107,7 +107,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -135,7 +135,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -170,7 +170,7 @@ public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable if (predicate == null) throw Error.ArgumentNull(nameof(predicate)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -198,7 +198,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class TakeWhileAsyncIterator : AsyncIterator { private readonly Func _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index be56090fb2..87960155b3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -26,7 +26,7 @@ static async Task> Core(IAsyncEnumerable _sou { var d = new Dictionary(_comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); @@ -73,7 +73,7 @@ static async Task> Core(IAsyncEnumerable _sou { var d = new Dictionary(_comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); @@ -121,7 +121,7 @@ static async Task> Core(IAsyncEnumerable _sou { var d = new Dictionary(_comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); @@ -171,7 +171,7 @@ static async Task> Core(IAsyncEnumerable _so { var d = new Dictionary(_comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); @@ -222,7 +222,7 @@ static async Task> Core(IAsyncEnumerable _so { var d = new Dictionary(_comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); @@ -274,7 +274,7 @@ static async Task> Core(IAsyncEnumerable _so { var d = new Dictionary(_comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 441265f71e..3efe87cec8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -24,7 +24,7 @@ static async Task> Core(IAsyncEnumerable _source, IEqu { var set = new HashSet(_comparer); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { set.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 8d45438d22..03770740be 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -24,7 +24,7 @@ static async Task> Core(IAsyncEnumerable _source, Cancell { var list = new List(); -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { list.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index 6507a2875e..ebdf1bb070 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -162,7 +162,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (TSource item in enumerable.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs index 414e0a406e..a99a513f91 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs @@ -38,7 +38,7 @@ public static async ValueTask AddRangeAsync(this List list, IAsyncEnumerab } } -#if CSHARP8 +#if USE_AWAIT_FOREACH await foreach (var item in collection.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index ea73f39276..0baf582388 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -34,7 +34,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -100,7 +100,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -133,7 +133,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Core(CancellationToken cancellationToken) @@ -228,7 +228,7 @@ protected override async ValueTask MoveNextCore() } } -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class WhereEnumerableWithIndexAsyncIterator : AsyncIterator { private readonly Func _predicate; @@ -428,7 +428,7 @@ protected override async ValueTask MoveNextCore() } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class WhereEnumerableWithIndexAsyncIteratorWithTask : AsyncIterator { private readonly Func> _predicate; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 32ffccf57c..097cb4aeb4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -20,7 +20,7 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -50,7 +50,7 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -81,7 +81,7 @@ public static IAsyncEnumerable Zip(this IAsyn if (selector == null) throw Error.ArgumentNull(nameof(selector)); -#if CSHARP8 && USE_ASYNC_ITERATOR +#if USE_ASYNC_ITERATOR return Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -103,7 +103,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif -#if !(CSHARP8 && USE_ASYNC_ITERATOR) +#if !USE_ASYNC_ITERATOR private sealed class ZipAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _first; From e0c899cb455454385bbd4fdbbb8b3845798073e5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 22:10:57 -0800 Subject: [PATCH 709/862] Use async iterators in IgnoreElements. --- .../System/Linq/Operators/IgnoreElements.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index 29064bf701..6cb3bac5e4 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -16,9 +16,21 @@ public static IAsyncEnumerable IgnoreElements(this IAsyncEnume if (source == null) throw Error.ArgumentNull(nameof(source)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await foreach (var _ in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + } + } +#else return new IgnoreElementsAsyncIterator(source); +#endif } +#if !USE_ASYNC_ITERATOR private sealed class IgnoreElementsAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _source; @@ -69,4 +81,5 @@ protected override async ValueTask MoveNextCore() } } } +#endif } From bc73c643413fa1a9371620c8ba160695534923f4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 22:14:59 -0800 Subject: [PATCH 710/862] Use static local functions. --- .../System/Linq/Operators/IsEmpty.cs | 6 +++--- .../System/Linq/Operators/Max.cs | 16 ++++++++-------- .../System/Linq/Operators/Min.cs | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index 4c541b2ae9..9a0d47b614 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -15,11 +15,11 @@ public static Task IsEmptyAsync(this IAsyncEnumerable so if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, cancellationToken); - async Task Core() + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - return !await source.AnyAsync(cancellationToken).ConfigureAwait(false); + return !await _source.AnyAsync(_cancellationToken).ConfigureAwait(false); } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index d95f3260a5..b85a11d79b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -15,17 +15,17 @@ public static Task MaxAsync(this IAsyncEnumerable sou if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, comparer, cancellationToken); - async Task Core() + static async Task Core(IAsyncEnumerable _source, IComparer _comparer, CancellationToken _cancellationToken) { - if (comparer == null) + if (_comparer == null) { - comparer = Comparer.Default; + _comparer = Comparer.Default; } #if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -36,7 +36,7 @@ async Task Core() { var cur = e.Current; - if (comparer.Compare(cur, max) > 0) + if (_comparer.Compare(cur, max) > 0) { max = cur; } @@ -45,7 +45,7 @@ async Task Core() return max; } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -58,7 +58,7 @@ async Task Core() { var cur = e.Current; - if (comparer.Compare(cur, max) > 0) + if (_comparer.Compare(cur, max) > 0) { max = cur; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 1d5e16e0b9..fb9bc49554 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -15,17 +15,17 @@ public static Task MinAsync(this IAsyncEnumerable sou if (source == null) throw Error.ArgumentNull(nameof(source)); - return Core(); + return Core(source, comparer, cancellationToken); - async Task Core() + static async Task Core(IAsyncEnumerable _source, IComparer _comparer, CancellationToken _cancellationToken) { - if (comparer == null) + if (_comparer == null) { - comparer = Comparer.Default; + _comparer = Comparer.Default; } #if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -36,7 +36,7 @@ async Task Core() { var cur = e.Current; - if (comparer.Compare(cur, min) < 0) + if (_comparer.Compare(cur, min) < 0) { min = cur; } @@ -45,7 +45,7 @@ async Task Core() return min; } #else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken); try { @@ -58,7 +58,7 @@ async Task Core() { var cur = e.Current; - if (comparer.Compare(cur, min) < 0) + if (_comparer.Compare(cur, min) < 0) { min = cur; } From c66fddaef7fea4c4cbe2c5e3ebf841dbefbc7c39 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 22:19:39 -0800 Subject: [PATCH 711/862] Use async iterator in Generate. --- .../System/Linq/Operators/Generate.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 97a8988a58..994fc0c7f7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -20,11 +20,28 @@ public static IAsyncEnumerable Generate(TState initial if (resultSelector == null) throw Error.ArgumentNull(nameof(resultSelector)); +#if USE_ASYNC_ITERATOR + return Create(Core); + +#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + for (TState state = initialState; condition(state); state = iterate(state)) + { + // REVIEW: Check for cancellation? + + yield return resultSelector(state); + } + } +#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously +#else return new GenerateAsyncIterator(initialState, condition, iterate, resultSelector); +#endif } // REVIEW: Add async variant? +#if !USE_ASYNC_ITERATOR private sealed class GenerateAsyncIterator : AsyncIterator { private readonly Func _condition; @@ -93,4 +110,5 @@ protected override async ValueTask MoveNextCore() } } } +#endif } From b48137d0b2d9520a41211b71c70c9cac44231c2a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 22:21:59 -0800 Subject: [PATCH 712/862] Use async iterators in Finally. --- .../System/Linq/Operators/Finally.cs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index bbf2c89cc6..55bf5ddfe2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -17,7 +18,26 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + try + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + finally + { + finallyAction(); + } + } +#else return new FinallyAsyncIterator(source, finallyAction); +#endif } public static IAsyncEnumerable Finally(this IAsyncEnumerable source, Func finallyAction) @@ -27,11 +47,31 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + try + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + finally + { + await finallyAction().ConfigureAwait(false); + } + } +#else return new FinallyAsyncIteratorWithTask(source, finallyAction); +#endif } // REVIEW: No cancellation support for finally action. +#if !USE_ASYNC_ITERATOR private sealed class FinallyAsyncIterator : AsyncIterator { private readonly Action _finallyAction; @@ -148,4 +188,5 @@ protected override async ValueTask MoveNextCore() } } } +#endif } From 322c338cac31b3f2eeabe8e3e78d778a8e7f2fa0 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 22:24:49 -0800 Subject: [PATCH 713/862] Use async iterators in Concat. --- .../System/Linq/Operators/Concat.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index e6f2671c91..7d2f1e7c4d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -16,7 +16,22 @@ public static IAsyncEnumerable Concat(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + await foreach (IAsyncEnumerable source in sources.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new ConcatAsyncEnumerableAsyncIterator(sources); +#endif } public static IAsyncEnumerable Concat(this IEnumerable> sources) @@ -24,7 +39,22 @@ public static IAsyncEnumerable Concat(this IEnumerable Core(CancellationToken cancellationToken) + { + foreach (IAsyncEnumerable source in sources) + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return ConcatCore(sources); +#endif } public static IAsyncEnumerable Concat(params IAsyncEnumerable[] sources) @@ -32,9 +62,25 @@ public static IAsyncEnumerable Concat(params IAsyncEnumerable< if (sources == null) throw Error.ArgumentNull(nameof(sources)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + foreach (IAsyncEnumerable source in sources) + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return ConcatCore(sources); +#endif } +#if !USE_ASYNC_ITERATOR private static IAsyncEnumerable ConcatCore(IEnumerable> sources) { return new ConcatEnumerableAsyncIterator(sources); @@ -218,4 +264,5 @@ protected override async ValueTask MoveNextCore() } } } +#endif } From 73df2b7b70d20f125e5778db06000eb3670f58d6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 22:41:45 -0800 Subject: [PATCH 714/862] Using async iterators for Buffer. --- .../System/Linq/Operators/Buffer.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index dd688ee6ad..4cdc84212b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -18,7 +18,33 @@ public static IAsyncEnumerable> Buffer(this IAsyncEnumer if (count <= 0) throw Error.ArgumentOutOfRange(nameof(count)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator> Core(CancellationToken cancellationToken) + { + var buffer = new List(count); + + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + buffer.Add(item); + + if (buffer.Count == count) + { + yield return buffer; + + buffer = new List(count); + } + } + + if (buffer.Count > 0) + { + yield return buffer; + } + } +#else return new BufferAsyncIterator(source, count, count); +#endif } public static IAsyncEnumerable> Buffer(this IAsyncEnumerable source, int count, int skip) @@ -30,9 +56,44 @@ public static IAsyncEnumerable> Buffer(this IAsyncEnumer if (skip <= 0) throw Error.ArgumentOutOfRange(nameof(skip)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator> Core(CancellationToken cancellationToken) + { + var buffers = new Queue>(); + + int index = 0; + + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + if (index++ % skip == 0) + { + buffers.Enqueue(new List(count)); + } + + foreach (var buffer in buffers) + { + buffer.Add(item); + } + + if (buffers.Count > 0 && buffers.Peek().Count == count) + { + yield return buffers.Dequeue(); + } + } + + while (buffers.Count > 0) + { + yield return buffers.Dequeue(); + } + } +#else return new BufferAsyncIterator(source, count, skip); +#endif } +#if !USE_ASYNC_ITERATOR private sealed class BufferAsyncIterator : AsyncIterator> { private readonly int _count; @@ -136,4 +197,5 @@ protected override async ValueTask MoveNextCore() } } } +#endif } From c80b4f19877c38b4e6d23cbc9c8016e1a06057ff Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 23:11:07 -0800 Subject: [PATCH 715/862] Use async iterators in Catch. --- .../System/Linq/Operators/Catch.cs | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 05d077ad0d..ea4e197c98 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -12,6 +12,11 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + // REVIEW: All Catch operators may catch OperationCanceledException due to cancellation of the enumeration + // of the source. Should we explicitly avoid handling this? E.g. as follows: + // + // catch (TException ex) when(!(ex is OperationCanceledException oce && oce.CancellationToken == cancellationToken)) + public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func> handler) where TException : Exception { @@ -20,7 +25,54 @@ public static IAsyncEnumerable Catch(this IAsyncEn if (handler == null) throw Error.ArgumentNull(nameof(handler)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + // REVIEW: This implementation mirrors the Ix implementation, which does not protect GetEnumerator + // using the try statement either. A more trivial implementation would use await foreach + // and protect the entire loop using a try statement, with two breaking changes: + // + // - Also protecting the call to GetAsyncEnumerator by the try statement. + // - Invocation of the handler after disposal of the failed first sequence. + + var err = default(IAsyncEnumerable); + + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (true) + { + var c = default(TSource); + + try + { + if (!await e.MoveNextAsync()) + break; + + c = e.Current; + } + catch (TException ex) + { + err = handler(ex); + break; + } + + yield return c; + } + } + + if (err != null) + { + await foreach (var item in err.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new CatchAsyncIterator(source, handler); +#endif } public static IAsyncEnumerable Catch(this IAsyncEnumerable source, Func>> handler) @@ -31,7 +83,54 @@ public static IAsyncEnumerable Catch(this IAsyncEn if (handler == null) throw Error.ArgumentNull(nameof(handler)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + // REVIEW: This implementation mirrors the Ix implementation, which does not protect GetEnumerator + // using the try statement either. A more trivial implementation would use await foreach + // and protect the entire loop using a try statement, with two breaking changes: + // + // - Also protecting the call to GetAsyncEnumerator by the try statement. + // - Invocation of the handler after disposal of the failed first sequence. + + var err = default(IAsyncEnumerable); + + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (true) + { + var c = default(TSource); + + try + { + if (!await e.MoveNextAsync()) + break; + + c = e.Current; + } + catch (TException ex) + { + err = await handler(ex).ConfigureAwait(false); + break; + } + + yield return c; + } + } + + if (err != null) + { + await foreach (var item in err.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new CatchAsyncIteratorWithTask(source, handler); +#endif } #if !NO_DEEP_CANCELLATION @@ -43,7 +142,54 @@ public static IAsyncEnumerable Catch(this IAsyncEn if (handler == null) throw Error.ArgumentNull(nameof(handler)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + // REVIEW: This implementation mirrors the Ix implementation, which does not protect GetEnumerator + // using the try statement either. A more trivial implementation would use await foreach + // and protect the entire loop using a try statement, with two breaking changes: + // + // - Also protecting the call to GetAsyncEnumerator by the try statement. + // - Invocation of the handler after disposal of the failed first sequence. + + var err = default(IAsyncEnumerable); + + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (true) + { + var c = default(TSource); + + try + { + if (!await e.MoveNextAsync()) + break; + + c = e.Current; + } + catch (TException ex) + { + err = await handler(ex, cancellationToken).ConfigureAwait(false); + break; + } + + yield return c; + } + } + + if (err != null) + { + await foreach (var item in err.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new CatchAsyncIteratorWithTaskAndCancellation(source, handler); +#endif } #endif @@ -75,9 +221,52 @@ public static IAsyncEnumerable Catch(this IAsyncEnumerable CatchCore(IEnumerable> sources) { +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var error = default(ExceptionDispatchInfo); + + foreach (var source in sources) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + error = null; + + while (true) + { + var c = default(TSource); + + try + { + if (!await e.MoveNextAsync()) + break; + + c = e.Current; + } + catch (Exception ex) + { + error = ExceptionDispatchInfo.Capture(ex); + break; + } + + yield return c; + } + + if (error == null) + break; + } + } + + error?.Throw(); + } +#else return new CatchAsyncIterator(sources); +#endif } +#if !USE_ASYNC_ITERATOR private sealed class CatchAsyncIterator : AsyncIterator where TException : Exception { private readonly Func> _handler; @@ -453,4 +642,5 @@ protected override async ValueTask MoveNextCore() } } } +#endif } From 95136a668bb484bbdca447af2ef65bf2b6b930b9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 23:13:21 -0800 Subject: [PATCH 716/862] Use async iterators in Defer. --- .../System/Linq/Operators/Defer.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index fb3784acaa..a30e577ee2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -16,7 +16,19 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) + { + await foreach (TSource item in factory().WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } +#else return new DeferIterator(factory); +#endif } public static IAsyncEnumerable Defer(Func>> factory) @@ -24,7 +36,19 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) + { + await foreach (TSource item in (await factory().ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } +#else return new AsyncDeferIterator(factory); +#endif } #if !NO_DEEP_CANCELLATION @@ -33,10 +57,23 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) + { + await foreach (TSource item in (await factory(cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } +#else return new AsyncDeferIteratorWithCancellation(factory); +#endif } #endif +#if !USE_ASYNC_ITERATOR private sealed class DeferIterator : AsyncIteratorBase { private readonly Func> _factory; @@ -209,4 +246,5 @@ private async ValueTask InitializeAndMoveNextAsync() } #endif } +#endif } From b3934fa8e4a1e6916b01667d7bf46a39a172e60b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 23:33:24 -0800 Subject: [PATCH 717/862] Add some notes for USE_ASYNC_ITERATOR --- Ix.NET/Source/Directory.build.targets | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index a3ddc67947..e6f0e6477a 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -12,7 +12,11 @@ - + $(DefineConstants);USE_AWAIT_FOREACH;USE_AWAIT_USING From ea0c7176bac9e2be018b5c7c5aed1ed9ebcb7d7b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 28 Jan 2019 23:44:00 -0800 Subject: [PATCH 718/862] Fix some async iterator implementations. --- .../System/Linq/Operators/Buffer.cs | 6 +++--- .../System/Linq/Operators/Catch.cs | 10 +++++----- .../System/Linq/Operators/Concat.cs | 8 ++++---- .../System/Linq/Operators/Defer.cs | 8 ++++---- .../System/Linq/Operators/Finally.cs | 6 +++--- .../System/Linq/Operators/Generate.cs | 4 ++-- .../System/Linq/Operators/IgnoreElements.cs | 6 ++++-- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 4cdc84212b..4ff739b8fe 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -19,7 +19,7 @@ public static IAsyncEnumerable> Buffer(this IAsyncEnumer throw Error.ArgumentOutOfRange(nameof(count)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator> Core(CancellationToken cancellationToken) { @@ -57,7 +57,7 @@ public static IAsyncEnumerable> Buffer(this IAsyncEnumer throw Error.ArgumentOutOfRange(nameof(skip)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator> Core(CancellationToken cancellationToken) { @@ -196,6 +196,6 @@ protected override async ValueTask MoveNextCore() return false; } } - } #endif + } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index ea4e197c98..df996f6396 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -26,7 +26,7 @@ public static IAsyncEnumerable Catch(this IAsyncEn throw Error.ArgumentNull(nameof(handler)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) { @@ -84,7 +84,7 @@ public static IAsyncEnumerable Catch(this IAsyncEn throw Error.ArgumentNull(nameof(handler)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) { @@ -143,7 +143,7 @@ public static IAsyncEnumerable Catch(this IAsyncEn throw Error.ArgumentNull(nameof(handler)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) { @@ -222,7 +222,7 @@ public static IAsyncEnumerable Catch(this IAsyncEnumerable CatchCore(IEnumerable> sources) { #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) { @@ -641,6 +641,6 @@ protected override async ValueTask MoveNextCore() return false; } } - } #endif + } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index 7d2f1e7c4d..1cf8c8c12c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -17,7 +17,7 @@ public static IAsyncEnumerable Concat(this IAsyncEnumerable Core(CancellationToken cancellationToken) { @@ -40,7 +40,7 @@ public static IAsyncEnumerable Concat(this IEnumerable Core(CancellationToken cancellationToken) { @@ -63,7 +63,7 @@ public static IAsyncEnumerable Concat(params IAsyncEnumerable< throw Error.ArgumentNull(nameof(sources)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) { @@ -263,6 +263,6 @@ protected override async ValueTask MoveNextCore() return false; } } - } #endif + } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index a30e577ee2..f13347a56c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -17,7 +17,7 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) { @@ -37,7 +37,7 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) { @@ -58,7 +58,7 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) { @@ -245,6 +245,6 @@ private async ValueTask InitializeAndMoveNextAsync() } } #endif - } #endif + } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index 55bf5ddfe2..d65dfb2a98 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -19,7 +19,7 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable Core(CancellationToken cancellationToken) { @@ -48,7 +48,7 @@ public static IAsyncEnumerable Finally(this IAsyncEnumerable Core(CancellationToken cancellationToken) { @@ -187,6 +187,6 @@ protected override async ValueTask MoveNextCore() return false; } } - } #endif + } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 994fc0c7f7..2668862057 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable Generate(TState initial throw Error.ArgumentNull(nameof(resultSelector)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -109,6 +109,6 @@ protected override async ValueTask MoveNextCore() return false; } } - } #endif + } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs index 6cb3bac5e4..1821ba53a0 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IgnoreElements.cs @@ -17,13 +17,15 @@ public static IAsyncEnumerable IgnoreElements(this IAsyncEnume throw Error.ArgumentNull(nameof(source)); #if USE_ASYNC_ITERATOR - return Create(Core); + return AsyncEnumerable.Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) { await foreach (var _ in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { } + + yield break; } #else return new IgnoreElementsAsyncIterator(source); @@ -80,6 +82,6 @@ protected override async ValueTask MoveNextCore() return false; } } - } #endif + } } From 3abd5af34210a017013fccd4c30699b4a9f0570d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 29 Jan 2019 00:00:55 -0800 Subject: [PATCH 719/862] Use async iterators in Do. --- .../System/Linq/Operators/Do.cs | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index a566512024..cd0ce69cbc 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -171,21 +171,148 @@ public static IAsyncEnumerable Do(this IAsyncEnumerable DoCore(IAsyncEnumerable source, Action onNext, Action onError, Action onCompleted) { +#if USE_ASYNC_ITERATOR + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (true) + { + TSource item; + + try + { + if (!await e.MoveNextAsync()) + { + break; + } + + item = e.Current; + + onNext(item); + } + catch (OperationCanceledException) + { + throw; + } + catch (Exception ex) when (onError != null) + { + onError(ex); + throw; + } + + yield return item; + } + + onCompleted?.Invoke(); + } + } +#else return new DoAsyncIterator(source, onNext, onError, onCompleted); +#endif } private static IAsyncEnumerable DoCore(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) { +#if USE_ASYNC_ITERATOR + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (true) + { + TSource item; + + try + { + if (!await e.MoveNextAsync()) + { + break; + } + + item = e.Current; + + await onNext(item).ConfigureAwait(false); + } + catch (OperationCanceledException) + { + throw; + } + catch (Exception ex) when (onError != null) + { + await onError(ex).ConfigureAwait(false); + throw; + } + + yield return item; + } + + if (onCompleted != null) + { + await onCompleted().ConfigureAwait(false); + } + } + } +#else return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); +#endif } #if !NO_DEEP_CANCELLATION private static IAsyncEnumerable DoCore(IAsyncEnumerable source, Func onNext, Func onError, Func onCompleted) { +#if USE_ASYNC_ITERATOR + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + while (true) + { + TSource item; + + try + { + if (!await e.MoveNextAsync()) + { + break; + } + + item = e.Current; + + await onNext(item, cancellationToken).ConfigureAwait(false); + } + catch (OperationCanceledException) + { + throw; + } + catch (Exception ex) when (onError != null) + { + await onError(ex, cancellationToken).ConfigureAwait(false); + throw; + } + + yield return item; + } + + if (onCompleted != null) + { + await onCompleted(cancellationToken).ConfigureAwait(false); + } + } + } +#else return new DoAsyncIteratorWithTaskAndCancellation(source, onNext, onError, onCompleted); +#endif } #endif +#if !USE_ASYNC_ITERATOR private sealed class DoAsyncIterator : AsyncIterator { private readonly Action _onCompleted; @@ -420,6 +547,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From a43c59fb3efd007dd0aad060071956f63e7f080c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 29 Jan 2019 09:09:43 -0800 Subject: [PATCH 720/862] Use async iterators in Using. --- .../System/Linq/Operators/Using.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 2e459a2109..60792729bb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -20,7 +20,22 @@ public static IAsyncEnumerable Using(Func Core(CancellationToken cancellationToken) + { + using (TResource resource = resourceFactory()) + { + await foreach (TSource item in enumerableFactory(resource).WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new UsingAsyncIterator(resourceFactory, enumerableFactory); +#endif } public static IAsyncEnumerable Using(Func> resourceFactory, Func>> enumerableFactory) where TResource : IDisposable @@ -30,7 +45,22 @@ public static IAsyncEnumerable Using(Func Core(CancellationToken cancellationToken) + { + using (TResource resource = await resourceFactory().ConfigureAwait(false)) + { + await foreach (TSource item in (await enumerableFactory(resource).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new UsingAsyncIteratorWithTask(resourceFactory, enumerableFactory); +#endif } #if !NO_DEEP_CANCELLATION @@ -41,10 +71,26 @@ public static IAsyncEnumerable Using(Func Core(CancellationToken cancellationToken) + { + using (TResource resource = await resourceFactory(cancellationToken).ConfigureAwait(false)) + { + await foreach (TSource item in (await enumerableFactory(resource, cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new UsingAsyncIteratorWithTaskAndCancellation(resourceFactory, enumerableFactory); +#endif } #endif +#if !USE_ASYNC_ITERATOR private sealed class UsingAsyncIterator : AsyncIterator where TResource : IDisposable { private readonly Func> _enumerableFactory; @@ -247,6 +293,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From 24c8bc9ebf3f3b097b9e1314fcf842cb4b55b41f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 29 Jan 2019 09:24:10 -0800 Subject: [PATCH 721/862] Use async iterators in Scan. --- .../System/Linq/Operators/Scan.cs | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index a9467cde4a..2a51c1b42b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -11,6 +11,10 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + // NB: Implementations of Scan never yield the first element, unlike the behavior of Aggregate on a sequence with one + // element, which returns the first element (or the seed if given an empty sequence). This is compatible with Rx + // but one could argue whether it was the right default. + public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func accumulator) { if (source == null) @@ -18,7 +22,31 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + TSource res = e.Current; + + while (await e.MoveNextAsync()) + { + res = accumulator(res, e.Current); + + yield return res; + } + } + } +#else return new ScanAsyncEnumerable(source, accumulator); +#endif } public static IAsyncEnumerable Scan(this IAsyncEnumerable source, TAccumulate seed, Func accumulator) @@ -28,7 +56,23 @@ public static IAsyncEnumerable Scan(this IAsy if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); +#if USE_ASYNC_ITERATOR + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + TAccumulate res = seed; + + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + res = accumulator(res, item); + + yield return res; + } + } +#else return new ScanAsyncEnumerable(source, seed, accumulator); +#endif } public static IAsyncEnumerable Scan(this IAsyncEnumerable source, Func> accumulator) @@ -38,7 +82,31 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + TSource res = e.Current; + + while (await e.MoveNextAsync()) + { + res = await accumulator(res, e.Current).ConfigureAwait(false); + + yield return res; + } + } + } +#else return new ScanAsyncEnumerableWithTask(source, accumulator); +#endif } #if !NO_DEEP_CANCELLATION @@ -49,7 +117,31 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + TSource res = e.Current; + + while (await e.MoveNextAsync()) + { + res = await accumulator(res, e.Current, cancellationToken).ConfigureAwait(false); + + yield return res; + } + } + } +#else return new ScanAsyncEnumerableWithTaskAndCancellation(source, accumulator); +#endif } #endif @@ -60,7 +152,23 @@ public static IAsyncEnumerable Scan(this IAsy if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); +#if USE_ASYNC_ITERATOR + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + TAccumulate res = seed; + + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + res = await accumulator(res, item).ConfigureAwait(false); + + yield return res; + } + } +#else return new ScanAsyncEnumerableWithTask(source, seed, accumulator); +#endif } #if !NO_DEEP_CANCELLATION @@ -71,10 +179,27 @@ public static IAsyncEnumerable Scan(this IAsy if (accumulator == null) throw Error.ArgumentNull(nameof(accumulator)); +#if USE_ASYNC_ITERATOR + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + TAccumulate res = seed; + + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + res = await accumulator(res, item, cancellationToken).ConfigureAwait(false); + + yield return res; + } + } +#else return new ScanAsyncEnumerableWithTaskAndCancellation(source, seed, accumulator); +#endif } #endif +#if !USE_ASYNC_ITERATOR private sealed class ScanAsyncEnumerable : AsyncIterator { private readonly Func _accumulator; @@ -496,6 +621,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From 9b88948aa1b3e5b64872e4dcae9be12e32ecd5a7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 29 Jan 2019 09:51:28 -0800 Subject: [PATCH 722/862] Use async iterators for DistinctUntilChanged. --- .../Linq/Operators/DistinctUntilChanged.cs | 158 ++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 885dc3faf9..ba123a30c0 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -93,26 +93,183 @@ public static IAsyncEnumerable DistinctUntilChanged(this private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, IEqualityComparer comparer) { +#if USE_ASYNC_ITERATOR + if (comparer == null) + { + comparer = EqualityComparer.Default; + } + + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + TSource latest = e.Current; + + yield return latest; + + while (await e.MoveNextAsync()) + { + TSource item = e.Current; + + if (!comparer.Equals(latest, item)) + { + latest = item; + + yield return latest; + } + } + } + } +#else return new DistinctUntilChangedAsyncIterator(source, comparer); +#endif } private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) { +#if USE_ASYNC_ITERATOR + if (comparer == null) + { + comparer = EqualityComparer.Default; + } + + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + TSource item = e.Current; + + TKey latestKey = keySelector(item); + + yield return item; + + while (await e.MoveNextAsync()) + { + item = e.Current; + + TKey currentKey = keySelector(item); + + if (!comparer.Equals(latestKey, currentKey)) + { + latestKey = currentKey; + + yield return item; + } + } + } + } +#else return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); +#endif } private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { +#if USE_ASYNC_ITERATOR + if (comparer == null) + { + comparer = EqualityComparer.Default; + } + + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + TSource item = e.Current; + + TKey latestKey = await keySelector(item).ConfigureAwait(false); + + yield return item; + + while (await e.MoveNextAsync()) + { + item = e.Current; + + TKey currentKey = await keySelector(item).ConfigureAwait(false); + + if (!comparer.Equals(latestKey, currentKey)) + { + latestKey = currentKey; + + yield return item; + } + } + } + } +#else return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); +#endif } #if !NO_DEEP_CANCELLATION private static IAsyncEnumerable DistinctUntilChangedCore(IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) { +#if USE_ASYNC_ITERATOR + if (comparer == null) + { + comparer = EqualityComparer.Default; + } + + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + { + if (!await e.MoveNextAsync()) + { + yield break; + } + + TSource item = e.Current; + + TKey latestKey = await keySelector(item, cancellationToken).ConfigureAwait(false); + + yield return item; + + while (await e.MoveNextAsync()) + { + item = e.Current; + + TKey currentKey = await keySelector(item, cancellationToken).ConfigureAwait(false); + + if (!comparer.Equals(latestKey, currentKey)) + { + latestKey = currentKey; + + yield return item; + } + } + } + } +#else return new DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(source, keySelector, comparer); +#endif } #endif +#if !USE_ASYNC_ITERATOR private sealed class DistinctUntilChangedAsyncIterator : AsyncIterator { private readonly IEqualityComparer _comparer; @@ -400,6 +557,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From c835b01ea95c007c16741215c524ca749475de4f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 29 Jan 2019 10:07:58 -0800 Subject: [PATCH 723/862] Use async iterators in Repeat. --- .../System/Linq/Operators/Repeat.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index 0f581e68be..48128ca66b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -13,7 +13,23 @@ public static partial class AsyncEnumerableEx { public static IAsyncEnumerable Repeat(TResult element) { +#if USE_ASYNC_ITERATOR + return AsyncEnumerable.Create(Core); + +#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + while (true) + { + cancellationToken.ThrowIfCancellationRequested(); + + yield return element; + } + } +#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously +#else return new RepeatElementAsyncIterator(element); +#endif } public static IAsyncEnumerable Repeat(this IAsyncEnumerable source) @@ -21,7 +37,22 @@ public static IAsyncEnumerable Repeat(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + while (true) + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new RepeatSequenceAsyncIterator(source, -1); +#endif } public static IAsyncEnumerable Repeat(this IAsyncEnumerable source, int count) @@ -31,9 +62,25 @@ public static IAsyncEnumerable Repeat(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + for (var i = 0; i < count; i++) + { + await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + { + yield return item; + } + } + } +#else return new RepeatSequenceAsyncIterator(source, count); +#endif } +#if !USE_ASYNC_ITERATOR private sealed class RepeatElementAsyncIterator : AsyncIterator { private readonly TResult _element; @@ -124,5 +171,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 038c9696f73a584854298c2a003130ef59ba155a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 29 Jan 2019 10:15:03 -0800 Subject: [PATCH 724/862] Use async iterators in Expand. --- .../System/Linq/Operators/Expand.cs | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index bb7aeda337..dcdf6e6590 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -18,7 +18,28 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var queue = new Queue>(); + + queue.Enqueue(source); + + while (queue.Count > 0) + { + await foreach (TSource item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) + { + queue.Enqueue(selector(item)); + + yield return item; + } + } + } +#else return new ExpandAsyncIterator(source, selector); +#endif } public static IAsyncEnumerable Expand(this IAsyncEnumerable source, Func>> selector) @@ -28,7 +49,28 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var queue = new Queue>(); + + queue.Enqueue(source); + + while (queue.Count > 0) + { + await foreach (TSource item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) + { + queue.Enqueue(await selector(item).ConfigureAwait(false)); + + yield return item; + } + } + } +#else return new ExpandAsyncIteratorWithTask(source, selector); +#endif } #if !NO_DEEP_CANCELLATION @@ -39,10 +81,32 @@ public static IAsyncEnumerable Expand(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var queue = new Queue>(); + + queue.Enqueue(source); + + while (queue.Count > 0) + { + await foreach (TSource item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) + { + queue.Enqueue(await selector(item, cancellationToken).ConfigureAwait(false)); + + yield return item; + } + } + } +#else return new ExpandAsyncIteratorWithTaskAndCancellation(source, selector); +#endif } #endif +#if !USE_ASYNC_ITERATOR private sealed class ExpandAsyncIterator : AsyncIterator { private readonly Func> _selector; @@ -313,6 +377,7 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif #endif } } From a161220127f35735902766a8740a8cc82aa2c2ae Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 30 Jan 2019 21:42:44 -0800 Subject: [PATCH 725/862] Use async iterators in Merge. --- .../System/Linq/Operators/Merge.cs | 156 +++++++++++++++++- .../System.Interactive.Async/TaskExt.cs | 2 +- 2 files changed, 152 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index aedf933ac4..bdbf119830 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -15,7 +16,128 @@ public static IAsyncEnumerable Merge(params IAsyncEnumerable Core(CancellationToken cancellationToken) + { + var count = sources.Length; + + var enumerators = new IAsyncEnumerator[count]; + var moveNextTasks = new Task[count]; + + try + { + for (var i = 0; i < count; i++) + { + IAsyncEnumerator enumerator = sources[i].GetAsyncEnumerator(cancellationToken); + enumerators[i] = enumerator; + + // REVIEW: This follows the lead of the original implementation where we kick off MoveNextAsync + // operations immediately. An alternative would be to do this in a separate stage, thus + // preventing concurrency across MoveNextAsync and GetAsyncEnumerator calls and avoiding + // any MoveNextAsync calls before all enumerators are acquired (or an exception has + // occurred doing so). + + moveNextTasks[i] = enumerator.MoveNextAsync().AsTask(); + } + + int active = count; + + while (active > 0) + { + // REVIEW: Performance of WhenAny may be an issue when called repeatedly like this. We should + // measure and could consider operating directly on the ValueTask objects, thus + // also preventing the Task allocations from AsTask. + + var moveNextTask = await Task.WhenAny(moveNextTasks).ConfigureAwait(false); + + int index = Array.IndexOf(moveNextTasks, moveNextTask); + + IAsyncEnumerator enumerator = enumerators[index]; + + if (!await moveNextTask.ConfigureAwait(false)) + { + moveNextTasks[index] = TaskExt.Never; + + // REVIEW: The original implementation did not dispose eagerly, which could lead to resource + // leaks when merged with other long-running sequences. + + enumerators[index] = null; // NB: Avoids attempt at double dispose in finally if disposing fails. + await enumerator.DisposeAsync().ConfigureAwait(false); + + active--; + } + else + { + TSource item = enumerator.Current; + + moveNextTasks[index] = enumerator.MoveNextAsync().AsTask(); + + yield return item; + } + } + } + finally + { + // REVIEW: The original implementation performs a concurrent dispose, which seems undesirable given the + // additional uncontrollable source of concurrency and the sequential resource acquisition. In + // this modern implementation, we release resources in opposite order as we acquired them, thus + // guaranteeing determinism (and mimicking a series of nested `await using` statements). + + // REVIEW: If we decide to phase GetAsyncEnumerator and the initial MoveNextAsync calls at the start of + // the operator implementation, we should make this symmetric and first await all in flight + // MoveNextAsync operations, prior to disposing the enumerators. + + var errors = default(List); + + for (var i = count - 1; i >= 0; i--) + { + Task moveNextTask = moveNextTasks[i]; + IAsyncEnumerator enumerator = enumerators[i]; + + try + { + try + { + if (moveNextTask != null && moveNextTask != TaskExt.Never) + { + _ = await moveNextTask.ConfigureAwait(false); + } + } + finally + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + } + } + catch (Exception ex) + { + if (errors == null) + { + errors = new List(); + } + + errors.Add(ex); + } + } + + // NB: If we had any errors during cleaning (and awaiting pending operations), we throw these exceptions + // instead of the original exception that may have led to running the finally block. This is similar + // to throwing from any finally block (except that we catch all exceptions to ensure cleanup of all + // concurrent sequences being merged). + + if (errors != null) + { + throw new AggregateException(errors); + } + } + } +#else return new MergeAsyncIterator(sources); +#endif } public static IAsyncEnumerable Merge(this IEnumerable> sources) @@ -23,6 +145,25 @@ public static IAsyncEnumerable Merge(this IEnumerable source); } @@ -31,6 +172,11 @@ public static IAsyncEnumerable Merge(this IAsyncEnumerable source); } @@ -39,7 +185,7 @@ private sealed class MergeAsyncIterator : AsyncIterator private readonly IAsyncEnumerable[] _sources; private IAsyncEnumerator[] _enumerators; - private ValueTask[] _moveNexts; + private Task[] _moveNexts; private int _active; public MergeAsyncIterator(IAsyncEnumerable[] sources) @@ -83,14 +229,14 @@ protected override async ValueTask MoveNextCore() var n = _sources.Length; _enumerators = new IAsyncEnumerator[n]; - _moveNexts = new ValueTask[n]; + _moveNexts = new Task[n]; _active = n; for (var i = 0; i < n; i++) { var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); _enumerators[i] = enumerator; - _moveNexts[i] = enumerator.MoveNextAsync(); + _moveNexts[i] = enumerator.MoveNextAsync().AsTask(); } _state = AsyncIteratorState.Iterating; @@ -105,7 +251,7 @@ protected override async ValueTask MoveNextCore() // want to consider a "prefer fairness" option. // - var moveNext = await Task.WhenAny(_moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); + var moveNext = await Task.WhenAny(_moveNexts).ConfigureAwait(false); var index = Array.IndexOf(_moveNexts, moveNext); @@ -118,7 +264,7 @@ protected override async ValueTask MoveNextCore() { var enumerator = _enumerators[index]; _current = enumerator.Current; - _moveNexts[index] = enumerator.MoveNextAsync(); + _moveNexts[index] = enumerator.MoveNextAsync().AsTask(); return true; } } diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index 521f0a63ca..4a6dc2dbc9 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -6,6 +6,6 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly ValueTask Never = new ValueTask(new TaskCompletionSource().Task); + public static readonly Task Never = new TaskCompletionSource().Task; } } From 57b45a60ad131fbec1c751617af3cb633ee622f3 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Jan 2019 12:05:10 -0800 Subject: [PATCH 726/862] Adding a prototype for a cheaper and fair concurrent Merge implementation (USE_FAIR_AND_CHEAPER_MERGE). --- .../System/Linq/Operators/Merge.cs | 166 ++++++++++++- .../System.Interactive.Async/TaskExt.cs | 235 ++++++++++++++++++ 2 files changed, 400 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index bdbf119830..954d28029b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -16,7 +16,161 @@ public static IAsyncEnumerable Merge(params IAsyncEnumerable to Task takes place using AsTask, + // - we don't instantiate Task.WhenAny tasks for each iteration. + // - It's fairer because: + // - the MoveNextAsync tasks are awaited concurently, but completions are queued, + // instead of awaiting a new WhenAny task where "left" sources have preferential + // treatment over "right" sources. + // + + return AsyncEnumerable.Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + var count = sources.Length; + + var enumerators = new IAsyncEnumerator[count]; + var moveNextTasks = new ValueTask[count]; + + try + { + for (var i = 0; i < count; i++) + { + IAsyncEnumerator enumerator = sources[i].GetAsyncEnumerator(cancellationToken); + enumerators[i] = enumerator; + + // REVIEW: This follows the lead of the original implementation where we kick off MoveNextAsync + // operations immediately. An alternative would be to do this in a separate stage, thus + // preventing concurrency across MoveNextAsync and GetAsyncEnumerator calls and avoiding + // any MoveNextAsync calls before all enumerators are acquired (or an exception has + // occurred doing so). + + moveNextTasks[i] = enumerator.MoveNextAsync(); + } + + var whenAny = TaskExt.WhenAny(moveNextTasks); + + int active = count; + + while (active > 0) + { + int index = await whenAny; + + IAsyncEnumerator enumerator = enumerators[index]; + ValueTask moveNextTask = moveNextTasks[index]; + + if (!await moveNextTask.ConfigureAwait(false)) + { + // + // Replace the task in our array by a completed task to make finally logic easier. Note that + // the WhenAnyValueTask object has a reference to our array (i.e. no copy is made), so this + // gets rid of any resources the original task may have held onto. However, we *don't* call + // whenAny.Replace to set this value, because it'd attach an awaiter to the already completed + // task, causing spurious wake-ups when awaiting whenAny. + // + + moveNextTasks[index] = new ValueTask(); + + // REVIEW: The original implementation did not dispose eagerly, which could lead to resource + // leaks when merged with other long-running sequences. + + enumerators[index] = null; // NB: Avoids attempt at double dispose in finally if disposing fails. + await enumerator.DisposeAsync().ConfigureAwait(false); + + active--; + } + else + { + TSource item = enumerator.Current; + + // + // Replace the task using whenAny.Replace, which will write it to the moveNextTasks array, and + // will start awaiting the task. Note we don't have to write to moveNextTasks ourselves because + // the whenAny object has a reference to it (i.e. no copy is made). + // + + whenAny.Replace(index, enumerator.MoveNextAsync()); + + yield return item; + } + } + } + finally + { + // REVIEW: The original implementation performs a concurrent dispose, which seems undesirable given the + // additional uncontrollable source of concurrency and the sequential resource acquisition. In + // this modern implementation, we release resources in opposite order as we acquired them, thus + // guaranteeing determinism (and mimicking a series of nested `await using` statements). + + // REVIEW: If we decide to phase GetAsyncEnumerator and the initial MoveNextAsync calls at the start of + // the operator implementation, we should make this symmetric and first await all in flight + // MoveNextAsync operations, prior to disposing the enumerators. + + var errors = default(List); + + for (var i = count - 1; i >= 0; i--) + { + ValueTask moveNextTask = moveNextTasks[i]; + IAsyncEnumerator enumerator = enumerators[i]; + + try + { + try + { + // + // Await the task to ensure outstanding work is completed prior to performing a dispose + // operation. Note that we don't have to do anything special for tasks belonging to + // enumerators that have finished; we swapped in a placeholder completed task. + // + + // REVIEW: This adds an additional continuation to all of the pending tasks (note that + // whenAny also has registered one). The whenAny object will be collectible + // after all of these complete. Alternatively, we could drain via whenAny, by + // awaiting it until the active count drops to 0. This saves on attaching the + // additional continuations, but we need to decide on order of dispose. Right + // now, we dispose in opposite order of acquiring the enumerators, with the + // exception of enumerators that were disposed eagerly upon early completion. + // Should we care about the dispose order at all? + + _ = await moveNextTask.ConfigureAwait(false); + } + finally + { + if (enumerator != null) + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } + } + } + catch (Exception ex) + { + if (errors == null) + { + errors = new List(); + } + + errors.Add(ex); + } + } + + // NB: If we had any errors during cleaning (and awaiting pending operations), we throw these exceptions + // instead of the original exception that may have led to running the finally block. This is similar + // to throwing from any finally block (except that we catch all exceptions to ensure cleanup of all + // concurrent sequences being merged). + + if (errors != null) + { + throw new AggregateException(errors); + } + } + } +#elif USE_ASYNC_ITERATOR return AsyncEnumerable.Create(Core); async IAsyncEnumerator Core(CancellationToken cancellationToken) @@ -52,6 +206,11 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var moveNextTask = await Task.WhenAny(moveNextTasks).ConfigureAwait(false); + // REVIEW: This seems wrong. AsTask can return the original Task (if the ValueTask + // is wrapping one) or return a singleton instance for true and false, at which point + // the use of IndexOf may pick an element closer to the start of the array because of + // reference equality checks and aliasing effects. See GetTaskForResult in the BCL. + int index = Array.IndexOf(moveNextTasks, moveNextTask); IAsyncEnumerator enumerator = enumerators[index]; @@ -253,6 +412,11 @@ protected override async ValueTask MoveNextCore() var moveNext = await Task.WhenAny(_moveNexts).ConfigureAwait(false); + // REVIEW: This seems wrong. AsTask can return the original Task (if the ValueTask + // is wrapping one) or return a singleton instance for true and false, at which point + // the use of IndexOf may pick an element closer to the start of the array because of + // reference equality checks and aliasing effects. See GetTaskForResult in the BCL. + var index = Array.IndexOf(_moveNexts, moveNext); if (!await moveNext.ConfigureAwait(false)) diff --git a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs index 4a6dc2dbc9..c91f053119 100644 --- a/Ix.NET/Source/System.Interactive.Async/TaskExt.cs +++ b/Ix.NET/Source/System.Interactive.Async/TaskExt.cs @@ -2,10 +2,245 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; + namespace System.Threading.Tasks { internal static class TaskExt { public static readonly Task Never = new TaskCompletionSource().Task; + +#if USE_FAIR_AND_CHEAPER_MERGE + public static WhenAnyValueTask WhenAny(ValueTask[] tasks) + { + var whenAny = new WhenAnyValueTask(tasks); + + whenAny.Start(); + + return whenAny; + } + + // REVIEW: Evaluate options to reduce locking and test performance. Right now, there's one lock + // protecting the queue and the completion delegate field. Care has been taken to limit + // the time under the lock, and the (sequential single) reader path has limited locking. + // Contention due to concurrent completion of tasks could be a concern. + + internal sealed class WhenAnyValueTask + { + /// + /// The tasks to await. Entries in this array may be replaced using . + /// + private readonly ValueTask[] _tasks; + + /// + /// Array of cached delegates passed to awaiters on tasks. These delegates have a closure containing the task index. + /// + private readonly Action[] _onReady; + + /// + /// Queue of indexes of ready tasks. Awaiting the object will consume this queue in order. + /// + /// + /// A lock on this field is taken when updating the queue or . + /// + private readonly Queue _ready; + + /// + /// Callback of the current awaiter, if any. + /// + /// + /// Protected for reads and writes by a lock on . + /// + private Action _onCompleted; + + /// + /// Creates a when any task around the specified tasks. + /// + /// Initial set of tasks to await. + public WhenAnyValueTask(ValueTask[] tasks) + { + _tasks = tasks; + + var n = tasks.Length; + + _ready = new Queue(n); // NB: Should never exceed this length, so we won't see dynamic realloc. + _onReady = new Action[n]; + + for (var i = 0; i < n; i++) + { + // + // Cache these delegates, for they have closures (over `this` and `index`), and we need them + // for each replacement of a task, to hook up the continuation. + // + + int index = i; + _onReady[index] = () => OnReady(index); + } + } + + /// + /// Start awaiting the tasks. This is done separately from the constructor to avoid complexity dealing + /// with handling concurrent callbacks to the current instance while the constructor is running. + /// + public void Start() + { + for (var i = 0; i < _tasks.Length; i++) + { + // + // Register a callback with the task, which will enqueue the index of the completed task + // for consumption by awaiters. + // + + _tasks[i].ConfigureAwait(false).GetAwaiter().OnCompleted(_onReady[i]); + } + } + + /// + /// Gets an awaiter to await completion of any of the awaited tasks, returning the index of the completed + /// task. When sequentially awaiting the current instance, task indices are yielded in the order that of + /// completion. If all tasks have completed and been observed by awaiting the current instance, the awaiter + /// never returns on a subsequent attempt to await the completion of any task. The caller is responsible + /// for bookkeeping that avoids awaiting this instance more often than the number of pending tasks. + /// + /// Awaiter to await completion of any of the awaited task. + /// This class only supports a single active awaiter at any point in time. + public Awaiter GetAwaiter() => new Awaiter(this); + + /// + /// Replaces the (completed) task at the specified and starts awaiting it. + /// + /// The index of the parameter to replace. + /// The new task to store and await at the specified index. + public void Replace(int index, in ValueTask task) + { + Debug.Assert(_tasks[index].IsCompleted, "A task shouldn't be replaced before it has completed."); + + _tasks[index] = task; + + task.ConfigureAwait(false).GetAwaiter().OnCompleted(_onReady[index]); + } + + /// + /// Called when any task has completed (thus may run concurrently). + /// + /// The index of the completed task in . + private void OnReady(int index) + { + Action onCompleted = null; + + lock (_ready) + { + // + // Store the index of the task that has completed. This will be picked up from GetResult. + // + + _ready.Enqueue(index); + + // + // If there's a current awaiter, we'll steal its continuation action and invoke it. By setting + // the continuation action to null, we avoid waking up the same awaiter more than once. Any + // task completions that occur while no awaiter is active will end up being enqueued in _ready. + // + + if (_onCompleted != null) + { + onCompleted = _onCompleted; + _onCompleted = null; + } + } + + onCompleted?.Invoke(); + } + + /// + /// Invoked by awaiters to check if any task has completed, in order to short-circuit the await operation. + /// + /// true if any task has completed; otherwise, false. + private bool IsCompleted() + { + // REVIEW: Evaluate options to reduce locking, so the single consuming awaiter has limited contention + // with the multiple concurrent completing enumerator tasks, e.g. using ConcurrentQueue. + + lock (_ready) + { + return _ready.Count > 0; + } + } + + /// + /// Gets the index of the earliest task that has completed, used by the awaiter. After stealing an index from + /// the ready queue (by means of awaiting the current instance), the user may chose to replace the task at the + /// returned index by a new task, using the method. + /// + /// Index of the earliest task that has completed. + private int GetResult() + { + lock (_ready) + { + return _ready.Dequeue(); + } + } + + /// + /// Register a continuation passed by an awaiter. + /// + /// The continuation action delegate to call when any task is ready. + private void OnCompleted(Action action) + { + bool shouldInvoke = false; + + lock (_ready) + { + // + // Check if we have anything ready (which could happen in the short window between checking + // for IsCompleted and calling OnCompleted). If so, we should invoke the action directly. Not + // doing so would be a correctness issue where a task has completed, its index was enqueued, + // but the continuation was never called (unless another task completes and calls the action + // delegate, whose subsequent call to GetResult would pick up the lost index). + // + + if (_ready.Count > 0) + { + shouldInvoke = true; + } + else + { + Debug.Assert(_onCompleted == null, "Only a single awaiter is allowed."); + + _onCompleted = action; + } + } + + // + // NB: We assume this case is rare enough (IsCompleted and OnCompleted happen right after one + // another, and an enqueue should have happened right in between to go from an empty to a + // non-empty queue), so we don't run the risk of triggering a stack overflow due to + // synchronous completion of the await operation (which may be in a loop that awaits the + // current instance again). + // + + if (shouldInvoke) + { + action(); + } + } + + /// + /// Awaiter type used to await completion of any task. + /// + public struct Awaiter : INotifyCompletion + { + private readonly WhenAnyValueTask _parent; + + public Awaiter(WhenAnyValueTask parent) => _parent = parent; + + public bool IsCompleted => _parent.IsCompleted(); + public int GetResult() => _parent.GetResult(); + public void OnCompleted(Action action) => _parent.OnCompleted(action); + } + } +#endif } } From a2762d977f04b9aa42df4e445c04da23bf832d97 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Jan 2019 13:49:56 -0800 Subject: [PATCH 727/862] Use async iterators in Amb (and fixing issues). --- .../System/Linq/Operators/Amb.cs | 239 +++++++++++++++++- 1 file changed, 233 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 436c13c62f..3464ec5344 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Threading; using System.Threading.Tasks; namespace System.Linq @@ -17,7 +18,117 @@ public static IAsyncEnumerable Amb(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + IAsyncEnumerator firstEnumerator = null; + IAsyncEnumerator secondEnumerator = null; + + Task firstMoveNext = null; + Task secondMoveNext = null; + + try + { + // + // REVIEW: We start both sequences unconditionally. An alternative implementation could be to just stick + // to the first sequence if we notice it already has a value (or exception) available. This would + // be similar to Task.WhenAny behavior (see CommonCWAnyLogic in dotnet/coreclr). We could consider + // adding a WhenAny combinator that does exactly that. We can even avoid calling AsTask. + // + + firstEnumerator = first.GetAsyncEnumerator(cancellationToken); + firstMoveNext = firstEnumerator.MoveNextAsync().AsTask(); + + // + // REVIEW: Order of operations has changed here compared to the original, but is now in sync with the N-ary + // overload which performs GetAsyncEnumerator/MoveNextAsync in pairs, rather than phased. + // + + secondEnumerator = second.GetAsyncEnumerator(cancellationToken); + secondMoveNext = secondEnumerator.MoveNextAsync().AsTask(); + } + catch + { + // NB: AwaitMoveNextAsyncAndDispose checks for null for both arguments, reducing the need for many null + // checks over here. + + var cleanup = new[] + { + AwaitMoveNextAsyncAndDispose(secondMoveNext, secondEnumerator), + AwaitMoveNextAsyncAndDispose(firstMoveNext, firstEnumerator) + }; + + await Task.WhenAll(cleanup).ConfigureAwait(false); + + throw; + } + + // + // REVIEW: Consider using the WhenAny combinator defined for Merge in TaskExt, which would avoid the need + // to convert to Task prior to calling Task.WhenAny. + // + + var moveNextWinner = await Task.WhenAny(firstMoveNext, secondMoveNext).ConfigureAwait(false); + + // + // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: + // + // 1. Concurrent DisposeAsync while a MoveNextAsync is in flight. + // 2. The winner elected by Amb is blocked to yield results until the loser unblocks. + // + + IAsyncEnumerator winner; + Task disposeLoser; + + if (moveNextWinner == firstMoveNext) + { + winner = firstEnumerator; + disposeLoser = AwaitMoveNextAsyncAndDispose(secondMoveNext, secondEnumerator); + } + else + { + winner = secondEnumerator; + disposeLoser = AwaitMoveNextAsyncAndDispose(firstMoveNext, firstEnumerator); + } + + try + { + await using (var e = winner.ConfigureAwait(false)) + { + if (!await moveNextWinner.ConfigureAwait(false)) + { + yield break; + } + + yield return e.Current; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + } + } + finally + { + // + // REVIEW: This behavior differs from the original implementation in that we never discard any in flight + // asynchronous operations. If an exception occurs while enumerating the winner, it can be + // subsumed by an exception thrown due to cleanup of the loser. Also, if Amb is used to deal with + // a potentially long-blocking sequence, this implementation would transfer this blocking behavior + // to the resulting sequence. However, it seems never discarding a non-completed task should be a + // general design tenet, and fire-and-forget dispose behavior could be added as another "unsafe" + // operator, so all such sins are made explicit by the user. Nonetheless, this change is a breaking + // change for Ix Async. + // + + await disposeLoser.ConfigureAwait(false); + } + } +#else return new AmbAsyncIterator(first, second); +#endif } public static IAsyncEnumerable Amb(params IAsyncEnumerable[] sources) @@ -25,7 +136,97 @@ public static IAsyncEnumerable Amb(params IAsyncEnumerable Core(CancellationToken cancellationToken) + { + // + // REVIEW: See remarks on binary overload for changes compared to the original. + // + + var n = sources.Length; + + var enumerators = new IAsyncEnumerator[n]; + var moveNexts = new Task[n]; + + try + { + for (var i = 0; i < n; i++) + { + var enumerator = sources[i].GetAsyncEnumerator(cancellationToken); + + enumerators[i] = enumerator; + moveNexts[i] = enumerator.MoveNextAsync().AsTask(); + } + } + catch + { + var cleanup = new Task[n]; + + for (var i = 0; i < n; i++) + { + cleanup[i] = AwaitMoveNextAsyncAndDispose(moveNexts[i], enumerators[i]); + } + + await Task.WhenAll(cleanup).ConfigureAwait(false); + throw; + } + + var moveNextWinner = await Task.WhenAny(moveNexts).ConfigureAwait(false); + + // + // NB: The use of IndexOf is fine. If task N completed by returning a ValueTask + // which is equivalent to the task returned by task M (where M < N), AsTask may + // return the same reference (e.g. due to caching of completed Boolean tasks). In + // such a case, IndexOf will find task M rather than N in the array, but both have + // an equivalent completion state (because they're reference equal). This only leads + // to a left-bias in selection of sources, but given Amb's "ambiguous" nature, this + // is acceptable. + // + + var winnerIndex = Array.IndexOf(moveNexts, moveNextWinner); + + IAsyncEnumerator winner = enumerators[winnerIndex]; + + var loserCleanupTasks = new List(n - 1); + + for (var i = 0; i < n; i++) + { + if (i != winnerIndex) + { + var loserCleanupTask = AwaitMoveNextAsyncAndDispose(moveNexts[i], enumerators[i]); + loserCleanupTasks.Add(loserCleanupTask); + } + } + + var cleanupLosers = Task.WhenAll(loserCleanupTasks); + + try + { + await using (var e = winner.ConfigureAwait(false)) + { + if (!await moveNextWinner.ConfigureAwait(false)) + { + yield break; + } + + yield return e.Current; + + while (await e.MoveNextAsync()) + { + yield return e.Current; + } + } + } + finally + { + await cleanupLosers.ConfigureAwait(false); + } + } +#else return new AmbAsyncIteratorN(sources); +#endif } public static IAsyncEnumerable Amb(this IEnumerable> sources) @@ -33,9 +234,30 @@ public static IAsyncEnumerable Amb(this IEnumerable(sources.ToArray()); +#endif + } + +#if USE_ASYNC_ITERATOR + private static async Task AwaitMoveNextAsyncAndDispose(Task moveNextAsync, IAsyncEnumerator enumerator) + { + if (enumerator != null) + { + await using (enumerator.ConfigureAwait(false)) + { + if (moveNextAsync != null) + { + await moveNextAsync.ConfigureAwait(false); + } + } + } } +#endif +#if !USE_ASYNC_ITERATOR private sealed class AmbAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _first; @@ -73,6 +295,10 @@ protected override async ValueTask MoveNextCore() switch (_state) { case AsyncIteratorState.Allocated: + // + // REVIEW: Exceptions in any of these steps don't cause cleanup. This has been fixed in the new implementation. + // + var firstEnumerator = _first.GetAsyncEnumerator(_cancellationToken); var secondEnumerator = _second.GetAsyncEnumerator(_cancellationToken); @@ -94,7 +320,7 @@ protected override async ValueTask MoveNextCore() { _enumerator = firstEnumerator; - var ignored = secondMoveNext.ContinueWith(_ => + _ = secondMoveNext.ContinueWith(_ => { secondEnumerator.DisposeAsync(); }); @@ -103,7 +329,7 @@ protected override async ValueTask MoveNextCore() { _enumerator = secondEnumerator; - var ignored = firstMoveNext.ContinueWith(_ => + _ = firstMoveNext.ContinueWith(_ => { firstEnumerator.DisposeAsync(); }); @@ -171,17 +397,17 @@ protected override async ValueTask MoveNextCore() var n = _sources.Length; var enumerators = new IAsyncEnumerator[n]; - var moveNexts = new ValueTask[n]; + var moveNexts = new Task[n]; for (var i = 0; i < n; i++) { var enumerator = _sources[i].GetAsyncEnumerator(_cancellationToken); enumerators[i] = enumerator; - moveNexts[i] = enumerator.MoveNextAsync(); + moveNexts[i] = enumerator.MoveNextAsync().AsTask(); } - var winner = await Task.WhenAny(moveNexts.Select(t => t.AsTask())).ConfigureAwait(false); + var winner = await Task.WhenAny(moveNexts).ConfigureAwait(false); // // REVIEW: An alternative option is to call DisposeAsync on the other and await it, but this has two drawbacks: @@ -200,7 +426,7 @@ protected override async ValueTask MoveNextCore() { if (i != winnerIndex) { - var ignored = moveNexts[i].AsTask().ContinueWith(_ => + _ = moveNexts[i].ContinueWith(_ => { enumerators[i].DisposeAsync(); }); @@ -231,5 +457,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 89ec92be8b088f40301871c59a5304ff8619933c Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Jan 2019 13:51:52 -0800 Subject: [PATCH 728/862] Implement IsEmpty directly. --- .../System/Linq/Operators/IsEmpty.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index 9a0d47b614..a35bf9d828 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -19,7 +19,10 @@ public static Task IsEmptyAsync(this IAsyncEnumerable so static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - return !await _source.AnyAsync(_cancellationToken).ConfigureAwait(false); + await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + { + return !await e.MoveNextAsync(); + } } } } From a2845c9de7e264009356da81066d0c01f5289d8d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Thu, 31 Jan 2019 13:54:24 -0800 Subject: [PATCH 729/862] Add review comment to StartWith. --- .../System/Linq/Operators/StartWith.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs index 87818ac81f..4376308702 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/StartWith.cs @@ -8,6 +8,9 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { + // REVIEW: This is really an n-ary Prepend. Should we add n-ary overloads of Append and Prepend as well? + // If so, likely in Ix rather than System.Linq.Async. + public static IAsyncEnumerable StartWith(this IAsyncEnumerable source, params TSource[] values) { if (source == null) From 2582c7ca3bd9d24454dc4eaf524001f46846c528 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Thu, 31 Jan 2019 23:19:50 +0000 Subject: [PATCH 730/862] Update to .NET Core 3 preview 2 SDK --- azure-pipelines.ix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.ix.yml b/azure-pipelines.ix.yml index 17ff3be657..b80f107f92 100644 --- a/azure-pipelines.ix.yml +++ b/azure-pipelines.ix.yml @@ -30,7 +30,7 @@ variables: steps: - task: DotNetCoreInstaller@0 inputs: - version: '3.0.100-preview-009812' + version: '3.0.100-preview-010184' - task: DotNetCoreCLI@2 inputs: From e3080a1784a6e2582ce3d39906a1f071ab4da559 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 16:35:54 -0800 Subject: [PATCH 731/862] Fix Scan generic types. --- .../System.Interactive.Async/System/Linq/Operators/Scan.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 2a51c1b42b..b9d534c720 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -59,7 +59,7 @@ public static IAsyncEnumerable Scan(this IAsy #if USE_ASYNC_ITERATOR return AsyncEnumerable.Create(Core); - async IAsyncEnumerator Core(CancellationToken cancellationToken) + async IAsyncEnumerator Core(CancellationToken cancellationToken) { TAccumulate res = seed; @@ -155,7 +155,7 @@ public static IAsyncEnumerable Scan(this IAsy #if USE_ASYNC_ITERATOR return AsyncEnumerable.Create(Core); - async IAsyncEnumerator Core(CancellationToken cancellationToken) + async IAsyncEnumerator Core(CancellationToken cancellationToken) { TAccumulate res = seed; @@ -182,7 +182,7 @@ public static IAsyncEnumerable Scan(this IAsy #if USE_ASYNC_ITERATOR return AsyncEnumerable.Create(Core); - async IAsyncEnumerator Core(CancellationToken cancellationToken) + async IAsyncEnumerator Core(CancellationToken cancellationToken) { TAccumulate res = seed; From e7186a43190dbe39b9ee135ae0865e21cc4d26ec Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 16:36:15 -0800 Subject: [PATCH 732/862] Add AWAIT_USING_REQUIRES_IASYNCDISPOSABLE to work around issue in .NET Core 3.0 Preview 2. --- .../Tasks/AsyncEnumerableExtensions.cs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index 4982783c87..a71d103807 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace System.Threading.Tasks { @@ -31,6 +32,59 @@ public static ConfiguredCancelableAsyncEnumerable WithCancellation( #endif + // + // REVIEW: `await using (var e = xs.GetAsyncEnumerator().ConfigureAwait(false)) { ... }` leads to the following error when using BCL types. + // + // error CS8410: 'ConfiguredCancelableAsyncEnumerable.Enumerator': type used in an async using statement must be implicitly convertible to 'System.IAsyncDisposable' + // + // See https://github.com/dotnet/csharplang/blob/master/meetings/2019/LDM-2019-01-16.md#pattern-based-disposal-in-await-foreach for the issues with + // `await foreach` (but not `await using`). This should be reviewed with the LDM. Also see https://github.com/dotnet/csharplang/issues/1623. + // +#if BCL_HAS_CONFIGUREAWAIT && AWAIT_USING_REQUIRES_IASYNCDISPOSABLE + public static ConfiguredAsyncEnumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) + { + if (enumerator == null) + throw Error.ArgumentNull(nameof(enumerator)); + + return new ConfiguredAsyncEnumerator(enumerator, continueOnCapturedContext); + } + + /// Provides an awaitable async enumerator that enables cancelable iteration and configured awaits. + [StructLayout(LayoutKind.Auto)] + public readonly struct ConfiguredAsyncEnumerator : IAsyncDisposable + { + private readonly IAsyncEnumerator _enumerator; + private readonly bool _continueOnCapturedContext; + + internal ConfiguredAsyncEnumerator(IAsyncEnumerator enumerator, bool continueOnCapturedContext) + { + _enumerator = enumerator; + _continueOnCapturedContext = continueOnCapturedContext; + } + + /// Advances the enumerator asynchronously to the next element of the collection. + /// + /// A that will complete with a result of true + /// if the enumerator was successfully advanced to the next element, or false if the enumerator has + /// passed the end of the collection. + /// + public ConfiguredValueTaskAwaitable MoveNextAsync() => + _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); + + /// Gets the element in the collection at the current position of the enumerator. + public T Current => _enumerator.Current; + + /// + /// Performs application-defined tasks associated with freeing, releasing, or + /// resetting unmanaged resources asynchronously. + /// + public ConfiguredValueTaskAwaitable DisposeAsync() => + _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); + + async ValueTask IAsyncDisposable.DisposeAsync() => + await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); + } +#else public static ConfiguredCancelableAsyncEnumerable.Enumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) { if (enumerator == null) @@ -38,5 +92,6 @@ public static ConfiguredCancelableAsyncEnumerable.Enumerator ConfigureAwait.Enumerator(enumerator, continueOnCapturedContext); } +#endif } } From a95267cda6e9d5733b32047c02b61b31cdf311dc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 16:37:02 -0800 Subject: [PATCH 733/862] Enable netcoreapp3.0 build using async iterators and new BCL types. --- Ix.NET/Source/Directory.build.targets | 11 ++++++++--- .../System.Interactive.Async.Providers.csproj | 2 +- .../System.Interactive.Async.csproj | 2 +- .../System.Linq.Async.Queryable.csproj | 2 +- .../Source/System.Linq.Async/System.Linq.Async.csproj | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index e6f0e6477a..5b5042b0e1 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -10,13 +10,18 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION - - + + $(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT;AWAIT_USING_REQUIRES_IASYNCDISPOSABLE + + + $(DefineConstants);USE_AWAIT_FOREACH;USE_AWAIT_USING diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index c716f03892..fa688e14d1 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Providers Library used to build query providers and express queries over async enumerable sequences. Interactive Extensions - Async Providers Library - net45;net46;netstandard1.4;netstandard2.0 + net45;net46;netstandard1.4;netstandard2.0;netcoreapp3.0 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 8d9ff6de02..3e21ccc5f6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. Interactive Extensions - Async Library - net45;net46;netstandard1.4;netstandard2.0 + net45;net46;netstandard1.4;netstandard2.0;netcoreapp3.0 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index 69dc5f50b2..4798bc4e4f 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -1,7 +1,7 @@  - net45;net46;netstandard1.4;netstandard2.0 + net45;net46;netstandard1.4;netstandard2.0;netcoreapp3.0 diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index cacafc0c9a..d65031ae11 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -1,7 +1,7 @@  - net45;net46;netstandard1.4;netstandard2.0 + net45;net46;netstandard1.4;netstandard2.0;netcoreapp3.0 From e1ffe0e5f30731400407bfa1bacc68a713c641f7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 16:37:20 -0800 Subject: [PATCH 734/862] Move SDK version to 3.0.100-preview2. --- Ix.NET/Source/global.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index 443c4bfae8..f6fec1c73d 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,4 +1,7 @@ { + "sdk": { + "version": "3.0.100-preview2" + }, "msbuild-sdks": { "MSBuild.Sdk.Extras": "2.0.0-preview.14" } From f5fc1e4353324d1904437cee98df7f273fe2b347 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 18:03:58 -0800 Subject: [PATCH 735/862] Getting rid of USE_AWAIT_USING to ensure proper binding for ConfigureAwait(false). --- Ix.NET/Source/Directory.build.targets | 2 +- .../System/Linq/Operators/Amb.cs | 30 +- .../System/Linq/Operators/Catch.cs | 32 +- .../Linq/Operators/DistinctUntilChanged.cs | 32 +- .../System/Linq/Operators/Do.cs | 24 +- .../System/Linq/Operators/IsEmpty.cs | 8 +- .../System/Linq/Operators/Max.cs | 30 +- .../System/Linq/Operators/Min.cs | 30 +- .../System/Linq/Operators/MinBy.cs | 114 +- .../System/Linq/Operators/Scan.cs | 24 +- .../System/Linq/AsyncEnumerableHelpers.cs | 58 +- .../System/Linq/Operators/Aggregate.cs | 81 +- .../System/Linq/Operators/Any.cs | 15 +- .../Linq/Operators/Average.Generated.cs | 1538 +---- .../Linq/Operators/Average.Generated.tt | 272 +- .../System/Linq/Operators/FirstOrDefault.cs | 87 +- .../System/Linq/Operators/GroupJoin.cs | 24 +- .../System/Linq/Operators/Join.cs | 24 +- .../System/Linq/Operators/Max.cs | 244 +- .../System/Linq/Operators/Min.cs | 244 +- .../System/Linq/Operators/MinMax.Generated.cs | 5746 ++++------------- .../System/Linq/Operators/MinMax.Generated.tt | 478 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 76 +- .../System/Linq/Operators/SequenceEqual.cs | 34 +- .../System/Linq/Operators/Single.cs | 119 +- .../System/Linq/Operators/SingleOrDefault.cs | 118 +- .../System/Linq/Operators/SkipLast.cs | 8 +- .../System/Linq/Operators/SkipWhile.cs | 48 +- .../System/Linq/Operators/TakeLast.cs | 8 +- .../System/Linq/Operators/Zip.cs | 48 +- .../ConfiguredCancelableAsyncEnumerable.cs | 5 +- .../Tasks/AsyncEnumerableExtensions.cs | 16 +- 32 files changed, 2115 insertions(+), 7502 deletions(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 5b5042b0e1..f017ee8361 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -22,7 +22,7 @@ - $(DefineConstants);USE_AWAIT_FOREACH;USE_AWAIT_USING + $(DefineConstants);USE_AWAIT_FOREACH diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 3464ec5344..e0a42ebb2b 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -95,20 +95,24 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) try { - await using (var e = winner.ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await moveNextWinner.ConfigureAwait(false)) { yield break; } - yield return e.Current; + yield return winner.Current; - while (await e.MoveNextAsync()) + while (await winner.MoveNextAsync().ConfigureAwait(false)) { - yield return e.Current; + yield return winner.Current; } } + finally + { + await winner.DisposeAsync().ConfigureAwait(false); + } } finally { @@ -204,20 +208,24 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) try { - await using (var e = winner.ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await moveNextWinner.ConfigureAwait(false)) { yield break; } - yield return e.Current; + yield return winner.Current; - while (await e.MoveNextAsync()) + while (await winner.MoveNextAsync().ConfigureAwait(false)) { - yield return e.Current; + yield return winner.Current; } } + finally + { + await winner.DisposeAsync().ConfigureAwait(false); + } } finally { @@ -246,13 +254,17 @@ private static async Task AwaitMoveNextAsyncAndDispose(Task moveNextAsy { if (enumerator != null) { - await using (enumerator.ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (moveNextAsync != null) { await moveNextAsync.ConfigureAwait(false); } } + finally + { + await enumerator.DisposeAsync().ConfigureAwait(false); + } } } #endif diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index df996f6396..251ae2a4c2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -39,7 +39,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (true) { @@ -61,6 +63,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return c; } } + finally + { + await e.DisposeAsync(); + } if (err != null) { @@ -97,7 +103,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (true) { @@ -119,6 +127,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return c; } } + finally + { + await e.DisposeAsync(); + } if (err != null) { @@ -156,7 +168,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (true) { @@ -178,6 +192,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return c; } } + finally + { + await e.DisposeAsync(); + } if (err != null) { @@ -230,7 +248,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) foreach (var source in sources) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { error = null; @@ -257,6 +277,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) if (error == null) break; } + finally + { + await e.DisposeAsync(); + } } error?.Throw(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index ba123a30c0..5e65ca5495 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -103,7 +103,9 @@ private static IAsyncEnumerable DistinctUntilChangedCore(IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -126,6 +128,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new DistinctUntilChangedAsyncIterator(source, comparer); @@ -144,7 +150,9 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -171,6 +179,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); @@ -189,7 +201,9 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -216,6 +230,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); @@ -235,7 +253,9 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -262,6 +282,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(source, keySelector, comparer); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index cd0ce69cbc..47a26e6ebf 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -176,7 +176,9 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (true) { @@ -208,6 +210,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) onCompleted?.Invoke(); } + finally + { + await e.DisposeAsync(); + } } #else return new DoAsyncIterator(source, onNext, onError, onCompleted); @@ -221,7 +227,9 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (true) { @@ -256,6 +264,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) await onCompleted().ConfigureAwait(false); } } + finally + { + await e.DisposeAsync(); + } } #else return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); @@ -270,7 +282,9 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (true) { @@ -305,6 +319,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) await onCompleted(cancellationToken).ConfigureAwait(false); } } + finally + { + await e.DisposeAsync(); + } } #else return new DoAsyncIteratorWithTaskAndCancellation(source, onNext, onError, onCompleted); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index a35bf9d828..c434ac0cf5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -19,10 +19,16 @@ public static Task IsEmptyAsync(this IAsyncEnumerable so static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { return !await e.MoveNextAsync(); } + finally + { + await e.DisposeAsync(); + } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index b85a11d79b..5138daa4ef 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -24,8 +24,9 @@ static async Task Core(IAsyncEnumerable _source, IComparer.Default; } -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -42,35 +43,12 @@ static async Task Core(IAsyncEnumerable _source, IComparer 0) - { - max = cur; - } - } - return max; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index fb9bc49554..ed2d3b6e9f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -24,8 +24,9 @@ static async Task Core(IAsyncEnumerable _source, IComparer.Default; } -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -42,35 +43,12 @@ static async Task Core(IAsyncEnumerable _source, IComparer> ExtremaBy(IAsyncEnumera { var result = new List(); -#if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -127,36 +128,6 @@ private static async Task> ExtremaBy(IAsyncEnumera var cmp = compare(key, resKey); - if (cmp == 0) - { - result.Add(cur); - } - else if (cmp > 0) - { - result = new List { cur }; - resKey = key; - } - } - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw Error.NoElements(); - - var current = e.Current; - var resKey = keySelector(current); - result.Add(current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var key = keySelector(cur); - - var cmp = compare(key, resKey); - if (cmp == 0) { result.Add(cur); @@ -170,9 +141,8 @@ private static async Task> ExtremaBy(IAsyncEnumera } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return result; } @@ -181,8 +151,9 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); -#if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -198,36 +169,6 @@ private static async Task> ExtremaBy(IAsyncEnumera var cmp = compare(key, resKey); - if (cmp == 0) - { - result.Add(cur); - } - else if (cmp > 0) - { - result = new List { cur }; - resKey = key; - } - } - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw Error.NoElements(); - - var current = e.Current; - var resKey = await keySelector(current).ConfigureAwait(false); - result.Add(current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var key = await keySelector(cur).ConfigureAwait(false); - - var cmp = compare(key, resKey); - if (cmp == 0) { result.Add(cur); @@ -241,9 +182,8 @@ private static async Task> ExtremaBy(IAsyncEnumera } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return result; } @@ -253,8 +193,9 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); -#if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -270,36 +211,6 @@ private static async Task> ExtremaBy(IAsyncEnumera var cmp = compare(key, resKey); - if (cmp == 0) - { - result.Add(cur); - } - else if (cmp > 0) - { - result = new List { cur }; - resKey = key; - } - } - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - throw Error.NoElements(); - - var current = e.Current; - var resKey = await keySelector(current, cancellationToken).ConfigureAwait(false); - result.Add(current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var key = await keySelector(cur, cancellationToken).ConfigureAwait(false); - - var cmp = compare(key, resKey); - if (cmp == 0) { result.Add(cur); @@ -313,9 +224,8 @@ private static async Task> ExtremaBy(IAsyncEnumera } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return result; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index b9d534c720..26564bf386 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -27,7 +27,9 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -43,6 +45,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return res; } } + finally + { + await e.DisposeAsync(); + } } #else return new ScanAsyncEnumerable(source, accumulator); @@ -87,7 +93,9 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -103,6 +111,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return res; } } + finally + { + await e.DisposeAsync(); + } } #else return new ScanAsyncEnumerableWithTask(source, accumulator); @@ -122,7 +134,9 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -138,6 +152,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return res; } } + finally + { + await e.DisposeAsync(); + } } #else return new ScanAsyncEnumerableWithTaskAndCancellation(source, accumulator); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 7e6804b3d7..0e6b8e3532 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -44,8 +44,9 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } else { -#if USE_AWAIT_USING - await using (var en = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var en = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (await en.MoveNextAsync()) { @@ -87,56 +88,6 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE arr[count++] = en.Current; } - result.Length = count; - result.Array = arr; - return result; - } - } -#else - var en = source.GetAsyncEnumerator(cancellationToken); - - try - { - if (await en.MoveNextAsync().ConfigureAwait(false)) - { - const int DefaultCapacity = 4; - var arr = new T[DefaultCapacity]; - arr[0] = en.Current; - var count = 1; - - while (await en.MoveNextAsync().ConfigureAwait(false)) - { - if (count == arr.Length) - { - // MaxArrayLength is defined in Array.MaxArrayLength and in gchelpers in CoreCLR. - // It represents the maximum number of elements that can be in an array where - // the size of the element is greater than one byte; a separate, slightly larger constant, - // is used when the size of the element is one. - const int MaxArrayLength = 0x7FEFFFFF; - - // This is the same growth logic as in List: - // If the array is currently empty, we make it a default size. Otherwise, we attempt to - // double the size of the array. Doubling will overflow once the size of the array reaches - // 2^30, since doubling to 2^31 is 1 larger than Int32.MaxValue. In that case, we instead - // constrain the length to be MaxArrayLength (this overflow check works because of the - // cast to uint). Because a slightly larger constant is used when T is one byte in size, we - // could then end up in a situation where arr.Length is MaxArrayLength or slightly larger, such - // that we constrain newLength to be MaxArrayLength but the needed number of elements is actually - // larger than that. For that case, we then ensure that the newLength is large enough to hold - // the desired capacity. This does mean that in the very rare case where we've grown to such a - // large size, each new element added after MaxArrayLength will end up doing a resize. - var newLength = count << 1; - if ((uint)newLength > MaxArrayLength) - { - newLength = MaxArrayLength <= count ? count + 1 : MaxArrayLength; - } - - Array.Resize(ref arr, newLength); - } - - arr[count++] = en.Current; - } - result.Length = count; result.Array = arr; return result; @@ -144,9 +95,8 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } finally { - await en.DisposeAsync().ConfigureAwait(false); + await en.DisposeAsync(); } -#endif } result.Length = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 306118535e..d5d96f8f72 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -21,8 +21,9 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -36,32 +37,12 @@ static async Task Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -91,32 +73,12 @@ static async Task Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -147,32 +110,12 @@ static async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - return await e.MoveNextAsync(); - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - return await e.MoveNextAsync().ConfigureAwait(false); + return await e.MoveNextAsync(); } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 6b5d54e7fd..1343b279b8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -19,8 +19,9 @@ public static Task AverageAsync(this IAsyncEnumerable source, Cance static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -38,36 +39,12 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - return (double)sum / count; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - long sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - return (double)sum / count; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } } @@ -82,8 +59,9 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -101,36 +79,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -164,36 +119,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -228,36 +160,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Canc static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -290,36 +199,12 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - return (double)sum / count; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - long sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - return (double)sum / count; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } } @@ -334,8 +219,9 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -353,36 +239,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -416,36 +279,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -480,36 +320,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Canc static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -542,36 +359,12 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - return (float)(sum / count); - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - double sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - return (float)(sum / count); } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } } @@ -586,8 +379,9 @@ public static Task AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -605,36 +399,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -668,36 +439,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -732,36 +480,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Ca static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -796,36 +521,12 @@ static async Task Core(IAsyncEnumerable _source, CancellationTok return sum / count; } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try + finally { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - double sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - - return sum / count; - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - } - } + await e.DisposeAsync(); + } + } + } public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { @@ -838,8 +539,9 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -857,36 +559,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -920,36 +599,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -984,36 +640,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -1046,36 +679,12 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - return sum / count; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - decimal sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - return sum / count; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } } @@ -1090,8 +699,9 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -1109,36 +719,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -1172,36 +759,12 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -1236,36 +800,12 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -1302,44 +843,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -1383,23 +895,42 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var v = _selector(e.Current); + var v = await _selector(e.Current).ConfigureAwait(false); if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; checked { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - v = _selector(e.Current); + v = await _selector(e.Current).ConfigureAwait(false); if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1414,15 +945,15 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1431,14 +962,15 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { - var v = await _selector(e.Current).ConfigureAwait(false); + var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (v.HasValue) { long sum = v.GetValueOrDefault(); @@ -1447,7 +979,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var v = await _selector(e.Current).ConfigureAwait(false); + var v = e.Current; if (v.HasValue) { long sum = v.GetValueOrDefault(); long count = 1; checked { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - v = await _selector(e.Current).ConfigureAwait(false); + v = e.Current; if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -1491,16 +1041,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1509,14 +1057,15 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { - var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var v = _selector(e.Current); if (v.HasValue) { long sum = v.GetValueOrDefault(); @@ -1525,7 +1074,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - while (await e.MoveNextAsync()) - { - var v = e.Current; - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync()) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = e.Current; - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return null; - } - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - while (await e.MoveNextAsync()) - { - var v = _selector(e.Current); - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync()) - { - v = _selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = _selector(e.Current); - if (v.HasValue) - { - long sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = _selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (double)sum / count; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return null; } @@ -1741,8 +1107,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -1764,44 +1131,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -1842,44 +1180,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -1918,44 +1227,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - while (await e.MoveNextAsync()) - { - var v = _selector(e.Current); - if (v.HasValue) - { - double sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync()) - { - v = _selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (float)(sum / count); - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = _selector(e.Current); - if (v.HasValue) - { - double sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = _selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (float)(sum / count); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return null; - } - } - - public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - while (await e.MoveNextAsync()) - { - var v = await _selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - double sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync()) - { - v = await _selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - - return (float)(sum / count); - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var v = await _selector(e.Current).ConfigureAwait(false); + var v = _selector(e.Current); if (v.HasValue) { double sum = v.GetValueOrDefault(); long count = 1; checked { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - v = await _selector(e.Current).ConfigureAwait(false); + v = _selector(e.Current); if (v.HasValue) { sum += v.GetValueOrDefault(); @@ -2107,16 +1281,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2125,14 +1297,15 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { - var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var v = await _selector(e.Current).ConfigureAwait(false); if (v.HasValue) { double sum = v.GetValueOrDefault(); @@ -2141,7 +1314,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (v.HasValue) @@ -2168,7 +1361,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2226,44 +1419,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2303,44 +1467,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2380,44 +1515,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2458,44 +1564,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2534,44 +1611,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2611,44 +1659,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2688,44 +1707,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -2766,44 +1756,14 @@ static async Task Core(IAsyncEnumerable _source, Func -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -81,44 +82,14 @@ if (isNullable) } } - return <#=res#>; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = e.Current; - if (v.HasValue) - { - <#=o.sum#> sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = e.Current; - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - return <#=res#>; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return null; <# @@ -126,8 +97,9 @@ if (isNullable) else { #> -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -145,36 +117,12 @@ else } } - return <#=res#>; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - <#=o.sum#> sum = e.Current; - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - ++count; - } - } - return <#=res#>; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif <# } #> @@ -196,8 +144,9 @@ else if (isNullable) { #> -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -219,44 +168,14 @@ if (isNullable) } } - return <#=res#>; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = _selector(e.Current); - if (v.HasValue) - { - <#=o.sum#> sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = _selector(e.Current); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - return <#=res#>; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return null; <# @@ -264,8 +183,9 @@ if (isNullable) else { #> -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -283,36 +203,12 @@ else } } - return <#=res#>; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - <#=o.sum#> sum = _selector(e.Current); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += _selector(e.Current); - ++count; - } - } - return <#=res#>; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif <# } #> @@ -334,8 +230,9 @@ else if (isNullable) { #> -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -357,44 +254,14 @@ if (isNullable) } } - return <#=res#>; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await _selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - <#=o.sum#> sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await _selector(e.Current).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - return <#=res#>; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return null; <# @@ -402,8 +269,9 @@ if (isNullable) else { #> -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -421,36 +289,12 @@ else } } - return <#=res#>; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - <#=o.sum#> sum = await _selector(e.Current).ConfigureAwait(false); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await _selector(e.Current).ConfigureAwait(false); - ++count; - } - } - return <#=res#>; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif <# } #> @@ -473,8 +317,9 @@ else if (isNullable) { #> -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -496,44 +341,14 @@ if (isNullable) } } - return <#=res#>; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - <#=o.sum#> sum = v.GetValueOrDefault(); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - v = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (v.HasValue) - { - sum += v.GetValueOrDefault(); - ++count; - } - } - } - return <#=res#>; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return null; <# @@ -541,8 +356,9 @@ if (isNullable) else { #> -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -560,36 +376,12 @@ else } } - return <#=res#>; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - <#=o.sum#> sum = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - long count = 1; - checked - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - ++count; - } - } - return <#=res#>; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif <# } #> diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 12c9a3581d..789373736b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -97,29 +97,19 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (await e.MoveNextAsync()) - { - return new Maybe(e.Current); - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - if (await e.MoveNextAsync().ConfigureAwait(false)) + if (await e.MoveNextAsync()) { return new Maybe(e.Current); } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return new Maybe(); } @@ -130,25 +120,11 @@ static async ValueTask> Core(IAsyncEnumerable _source, C private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { -#if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) - { - while (await e.MoveNextAsync()) - { - var value = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); - if (predicate(value)) - { - return new Maybe(value); - } - } - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { var value = e.Current; @@ -160,34 +136,19 @@ private static async Task> TryGetFirst(IAsyncEnumerable< } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return new Maybe(); } private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { -#if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) - { - while (await e.MoveNextAsync()) - { - var value = e.Current; - - if (await predicate(value).ConfigureAwait(false)) - { - return new Maybe(value); - } - } - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { var value = e.Current; @@ -199,9 +160,8 @@ private static async Task> TryGetFirst(IAsyncEnumerable< } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return new Maybe(); } @@ -209,25 +169,11 @@ private static async Task> TryGetFirst(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { -#if USE_AWAIT_USING - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) - { - while (await e.MoveNextAsync()) - { - var value = e.Current; + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); - if (await predicate(value, cancellationToken).ConfigureAwait(false)) - { - return new Maybe(value); - } - } - } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { var value = e.Current; @@ -239,9 +185,8 @@ private static async Task> TryGetFirst(IAsyncEnumerable< } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return new Maybe(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 1e427f97ef..962c59fd3b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -31,7 +31,9 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (await e.MoveNextAsync()) { @@ -46,6 +48,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (await e.MoveNextAsync()); } } + finally + { + await e.DisposeAsync(); + } } #else return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -73,7 +79,9 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (await e.MoveNextAsync()) { @@ -88,6 +96,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (await e.MoveNextAsync()); } } + finally + { + await e.DisposeAsync(); + } } #else return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -116,7 +128,9 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (await e.MoveNextAsync()) { @@ -131,6 +145,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (await e.MoveNextAsync()); } } + finally + { + await e.DisposeAsync(); + } } #else return new GroupJoinAsyncEnumerableWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index e5af5c9e0c..b6fbf38ec1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -32,7 +32,9 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (await e.MoveNextAsync()) { @@ -63,6 +65,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -90,7 +96,9 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (await e.MoveNextAsync()) { @@ -121,6 +129,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -149,7 +161,9 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (await e.MoveNextAsync()) { @@ -180,6 +194,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new JoinAsyncIteratorWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index b6b032c498..03fbf16d39 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -25,8 +25,9 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { do { @@ -49,36 +50,10 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (value == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x != null && comparer.Compare(x, value) > 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -93,8 +68,9 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -112,31 +88,10 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (comparer.Compare(x, value) > 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -160,8 +115,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -228,8 +158,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -295,8 +205,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -363,8 +248,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -432,8 +297,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -500,8 +340,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index f39cb91fbd..8692ea1448 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -25,8 +25,9 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { do { @@ -49,36 +50,10 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (value == null); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x != null && comparer.Compare(x, value) < 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -93,8 +68,9 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -113,31 +89,10 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (comparer.Compare(x, value) < 0) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -161,8 +116,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ca { int value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -40,32 +41,10 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -84,8 +63,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -147,8 +105,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -211,8 +148,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -273,8 +189,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. if (cur.HasValue & x > valueVal) @@ -393,9 +250,8 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = _selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); - // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. if (cur.HasValue & x > valueVal) @@ -534,9 +331,8 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. if (cur.HasValue & x > valueVal) @@ -675,9 +412,8 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif + await e.DisposeAsync(); + } return value; } @@ -837,8 +513,9 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ { long value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -856,32 +533,10 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -900,8 +555,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -963,8 +597,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -1027,8 +640,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -1089,8 +681,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. if (cur.HasValue & x > valueVal) @@ -1209,9 +742,8 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = _selector(e.Current); + value = await _selector(e.Current).ConfigureAwait(false); } while (!value.HasValue); @@ -1319,9 +873,9 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) @@ -1333,9 +887,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1367,12 +921,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -1383,7 +938,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) @@ -1416,7 +971,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + throw Error.NoElements(); + } + + value = e.Current; + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (float.IsNaN(value)) + { + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + value = e.Current; } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else + while (await e.MoveNextAsync()) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var x = e.Current; + if (x > value) { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } + value = x; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } -#if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1509,159 +1058,77 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - long? value = null; + float value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + throw Error.NoElements(); } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync()) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync()) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + value = _selector(e.Current); - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + while (float.IsNaN(value)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + value = _selector(e.Current); } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - if (x > valueVal) - { - valueVal = x; - value = cur; - } - } - } - else + while (await e.MoveNextAsync()) { - while (await e.MoveNextAsync().ConfigureAwait(false)) + var x = _selector(e.Current); + if (x > value) { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) - { - valueVal = x; - value = cur; - } + value = x; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } -#endif - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = e.Current; + value = await _selector(e.Current).ConfigureAwait(false); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no @@ -1675,29 +1142,51 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken return value; } - value = e.Current; + value = await _selector(e.Current).ConfigureAwait(false); } while (await e.MoveNextAsync()) { - var x = e.Current; + var x = await _selector(e.Current).ConfigureAwait(false); if (x > value) { value = x; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + finally + { + await e.DisposeAsync(); + } + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + float value; - try + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = e.Current; + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no @@ -1706,17 +1195,17 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken while (float.IsNaN(value)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = e.Current; + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = e.Current; + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); if (x > value) { value = x; @@ -1725,108 +1214,90 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) +#endif + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - float value; + float? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - if (!await e.MoveNextAsync()) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - throw Error.NoElements(); + if (!await e.MoveNextAsync()) + { + return value; + } + + value = e.Current; } + while (!value.HasValue); - value = _selector(e.Current); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(value)) + while (float.IsNaN(valueVal)) { if (!await e.MoveNextAsync()) { return value; } - value = _selector(e.Current); + var cur = e.Current; + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } while (await e.MoveNextAsync()) { - var x = _selector(e.Current); - if (x > value) + var cur = e.Current; + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try + finally { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). - - while (float.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = _selector(e.Current); - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = _selector(e.Current); - if (x > value) - { - value = x; - } - } + await e.DisposeAsync(); } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1835,92 +1306,75 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - float value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current).ConfigureAwait(false); + float? value = null; - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - while (float.IsNaN(value)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); - } - - while (await e.MoveNextAsync()) - { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); + value = _selector(e.Current); } + while (!value.HasValue); - value = await _selector(e.Current).ConfigureAwait(false); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(value)) + while (float.IsNaN(valueVal)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + var cur = _selector(e.Current); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x > value) + var cur = _selector(e.Current); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } -#if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1929,104 +1383,91 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + float? value = null; - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - while (float.IsNaN(value)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - - while (await e.MoveNextAsync()) - { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); + value = await _selector(e.Current).ConfigureAwait(false); } + while (!value.HasValue); - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(value)) + while (float.IsNaN(valueVal)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var cur = await _selector(e.Current).ConfigureAwait(false); + + if (cur.HasValue) + { + valueVal = (value = cur).GetValueOrDefault(); + } } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x > value) + var cur = await _selector(e.Current).ConfigureAwait(false); + var x = cur.GetValueOrDefault(); + + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x > valueVal) { - value = x; + valueVal = x; + value = cur; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } -#endif - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -2037,7 +1478,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = e.Current; // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(valueVal)) + while (double.IsNaN(value)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - var cur = e.Current; - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + value = e.Current; } - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + var x = e.Current; + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2154,145 +1594,184 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - float? value = null; + double value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = _selector(e.Current); + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = _selector(e.Current); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(valueVal)) + while (double.IsNaN(value)) { if (!await e.MoveNextAsync()) { return value; } - var cur = _selector(e.Current); - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + value = _selector(e.Current); } while (await e.MoveNextAsync()) { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + var x = _selector(e.Current); + if (x > value) { - valueVal = x; - value = cur; + value = x; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + finally + { + await e.DisposeAsync(); + } + + return value; + } + } + + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = _selector(e.Current); + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = await _selector(e.Current).ConfigureAwait(false); // NaN is ordered less than all other values. We need to do explicit checks // to ensure this, but once we've found a value that is not NaN we need no // longer worry about it, so first loop until such a value is found (or not, // as the case may be). - while (float.IsNaN(valueVal)) + while (double.IsNaN(value)) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - var cur = _selector(e.Current); + value = await _selector(e.Current).ConfigureAwait(false); + } - if (cur.HasValue) + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x > value) { - valueVal = (value = cur).GetValueOrDefault(); + value = x; } } + } + finally + { + await e.DisposeAsync(); + } + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double value; - while (await e.MoveNextAsync().ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + if (!await e.MoveNextAsync()) { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); + throw Error.NoElements(); + } - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + // NaN is ordered less than all other values. We need to do explicit checks + // to ensure this, but once we've found a value that is not NaN we need no + // longer worry about it, so first loop until such a value is found (or not, + // as the case may be). + + while (double.IsNaN(value)) + { + if (!await e.MoveNextAsync()) { - valueVal = x; - value = cur; + return value; + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + } + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x > value) + { + value = x; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - float? value = null; + double? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -2303,7 +1782,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + value = _selector(e.Current); } while (!value.HasValue); @@ -2372,14 +1872,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2421,12 +1919,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - float? value = null; + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -2437,7 +1936,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } @@ -2506,9 +2027,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - double value; + decimal value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -2567,21 +2088,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationTok value = e.Current; - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). - - while (double.IsNaN(value)) - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = e.Current; - } - while (await e.MoveNextAsync()) { var x = e.Current; @@ -2591,53 +2097,16 @@ static async Task Core(IAsyncEnumerable _source, CancellationTok } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try + finally { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). - - while (double.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2646,12 +2115,13 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - double value; + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -2660,21 +2130,6 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2739,12 +2157,13 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double value; + decimal value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -2753,21 +2172,6 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2833,12 +2200,13 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double value; + decimal value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -2847,21 +2215,6 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } #endif - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - double? value = null; + decimal? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -2949,55 +2266,54 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) + if (cur.HasValue && x > valueVal) { valueVal = x; value = cur; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + finally + { + await e.DisposeAsync(); + } + + return value; + } + } + + public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + decimal? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = e.Current; + value = _selector(e.Current); } while (!value.HasValue); @@ -3005,34 +2321,12 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) + if (cur.HasValue && x > valueVal) { valueVal = x; value = cur; @@ -3041,15 +2335,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3058,12 +2351,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double? value = null; + decimal? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -3074,7 +2368,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func valueVal) + if (cur.HasValue && x > valueVal) { valueVal = x; value = cur; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + finally + { + await e.DisposeAsync(); + } + + return value; + } + } + +#if !NO_DEEP_CANCELLATION + public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + decimal? value = null; - try + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = _selector(e.Current); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } while (!value.HasValue); @@ -3138,34 +2432,12 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) + if (cur.HasValue && x > valueVal) { valueVal = x; value = cur; @@ -3174,149 +2446,140 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - double? value = null; + int value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); + throw Error.NoElements(); } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). + value = e.Current; - while (double.IsNaN(valueVal)) + while (await e.MoveNextAsync()) { - if (!await e.MoveNextAsync()) + var x = e.Current; + if (x < value) { - return value; + value = x; } + } + } + finally + { + await e.DisposeAsync(); + } - var cur = await _selector(e.Current).ConfigureAwait(false); + return value; + } + } - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); } + value = _selector(e.Current); + while (await e.MoveNextAsync()) { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + var x = _selector(e.Current); + if (x < value) { - valueVal = x; - value = cur; + value = x; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try + finally { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } + await e.DisposeAsync(); + } - value = await _selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); + return value; + } + } - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). + return Core(source, selector, cancellationToken); - while (double.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int value; - var cur = await _selector(e.Current).ConfigureAwait(false); + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); } - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); + value = await _selector(e.Current).ConfigureAwait(false); - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) { - valueVal = x; - value = cur; + value = x; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3325,12 +2588,54 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double? value = null; + int value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + if (!await e.MoveNextAsync()) + { + throw Error.NoElements(); + } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + + while (await e.MoveNextAsync()) + { + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) + { + value = x; + } + } + } + finally + { + await e.DisposeAsync(); + } + + return value; + } + } + +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + + return Core(source, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -3341,7 +2646,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) { - valueVal = (value = cur).GetValueOrDefault(); + return value; } + + value = _selector(e.Current); } + while (!value.HasValue); + + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync()) { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var cur = _selector(e.Current); var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + if (cur.HasValue & x < valueVal) { valueVal = x; value = cur; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + finally + { + await e.DisposeAsync(); + } + + return value; + } + } + + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int? value = null; - try + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + value = await _selector(e.Current).ConfigureAwait(false); } while (!value.HasValue); @@ -3405,34 +2768,72 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + int? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + { + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do + { + if (!await e.MoveNextAsync()) { - valueVal = (value = cur).GetValueOrDefault(); + return value; } + + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } + while (!value.HasValue); - while (await e.MoveNextAsync().ConfigureAwait(false)) + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); + + while (await e.MoveNextAsync()) { var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); var x = cur.GetValueOrDefault(); // Do not replace & with &&. The branch prediction cost outweighs the extra operation // unless nulls either never happen or always happen. - if (cur.HasValue & x > valueVal) + if (cur.HasValue & x < valueVal) { valueVal = x; value = cur; @@ -3441,28 +2842,28 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - decimal value; + long value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -3474,28 +2875,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT while (await e.MoveNextAsync()) { var x = e.Current; - if (x > value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x > value) + if (x < value) { value = x; } @@ -3503,15 +2883,14 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3520,12 +2899,13 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - decimal value; + long value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -3537,28 +2917,7 @@ static async Task Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = _selector(e.Current); - if (x > value) + if (x < value) { value = x; } @@ -3566,15 +2925,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3583,12 +2941,13 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - decimal value; + long value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -3600,45 +2959,23 @@ static async Task Core(IAsyncEnumerable _source, Func value) + if (x < value) { value = x; } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try + finally { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } + await e.DisposeAsync(); + } - value = await _selector(e.Current).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x > value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } + return value; + } + } #if !NO_DEEP_CANCELLATION - public static Task MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3647,12 +2984,13 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - decimal value; + long value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -3664,28 +3002,7 @@ static async Task Core(IAsyncEnumerable _source, Func value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x > value) + if (x < value) { value = x; } @@ -3693,28 +3010,28 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - decimal? value = null; + long? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -3738,41 +3055,9 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - if (cur.HasValue && x > valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) { valueVal = x; value = cur; @@ -3781,15 +3066,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3798,12 +3082,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - decimal? value = null; + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -3827,41 +3112,9 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = _selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); - - if (cur.HasValue && x > valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) { valueVal = x; value = cur; @@ -3870,15 +3123,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3887,12 +3139,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - decimal? value = null; + long? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -3916,41 +3169,9 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - if (cur.HasValue && x > valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) { valueVal = x; value = cur; @@ -3959,16 +3180,15 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3977,12 +3197,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - decimal? value = null; + long? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -4006,41 +3227,9 @@ static async Task Core(IAsyncEnumerable _source, Func valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - if (cur.HasValue && x > valueVal) + // Do not replace & with &&. The branch prediction cost outweighs the extra operation + // unless nulls either never happen or always happen. + if (cur.HasValue & x < valueVal) { valueVal = x; value = cur; @@ -4049,28 +3238,28 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - int value; + float value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -4086,40 +3275,34 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca { value = x; } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) + else { - value = x; + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return x; + } } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4128,12 +3311,13 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - int value; + float value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -4149,40 +3333,34 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4191,12 +3369,13 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - int value; + float value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -4212,41 +3391,35 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4255,12 +3428,13 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - int value; + float value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -4276,53 +3450,48 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - int? value = null; + float? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -4344,64 +3513,43 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4410,12 +3558,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - int? value = null; + float? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -4437,64 +3586,43 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4503,12 +3631,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - int? value = null; + float? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -4530,1756 +3659,44 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - int? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#endif - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { - long value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync()) - { - var x = e.Current; - if (x < value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - long value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - while (await e.MoveNextAsync()) - { - var x = _selector(e.Current); - if (x < value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = _selector(e.Current); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - long value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current).ConfigureAwait(false); - - while (await e.MoveNextAsync()) - { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - long value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - - while (await e.MoveNextAsync()) - { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#endif - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { - long? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - long? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = _selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = _selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = _selector(e.Current); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - long? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - long? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x < valueVal) - { - valueVal = x; - value = cur; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#endif - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { - float value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync()) - { - var x = e.Current; - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - float value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - while (await e.MoveNextAsync()) - { - var x = _selector(e.Current); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = _selector(e.Current); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - float value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current).ConfigureAwait(false); - - while (await e.MoveNextAsync()) - { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - float value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - - while (await e.MoveNextAsync()) - { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return x; - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#endif - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { - float? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = e.Current; - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) - { - float? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = _selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = _selector(e.Current); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = _selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = _selector(e.Current); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - float? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - float? value = null; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync()) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (float.IsNaN(x)) - { - return cur; - } - } - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - -#endif - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - - return Core(source, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) - { - double value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync()) - { - var x = e.Current; - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) + var x = cur.GetValueOrDefault(); + if (x < valueVal) { - return x; + valueVal = x; + value = cur; } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) + else { - return x; + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } } } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -6288,214 +3705,96 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double value; - -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - while (await e.MoveNextAsync()) - { - var x = _selector(e.Current); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. + float? value = null; - if (double.IsNaN(x)) - { - return x; - } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = _selector(e.Current); - - while (await e.MoveNextAsync().ConfigureAwait(false)) + // Start off knowing that we've a non-null value (or exit here, knowing we don't) + // so we don't have to keep testing for nullity. + do { - var x = _selector(e.Current); - if (x < value) - { - value = x; - } - else + if (!await e.MoveNextAsync()) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) - { - return x; - } + return value; } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif - - return value; - } - } - - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - - return Core(source, selector, cancellationToken); - - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) - { - double value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - throw Error.NoElements(); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); } + while (!value.HasValue); - value = await _selector(e.Current).ConfigureAwait(false); + // Keep hold of the wrapped value, and do comparisons on that, rather than + // using the lifted operation each time. + var valueVal = value.GetValueOrDefault(); while (await e.MoveNextAsync()) { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else + var cur = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (cur.HasValue) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) + var x = cur.GetValueOrDefault(); + if (x < valueVal) { - return x; + valueVal = x; + value = cur; } - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = await _selector(e.Current).ConfigureAwait(false); - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = await _selector(e.Current).ConfigureAwait(false); - if (x < value) - { - value = x; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) + else { - return x; + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. + + if (float.IsNaN(x)) + { + return cur; + } } } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } -#if !NO_DEEP_CANCELLATION - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + value = e.Current; while (await e.MoveNextAsync()) { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = e.Current; if (x < value) { value = x; @@ -6518,21 +3817,42 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { throw Error.NoElements(); } - value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + value = _selector(e.Current); - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { - var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + var x = _selector(e.Current); if (x < value) { value = x; @@ -6557,139 +3877,73 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); - return Core(source, cancellationToken); + return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double? value = null; + double value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = e.Current; + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = await _selector(e.Current).ConfigureAwait(false); while (await e.MoveNextAsync()) { - var cur = e.Current; - if (cur.HasValue) + var x = await _selector(e.Current).ConfigureAwait(false); + if (x < value) { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) - { - return cur; - } - } + value = x; } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + else { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else + if (double.IsNaN(x)) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) - { - return cur; - } + return x; } } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) +#if !NO_DEEP_CANCELLATION + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -6698,137 +3952,70 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - double? value = null; + double value; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do + if (!await e.MoveNextAsync()) { - if (!await e.MoveNextAsync()) - { - return value; - } - - value = _selector(e.Current); + throw Error.NoElements(); } - while (!value.HasValue); - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync()) { - var cur = _selector(e.Current); - if (cur.HasValue) + var x = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); + if (x < value) { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) - { - return cur; - } - } + value = x; } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + else { - return value; - } - - value = _selector(e.Current); - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); + // Normally NaN < anything is false, as is anything < NaN + // However, this leads to some irksome outcomes in Min and Max. + // If we use those semantics then Min(NaN, 5.0) is NaN, but + // Min(5.0, NaN) is 5.0! To fix this, we impose a total + // ordering where NaN is smaller than every value, including + // negative infinity. + // Not testing for NaN therefore isn't an option, but since we + // can't find a smaller value, we can short-circuit. - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = _selector(e.Current); - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x < valueVal) - { - valueVal = x; - value = cur; - } - else + if (double.IsNaN(x)) { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (double.IsNaN(x)) - { - return cur; - } + return x; } } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } } - public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) +#endif + public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); - if (selector == null) - throw Error.ArgumentNull(nameof(selector)); - return Core(source, selector, cancellationToken); + return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -6839,7 +4026,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + { + double? value = null; + + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } - value = await _selector(e.Current).ConfigureAwait(false); + value = _selector(e.Current); } while (!value.HasValue); @@ -6899,9 +4107,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static Task MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -6949,12 +4155,13 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -6965,7 +4172,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw Error.ArgumentNull(nameof(source)); + if (selector == null) + throw Error.ArgumentNull(nameof(selector)); + + return Core(source, selector, cancellationToken); + + static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + { + double? value = null; - try + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. do { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return value; } @@ -7025,7 +4254,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT { decimal value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -7096,32 +4325,10 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x < value) - { - value = x; - } - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; } @@ -7140,8 +4347,9 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func <#=t#> value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -104,80 +105,13 @@ foreach (var m in new[] { "Max", "Min" }) } <# } -#> - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = e.Current; - -<# - if (isFloatingPoint && m == "Max") - { -#> - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). - - while (<#=t#>.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - -<# - } -#> - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = e.Current; - if (x <#=comparison#> value) - { - value = x; - } -<# - if (isFloatingPoint && m == "Min") - { -#> - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (<#=t#>.IsNaN(x)) - { - return x; - } - } -<# - } #> } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; <# @@ -187,8 +121,9 @@ foreach (var m in new[] { "Max", "Min" }) #> <#=t#> value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -317,163 +252,6 @@ foreach (var m in new[] { "Max", "Min" }) var cur = e.Current; var x = cur.GetValueOrDefault(); -<# - if (shortCircuit) - { -#> - if (cur.HasValue && x <#=comparison#> valueVal) -<# - } - else - { -#> - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x <#=comparison#> valueVal) -<# - } -#> - { - valueVal = x; - value = cur; - } - } -<# - } -#> - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = e.Current; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - -<# - if (isInteger && m == "Max") - { -#> - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - if (x <#=comparison#> valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x <#=comparison#> valueVal) - { - valueVal = x; - value = cur; - } - } - } -<# - } - else if (isFloatingPoint && m == "Min") - { -#> - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x <#=comparison#> valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (<#=t.TrimEnd('?')#>.IsNaN(x)) - { - return cur; - } - } - } - } -<# - } - else - { - if (isFloatingPoint && m == "Max") - { -#> - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). - - while (<#=t.TrimEnd('?')#>.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = e.Current; - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - -<# - } -#> - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = e.Current; - var x = cur.GetValueOrDefault(); - <# if (shortCircuit) { @@ -501,9 +279,8 @@ foreach (var m in new[] { "Max", "Min" }) } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; <# @@ -545,8 +322,9 @@ foreach (var overload in new[] { #> <#=t#> value; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -606,80 +384,13 @@ foreach (var overload in new[] { } <# } -#> - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - value = <#=overload.invoke#>; - -<# - if (isFloatingPoint && m == "Max") - { -#> - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). - - while (<#=t#>.IsNaN(value)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = <#=overload.invoke#>; - } - -<# - } -#> - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var x = <#=overload.invoke#>; - if (x <#=comparison#> value) - { - value = x; - } -<# - if (isFloatingPoint && m == "Min") - { -#> - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (<#=t#>.IsNaN(x)) - { - return x; - } - } -<# - } #> } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; <# @@ -689,8 +400,9 @@ foreach (var overload in new[] { #> <#=t#> value = null; -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -819,163 +531,6 @@ foreach (var overload in new[] { var cur = <#=overload.invoke#>; var x = cur.GetValueOrDefault(); -<# - if (shortCircuit) - { -#> - if (cur.HasValue && x <#=comparison#> valueVal) -<# - } - else - { -#> - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x <#=comparison#> valueVal) -<# - } -#> - { - valueVal = x; - value = cur; - } - } -<# - } -#> - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - // Start off knowing that we've a non-null value (or exit here, knowing we don't) - // so we don't have to keep testing for nullity. - do - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - value = <#=overload.invoke#>; - } - while (!value.HasValue); - - // Keep hold of the wrapped value, and do comparisons on that, rather than - // using the lifted operation each time. - var valueVal = value.GetValueOrDefault(); - -<# - if (isInteger && m == "Max") - { -#> - if (valueVal >= 0) - { - // We can fast-path this case where we know HasValue will - // never affect the outcome, without constantly checking - // if we're in such a state. Similar fast-paths could - // be done for other cases, but as all-positive or mostly- - // positive integer values are quite common in real-world - // uses, it's only been done for int? and long?. - - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = <#=overload.invoke#>; - var x = cur.GetValueOrDefault(); - - if (x <#=comparison#> valueVal) - { - valueVal = x; - value = cur; - } - } - } - else - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = <#=overload.invoke#>; - var x = cur.GetValueOrDefault(); - - // Do not replace & with &&. The branch prediction cost outweighs the extra operation - // unless nulls either never happen or always happen. - if (cur.HasValue & x <#=comparison#> valueVal) - { - valueVal = x; - value = cur; - } - } - } -<# - } - else if (isFloatingPoint && m == "Min") - { -#> - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = <#=overload.invoke#>; - if (cur.HasValue) - { - var x = cur.GetValueOrDefault(); - if (x <#=comparison#> valueVal) - { - valueVal = x; - value = cur; - } - else - { - // Normally NaN < anything is false, as is anything < NaN - // However, this leads to some irksome outcomes in Min and Max. - // If we use those semantics then Min(NaN, 5.0) is NaN, but - // Min(5.0, NaN) is 5.0! To fix this, we impose a total - // ordering where NaN is smaller than every value, including - // negative infinity. - // Not testing for NaN therefore isn't an option, but since we - // can't find a smaller value, we can short-circuit. - - if (<#=t.TrimEnd('?')#>.IsNaN(x)) - { - return cur; - } - } - } - } -<# - } - else - { - if (isFloatingPoint && m == "Max") - { -#> - // NaN is ordered less than all other values. We need to do explicit checks - // to ensure this, but once we've found a value that is not NaN we need no - // longer worry about it, so first loop until such a value is found (or not, - // as the case may be). - - while (<#=t.TrimEnd('?')#>.IsNaN(valueVal)) - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return value; - } - - var cur = <#=overload.invoke#>; - - if (cur.HasValue) - { - valueVal = (value = cur).GetValueOrDefault(); - } - } - -<# - } -#> - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var cur = <#=overload.invoke#>; - var x = cur.GetValueOrDefault(); - <# if (shortCircuit) { @@ -1003,9 +558,8 @@ foreach (var overload in new[] { } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return value; <# diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index f7861a780e..db533b7f0c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -264,38 +264,11 @@ private ValueTask SortedMap(TElement[] elements, int count, int minIndexI public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - return new Maybe(); - } - - var value = e.Current; - - var comparer = GetComparer(); + var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); - await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); - - while (await e.MoveNextAsync()) - { - var x = e.Current; - - if (await comparer.Compare(x, cacheLower: true, cancellationToken).ConfigureAwait(false) < 0) - { - value = x; - } - } - - return new Maybe(value); - } -#else - IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken); - - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return new Maybe(); } @@ -306,7 +279,7 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { TElement x = e.Current; @@ -320,45 +293,17 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) - { - if (!await e.MoveNextAsync()) - { - return new Maybe(); - } - - var value = e.Current; - - var comparer = GetComparer(); + var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); - await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); - - while (await e.MoveNextAsync()) - { - var current = e.Current; - - if (await comparer.Compare(current, cacheLower: false, cancellationToken).ConfigureAwait(false) >= 0) - { - value = current; - } - } - - return new Maybe(value); - } -#else - IAsyncEnumerator e = _source.GetAsyncEnumerator(cancellationToken); - - try + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - if (!await e.MoveNextAsync().ConfigureAwait(false)) + if (!await e.MoveNextAsync()) { return new Maybe(); } @@ -369,7 +314,7 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); - while (await e.MoveNextAsync().ConfigureAwait(false)) + while (await e.MoveNextAsync()) { TElement current = e.Current; @@ -383,9 +328,8 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } internal async ValueTask> TryGetLastAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index f5c75f23e5..63ceee8603 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -52,10 +52,13 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e1 = _first.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e1 = _first.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - await using (var e2 = _second.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e2 = _second.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e1.MoveNextAsync()) { @@ -67,36 +70,15 @@ static async Task Core(IAsyncEnumerable _first, IAsyncEnumerable< return !await e2.MoveNextAsync(); } - } -#else - var e1 = _first.GetAsyncEnumerator(_cancellationToken); - - try - { - var e2 = _second.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e1.MoveNextAsync().ConfigureAwait(false)) - { - if (!(await e2.MoveNextAsync().ConfigureAwait(false) && _comparer.Equals(e1.Current, e2.Current))) - { - return false; - } - } - - return !await e2.MoveNextAsync().ConfigureAwait(false); - } finally { - await e2.DisposeAsync().ConfigureAwait(false); + await e2.DisposeAsync(); } } finally { - await e1.DisposeAsync().ConfigureAwait(false); + await e1.DisposeAsync(); } -#endif } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index b31bcf1397..506f145c79 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -30,8 +30,9 @@ static async Task Core(IAsyncEnumerable _source, CancellationT throw Error.MoreThanOneElement(); } -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -45,31 +46,12 @@ static async Task Core(IAsyncEnumerable _source, CancellationT throw Error.MoreThanOneElement(); } - return result; - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.NoElements(); - } - - var result = e.Current; - if (await e.MoveNextAsync().ConfigureAwait(false)) - { - throw Error.MoreThanOneElement(); - } - return result; } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif } } @@ -84,8 +66,9 @@ public static Task SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -101,38 +84,14 @@ static async Task Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -166,38 +126,14 @@ static async Task Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -232,38 +169,14 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _c throw Error.MoreThanOneElement(); } -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -45,28 +46,10 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c return result; } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return default; - } - - var result = e.Current; - - if (!await e.MoveNextAsync().ConfigureAwait(false)) - { - return result; - } - } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif throw Error.MoreThanOneElement(); } @@ -83,8 +66,9 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -100,38 +84,14 @@ async Task Core(IAsyncEnumerable _source, Func } } - return result; - } - } - } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var result = e.Current; - - if (_predicate(result)) - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - if (_predicate(e.Current)) - { - throw Error.MoreThanOneElement(); - } - } - return result; } } } finally { - await e.DisposeAsync().ConfigureAwait(false); + await e.DisposeAsync(); } -#endif return default; } @@ -148,8 +108,9 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -165,38 +126,14 @@ async Task Core(IAsyncEnumerable _source, Func SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_USING - await using (var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false)) + var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -231,38 +169,14 @@ async Task Core(IAsyncEnumerable _source, Func Core(CancellationToken cancellationToken) { var queue = new Queue(); - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -55,6 +57,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new SkipLastAsyncIterator(source, count); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 87141b0810..904b82c74d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -23,7 +23,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -42,6 +44,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new SkipWhileAsyncIterator(source, predicate); @@ -60,7 +66,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { var index = -1; @@ -86,6 +94,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new SkipWhileWithIndexAsyncIterator(source, predicate); @@ -104,7 +116,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -123,6 +137,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new SkipWhileAsyncIteratorWithTask(source, predicate); @@ -142,7 +160,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e.MoveNextAsync()) { @@ -161,6 +181,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new SkipWhileAsyncIteratorWithTaskAndCancellation(source, predicate); @@ -180,7 +204,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { var index = -1; @@ -206,6 +232,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); @@ -225,7 +255,9 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { var index = -1; @@ -251,6 +283,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } } #else return new SkipWhileWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 56865d6141..28d7d9b505 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -28,7 +28,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { Queue queue; - await using (var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { if (!await e.MoveNextAsync()) { @@ -56,6 +58,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } + finally + { + await e.DisposeAsync(); + } Debug.Assert(queue.Count <= count); do diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 097cb4aeb4..de24bf13e9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -25,15 +25,27 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - await using (var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { yield return selector(e1.Current, e2.Current); } } + finally + { + await e2.DisposeAsync(); + } + } + finally + { + await e1.DisposeAsync(); } } #else @@ -55,15 +67,27 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - await using (var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { yield return await selector(e1.Current, e2.Current).ConfigureAwait(false); } } + finally + { + await e2.DisposeAsync(); + } + } + finally + { + await e1.DisposeAsync(); } } #else @@ -86,15 +110,27 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - await using (var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - await using (var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false)) + var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + + try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { yield return await selector(e1.Current, e2.Current, cancellationToken).ConfigureAwait(false); } } + finally + { + await e2.DisposeAsync(); + } + } + finally + { + await e1.DisposeAsync(); } } #else diff --git a/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs index 5db327f2e5..9f82213763 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/ConfiguredCancelableAsyncEnumerable.cs @@ -47,7 +47,7 @@ public Enumerator GetAsyncEnumerator() => /// Provides an awaitable async enumerator that enables cancelable iteration and configured awaits. [StructLayout(LayoutKind.Auto)] - public readonly struct Enumerator : IAsyncDisposable // Workaround for https://github.com/dotnet/csharplang/blob/master/meetings/2019/LDM-2019-01-16.md + public readonly struct Enumerator { private readonly IAsyncEnumerator _enumerator; private readonly bool _continueOnCapturedContext; @@ -76,9 +76,6 @@ public ConfiguredValueTaskAwaitable MoveNextAsync() => /// public ConfiguredValueTaskAwaitable DisposeAsync() => _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - - async ValueTask IAsyncDisposable.DisposeAsync() => - await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index a71d103807..e3015d560e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -32,26 +32,19 @@ public static ConfiguredCancelableAsyncEnumerable WithCancellation( #endif - // - // REVIEW: `await using (var e = xs.GetAsyncEnumerator().ConfigureAwait(false)) { ... }` leads to the following error when using BCL types. - // - // error CS8410: 'ConfiguredCancelableAsyncEnumerable.Enumerator': type used in an async using statement must be implicitly convertible to 'System.IAsyncDisposable' - // - // See https://github.com/dotnet/csharplang/blob/master/meetings/2019/LDM-2019-01-16.md#pattern-based-disposal-in-await-foreach for the issues with - // `await foreach` (but not `await using`). This should be reviewed with the LDM. Also see https://github.com/dotnet/csharplang/issues/1623. - // -#if BCL_HAS_CONFIGUREAWAIT && AWAIT_USING_REQUIRES_IASYNCDISPOSABLE +#if BCL_HAS_CONFIGUREAWAIT public static ConfiguredAsyncEnumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) { if (enumerator == null) throw Error.ArgumentNull(nameof(enumerator)); + // NB: We need our own copy of the struct to access the constructor. return new ConfiguredAsyncEnumerator(enumerator, continueOnCapturedContext); } /// Provides an awaitable async enumerator that enables cancelable iteration and configured awaits. [StructLayout(LayoutKind.Auto)] - public readonly struct ConfiguredAsyncEnumerator : IAsyncDisposable + public readonly struct ConfiguredAsyncEnumerator { private readonly IAsyncEnumerator _enumerator; private readonly bool _continueOnCapturedContext; @@ -80,9 +73,6 @@ public ConfiguredValueTaskAwaitable MoveNextAsync() => /// public ConfiguredValueTaskAwaitable DisposeAsync() => _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - - async ValueTask IAsyncDisposable.DisposeAsync() => - await _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); } #else public static ConfiguredCancelableAsyncEnumerable.Enumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) From 9ec8a1f1b47cf9216d7dc24ab6a63dbbe8a12420 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 18:22:26 -0800 Subject: [PATCH 736/862] Remove ConfigureAwait on IAsyncEnumerator in favor of GetConfiguredAsyncEnumerator. --- .../System/Linq/Operators/Catch.cs | 8 +- .../Linq/Operators/DistinctUntilChanged.cs | 8 +- .../System/Linq/Operators/Do.cs | 6 +- .../System/Linq/Operators/IsEmpty.cs | 2 +- .../System/Linq/Operators/Max.cs | 2 +- .../System/Linq/Operators/Min.cs | 2 +- .../System/Linq/Operators/MinBy.cs | 6 +- .../System/Linq/Operators/Scan.cs | 6 +- .../System/Linq/AsyncEnumerableHelpers.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 6 +- .../System/Linq/Operators/Any.cs | 2 +- .../Linq/Operators/Average.Generated.cs | 80 ++++----- .../System/Linq/Operators/FirstOrDefault.cs | 8 +- .../System/Linq/Operators/GroupJoin.cs | 6 +- .../System/Linq/Operators/Join.cs | 6 +- .../System/Linq/Operators/Max.cs | 16 +- .../System/Linq/Operators/Min.cs | 16 +- .../System/Linq/Operators/MinMax.Generated.cs | 160 +++++++++--------- .../Linq/Operators/OrderedAsyncEnumerable.cs | 4 +- .../System/Linq/Operators/SequenceEqual.cs | 4 +- .../System/Linq/Operators/Single.cs | 8 +- .../System/Linq/Operators/SingleOrDefault.cs | 8 +- .../System/Linq/Operators/SkipLast.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 12 +- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/Zip.cs | 12 +- .../Tasks/AsyncEnumerableExtensions.cs | 52 +----- 27 files changed, 199 insertions(+), 247 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 251ae2a4c2..f21c803f6e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -39,7 +39,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -103,7 +103,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -168,7 +168,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -248,7 +248,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) foreach (var source in sources) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 5e65ca5495..8cb9b730f6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -103,7 +103,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore(IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -150,7 +150,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -201,7 +201,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -253,7 +253,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index 47a26e6ebf..f731896045 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -176,7 +176,7 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -227,7 +227,7 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -282,7 +282,7 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index c434ac0cf5..a8f98af091 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -19,7 +19,7 @@ public static Task IsEmptyAsync(this IAsyncEnumerable so static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 5138daa4ef..95c41c8dcb 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -24,7 +24,7 @@ static async Task Core(IAsyncEnumerable _source, IComparer.Default; } - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index ed2d3b6e9f..9964edd88c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -24,7 +24,7 @@ static async Task Core(IAsyncEnumerable _source, IComparer.Default; } - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index acda5e36c7..49fec83972 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -110,7 +110,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -151,7 +151,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -193,7 +193,7 @@ private static async Task> ExtremaBy(IAsyncEnumera { var result = new List(); - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 26564bf386..1b15e64850 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -27,7 +27,7 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -93,7 +93,7 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -134,7 +134,7 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 0e6b8e3532..1a6b9908b0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -44,7 +44,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } else { - var en = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var en = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index d5d96f8f72..bcae0bb381 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -21,7 +21,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -57,7 +57,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -94,7 +94,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 9d2e47bd3c..24942cc796 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -19,7 +19,7 @@ public static Task AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 1343b279b8..019e369cbf 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -19,7 +19,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Cance static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -59,7 +59,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -99,7 +99,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -140,7 +140,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -179,7 +179,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -219,7 +219,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -259,7 +259,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -300,7 +300,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -339,7 +339,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Canc static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -379,7 +379,7 @@ public static Task AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -419,7 +419,7 @@ public static Task AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -460,7 +460,7 @@ public static Task AverageAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -499,7 +499,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, Ca static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -539,7 +539,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -579,7 +579,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -620,7 +620,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -659,7 +659,7 @@ public static Task AverageAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -699,7 +699,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -739,7 +739,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -780,7 +780,7 @@ public static Task AverageAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -819,7 +819,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -867,7 +867,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -915,7 +915,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -964,7 +964,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1011,7 +1011,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1059,7 +1059,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1107,7 +1107,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1156,7 +1156,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1203,7 +1203,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1251,7 +1251,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1299,7 +1299,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1348,7 +1348,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1395,7 +1395,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1443,7 +1443,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1491,7 +1491,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1540,7 +1540,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1587,7 +1587,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1635,7 +1635,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1683,7 +1683,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1732,7 +1732,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 789373736b..b9b53dbaf9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -97,7 +97,7 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -120,7 +120,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, C private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -144,7 +144,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -169,7 +169,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< #if !NO_DEEP_CANCELLATION private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 962c59fd3b..235b753bd9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -31,7 +31,7 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -79,7 +79,7 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -128,7 +128,7 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index b6fbf38ec1..3c4a27e920 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -32,7 +32,7 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -96,7 +96,7 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -161,7 +161,7 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 03fbf16d39..d70bb53cdb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -25,7 +25,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -68,7 +68,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -115,7 +115,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -68,7 +68,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT var value = default(TSource); - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -116,7 +116,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ca { int value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -63,7 +63,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ { long value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -555,7 +555,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken { float value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1062,7 +1062,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok { double value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -1598,7 +1598,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT { decimal value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -2119,7 +2119,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ca { int value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -2507,7 +2507,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ { long value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -2903,7 +2903,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken { float value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -3315,7 +3315,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok { double value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -3839,7 +3839,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT { decimal value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -4347,7 +4347,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func SortedMap(TElement[] elements, int count, int minIndexI public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { - var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -299,7 +299,7 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { - var e = _source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 63ceee8603..ede3bf19b4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -52,11 +52,11 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { - var e1 = _first.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e1 = _first.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - var e2 = _second.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e2 = _second.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 506f145c79..37a3a85e89 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -30,7 +30,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT throw Error.MoreThanOneElement(); } - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -66,7 +66,7 @@ public static Task SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -108,7 +108,7 @@ public static Task SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -151,7 +151,7 @@ public static Task SingleAsync(this IAsyncEnumerable static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index a4ca997541..fe7c076640 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -30,7 +30,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c throw Error.MoreThanOneElement(); } - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -66,7 +66,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -108,7 +108,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -151,7 +151,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs index d870a05d19..a7b81f03f3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs @@ -35,7 +35,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var queue = new Queue(); - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 904b82c74d..1f43f4c0a7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -23,7 +23,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -66,7 +66,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -116,7 +116,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -160,7 +160,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -204,7 +204,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -255,7 +255,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 28d7d9b505..365cb090a4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -28,7 +28,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { Queue queue; - var e = source.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index de24bf13e9..1b18004e5e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -25,11 +25,11 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -67,11 +67,11 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -110,11 +110,11 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e1 = first.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { - var e2 = second.GetAsyncEnumerator(cancellationToken).ConfigureAwait(false); + var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index e3015d560e..16af70fb6e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; namespace System.Threading.Tasks { @@ -32,56 +31,9 @@ public static ConfiguredCancelableAsyncEnumerable WithCancellation( #endif -#if BCL_HAS_CONFIGUREAWAIT - public static ConfiguredAsyncEnumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) + public static ConfiguredCancelableAsyncEnumerable.Enumerator GetConfiguredAsyncEnumerator(this IAsyncEnumerable enumerable, CancellationToken cancellationToken, bool continueOnCapturedContext) { - if (enumerator == null) - throw Error.ArgumentNull(nameof(enumerator)); - - // NB: We need our own copy of the struct to access the constructor. - return new ConfiguredAsyncEnumerator(enumerator, continueOnCapturedContext); - } - - /// Provides an awaitable async enumerator that enables cancelable iteration and configured awaits. - [StructLayout(LayoutKind.Auto)] - public readonly struct ConfiguredAsyncEnumerator - { - private readonly IAsyncEnumerator _enumerator; - private readonly bool _continueOnCapturedContext; - - internal ConfiguredAsyncEnumerator(IAsyncEnumerator enumerator, bool continueOnCapturedContext) - { - _enumerator = enumerator; - _continueOnCapturedContext = continueOnCapturedContext; - } - - /// Advances the enumerator asynchronously to the next element of the collection. - /// - /// A that will complete with a result of true - /// if the enumerator was successfully advanced to the next element, or false if the enumerator has - /// passed the end of the collection. - /// - public ConfiguredValueTaskAwaitable MoveNextAsync() => - _enumerator.MoveNextAsync().ConfigureAwait(_continueOnCapturedContext); - - /// Gets the element in the collection at the current position of the enumerator. - public T Current => _enumerator.Current; - - /// - /// Performs application-defined tasks associated with freeing, releasing, or - /// resetting unmanaged resources asynchronously. - /// - public ConfiguredValueTaskAwaitable DisposeAsync() => - _enumerator.DisposeAsync().ConfigureAwait(_continueOnCapturedContext); - } -#else - public static ConfiguredCancelableAsyncEnumerable.Enumerator ConfigureAwait(this IAsyncEnumerator enumerator, bool continueOnCapturedContext) - { - if (enumerator == null) - throw Error.ArgumentNull(nameof(enumerator)); - - return new ConfiguredCancelableAsyncEnumerable.Enumerator(enumerator, continueOnCapturedContext); + return enumerable.ConfigureAwait(continueOnCapturedContext).WithCancellation(cancellationToken).GetAsyncEnumerator(); } -#endif } } From e7fa52d4bc19c15d55566d748af1802bc3ca73b6 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 18:23:06 -0800 Subject: [PATCH 737/862] Remove unused define. --- Ix.NET/Source/Directory.build.targets | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index f017ee8361..1e22a03613 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -15,10 +15,8 @@ NB: USE_ASYNC_ITERATOR relies on members in the framework only present in .NET Core 3.0 Preview 2 at the moment: error CS0518: Predefined type 'System.Runtime.CompilerServices.AsyncIteratorMethodBuilder' is not defined or imported error CS0656: Missing compiler required member 'System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.* - - NB: AWAIT_USING_REQUIRES_IASYNCDISPOSABLE - See comments in AsyncEnumerableExtensions.cs. --> - $(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT;AWAIT_USING_REQUIRES_IASYNCDISPOSABLE + $(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT From d5aa7e28b06edd04840c88a130998d8af0e33052 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 18:41:34 -0800 Subject: [PATCH 738/862] Remove USE_AWAIT_FOREACH (always on now). --- Ix.NET/Source/Directory.build.targets | 4 - .../System/Linq/AsyncEnumerableHelpers.cs | 16 - .../System/Linq/Operators/Aggregate.cs | 96 --- .../System/Linq/Operators/All.cs | 51 -- .../System/Linq/Operators/Any.cs | 51 -- .../System/Linq/Operators/AppendPrepend.cs | 66 -- .../System/Linq/Operators/Concat.cs | 16 - .../System/Linq/Operators/Contains.cs | 38 - .../System/Linq/Operators/Count.cs | 85 -- .../System/Linq/Operators/ElementAt.cs | 21 - .../Linq/Operators/ElementAtOrDefault.cs | 21 - .../System/Linq/Operators/ForEach.cs | 96 --- .../System/Linq/Operators/LastOrDefault.cs | 83 -- .../System/Linq/Operators/LongCount.cs | 85 -- .../System/Linq/Operators/Lookup.cs | 189 ----- .../System/Linq/Operators/SelectMany.cs | 115 --- .../System/Linq/Operators/Sum.Generated.cs | 748 ------------------ .../System/Linq/Operators/Sum.Generated.tt | 134 ---- .../System/Linq/Operators/ToDictionary.cs | 123 --- .../System/Linq/Operators/ToHashSet.cs | 16 - .../System/Linq/Operators/ToList.cs | 16 - .../System/Linq/Operators/Union.cs | 16 - .../System/Linq/Operators/Utilities.cs | 16 - 23 files changed, 2102 deletions(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 1e22a03613..41ee048fb2 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -19,10 +19,6 @@ $(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT - - $(DefineConstants);USE_AWAIT_FOREACH - - $(AssemblyName) ($(TargetFramework)) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 1a6b9908b0..678b90771a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -112,26 +112,10 @@ internal static async Task> ToSet(IAsyncEnumerable source, IEqualit { var set = new Set(comparer); -#if USE_AWAIT_FOREACH await foreach (T item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - set.Add(e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return set; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index bcae0bb381..768f375147 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -133,26 +133,10 @@ static async Task Core(IAsyncEnumerable _source, TAccumula { var acc = _seed; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = _accumulator(acc, e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return acc; } @@ -171,26 +155,10 @@ static async Task Core(IAsyncEnumerable _source, TAccumula { var acc = _seed; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = await _accumulator(acc, e.Current).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return acc; } @@ -210,26 +178,10 @@ static async Task Core(IAsyncEnumerable _source, TAccumula { var acc = _seed; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return acc; } @@ -251,26 +203,10 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ { var acc = _seed; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = _accumulator(acc, e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return _resultSelector(acc); } @@ -291,26 +227,10 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ { var acc = _seed; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = await _accumulator(acc, e.Current).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return await _resultSelector(acc).ConfigureAwait(false); } @@ -332,26 +252,10 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ { var acc = _seed; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - acc = await _accumulator(acc, e.Current, _cancellationToken).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return await _resultSelector(acc, _cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 797b3ddade..c933160013 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -21,7 +21,6 @@ public static Task AllAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!_predicate(item)) @@ -29,22 +28,6 @@ static async Task Core(IAsyncEnumerable _source, Func AllAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!await _predicate(item).ConfigureAwait(false)) @@ -69,22 +51,6 @@ static async Task Core(IAsyncEnumerable _source, Func AllAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!await _predicate(item, _cancellationToken).ConfigureAwait(false)) @@ -110,22 +75,6 @@ static async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_predicate(item)) @@ -51,22 +50,6 @@ static async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item).ConfigureAwait(false)) @@ -91,22 +73,6 @@ static async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) @@ -132,22 +97,6 @@ static async Task Core(IAsyncEnumerable _source, Func ToArrayAsync(CancellationToken cancel } else { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; ++index; } -#else - var en = _source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await en.MoveNextAsync().ConfigureAwait(false)) - { - array[index] = en.Current; - ++index; - } - } - finally - { - await en.DisposeAsync().ConfigureAwait(false); - } -#endif } if (_appending) @@ -251,26 +234,10 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(_item); } -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); } -#else - var en = _source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await en.MoveNextAsync().ConfigureAwait(false)) - { - list.Add(en.Current); - } - } - finally - { - await en.DisposeAsync().ConfigureAwait(false); - } -#endif if (_appending) { @@ -428,28 +395,11 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; ++index; } -#else - var en = _source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await en.MoveNextAsync().ConfigureAwait(false)) - { - array[index] = en.Current; - ++index; - } - } - finally - { - await en.DisposeAsync().ConfigureAwait(false); - } -#endif } index = array.Length; @@ -471,26 +421,10 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(n.Item); } -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); } -#else - var en = _source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await en.MoveNextAsync().ConfigureAwait(false)) - { - list.Add(en.Current); - } - } - finally - { - await en.DisposeAsync().ConfigureAwait(false); - } -#endif if (_appended != null) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index ea93d3b6fb..b89979ac81 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -84,26 +84,10 @@ public async ValueTask> ToListAsync(CancellationToken cancellation break; } -#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); } -#else - var e = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - list.Add(e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } return list; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index cb835ca9d1..c3632769ba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -28,7 +28,6 @@ public static Task ContainsAsync(this IAsyncEnumerable s static async Task Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (EqualityComparer.Default.Equals(item, _value)) @@ -36,24 +35,6 @@ static async Task Core(IAsyncEnumerable _source, TSource _value, return true; } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - if (EqualityComparer.Default.Equals(e.Current, _value)) - { - return true; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return false; } @@ -64,7 +45,6 @@ static async Task Core(IAsyncEnumerable _source, TSource _value, static async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_comparer.Equals(item, _value)) @@ -72,24 +52,6 @@ static async Task Core(IAsyncEnumerable _source, TSource _value, return true; } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - if (_comparer.Equals(e.Current, _value)) - { - return true; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return false; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 0f753b0fe8..fd1835f874 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -32,7 +32,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken { var count = 0; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -40,24 +39,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken count++; } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - count++; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return count; } @@ -76,7 +57,6 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, int _index, C if (_index >= 0) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) @@ -47,26 +46,6 @@ static async Task Core(IAsyncEnumerable _source, int _index, C _index--; } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - if (_index == 0) - { - return e.Current; - } - - _index--; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index f289b89bbf..5dd69697fe 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -40,7 +40,6 @@ static async Task Core(IAsyncEnumerable _source, int _index, C } else { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) @@ -50,26 +49,6 @@ static async Task Core(IAsyncEnumerable _source, int _index, C _index--; } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - if (_index == 0) - { - return e.Current; - } - - _index--; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index f695f2cfaf..263d5d3698 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -28,26 +28,10 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - _action(e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } @@ -64,26 +48,10 @@ static async Task Core(IAsyncEnumerable _source, Action _ { var index = 0; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item, checked(index++)); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - _action(e.Current, checked(index++)); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } @@ -98,26 +66,10 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - await _action(e.Current).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } @@ -127,26 +79,10 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item, _cancellationToken).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - await _action(e.Current, _cancellationToken).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } @@ -163,26 +99,10 @@ static async Task Core(IAsyncEnumerable _source, Func _source, Func> Core(IAsyncEnumerable _source, C var last = default(TSource); var hasLast = false; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { hasLast = true; last = item; } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - hasLast = true; - last = e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return hasLast ? new Maybe(last) : new Maybe(); } @@ -136,7 +119,6 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable(last) : new Maybe(); } @@ -175,7 +136,6 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable(last) : new Maybe(); } @@ -215,7 +154,6 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable(last) : new Maybe(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 2d8447b9cf..a60240806a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -21,7 +21,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationToke { var count = 0L; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -29,24 +28,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationToke count++; } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - count++; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return count; } @@ -65,7 +46,6 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -100,27 +99,6 @@ internal static async Task> CreateAsync(IAsyncEn var element = elementSelector(item); group.Add(element); } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = keySelector(item); - var group = lookup.GetGrouping(key, create: true); - - var element = elementSelector(item); - group.Add(element); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -132,30 +110,11 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); -#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); lookup.GetGrouping(key, create: true).Add(item); } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = keySelector(item); - lookup.GetGrouping(key, create: true).Add(item); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -164,7 +123,6 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { var lookup = new Lookup(comparer); -#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); @@ -173,27 +131,6 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum lookup.GetGrouping(key, create: true).Add(item); } } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = keySelector(item); - if (key != null) - { - lookup.GetGrouping(key, create: true).Add(item); - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -419,7 +356,6 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -428,27 +364,6 @@ internal static async Task> CreateAsync( var element = await elementSelector(item).ConfigureAwait(false); group.Add(element); } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = await keySelector(item).ConfigureAwait(false); - var group = lookup.GetGrouping(key, create: true); - - var element = await elementSelector(item).ConfigureAwait(false); - group.Add(element); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -462,7 +377,6 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); @@ -471,27 +385,6 @@ internal static async Task> CreateAsync( var element = await elementSelector(item, cancellationToken).ConfigureAwait(false); group.Add(element); } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = await keySelector(item, cancellationToken).ConfigureAwait(false); - var group = lookup.GetGrouping(key, create: true); - - var element = await elementSelector(item, cancellationToken).ConfigureAwait(false); - group.Add(element); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -504,30 +397,11 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); -#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(item); } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = await keySelector(item).ConfigureAwait(false); - lookup.GetGrouping(key, create: true).Add(item); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -540,30 +414,11 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); -#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(item); } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = await keySelector(item, cancellationToken).ConfigureAwait(false); - lookup.GetGrouping(key, create: true).Add(item); - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -573,7 +428,6 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); -#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); @@ -582,27 +436,6 @@ internal static async Task> CreateForJoinAsync(IA lookup.GetGrouping(key, create: true).Add(item); } } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = await keySelector(item).ConfigureAwait(false); - if (key != null) - { - lookup.GetGrouping(key, create: true).Add(item); - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } @@ -612,7 +445,6 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); -#if USE_AWAIT_FOREACH await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); @@ -621,27 +453,6 @@ internal static async Task> CreateForJoinAsync(IA lookup.GetGrouping(key, create: true).Add(item); } } -#else - var enu = source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await enu.MoveNextAsync().ConfigureAwait(false)) - { - var item = enu.Current; - - var key = await keySelector(item, cancellationToken).ConfigureAwait(false); - if (key != null) - { - lookup.GetGrouping(key, create: true).Add(item); - } - } - } - finally - { - await enu.DisposeAsync().ConfigureAwait(false); - } -#endif return lookup; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 4f6bf7fb72..4f6543a2de 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -402,7 +402,6 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -410,24 +409,6 @@ async ValueTask Core(CancellationToken _cancellationToken) count += await _selector(element).CountAsync().ConfigureAwait(false); } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - count += await _selector(e.Current).CountAsync().ConfigureAwait(false); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return count; } @@ -446,30 +427,12 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = _selector(element); await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var items = _selector(e.Current); - - await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return list; } @@ -578,7 +541,6 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var items = await _selector(element).ConfigureAwait(false); @@ -588,26 +550,6 @@ async ValueTask Core(CancellationToken _cancellationToken) count += await items.CountAsync().ConfigureAwait(false); } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var items = await _selector(e.Current).ConfigureAwait(false); - - checked - { - count += await items.CountAsync().ConfigureAwait(false); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return count; } @@ -626,30 +568,12 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = await _selector(element).ConfigureAwait(false); await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var items = await _selector(e.Current).ConfigureAwait(false); - - await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return list; } @@ -759,7 +683,6 @@ async ValueTask Core(CancellationToken _cancellationToken) { var count = 0; -#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var items = await _selector(element, _cancellationToken).ConfigureAwait(false); @@ -769,26 +692,6 @@ async ValueTask Core(CancellationToken _cancellationToken) count += await items.CountAsync().ConfigureAwait(false); } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var items = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - - checked - { - count += await items.CountAsync().ConfigureAwait(false); - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return count; } @@ -807,30 +710,12 @@ public async ValueTask> ToListAsync(CancellationToken cancellation { var list = new List(); -#if USE_AWAIT_FOREACH await foreach (var element in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var items = await _selector(element, cancellationToken).ConfigureAwait(false); await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); } -#else - var e = _source.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var items = await _selector(e.Current, cancellationToken).ConfigureAwait(false); - - await list.AddRangeAsync(items, cancellationToken).ConfigureAwait(false); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return list; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index a0c82d78cd..dbee6eafae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -21,7 +21,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca { var sum = 0; -#if USE_AWAIT_FOREACH await foreach (int value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -29,24 +28,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca sum += value; } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - sum += e.Current; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -65,7 +46,6 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _ { var sum = 0L; -#if USE_AWAIT_FOREACH await foreach (long value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked @@ -217,24 +134,6 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ sum += value; } } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - checked - { - sum += e.Current; - } - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -253,7 +152,6 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken { var sum = 0.0f; -#if USE_AWAIT_FOREACH await foreach (float value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -435,30 +255,12 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok { var sum = 0.0; -#if USE_AWAIT_FOREACH await foreach (double value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -599,30 +349,12 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationT { var sum = 0m; -#if USE_AWAIT_FOREACH await foreach (decimal value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { sum += value; } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - sum += e.Current; - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -763,30 +443,12 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func; -#if USE_AWAIT_FOREACH await foreach (<#=o.type#> value in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { <# @@ -67,37 +66,6 @@ else } #> } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { -<# -if (o.@checked) -{ -#> - checked - { - sum += e.Current<#=n#>; - } -<# -} -else -{ -#> - sum += e.Current<#=n#>; -<# -} -#> - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -116,7 +84,6 @@ else { var sum = <#=o.zero#>; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = _selector(item); @@ -139,39 +106,6 @@ else } #> } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = _selector(e.Current); - -<# -if (o.@checked) -{ -#> - checked - { - sum += value<#=n#>; - } -<# -} -else -{ -#> - sum += value<#=n#>; -<# -} -#> - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -190,7 +124,6 @@ else { var sum = <#=o.zero#>; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = await _selector(item).ConfigureAwait(false); @@ -213,39 +146,6 @@ else } #> } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await _selector(e.Current).ConfigureAwait(false); - -<# -if (o.@checked) -{ -#> - checked - { - sum += value<#=n#>; - } -<# -} -else -{ -#> - sum += value<#=n#>; -<# -} -#> - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } @@ -265,7 +165,6 @@ else { var sum = <#=o.zero#>; -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var value = await _selector(item, _cancellationToken).ConfigureAwait(false); @@ -288,39 +187,6 @@ else } #> } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var value = await _selector(e.Current, _cancellationToken).ConfigureAwait(false); - -<# -if (o.@checked) -{ -#> - checked - { - sum += value<#=n#>; - } -<# -} -else -{ -#> - sum += value<#=n#>; -<# -} -#> - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return sum; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 87960155b3..a951bddead 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -26,32 +26,12 @@ static async Task> Core(IAsyncEnumerable _sou { var d = new Dictionary(_comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); d.Add(key, item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var item = e.Current; - - var key = _keySelector(item); - - d.Add(key, item); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return d; } @@ -73,32 +53,12 @@ static async Task> Core(IAsyncEnumerable _sou { var d = new Dictionary(_comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); d.Add(key, item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var item = e.Current; - - var key = await _keySelector(item).ConfigureAwait(false); - - d.Add(key, item); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return d; } @@ -121,32 +81,12 @@ static async Task> Core(IAsyncEnumerable _sou { var d = new Dictionary(_comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); d.Add(key, item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var item = e.Current; - - var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); - - d.Add(key, item); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return d; } @@ -171,7 +111,6 @@ static async Task> Core(IAsyncEnumerable _so { var d = new Dictionary(_comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); @@ -179,26 +118,6 @@ static async Task> Core(IAsyncEnumerable _so d.Add(key, value); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var item = e.Current; - - var key = _keySelector(item); - var value = _elementSelector(item); - - d.Add(key, value); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return d; } @@ -222,7 +141,6 @@ static async Task> Core(IAsyncEnumerable _so { var d = new Dictionary(_comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); @@ -230,26 +148,6 @@ static async Task> Core(IAsyncEnumerable _so d.Add(key, value); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var item = e.Current; - - var key = await _keySelector(item).ConfigureAwait(false); - var value = await _elementSelector(item).ConfigureAwait(false); - - d.Add(key, value); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return d; } @@ -274,7 +172,6 @@ static async Task> Core(IAsyncEnumerable _so { var d = new Dictionary(_comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); @@ -282,26 +179,6 @@ static async Task> Core(IAsyncEnumerable _so d.Add(key, value); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - var item = e.Current; - - var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); - var value = await _elementSelector(item, _cancellationToken).ConfigureAwait(false); - - d.Add(key, value); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return d; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 3efe87cec8..e2c7aae414 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -24,26 +24,10 @@ static async Task> Core(IAsyncEnumerable _source, IEqu { var set = new HashSet(_comparer); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { set.Add(item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - set.Add(e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return set; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 03770740be..4595543f3d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -24,26 +24,10 @@ static async Task> Core(IAsyncEnumerable _source, Cancell { var list = new List(); -#if USE_AWAIT_FOREACH await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { list.Add(item); } -#else - var e = _source.GetAsyncEnumerator(_cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - list.Add(e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif return list; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index ebdf1bb070..e938cd6e5b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -162,26 +162,10 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } -#if USE_AWAIT_FOREACH await foreach (TSource item in enumerable.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); } -#else - var e = enumerable.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - set.Add(e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs index a99a513f91..e26284561b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Utilities.cs @@ -38,26 +38,10 @@ public static async ValueTask AddRangeAsync(this List list, IAsyncEnumerab } } -#if USE_AWAIT_FOREACH await foreach (var item in collection.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); } -#else - var e = collection.GetAsyncEnumerator(cancellationToken); - - try - { - while (await e.MoveNextAsync().ConfigureAwait(false)) - { - list.Add(e.Current); - } - } - finally - { - await e.DisposeAsync().ConfigureAwait(false); - } -#endif } } } From b7cc8e756ecbd8c709a6cd09c41f65e76ba5ab2d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 20:54:47 -0800 Subject: [PATCH 739/862] Fix T4 files to use GetConfiguredAsyncEnumerator. --- .../System/Linq/Operators/Average.Generated.tt | 16 ++++++++-------- .../System/Linq/Operators/MinMax.Generated.tt | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index ac012d08e7..6f0131db83 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -58,7 +58,7 @@ foreach (var o in os) if (isNullable) { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -97,7 +97,7 @@ if (isNullable) else { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -144,7 +144,7 @@ else if (isNullable) { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -183,7 +183,7 @@ if (isNullable) else { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -230,7 +230,7 @@ else if (isNullable) { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -269,7 +269,7 @@ if (isNullable) else { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -317,7 +317,7 @@ else if (isNullable) { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -356,7 +356,7 @@ if (isNullable) else { #> - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 35fbd00366..49b69f5882 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -43,7 +43,7 @@ foreach (var m in new[] { "Max", "Min" }) #> <#=t#> value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -121,7 +121,7 @@ foreach (var m in new[] { "Max", "Min" }) #> <#=t#> value = null; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -322,7 +322,7 @@ foreach (var overload in new[] { #> <#=t#> value; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { @@ -400,7 +400,7 @@ foreach (var overload in new[] { #> <#=t#> value = null; - var e = _source.GetAsyncEnumerator(_cancellationToken).ConfigureAwait(false); + var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) { From 1a63ba15ab5d5e1b18ec8fca75524dd1c2bc8014 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 23:36:11 -0800 Subject: [PATCH 740/862] Use ValueTask for aggregates to improve ergonomics when used in e.g. Select. --- .../AsyncQueryableExTests.Generated.tt | 4 +- .../ValueTaskExtensions.cs | 13 + .../System/Linq/AsyncQueryableEx.Generated.cs | 30 +- .../System/Linq/AsyncQueryableEx.Generated.tt | 2 +- .../System/Linq/Operators/IsEmpty.cs | 4 +- .../System/Linq/Operators/Max.cs | 4 +- .../System/Linq/Operators/MaxBy.cs | 18 +- .../System/Linq/Operators/Min.cs | 4 +- .../System/Linq/Operators/MinBy.cs | 18 +- .../System/Linq/Operators/IsEmpty.cs | 4 +- .../System/Linq/Operators/Max.cs | 4 +- .../System/Linq/Operators/MaxBy.cs | 18 +- .../System/Linq/Operators/Min.cs | 4 +- .../System/Linq/Operators/MinBy.cs | 24 +- .../AsyncQueryableTests.Generated.cs | 660 +++++++++--------- .../AsyncQueryableTests.Generated.tt | 4 +- .../ValueTaskExtensions.cs | 13 + .../System/Linq/AsyncEnumerableExecutor.cs | 6 +- .../System/Linq/AsyncEnumerableQuery.cs | 2 +- .../System/Linq/AsyncQueryable.Generated.cs | 500 ++++++------- .../System/Linq/AsyncQueryable.Generated.tt | 2 +- .../System/Linq/IAsyncQueryProvider.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 30 +- .../System/Linq/Operators/All.cs | 16 +- .../System/Linq/Operators/Any.cs | 20 +- .../Linq/Operators/Average.Generated.cs | 40 +- .../Linq/Operators/Average.Generated.tt | 8 +- .../System/Linq/Operators/Average.cs | 260 +++---- .../System/Linq/Operators/Contains.cs | 8 +- .../System/Linq/Operators/Count.cs | 12 +- .../System/Linq/Operators/ElementAt.cs | 14 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/First.cs | 60 +- .../System/Linq/Operators/FirstOrDefault.cs | 30 +- .../System/Linq/Operators/Last.cs | 60 +- .../System/Linq/Operators/LastOrDefault.cs | 30 +- .../System/Linq/Operators/LongCount.cs | 12 +- .../System/Linq/Operators/Max.cs | 274 ++++---- .../System/Linq/Operators/Min.cs | 274 ++++---- .../System/Linq/Operators/MinMax.Generated.cs | 80 +-- .../System/Linq/Operators/MinMax.Generated.tt | 8 +- .../System/Linq/Operators/SequenceEqual.cs | 20 +- .../System/Linq/Operators/Single.cs | 36 +- .../System/Linq/Operators/SingleOrDefault.cs | 28 +- .../System/Linq/Operators/Sum.cs | 240 +++---- .../System/Linq/Operators/ToArray.cs | 4 +- .../System/Linq/Operators/ToDictionary.cs | 46 +- .../System/Linq/Operators/ToHashSet.cs | 6 +- .../System/Linq/Operators/ToList.cs | 4 +- .../System/Linq/Operators/ToLookup.cs | 40 +- .../System/Linq/Operators/Aggregate.cs | 36 +- .../System/Linq/Operators/All.cs | 12 +- .../System/Linq/Operators/Any.cs | 16 +- .../Linq/Operators/Average.Generated.cs | 160 ++--- .../Linq/Operators/Average.Generated.tt | 16 +- .../System/Linq/Operators/Contains.cs | 10 +- .../System/Linq/Operators/Count.cs | 22 +- .../System/Linq/Operators/ElementAt.cs | 4 +- .../Linq/Operators/ElementAtOrDefault.cs | 4 +- .../System/Linq/Operators/First.cs | 16 +- .../System/Linq/Operators/FirstOrDefault.cs | 22 +- .../System/Linq/Operators/Last.cs | 16 +- .../System/Linq/Operators/LastOrDefault.cs | 22 +- .../System/Linq/Operators/LongCount.cs | 16 +- .../System/Linq/Operators/Max.cs | 24 +- .../System/Linq/Operators/Min.cs | 24 +- .../System/Linq/Operators/MinMax.Generated.cs | 320 ++++----- .../System/Linq/Operators/MinMax.Generated.tt | 8 +- .../System/Linq/Operators/Reverse.cs | 2 +- .../System/Linq/Operators/SequenceEqual.cs | 12 +- .../System/Linq/Operators/Single.cs | 16 +- .../System/Linq/Operators/SingleOrDefault.cs | 16 +- .../System/Linq/Operators/Sum.Generated.cs | 160 ++--- .../System/Linq/Operators/Sum.Generated.tt | 16 +- .../System/Linq/Operators/ToArray.cs | 6 +- .../System/Linq/Operators/ToDictionary.cs | 36 +- .../System/Linq/Operators/ToHashSet.cs | 6 +- .../System/Linq/Operators/ToList.cs | 6 +- .../System/Linq/Operators/ToLookup.cs | 36 +- 79 files changed, 2045 insertions(+), 2019 deletions(-) create mode 100644 Ix.NET/Source/System.Interactive.Async.Providers.Tests/ValueTaskExtensions.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Queryable.Tests/ValueTaskExtensions.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt index 8f56d1f33f..d77b7edeac 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/AsyncQueryableExTests.Generated.tt @@ -185,7 +185,7 @@ foreach (var m in typeof(AsyncEnumerableEx).GetMethods() { var td = m.ReturnType.GetGenericTypeDefinition(); - if (td == typeof(Task<>)) + if (td.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask { factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; @@ -453,7 +453,7 @@ if (indexes.Count != 0) if (!failing.Contains(tm.Name)) { - if (tmRet == typeof(Task<>)) + if (tmRet.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask { #> AssertEx.SucceedOrFailProper(() => res.Wait()); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/ValueTaskExtensions.cs b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/ValueTaskExtensions.cs new file mode 100644 index 0000000000..63730dea23 --- /dev/null +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/ValueTaskExtensions.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading.Tasks; + +namespace Tests +{ + public static class ValueTaskExtensions + { + public static void Wait(this ValueTask task) => task.AsTask().Wait(); + } +} diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 25ad89b71e..1fec3b22cc 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -598,7 +598,7 @@ public static IAsyncQueryable IgnoreElements(this IAsyncQuerya #endif } - public static Task IsEmptyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask IsEmptyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -610,7 +610,7 @@ public static Task IsEmptyAsync(this IAsyncQueryable sou #endif } - public static Task MaxAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -622,7 +622,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -636,7 +636,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -650,7 +650,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -664,7 +664,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -678,7 +678,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -692,7 +692,7 @@ public static Task> MaxByAsync(this IAsyncQueryabl #endif } - public static Task> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -718,7 +718,7 @@ public static IAsyncQueryable Merge(this IAsyncQueryable MinAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -730,7 +730,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -744,7 +744,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -758,7 +758,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -772,7 +772,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -786,7 +786,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -800,7 +800,7 @@ public static Task> MinByAsync(this IAsyncQueryabl #endif } - public static Task> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt index d820e47424..75c0d4238e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -189,7 +189,7 @@ foreach (var m in typeof(AsyncEnumerableEx).GetMethods() { var td = m.ReturnType.GetGenericTypeDefinition(); - if (td == typeof(Task<>)) + if (td.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask { factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs index c981bf5853..c2dbde6999 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/IsEmpty.cs @@ -15,8 +15,8 @@ public class IsEmpty : AsyncEnumerableExTests [Fact] public async Task IsEmpty_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmptyAsync(default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmptyAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmptyAsync(default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.IsEmptyAsync(default, CancellationToken.None).AsTask()); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs index cdbae20062..758022a45d 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Max.cs @@ -16,9 +16,9 @@ public class Max : AsyncEnumerableExTests [Fact] public async Task Max_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxAsync(default, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxAsync(default, Comparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxAsync(default, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxAsync(default, Comparer.Default, CancellationToken.None).AsTask()); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs index ef95ed0b21..f125775c8b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MaxBy.cs @@ -16,17 +16,17 @@ public class MaxBy : AsyncEnumerableExTests [Fact] public async Task MaxBy_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, Comparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), Comparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MaxByAsync(Return42, default(Func), Comparer.Default, CancellationToken.None).AsTask()); } [Fact] @@ -43,7 +43,7 @@ public async Task MaxBy2() { var xs = new int[0].ToAsyncEnumerable().MaxByAsync(x => x / 2); - await AssertThrowsAsync(xs); + await AssertThrowsAsync(xs.AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs index 7c55e0f450..f800de8d31 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Min.cs @@ -16,9 +16,9 @@ public class Min : AsyncEnumerableExTests [Fact] public async Task Min_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinAsync(default, Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinAsync(default, Comparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinAsync(default, Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinAsync(default, Comparer.Default, CancellationToken.None).AsTask()); } } } diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs index b51167d5b2..c6a0cb0e97 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/MinBy.cs @@ -16,17 +16,17 @@ public class MinBy : AsyncEnumerableExTests [Fact] public async Task MinBy_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, Comparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), Comparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, Comparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), Comparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), Comparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(default(IAsyncEnumerable), x => x, Comparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerableEx.MinByAsync(Return42, default(Func), Comparer.Default, CancellationToken.None).AsTask()); } [Fact] @@ -43,7 +43,7 @@ public async Task MinBy2Async() { var xs = new int[0].ToAsyncEnumerable().MinByAsync(x => x / 2); - await AssertThrowsAsync(xs); + await AssertThrowsAsync(xs.AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index a8f98af091..cc57d60a40 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task IsEmptyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask IsEmptyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 95c41c8dcb..2d2266b230 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task MaxAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, comparer, cancellationToken); - static async Task Core(IAsyncEnumerable _source, IComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, IComparer _comparer, CancellationToken _cancellationToken) { if (_comparer == null) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs index 5cc5134b0a..483485a2a9 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MaxBy.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer: null, cancellationToken); } - public static Task> MaxByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab return MaxByCore(source, keySelector, comparer, cancellationToken); } - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -52,7 +52,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab } #endif - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -63,7 +63,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MaxByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -74,7 +74,7 @@ public static Task> MaxByAsync(this IAsyncEnumerab } #endif - private static Task> MaxByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + private static ValueTask> MaxByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { @@ -84,7 +84,7 @@ private static Task> MaxByCore(IAsyncEnumerable comparer.Compare(key, minValue), cancellationToken); } - private static Task> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + private static ValueTask> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { @@ -95,7 +95,7 @@ private static Task> MaxByCore(IAsyncEnumerable> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + private static ValueTask> MaxByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index 9964edd88c..ae8e72d0b0 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task MinAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, comparer, cancellationToken); - static async Task Core(IAsyncEnumerable _source, IComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, IComparer _comparer, CancellationToken _cancellationToken) { if (_comparer == null) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 49fec83972..4a6b5a7139 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerableEx { - public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -20,7 +20,7 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer: null, cancellationToken); } - public static Task> MinByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -30,7 +30,7 @@ public static Task> MinByAsync(this IAsyncEnumerab return MinByCore(source, keySelector, comparer, cancellationToken); } - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static Task> MinByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -52,7 +52,7 @@ public static Task> MinByAsync(this IAsyncEnumerab } #endif - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -63,7 +63,7 @@ public static Task> MinByAsync(this IAsyncEnumerab } #if !NO_DEEP_CANCELLATION - public static Task> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> MinByAsync(this IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -74,7 +74,7 @@ public static Task> MinByAsync(this IAsyncEnumerab } #endif - private static Task> MinByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) + private static ValueTask> MinByCore(IAsyncEnumerable source, Func keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { @@ -84,7 +84,7 @@ private static Task> MinByCore(IAsyncEnumerable -comparer.Compare(key, minValue), cancellationToken); } - private static Task> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + private static ValueTask> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { @@ -95,7 +95,7 @@ private static Task> MinByCore(IAsyncEnumerable> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) + private static ValueTask> MinByCore(IAsyncEnumerable source, Func> keySelector, IComparer comparer, CancellationToken cancellationToken) { if (comparer == null) { @@ -106,7 +106,7 @@ private static Task> MinByCore(IAsyncEnumerable> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) + private static async ValueTask> ExtremaBy(IAsyncEnumerable source, Func keySelector, Func compare, CancellationToken cancellationToken) { var result = new List(); @@ -147,7 +147,7 @@ private static async Task> ExtremaBy(IAsyncEnumera return result; } - private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) + private static async ValueTask> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) { var result = new List(); @@ -189,7 +189,7 @@ private static async Task> ExtremaBy(IAsyncEnumera } #if !NO_DEEP_CANCELLATION - private static async Task> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) + private static async ValueTask> ExtremaBy(IAsyncEnumerable source, Func> keySelector, Func compare, CancellationToken cancellationToken) { var result = new List(); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index 99cee2c1ed..dfe28b3f75 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -278,16 +278,6 @@ public void AverageAsync10() [Fact] public void AverageAsync11() - { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void AverageAsync12() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -297,7 +287,7 @@ public void AverageAsync12() } [Fact] - public void AverageAsync13() + public void AverageAsync12() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -307,7 +297,7 @@ public void AverageAsync13() } [Fact] - public void AverageAsync14() + public void AverageAsync13() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -317,7 +307,7 @@ public void AverageAsync14() } [Fact] - public void AverageAsync15() + public void AverageAsync14() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -327,7 +317,7 @@ public void AverageAsync15() } [Fact] - public void AverageAsync16() + public void AverageAsync15() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -337,7 +327,7 @@ public void AverageAsync16() } [Fact] - public void AverageAsync17() + public void AverageAsync16() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -347,7 +337,7 @@ public void AverageAsync17() } [Fact] - public void AverageAsync18() + public void AverageAsync17() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -357,7 +347,7 @@ public void AverageAsync18() } [Fact] - public void AverageAsync19() + public void AverageAsync18() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -367,7 +357,7 @@ public void AverageAsync19() } [Fact] - public void AverageAsync20() + public void AverageAsync19() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -377,7 +367,7 @@ public void AverageAsync20() } [Fact] - public void AverageAsync21() + public void AverageAsync20() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -387,7 +377,7 @@ public void AverageAsync21() } [Fact] - public void AverageAsync22() + public void AverageAsync21() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -397,7 +387,7 @@ public void AverageAsync22() } [Fact] - public void AverageAsync23() + public void AverageAsync22() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -407,7 +397,7 @@ public void AverageAsync23() } [Fact] - public void AverageAsync24() + public void AverageAsync23() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -417,7 +407,7 @@ public void AverageAsync24() } [Fact] - public void AverageAsync25() + public void AverageAsync24() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -427,7 +417,7 @@ public void AverageAsync25() } [Fact] - public void AverageAsync26() + public void AverageAsync25() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -437,7 +427,7 @@ public void AverageAsync26() } [Fact] - public void AverageAsync27() + public void AverageAsync26() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -447,7 +437,7 @@ public void AverageAsync27() } [Fact] - public void AverageAsync28() + public void AverageAsync27() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -457,7 +447,7 @@ public void AverageAsync28() } [Fact] - public void AverageAsync29() + public void AverageAsync28() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -467,7 +457,7 @@ public void AverageAsync29() } [Fact] - public void AverageAsync30() + public void AverageAsync29() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -477,7 +467,7 @@ public void AverageAsync30() } [Fact] - public void AverageAsync31() + public void AverageAsync30() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -487,7 +477,7 @@ public void AverageAsync31() } [Fact] - public void AverageAsync32() + public void AverageAsync31() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -497,7 +487,7 @@ public void AverageAsync32() } [Fact] - public void AverageAsync33() + public void AverageAsync32() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -507,7 +497,7 @@ public void AverageAsync33() } [Fact] - public void AverageAsync34() + public void AverageAsync33() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -517,7 +507,7 @@ public void AverageAsync34() } [Fact] - public void AverageAsync35() + public void AverageAsync34() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -527,7 +517,7 @@ public void AverageAsync35() } [Fact] - public void AverageAsync36() + public void AverageAsync35() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -537,7 +527,7 @@ public void AverageAsync36() } [Fact] - public void AverageAsync37() + public void AverageAsync36() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -547,7 +537,7 @@ public void AverageAsync37() } [Fact] - public void AverageAsync38() + public void AverageAsync37() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -557,7 +547,7 @@ public void AverageAsync38() } [Fact] - public void AverageAsync39() + public void AverageAsync38() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -567,7 +557,7 @@ public void AverageAsync39() } [Fact] - public void AverageAsync40() + public void AverageAsync39() { AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -576,6 +566,16 @@ public void AverageAsync40() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void AverageAsync40() + { + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void Cast1() { @@ -881,11 +881,11 @@ public void GroupBy6() [Fact] public void GroupBy7() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -893,11 +893,11 @@ public void GroupBy7() [Fact] public void GroupBy8() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -905,11 +905,11 @@ public void GroupBy8() [Fact] public void GroupBy9() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -953,11 +953,11 @@ public void GroupBy12() [Fact] public void GroupBy13() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -965,11 +965,11 @@ public void GroupBy13() [Fact] public void GroupBy14() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -977,11 +977,11 @@ public void GroupBy14() [Fact] public void GroupBy15() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1838,24 +1838,6 @@ public void MaxAsync44() [Fact] public void MinAsync1() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync2() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync3() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1864,7 +1846,7 @@ public void MinAsync3() } [Fact] - public void MinAsync4() + public void MinAsync2() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1873,7 +1855,7 @@ public void MinAsync4() } [Fact] - public void MinAsync5() + public void MinAsync3() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1882,7 +1864,7 @@ public void MinAsync5() } [Fact] - public void MinAsync6() + public void MinAsync4() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1891,7 +1873,7 @@ public void MinAsync6() } [Fact] - public void MinAsync7() + public void MinAsync5() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1900,7 +1882,7 @@ public void MinAsync7() } [Fact] - public void MinAsync8() + public void MinAsync6() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1909,7 +1891,7 @@ public void MinAsync8() } [Fact] - public void MinAsync9() + public void MinAsync7() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1918,7 +1900,7 @@ public void MinAsync9() } [Fact] - public void MinAsync10() + public void MinAsync8() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); @@ -1927,86 +1909,34 @@ public void MinAsync10() } [Fact] - public void MinAsync11() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync12() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync13() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync14() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync15() - { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); - AssertEx.SucceedOrFailProper(() => res.Wait()); - } - - [Fact] - public void MinAsync16() + public void MinAsync9() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync17() + public void MinAsync10() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync18() + public void MinAsync11() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync19() + public void MinAsync12() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2016,7 +1946,7 @@ public void MinAsync19() } [Fact] - public void MinAsync20() + public void MinAsync13() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2026,7 +1956,7 @@ public void MinAsync20() } [Fact] - public void MinAsync21() + public void MinAsync14() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2036,7 +1966,7 @@ public void MinAsync21() } [Fact] - public void MinAsync22() + public void MinAsync15() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2046,7 +1976,7 @@ public void MinAsync22() } [Fact] - public void MinAsync23() + public void MinAsync16() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2056,7 +1986,7 @@ public void MinAsync23() } [Fact] - public void MinAsync24() + public void MinAsync17() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2066,7 +1996,7 @@ public void MinAsync24() } [Fact] - public void MinAsync25() + public void MinAsync18() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2076,7 +2006,7 @@ public void MinAsync25() } [Fact] - public void MinAsync26() + public void MinAsync19() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2086,7 +2016,7 @@ public void MinAsync26() } [Fact] - public void MinAsync27() + public void MinAsync20() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2096,7 +2026,7 @@ public void MinAsync27() } [Fact] - public void MinAsync28() + public void MinAsync21() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2106,7 +2036,7 @@ public void MinAsync28() } [Fact] - public void MinAsync29() + public void MinAsync22() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2116,7 +2046,7 @@ public void MinAsync29() } [Fact] - public void MinAsync30() + public void MinAsync23() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2126,7 +2056,7 @@ public void MinAsync30() } [Fact] - public void MinAsync31() + public void MinAsync24() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2136,7 +2066,7 @@ public void MinAsync31() } [Fact] - public void MinAsync32() + public void MinAsync25() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2146,7 +2076,7 @@ public void MinAsync32() } [Fact] - public void MinAsync33() + public void MinAsync26() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2156,7 +2086,7 @@ public void MinAsync33() } [Fact] - public void MinAsync34() + public void MinAsync27() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2166,7 +2096,7 @@ public void MinAsync34() } [Fact] - public void MinAsync35() + public void MinAsync28() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2176,7 +2106,7 @@ public void MinAsync35() } [Fact] - public void MinAsync36() + public void MinAsync29() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2186,7 +2116,7 @@ public void MinAsync36() } [Fact] - public void MinAsync37() + public void MinAsync30() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2196,7 +2126,7 @@ public void MinAsync37() } [Fact] - public void MinAsync38() + public void MinAsync31() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2206,7 +2136,7 @@ public void MinAsync38() } [Fact] - public void MinAsync39() + public void MinAsync32() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2216,7 +2146,7 @@ public void MinAsync39() } [Fact] - public void MinAsync40() + public void MinAsync33() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2226,7 +2156,7 @@ public void MinAsync40() } [Fact] - public void MinAsync41() + public void MinAsync34() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2236,27 +2166,77 @@ public void MinAsync41() } [Fact] - public void MinAsync42() + public void MinAsync35() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync43() + public void MinAsync36() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync44() + public void MinAsync37() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync38() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync39() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync40() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync41() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync42() { AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); @@ -2265,6 +2245,26 @@ public void MinAsync44() AssertEx.SucceedOrFailProper(() => res.Wait()); } + [Fact] + public void MinAsync43() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + + [Fact] + public void MinAsync44() + { + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + AssertEx.SucceedOrFailProper(() => res.Wait()); + } + [Fact] public void OfType1() { @@ -2405,17 +2405,6 @@ public void Reverse1() [Fact] public void Select1() - { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - - [Fact] - public void Select2() { AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); @@ -2426,7 +2415,7 @@ public void Select2() } [Fact] - public void Select3() + public void Select2() { AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2437,7 +2426,7 @@ public void Select3() } [Fact] - public void Select4() + public void Select3() { AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2448,7 +2437,7 @@ public void Select4() } [Fact] - public void Select5() + public void Select4() { AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2459,7 +2448,7 @@ public void Select5() } [Fact] - public void Select6() + public void Select5() { AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); @@ -2469,6 +2458,17 @@ public void Select6() AssertEx.SucceedOrFailProper(() => task.Wait()); } + [Fact] + public void Select6() + { + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + [Fact] public void SelectMany1() { @@ -2727,6 +2727,17 @@ public void SkipLast1() [Fact] public void SkipWhile1() + { + AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); + + var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); + var task = res.ForEachAsync(_ => { }); + AssertEx.SucceedOrFailProper(() => task.Wait()); + } + + [Fact] + public void SkipWhile2() { AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => true), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); @@ -2737,7 +2748,7 @@ public void SkipWhile1() } [Fact] - public void SkipWhile2() + public void SkipWhile3() { AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); @@ -2748,7 +2759,7 @@ public void SkipWhile2() } [Fact] - public void SkipWhile3() + public void SkipWhile4() { AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); @@ -2759,7 +2770,7 @@ public void SkipWhile3() } [Fact] - public void SkipWhile4() + public void SkipWhile5() { AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); @@ -2770,7 +2781,7 @@ public void SkipWhile4() } [Fact] - public void SkipWhile5() + public void SkipWhile6() { AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); @@ -2780,404 +2791,393 @@ public void SkipWhile5() AssertEx.SucceedOrFailProper(() => task.Wait()); } - [Fact] - public void SkipWhile6() - { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => true), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "predicate"); - - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => true); - var task = res.ForEachAsync(_ => { }); - AssertEx.SucceedOrFailProper(() => task.Wait()); - } - [Fact] public void SumAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new float?[] { default(float?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync5() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new double?[] { default(double?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync6() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new decimal?[] { default(decimal?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync7() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync8() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new decimal[] { default(decimal) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new long[] { default(long) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync9() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new int?[] { default(int?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new float[] { default(float) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync10() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), CancellationToken.None), ane => ane.ParamName == "source"); - var res = AsyncQueryable.SumAsync(new long?[] { default(long?) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new double[] { default(double) }.ToAsyncEnumerable().AsAsyncQueryable(), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync11() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync12() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync13() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync14() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync15() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync16() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync17() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync18() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync19() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync20() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync21() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync22() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync23() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync24() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync25() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync26() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync27() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync28() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync29() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync30() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync31() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync32() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync33() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync34() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync35() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync36() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync37() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync38() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync39() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync40() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3324,28 +3324,28 @@ public void ThenBy6() [Fact] public void ThenByDescending1() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); } [Fact] public void ThenByDescending2() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); } [Fact] public void ThenByDescending3() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] @@ -3788,4 +3788,4 @@ public void Zip3() } } -} +} \ No newline at end of file diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt index e27f0093e4..6f8c7258c1 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.tt @@ -184,7 +184,7 @@ foreach (var m in typeof(AsyncEnumerable).GetMethods() { var td = m.ReturnType.GetGenericTypeDefinition(); - if (td == typeof(Task<>)) + if (td.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask { factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; @@ -452,7 +452,7 @@ if (indexes.Count != 0) if (!failing.Contains(tm.Name)) { - if (tmRet == typeof(Task<>)) + if (tmRet.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask { #> AssertEx.SucceedOrFailProper(() => res.Wait()); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/ValueTaskExtensions.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/ValueTaskExtensions.cs new file mode 100644 index 0000000000..63730dea23 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/ValueTaskExtensions.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System.Threading.Tasks; + +namespace Tests +{ + public static class ValueTaskExtensions + { + public static void Wait(this ValueTask task) => task.AsTask().Wait(); + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableExecutor.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableExecutor.cs index 6d9231ad97..ab5bce51b5 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableExecutor.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableExecutor.cs @@ -15,7 +15,7 @@ namespace System.Linq internal class AsyncEnumerableExecutor { private readonly Expression _expression; - private Func> _func; + private Func> _func; /// /// Creates a new execution helper instance for the specified expression tree representing a computation over asynchronous enumerable sequences. @@ -31,11 +31,11 @@ public AsyncEnumerableExecutor(Expression expression) /// /// Token to cancel the evaluation. /// Task representing the evaluation of the expression tree. - internal Task ExecuteAsync(CancellationToken token) + internal ValueTask ExecuteAsync(CancellationToken token) { if (_func == null) { - var expression = Expression.Lambda>>(new AsyncEnumerableRewriter().Visit(_expression), Expression.Parameter(typeof(CancellationToken))); + var expression = Expression.Lambda>>(new AsyncEnumerableRewriter().Visit(_expression), Expression.Parameter(typeof(CancellationToken))); _func = expression.Compile(); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs index 74128d64b4..a1b14c4bec 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs @@ -96,7 +96,7 @@ IAsyncQueryable IAsyncQueryProvider.CreateQuery(Expression e /// The expression tree to evaluate. /// Cancellation token used to cancel the evaluation. /// Task representing the result of evaluating the specified expression tree. - Task IAsyncQueryProvider.ExecuteAsync(Expression expression, CancellationToken token) + ValueTask IAsyncQueryProvider.ExecuteAsync(Expression expression, CancellationToken token) { if (expression == null) { diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 1356b0810d..1760dd7ba8 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -12,7 +12,7 @@ namespace System.Linq { public static partial class AsyncQueryable { - public static Task AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -26,7 +26,7 @@ public static Task AggregateAsync(this IAsyncQueryable AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -40,7 +40,7 @@ public static Task AggregateAsync(this IAsyncQueryable AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -54,7 +54,7 @@ public static Task AggregateAsync(this IAsyncQueryable AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -68,7 +68,7 @@ public static Task AggregateAsync(this IAsync #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -82,7 +82,7 @@ public static Task AggregateAsync(this IAsync #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -96,7 +96,7 @@ public static Task AggregateAsync(this IAsync #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -112,7 +112,7 @@ public static Task AggregateAsync(this I #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -128,7 +128,7 @@ public static Task AggregateAsync(this I #endif } - public static Task AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -144,7 +144,7 @@ public static Task AggregateAsync(this I #endif } - public static Task AllAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -158,7 +158,7 @@ public static Task AllAsync(this IAsyncQueryable source, #endif } - public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -172,7 +172,7 @@ public static Task AllAsync(this IAsyncQueryable source, #endif } - public static Task AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -186,7 +186,7 @@ public static Task AllAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -198,7 +198,7 @@ public static Task AnyAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -212,7 +212,7 @@ public static Task AnyAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -226,7 +226,7 @@ public static Task AnyAsync(this IAsyncQueryable source, #endif } - public static Task AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -252,7 +252,7 @@ public static IAsyncQueryable Append(this IAsyncQueryable AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -264,7 +264,7 @@ public static IAsyncQueryable Append(this IAsyncQueryable AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -276,7 +276,7 @@ public static Task AverageAsync(this IAsyncQueryable source, C #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -288,7 +288,7 @@ public static Task AverageAsync(this IAsyncQueryable source, C #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -300,7 +300,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Can #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -312,7 +312,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Can #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -324,7 +324,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Cance #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -336,7 +336,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Cance #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -348,7 +348,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Cancel #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -360,7 +360,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Cancel #endif } - public static Task AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -372,7 +372,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Cance #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -386,7 +386,7 @@ public static Task AverageAsync(this IAsyncQueryable source, Cance #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -400,7 +400,7 @@ public static Task AverageAsync(this IAsyncQueryable #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -414,7 +414,7 @@ public static Task AverageAsync(this IAsyncQueryable #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -428,7 +428,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -442,7 +442,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -456,7 +456,7 @@ public static Task AverageAsync(this IAsyncQueryable so #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -470,7 +470,7 @@ public static Task AverageAsync(this IAsyncQueryable so #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -484,7 +484,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -498,7 +498,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -512,7 +512,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -526,7 +526,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -540,7 +540,7 @@ public static Task AverageAsync(this IAsyncQueryable #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -554,7 +554,7 @@ public static Task AverageAsync(this IAsyncQueryable #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -568,7 +568,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -582,7 +582,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -596,7 +596,7 @@ public static Task AverageAsync(this IAsyncQueryable so #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -610,7 +610,7 @@ public static Task AverageAsync(this IAsyncQueryable so #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -624,7 +624,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -638,7 +638,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -652,7 +652,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -666,7 +666,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -680,7 +680,7 @@ public static Task AverageAsync(this IAsyncQueryable #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -694,7 +694,7 @@ public static Task AverageAsync(this IAsyncQueryable #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -708,7 +708,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -722,7 +722,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -736,7 +736,7 @@ public static Task AverageAsync(this IAsyncQueryable so #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -750,7 +750,7 @@ public static Task AverageAsync(this IAsyncQueryable so #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -764,7 +764,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -778,7 +778,7 @@ public static Task AverageAsync(this IAsyncQueryable s #endif } - public static Task AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -818,7 +818,7 @@ public static IAsyncQueryable Concat(this IAsyncQueryable ContainsAsync(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken = default) + public static ValueTask ContainsAsync(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -830,7 +830,7 @@ public static Task ContainsAsync(this IAsyncQueryable so #endif } - public static Task ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -842,7 +842,7 @@ public static Task ContainsAsync(this IAsyncQueryable so #endif } - public static Task CountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -854,7 +854,7 @@ public static Task CountAsync(this IAsyncQueryable source #endif } - public static Task CountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -868,7 +868,7 @@ public static Task CountAsync(this IAsyncQueryable source #endif } - public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -882,7 +882,7 @@ public static Task CountAsync(this IAsyncQueryable source #endif } - public static Task CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -944,7 +944,7 @@ public static IAsyncQueryable Distinct(this IAsyncQueryable ElementAtAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) + public static ValueTask ElementAtAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -956,7 +956,7 @@ public static Task ElementAtAsync(this IAsyncQueryable ElementAtOrDefaultAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) + public static ValueTask ElementAtOrDefaultAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -996,7 +996,7 @@ public static IAsyncQueryable Except(this IAsyncQueryable FirstAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1008,7 +1008,7 @@ public static Task FirstAsync(this IAsyncQueryable so #endif } - public static Task FirstAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1022,7 +1022,7 @@ public static Task FirstAsync(this IAsyncQueryable so #endif } - public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1036,7 +1036,7 @@ public static Task FirstAsync(this IAsyncQueryable so #endif } - public static Task FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1050,7 +1050,7 @@ public static Task FirstAsync(this IAsyncQueryable so #endif } - public static Task FirstOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1062,7 +1062,7 @@ public static Task FirstOrDefaultAsync(this IAsyncQueryable FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1076,7 +1076,7 @@ public static Task FirstOrDefaultAsync(this IAsyncQueryable FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1090,7 +1090,7 @@ public static Task FirstOrDefaultAsync(this IAsyncQueryable FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1756,7 +1756,7 @@ public static IAsyncQueryable Join(this #endif } - public static Task LastAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1768,7 +1768,7 @@ public static Task LastAsync(this IAsyncQueryable sou #endif } - public static Task LastAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1782,7 +1782,7 @@ public static Task LastAsync(this IAsyncQueryable sou #endif } - public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1796,7 +1796,7 @@ public static Task LastAsync(this IAsyncQueryable sou #endif } - public static Task LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1810,7 +1810,7 @@ public static Task LastAsync(this IAsyncQueryable sou #endif } - public static Task LastOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1822,7 +1822,7 @@ public static Task LastOrDefaultAsync(this IAsyncQueryable LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1836,7 +1836,7 @@ public static Task LastOrDefaultAsync(this IAsyncQueryable LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1850,7 +1850,7 @@ public static Task LastOrDefaultAsync(this IAsyncQueryable LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1864,7 +1864,7 @@ public static Task LastOrDefaultAsync(this IAsyncQueryable LongCountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1876,7 +1876,7 @@ public static Task LongCountAsync(this IAsyncQueryable s #endif } - public static Task LongCountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1890,7 +1890,7 @@ public static Task LongCountAsync(this IAsyncQueryable s #endif } - public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1904,7 +1904,7 @@ public static Task LongCountAsync(this IAsyncQueryable s #endif } - public static Task LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1918,7 +1918,7 @@ public static Task LongCountAsync(this IAsyncQueryable s #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1930,7 +1930,7 @@ public static Task LongCountAsync(this IAsyncQueryable s #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1942,7 +1942,7 @@ public static Task MaxAsync(this IAsyncQueryable source, Cance #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1954,7 +1954,7 @@ public static Task MaxAsync(this IAsyncQueryable source, Cance #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1966,7 +1966,7 @@ public static Task MaxAsync(this IAsyncQueryable source, Cancell #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1978,7 +1978,7 @@ public static Task MaxAsync(this IAsyncQueryable source, Cancell #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1990,7 +1990,7 @@ public static Task MaxAsync(this IAsyncQueryable source, Cancellat #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2002,7 +2002,7 @@ public static Task MaxAsync(this IAsyncQueryable source, Cancellat #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2014,7 +2014,7 @@ public static Task MaxAsync(this IAsyncQueryable source, CancellationT #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2026,7 +2026,7 @@ public static Task MaxAsync(this IAsyncQueryable source, CancellationT #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2038,7 +2038,7 @@ public static Task MaxAsync(this IAsyncQueryable source, Cancellatio #endif } - public static Task MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2050,7 +2050,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2064,7 +2064,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2078,7 +2078,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2092,7 +2092,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2106,7 +2106,7 @@ public static Task MaxAsync(this IAsyncQueryable sourc #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2120,7 +2120,7 @@ public static Task MaxAsync(this IAsyncQueryable sourc #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2134,7 +2134,7 @@ public static Task MaxAsync(this IAsyncQueryable source #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2148,7 +2148,7 @@ public static Task MaxAsync(this IAsyncQueryable source #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2162,7 +2162,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2176,7 +2176,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2190,7 +2190,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2204,7 +2204,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2218,7 +2218,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2232,7 +2232,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2246,7 +2246,7 @@ public static Task MaxAsync(this IAsyncQueryable sourc #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2260,7 +2260,7 @@ public static Task MaxAsync(this IAsyncQueryable sourc #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2274,7 +2274,7 @@ public static Task MaxAsync(this IAsyncQueryable source #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2288,7 +2288,7 @@ public static Task MaxAsync(this IAsyncQueryable source #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2302,7 +2302,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2316,7 +2316,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2330,7 +2330,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2344,7 +2344,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2358,7 +2358,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2372,7 +2372,7 @@ public static Task MaxAsync(this IAsyncQueryable sour #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2386,7 +2386,7 @@ public static Task MaxAsync(this IAsyncQueryable sourc #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2400,7 +2400,7 @@ public static Task MaxAsync(this IAsyncQueryable sourc #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2414,7 +2414,7 @@ public static Task MaxAsync(this IAsyncQueryable source #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2428,7 +2428,7 @@ public static Task MaxAsync(this IAsyncQueryable source #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2442,7 +2442,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2456,7 +2456,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2470,7 +2470,7 @@ public static Task MaxAsync(this IAsyncQueryable source, #endif } - public static Task MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2484,7 +2484,7 @@ public static Task MaxAsync(this IAsyncQueryable MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2498,7 +2498,7 @@ public static Task MaxAsync(this IAsyncQueryable MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2512,7 +2512,7 @@ public static Task MaxAsync(this IAsyncQueryable MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2524,7 +2524,7 @@ public static Task MaxAsync(this IAsyncQueryable MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2536,7 +2536,7 @@ public static Task MinAsync(this IAsyncQueryable source, Cance #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2548,7 +2548,7 @@ public static Task MinAsync(this IAsyncQueryable source, Cance #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2560,7 +2560,7 @@ public static Task MinAsync(this IAsyncQueryable source, Cancell #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2572,7 +2572,7 @@ public static Task MinAsync(this IAsyncQueryable source, Cancell #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2584,7 +2584,7 @@ public static Task MinAsync(this IAsyncQueryable source, Cancellat #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2596,7 +2596,7 @@ public static Task MinAsync(this IAsyncQueryable source, Cancellat #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2608,7 +2608,7 @@ public static Task MinAsync(this IAsyncQueryable source, CancellationT #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2620,7 +2620,7 @@ public static Task MinAsync(this IAsyncQueryable source, CancellationT #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2632,7 +2632,7 @@ public static Task MinAsync(this IAsyncQueryable source, Cancellatio #endif } - public static Task MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2644,7 +2644,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2658,7 +2658,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2672,7 +2672,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2686,7 +2686,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2700,7 +2700,7 @@ public static Task MinAsync(this IAsyncQueryable sourc #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2714,7 +2714,7 @@ public static Task MinAsync(this IAsyncQueryable sourc #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2728,7 +2728,7 @@ public static Task MinAsync(this IAsyncQueryable source #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2742,7 +2742,7 @@ public static Task MinAsync(this IAsyncQueryable source #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2756,7 +2756,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2770,7 +2770,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2784,7 +2784,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2798,7 +2798,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2812,7 +2812,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2826,7 +2826,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2840,7 +2840,7 @@ public static Task MinAsync(this IAsyncQueryable sourc #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2854,7 +2854,7 @@ public static Task MinAsync(this IAsyncQueryable sourc #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2868,7 +2868,7 @@ public static Task MinAsync(this IAsyncQueryable source #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2882,7 +2882,7 @@ public static Task MinAsync(this IAsyncQueryable source #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2896,7 +2896,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2910,7 +2910,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2924,7 +2924,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2938,7 +2938,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2952,7 +2952,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2966,7 +2966,7 @@ public static Task MinAsync(this IAsyncQueryable sour #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2980,7 +2980,7 @@ public static Task MinAsync(this IAsyncQueryable sourc #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2994,7 +2994,7 @@ public static Task MinAsync(this IAsyncQueryable sourc #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3008,7 +3008,7 @@ public static Task MinAsync(this IAsyncQueryable source #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3022,7 +3022,7 @@ public static Task MinAsync(this IAsyncQueryable source #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3036,7 +3036,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3050,7 +3050,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3064,7 +3064,7 @@ public static Task MinAsync(this IAsyncQueryable source, #endif } - public static Task MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3078,7 +3078,7 @@ public static Task MinAsync(this IAsyncQueryable MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3092,7 +3092,7 @@ public static Task MinAsync(this IAsyncQueryable MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3574,7 +3574,7 @@ public static IAsyncQueryable SelectMany #endif } - public static Task SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) + public static ValueTask SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -3588,7 +3588,7 @@ public static Task SequenceEqualAsync(this IAsyncQueryable SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -3602,7 +3602,7 @@ public static Task SequenceEqualAsync(this IAsyncQueryable SingleAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3614,7 +3614,7 @@ public static Task SingleAsync(this IAsyncQueryable s #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3628,7 +3628,7 @@ public static Task SingleAsync(this IAsyncQueryable s #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3642,7 +3642,7 @@ public static Task SingleAsync(this IAsyncQueryable s #endif } - public static Task SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3656,7 +3656,7 @@ public static Task SingleAsync(this IAsyncQueryable s #endif } - public static Task SingleOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3668,7 +3668,7 @@ public static Task SingleOrDefaultAsync(this IAsyncQueryable SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3682,7 +3682,7 @@ public static Task SingleOrDefaultAsync(this IAsyncQueryable SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3696,7 +3696,7 @@ public static Task SingleOrDefaultAsync(this IAsyncQueryable SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3818,7 +3818,7 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3830,7 +3830,7 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3842,7 +3842,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cance #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3854,7 +3854,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cance #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3866,7 +3866,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cancell #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3878,7 +3878,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cancell #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3890,7 +3890,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cancellat #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3902,7 +3902,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cancellat #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3914,7 +3914,7 @@ public static Task SumAsync(this IAsyncQueryable source, CancellationT #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3926,7 +3926,7 @@ public static Task SumAsync(this IAsyncQueryable source, CancellationT #endif } - public static Task SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3938,7 +3938,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cancellatio #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3952,7 +3952,7 @@ public static Task SumAsync(this IAsyncQueryable source, Cancellatio #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3966,7 +3966,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3980,7 +3980,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3994,7 +3994,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4008,7 +4008,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4022,7 +4022,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4036,7 +4036,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4050,7 +4050,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4064,7 +4064,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4078,7 +4078,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4092,7 +4092,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4106,7 +4106,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4120,7 +4120,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4134,7 +4134,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4148,7 +4148,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4162,7 +4162,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4176,7 +4176,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4190,7 +4190,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4204,7 +4204,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4218,7 +4218,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4232,7 +4232,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4246,7 +4246,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4260,7 +4260,7 @@ public static Task SumAsync(this IAsyncQueryable sour #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4274,7 +4274,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4288,7 +4288,7 @@ public static Task SumAsync(this IAsyncQueryable sourc #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4302,7 +4302,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4316,7 +4316,7 @@ public static Task SumAsync(this IAsyncQueryable source #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4330,7 +4330,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4344,7 +4344,7 @@ public static Task SumAsync(this IAsyncQueryable source, #endif } - public static Task SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4634,7 +4634,7 @@ public static IOrderedAsyncQueryable ThenByDescending(th #endif } - public static Task ToArrayAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask ToArrayAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4646,7 +4646,7 @@ public static Task ToArrayAsync(this IAsyncQueryable> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4660,7 +4660,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4674,7 +4674,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4688,7 +4688,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4702,7 +4702,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4716,7 +4716,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4730,7 +4730,7 @@ public static Task> ToDictionaryAsync(t #endif } - public static Task> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4746,7 +4746,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4762,7 +4762,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4778,7 +4778,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4794,7 +4794,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4810,7 +4810,7 @@ public static Task> ToDictionaryAsync> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4826,7 +4826,7 @@ public static Task> ToDictionaryAsync> ToHashSetAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask> ToHashSetAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4838,7 +4838,7 @@ public static Task> ToHashSetAsync(this IAsyncQueryabl #endif } - public static Task> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4850,7 +4850,7 @@ public static Task> ToHashSetAsync(this IAsyncQueryabl #endif } - public static Task> ToListAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) + public static ValueTask> ToListAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4862,7 +4862,7 @@ public static Task> ToListAsync(this IAsyncQueryable> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4876,7 +4876,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4890,7 +4890,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4904,7 +4904,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4918,7 +4918,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4932,7 +4932,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4946,7 +4946,7 @@ public static Task> ToLookupAsync(this IAs #endif } - public static Task> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4962,7 +4962,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4978,7 +4978,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4994,7 +4994,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5010,7 +5010,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5026,7 +5026,7 @@ public static Task> ToLookupAsync> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index e725cad53a..deb78e6915 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -188,7 +188,7 @@ foreach (var m in typeof(AsyncEnumerable).GetMethods() { var td = m.ReturnType.GetGenericTypeDefinition(); - if (td == typeof(Task<>)) + if (td.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask { factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs index 4274919428..e1c1f7b1da 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/IAsyncQueryProvider.cs @@ -28,6 +28,6 @@ public interface IAsyncQueryProvider /// The expression tree to evaluate. /// Cancellation token used to cancel the evaluation. /// Task representing the result of evaluating the specified expression tree. - Task ExecuteAsync(Expression expression, CancellationToken token); + ValueTask ExecuteAsync(Expression expression, CancellationToken token); } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index c6b7504f82..a9b1b42eb3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -15,25 +15,25 @@ public class Aggregate : AsyncEnumerableTests [Fact] public async Task Aggregate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default, CancellationToken.None).AsTask()); } [Fact] @@ -49,7 +49,7 @@ public async Task Aggregate2Async() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync((x, y) => x * y); - await AssertThrowsAsync(ys); + await AssertThrowsAsync(ys.AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index d7a0e56fa4..5e7842a416 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -15,17 +15,17 @@ public class All : AsyncEnumerableTests [Fact] public async Task All_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 4807b77bb0..6aaa538566 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -15,20 +15,20 @@ public class Any : AsyncEnumerableTests [Fact] public async Task Any_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs index 9a46f93c36..64d8f38d56 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs @@ -17,7 +17,7 @@ public class AverageAsync : AsyncEnumerableTests public async Task AverageAsync_Int32_Empty() { var ys = new int[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -32,7 +32,7 @@ public async Task AverageAsync_Int32_Many() public async Task AverageAsync_Selector_Int32_Empty() { var ys = new int[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x).AsTask()); } [Fact] @@ -47,7 +47,7 @@ public async Task AverageAsync_Selector_Int32_Many() public async Task AverageAsync_AsyncSelector_Int32_Empty() { var ys = new int[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); } [Fact] @@ -63,7 +63,7 @@ public async Task AverageAsync_AsyncSelector_Int32_Many() public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Empty() { var ys = new int[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] @@ -141,7 +141,7 @@ public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Nullable_Many public async Task AverageAsync_Int64_Empty() { var ys = new long[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -156,7 +156,7 @@ public async Task AverageAsync_Int64_Many() public async Task AverageAsync_Selector_Int64_Empty() { var ys = new long[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x).AsTask()); } [Fact] @@ -171,7 +171,7 @@ public async Task AverageAsync_Selector_Int64_Many() public async Task AverageAsync_AsyncSelector_Int64_Empty() { var ys = new long[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); } [Fact] @@ -187,7 +187,7 @@ public async Task AverageAsync_AsyncSelector_Int64_Many() public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Empty() { var ys = new long[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] @@ -265,7 +265,7 @@ public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Nullable_Many public async Task AverageAsync_Single_Empty() { var ys = new float[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -280,7 +280,7 @@ public async Task AverageAsync_Single_Many() public async Task AverageAsync_Selector_Single_Empty() { var ys = new float[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x).AsTask()); } [Fact] @@ -295,7 +295,7 @@ public async Task AverageAsync_Selector_Single_Many() public async Task AverageAsync_AsyncSelector_Single_Empty() { var ys = new float[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); } [Fact] @@ -311,7 +311,7 @@ public async Task AverageAsync_AsyncSelector_Single_Many() public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Empty() { var ys = new float[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] @@ -389,7 +389,7 @@ public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Nullable_Man public async Task AverageAsync_Double_Empty() { var ys = new double[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -404,7 +404,7 @@ public async Task AverageAsync_Double_Many() public async Task AverageAsync_Selector_Double_Empty() { var ys = new double[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x).AsTask()); } [Fact] @@ -419,7 +419,7 @@ public async Task AverageAsync_Selector_Double_Many() public async Task AverageAsync_AsyncSelector_Double_Empty() { var ys = new double[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); } [Fact] @@ -435,7 +435,7 @@ public async Task AverageAsync_AsyncSelector_Double_Many() public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Empty() { var ys = new double[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] @@ -513,7 +513,7 @@ public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Nullable_Man public async Task AverageAsync_Decimal_Empty() { var ys = new decimal[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -528,7 +528,7 @@ public async Task AverageAsync_Decimal_Many() public async Task AverageAsync_Selector_Decimal_Empty() { var ys = new decimal[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x).AsTask()); } [Fact] @@ -543,7 +543,7 @@ public async Task AverageAsync_Selector_Decimal_Many() public async Task AverageAsync_AsyncSelector_Decimal_Empty() { var ys = new decimal[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x))); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); } [Fact] @@ -559,7 +559,7 @@ public async Task AverageAsync_AsyncSelector_Decimal_Many() public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Empty() { var ys = new decimal[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt index 4de6fe5be9..53eaefcdf6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt @@ -47,7 +47,7 @@ foreach (var t in types) public async Task AverageAsync_<#=t.Name#>_Empty() { var ys = new <#=cs#>[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -62,7 +62,7 @@ foreach (var t in types) public async Task AverageAsync_Selector_<#=t.Name#>_Empty() { var ys = new <#=cs#>[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => x)); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => x).AsTask()); } [Fact] @@ -77,7 +77,7 @@ foreach (var t in types) public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Empty() { var ys = new <#=cs#>[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask<<#=cs#>>(x))); + await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask<<#=cs#>>(x)).AsTask()); } [Fact] @@ -93,7 +93,7 @@ foreach (var t in types) public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Empty() { var ys = new <#=cs#>[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs index 646a8a702f..ccd7c44fa3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs @@ -18,150 +18,150 @@ public async Task Average_Null() { // Average(IAE

) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); // Average(IAE

, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); // Average(IAE, Func) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); // Average(IAE, Func, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); // Average(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Average(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Average(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } @@ -270,7 +270,7 @@ public async Task Average11() { var xs = new int[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -286,7 +286,7 @@ public async Task Average13() { var xs = new long[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -302,7 +302,7 @@ public async Task Average15() { var xs = new double[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -318,7 +318,7 @@ public async Task Average17() { var xs = new float[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] @@ -334,7 +334,7 @@ public async Task Average19() { var xs = new decimal[0]; var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync()); + await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index a98c1b9d38..2b6bd7276a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -16,11 +16,11 @@ public class Contains : AsyncEnumerableTests [Fact] public async Task Contains_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, EqualityComparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, EqualityComparer.Default, CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index fd0a9b11e4..45eb851cfb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -15,13 +15,13 @@ public class Count : AsyncEnumerableTests [Fact] public async Task Count_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func), CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs index e23b7f8047..de78e62bc6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAt.cs @@ -15,18 +15,18 @@ public class ElementAt : AsyncEnumerableTests [Fact] public async Task ElementAt_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(default, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(Return42, -1)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(default, 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(Return42, -1).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(default, 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(Return42, -1, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(default, 0, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtAsync(Return42, -1, CancellationToken.None).AsTask()); } [Fact] public async Task ElementAt1Async() { var res = AsyncEnumerable.Empty().ElementAtAsync(0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -40,7 +40,7 @@ public async Task ElementAt2Async() public async Task ElementAt3Async() { var res = Return42.ElementAtAsync(1); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -54,7 +54,7 @@ public async Task ElementAt4Async() public async Task ElementAt5Async() { var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtAsync(7); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs index 8c9add492c..e8cce2e28d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ElementAtOrDefault.cs @@ -15,8 +15,8 @@ public class ElementAtOrDefault : AsyncEnumerableTests [Fact] public async Task ElementAtOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefaultAsync(default, 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefaultAsync(default, 0, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefaultAsync(default, 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ElementAtOrDefaultAsync(default, 0, CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 9e77b089b3..492499282f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -15,25 +15,25 @@ public class First : AsyncEnumerableTests [Fact] public async Task FirstAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #endif } @@ -41,21 +41,21 @@ public async Task FirstAsync_Null() public async Task FirstAsync_NoParam_Empty() { var res = AsyncEnumerable.Empty().FirstAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_NoParam_Empty_Enumerable() { var res = new int[0].Select(x => x).ToAsyncEnumerable().FirstAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_NoParam_Empty_IList() { var res = new int[0].ToAsyncEnumerable().FirstAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -98,7 +98,7 @@ public async Task FirstAsync_NoParam_Many() public async Task FirstAsync_Predicate_Empty() { var res = AsyncEnumerable.Empty().FirstAsync(x => true); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -113,21 +113,21 @@ public async Task FirstAsync_Predicate_Throw() public async Task FirstAsync_Predicate_Single_None() { var res = Return42.FirstAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_Predicate_Many_IList_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_Predicate_Many_None() { var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -169,14 +169,14 @@ public async Task FirstAsync_Predicate_Many_Pass2() public async Task FirstAsync_Predicate_PredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync(x => 1 / x > 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_AsyncPredicate_Empty() { var res = AsyncEnumerable.Empty().FirstAsync(x => new ValueTask(true)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -191,21 +191,21 @@ public async Task FirstAsync_AsyncPredicate_Throw() public async Task FirstAsync_AsyncPredicate_Single_None() { var res = Return42.FirstAsync(x => new ValueTask(x % 2 != 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_AsyncPredicate_Many_IList_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_AsyncPredicate_Many_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select(x => x).FirstAsync(x => new ValueTask(x % 2 != 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -247,7 +247,7 @@ public async Task FirstAsync_AsyncPredicate_Many_Pass2() public async Task FirstAsync_AsyncPredicate_AsyncPredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(1 / x > 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION @@ -255,7 +255,7 @@ public async Task FirstAsync_AsyncPredicate_AsyncPredicateThrows() public async Task FirstAsync_AsyncPredicateWithCancellation_Empty() { var res = AsyncEnumerable.Empty().FirstAsync((x, ct) => new ValueTask(true), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -270,21 +270,21 @@ public async Task FirstAsync_AsyncPredicateWithCancellation_Throw() public async Task FirstAsync_AsyncPredicateWithCancellation_Single_None() { var res = Return42.FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_AsyncPredicateWithCancellation_Many_IList_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task FirstAsync_AsyncPredicateWithCancellation_Many_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select((x, ct) => x).FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -326,7 +326,7 @@ public async Task FirstAsync_AsyncPredicateWithCancellation_Many_Pass2() public async Task FirstAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 2d39aea27d..26e4fa0f7d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -15,25 +15,25 @@ public class FirstOrDefault : AsyncEnumerableTests [Fact] public async Task FirstOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #endif } @@ -170,7 +170,7 @@ public async Task FirstOrDefaultAsync_Predicate_Many_Pass2() public async Task FirstOrDefaultAsync_Predicate_PredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => 1 / x > 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -248,7 +248,7 @@ public async Task FirstOrDefaultAsync_AsyncPredicate_Many_Pass2() public async Task FirstOrDefaultAsync_AsyncPredicate_AsyncPredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(1 / x > 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION @@ -327,7 +327,7 @@ public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass2( public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index d2dd2692e4..ea470b905f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -15,25 +15,25 @@ public class Last : AsyncEnumerableTests [Fact] public async Task Last_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #endif } @@ -41,21 +41,21 @@ public async Task Last_Null() public async Task LastAsync_NoParam_Empty() { var res = AsyncEnumerable.Empty().LastAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_NoParam_Empty_Enumerable() { var res = new int[0].Select(x => x).ToAsyncEnumerable().LastAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_NoParam_Empty_IList() { var res = new int[0].ToAsyncEnumerable().LastAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -98,7 +98,7 @@ public async Task LastAsync_NoParam_Many() public async Task LastAsync_Predicate_Empty() { var res = AsyncEnumerable.Empty().LastAsync(x => true); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -113,21 +113,21 @@ public async Task LastAsync_Predicate_Throw() public async Task LastAsync_Predicate_Single_None() { var res = Return42.LastAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_Predicate_Many_IList_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_Predicate_Many_None() { var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -169,14 +169,14 @@ public async Task LastAsync_Predicate_Many_Pass2() public async Task LastAsync_Predicate_PredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync(x => 1 / x > 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_AsyncPredicate_Empty() { var res = AsyncEnumerable.Empty().LastAsync(x => new ValueTask(true)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -191,21 +191,21 @@ public async Task LastAsync_AsyncPredicate_Throw() public async Task LastAsync_AsyncPredicate_Single_None() { var res = Return42.LastAsync(x => new ValueTask(x % 2 != 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_AsyncPredicate_Many_IList_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_AsyncPredicate_Many_None() { var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -247,7 +247,7 @@ public async Task LastAsync_AsyncPredicate_Many_Pass2() public async Task LastAsync_AsyncPredicate_AsyncPredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(1 / x > 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION @@ -255,7 +255,7 @@ public async Task LastAsync_AsyncPredicate_AsyncPredicateThrows() public async Task LastAsync_AsyncPredicateWithCancellation_Empty() { var res = AsyncEnumerable.Empty().LastAsync((x, ct) => new ValueTask(true), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -270,21 +270,21 @@ public async Task LastAsync_AsyncPredicateWithCancellation_Throw() public async Task LastAsync_AsyncPredicateWithCancellation_Single_None() { var res = Return42.LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_AsyncPredicateWithCancellation_Many_IList_None() { var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task LastAsync_AsyncPredicateWithCancellation_Many_None() { var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -326,7 +326,7 @@ public async Task LastAsync_AsyncPredicateWithCancellation_Many_Pass2() public async Task LastAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 511303b82e..bf72fa19c3 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -15,25 +15,25 @@ public class LastOrDefault : AsyncEnumerableTests [Fact] public async Task LastOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #endif } @@ -169,7 +169,7 @@ public async Task LastOrDefaultAsync_Predicate_Many_Pass2() public async Task LastOrDefaultAsync_Predicate_PredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync(x => 1 / x > 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -247,7 +247,7 @@ public async Task LastOrDefaultAsync_AsyncPredicate_Many_Pass2() public async Task LastOrDefaultAsync_AsyncPredicate_AsyncPredicateThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(1 / x > 0)); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION @@ -326,7 +326,7 @@ public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass2() public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() { var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index 724c3f58b8..893c6edd8a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -15,13 +15,13 @@ public class LongCount : AsyncEnumerableTests [Fact] public async Task LongCount_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func), CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs index 51a8ca1450..b02526366c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -18,185 +18,185 @@ public async Task Max_Null() { // Max(IAE

) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); // Max(IAE

, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); // Max(IAE, Func) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); // Max(IAE, Func, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); // Max(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif // Max(IAE) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable)).AsTask()); // Max(IAE, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); // Max(IAE, Func) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); // Max(IAE, Func, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); // Max(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs index 3aeeb7b958..6b5430165c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -18,185 +18,185 @@ public async Task Min_Null() { // Min(IAE

) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); // Min(IAE

, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); // Min(IAE, Func) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); // Min(IAE, Func, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); // Min(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif // Min(IAE) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable)).AsTask()); // Min(IAE, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); // Min(IAE, Func) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); // Min(IAE, Func, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); // Min(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs index beaad722d6..ee8fcdcedb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs @@ -16,26 +16,26 @@ public class MinMax : AsyncEnumerableTests [Fact] public async Task Min_Empty_Int32() { - await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Min_Selector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(int), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(int), CancellationToken.None).AsTask()); } [Fact] public async Task Min_AsyncSelector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Min_AsyncSelectorWithCancellation_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -980,26 +980,26 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() [Fact] public async Task Min_Empty_Int64() { - await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Min_Selector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(long), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(long), CancellationToken.None).AsTask()); } [Fact] public async Task Min_AsyncSelector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Min_AsyncSelectorWithCancellation_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -1944,26 +1944,26 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() [Fact] public async Task Min_Empty_Single() { - await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Min_Selector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(float), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(float), CancellationToken.None).AsTask()); } [Fact] public async Task Min_AsyncSelector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Min_AsyncSelectorWithCancellation_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -2908,26 +2908,26 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull( [Fact] public async Task Min_Empty_Double() { - await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Min_Selector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(double), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(double), CancellationToken.None).AsTask()); } [Fact] public async Task Min_AsyncSelector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Min_AsyncSelectorWithCancellation_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -3872,26 +3872,26 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull( [Fact] public async Task Min_Empty_Decimal() { - await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); + await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Min_Selector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(decimal), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(decimal), CancellationToken.None).AsTask()); } [Fact] public async Task Min_AsyncSelector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Min_AsyncSelectorWithCancellation_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -4836,26 +4836,26 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_SomeNull [Fact] public async Task Max_Empty_Int32() { - await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Max_Selector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(int), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(int), CancellationToken.None).AsTask()); } [Fact] public async Task Max_AsyncSelector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Max_AsyncSelectorWithCancellation_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -5800,26 +5800,26 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() [Fact] public async Task Max_Empty_Int64() { - await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Max_Selector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(long), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(long), CancellationToken.None).AsTask()); } [Fact] public async Task Max_AsyncSelector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Max_AsyncSelectorWithCancellation_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -6764,26 +6764,26 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() [Fact] public async Task Max_Empty_Single() { - await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Max_Selector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(float), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(float), CancellationToken.None).AsTask()); } [Fact] public async Task Max_AsyncSelector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Max_AsyncSelectorWithCancellation_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -7728,26 +7728,26 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull( [Fact] public async Task Max_Empty_Double() { - await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Max_Selector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(double), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(double), CancellationToken.None).AsTask()); } [Fact] public async Task Max_AsyncSelector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Max_AsyncSelectorWithCancellation_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif @@ -8692,26 +8692,26 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull( [Fact] public async Task Max_Empty_Decimal() { - await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); + await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] public async Task Max_Selector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(decimal), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(decimal), CancellationToken.None).AsTask()); } [Fact] public async Task Max_AsyncSelector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task Max_AsyncSelectorWithCancellation_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt index bf4667f039..2421c2f755 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt @@ -56,26 +56,26 @@ foreach (var op in new[] { "Min", "Max" }) [Fact] public async Task <#=op#>_Empty_<#=t.Name#>() { - await AssertThrowsAsync(new <#=cs#>[0].ToAsyncEnumerable().<#=op#>Async(CancellationToken.None)); + await AssertThrowsAsync(new <#=cs#>[0].ToAsyncEnumerable().<#=op#>Async(CancellationToken.None).AsTask()); } [Fact] public async Task <#=op#>_Selector_Empty_<#=t.Name#>() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(<#=cs#>), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(<#=cs#>), CancellationToken.None).AsTask()); } [Fact] public async Task <#=op#>_AsyncSelector_Empty_<#=t.Name#>() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(ValueTask<<#=cs#>>), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(ValueTask<<#=cs#>>), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] public async Task <#=op#>_AsyncSelectorWithCancellation_Empty_<#=t.Name#>() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async((x, ct) => default(ValueTask<<#=cs#>>), CancellationToken.None)); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async((x, ct) => default(ValueTask<<#=cs#>>), CancellationToken.None).AsTask()); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs index 1014bd2df0..01069f08ec 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SequenceEqual.cs @@ -16,17 +16,17 @@ public class SequenceEqual : AsyncEnumerableTests [Fact] public async Task SequenceEqual_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, new Eq())); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, new Eq())); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, new Eq()).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, new Eq()).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, new Eq(), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, new Eq(), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(default, Return42, new Eq(), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SequenceEqualAsync(Return42, default, new Eq(), CancellationToken.None).AsTask()); } [Fact] @@ -173,7 +173,7 @@ public async Task SequenceEqual16Async() { var xs = new[] { 1, 2, -3, 4 }.ToAsyncEnumerable(); var ys = new[] { 1, -2, 3, 4 }.ToAsyncEnumerable(); // NB: Implements IList, resulting in optimized code path. - await Assert.ThrowsAsync(() => xs.SequenceEqualAsync(ys, new EqEx())); + await Assert.ThrowsAsync(() => xs.SequenceEqualAsync(ys, new EqEx()).AsTask()); } [Fact] @@ -182,7 +182,7 @@ public async Task SequenceEqual17Async() var xs = new[] { 1, 2, -3, 4 }.Select(x => x * 2).ToAsyncEnumerable(); var ys = new[] { 1, -2, 3, 4 }.Select(x => x * 2).ToAsyncEnumerable(); var res = xs.SequenceEqualAsync(ys, new EqEx()); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } private sealed class EqEx : IEqualityComparer diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 5aec943005..f8c254d194 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -15,25 +15,25 @@ public class Single : AsyncEnumerableTests [Fact] public async Task Single_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #endif } @@ -41,21 +41,21 @@ public async Task Single_Null() public async Task Single1Async() { var res = AsyncEnumerable.Empty().SingleAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task Single2Async() { var res = AsyncEnumerable.Empty().SingleAsync(x => true); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task Single3Async() { var res = Return42.SingleAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -92,7 +92,7 @@ public async Task Single7Async() public async Task Single8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -106,14 +106,14 @@ public async Task Single9Async() public async Task Single10Async() { var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().SingleAsync(x => x % 2 != 0); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] public async Task Single11Async() { var res = new int[0].ToAsyncEnumerable().SingleAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 7b9192582b..71c2944374 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -15,25 +15,25 @@ public class SingleOrDefault : AsyncEnumerableTests [Fact] public async Task SingleOrDefault_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); #endif } @@ -92,7 +92,7 @@ public async Task SingleOrDefault7Async() public async Task SingleOrDefault8Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] @@ -113,7 +113,7 @@ public async Task SingleOrDefault10Async() public async Task SingleOrDefault11Async() { var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(x => true); - await AssertThrowsAsync(res); + await AssertThrowsAsync(res.AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs index 4104969e6b..c70cb0bb48 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs @@ -18,150 +18,150 @@ public async Task Sum_Null() { // Sum(IAE

) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable)).AsTask()); // Sum(IAE

, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); // Sum(IAE, Func) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); // Sum(IAE, Func, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); // Sum(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>))); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Sum(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Sum(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 290c865c2c..849a7fb520 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -16,8 +16,8 @@ public class ToArray : AsyncEnumerableTests [Fact] public async Task ToArray_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArrayAsync(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToArrayAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArrayAsync(default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToArrayAsync(default, CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index 5cd7967787..c5e99d2982 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -16,33 +16,33 @@ public class ToDictionary : AsyncEnumerableTests [Fact] public async Task ToDictionary_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, EqualityComparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None).AsTask()); } [Fact] @@ -58,7 +58,7 @@ public async Task ToDictionary1Async() public async Task ToDictionary2Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2)); + await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2).AsTask()); } [Fact] @@ -74,7 +74,7 @@ public async Task ToDictionary3Async() public async Task ToDictionary4Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2, x => x + 1)); + await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2, x => x + 1).AsTask()); } [Fact] @@ -90,7 +90,7 @@ public async Task ToDictionary5Async() public async Task ToDictionary6Async() { var xs = new[] { 1, 4, 2 }.ToAsyncEnumerable(); - await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2, new Eq())); + await AssertThrowsAsync(xs.ToDictionaryAsync(x => x % 2, new Eq()).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index 84f9b8e9b8..d39069616f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -16,10 +16,10 @@ public class ToHashSet : AsyncEnumerableTests [Fact] public async Task ToHashSet_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToHashSetAsync(default, EqualityComparer.Default, CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index ff654ae535..70c25723ed 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -15,8 +15,8 @@ public class ToList : AsyncEnumerableTests [Fact] public async Task ToList_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToListAsync(default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToListAsync(default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToListAsync(default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToListAsync(default, CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index 1262103000..0a95b6bfbb 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -17,33 +17,33 @@ public class ToLookup : AsyncEnumerableTests [Fact] public async Task ToLookup_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, EqualityComparer.Default)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, EqualityComparer.Default)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, EqualityComparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, x => 0, default, EqualityComparer.Default, CancellationToken.None).AsTask()); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 768f375147..cb27ecc568 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AggregateAsync(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -19,7 +19,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -46,7 +46,7 @@ static async Task Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -55,7 +55,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -83,7 +83,7 @@ static async Task Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -92,7 +92,7 @@ public static Task AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -120,7 +120,7 @@ static async Task Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -129,7 +129,7 @@ public static Task AggregateAsync(this IAsync return Core(source, seed, accumulator, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, CancellationToken _cancellationToken) { var acc = _seed; @@ -142,7 +142,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumula } } - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -151,7 +151,7 @@ public static Task AggregateAsync(this IAsync return Core(source, seed, accumulator, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) { var acc = _seed; @@ -165,7 +165,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumula } #if !NO_DEEP_CANCELLATION - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -174,7 +174,7 @@ public static Task AggregateAsync(this IAsync return Core(source, seed, accumulator, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, CancellationToken _cancellationToken) { var acc = _seed; @@ -188,7 +188,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumula } #endif - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func accumulator, Func resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -199,7 +199,7 @@ public static Task AggregateAsync(this I return Core(source, seed, accumulator, resultSelector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, Func _resultSelector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TAccumulate _seed, Func _accumulator, Func _resultSelector, CancellationToken _cancellationToken) { var acc = _seed; @@ -212,7 +212,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ } } - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -223,7 +223,7 @@ public static Task AggregateAsync(this I return Core(source, seed, accumulator, resultSelector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) { var acc = _seed; @@ -237,7 +237,7 @@ static async Task Core(IAsyncEnumerable _source, TAccumulate _ } #if !NO_DEEP_CANCELLATION - public static Task AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -248,7 +248,7 @@ public static Task AggregateAsync(this I return Core(source, seed, accumulator, resultSelector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TAccumulate _seed, Func> _accumulator, Func> _resultSelector, CancellationToken _cancellationToken) { var acc = _seed; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index c933160013..456164c289 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AllAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -19,7 +19,7 @@ public static Task AllAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { @@ -33,7 +33,7 @@ static async Task Core(IAsyncEnumerable _source, Func AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -42,7 +42,7 @@ public static Task AllAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { @@ -57,7 +57,7 @@ static async Task Core(IAsyncEnumerable _source, Func AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -66,7 +66,7 @@ public static Task AllAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 8fc1cc5389..8f8807a16f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AnyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -32,7 +32,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToke } } - public static Task AnyAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -41,7 +41,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { @@ -55,7 +55,7 @@ static async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -64,7 +64,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { @@ -79,7 +79,7 @@ static async Task Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -88,7 +88,7 @@ public static Task AnyAsync(this IAsyncEnumerable source return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 019e369cbf..453e5bbd5d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -48,7 +48,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,7 +57,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -88,7 +88,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -97,7 +97,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -129,7 +129,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,7 +138,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -170,14 +170,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -208,7 +208,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -217,7 +217,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -248,7 +248,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -257,7 +257,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -289,7 +289,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -298,7 +298,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -330,14 +330,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -368,7 +368,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -377,7 +377,7 @@ public static Task AverageAsync(this IAsyncEnumerable s return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -408,7 +408,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -417,7 +417,7 @@ public static Task AverageAsync(this IAsyncEnumerable s return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -449,7 +449,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -458,7 +458,7 @@ public static Task AverageAsync(this IAsyncEnumerable s return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -490,14 +490,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -528,7 +528,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationTok } } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -537,7 +537,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -568,7 +568,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -577,7 +577,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -609,7 +609,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -618,7 +618,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -650,14 +650,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -688,7 +688,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -697,7 +697,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -728,7 +728,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -737,7 +737,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -769,7 +769,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -778,7 +778,7 @@ public static Task AverageAsync(this IAsyncEnumerable return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -810,14 +810,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -856,7 +856,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -865,7 +865,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -904,7 +904,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -913,7 +913,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -953,7 +953,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -962,7 +962,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1002,14 +1002,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1048,7 +1048,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1057,7 +1057,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1096,7 +1096,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1105,7 +1105,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1145,7 +1145,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1154,7 +1154,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1194,14 +1194,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1240,7 +1240,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1249,7 +1249,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1288,7 +1288,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1297,7 +1297,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1337,7 +1337,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1346,7 +1346,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1386,14 +1386,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1432,7 +1432,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1441,7 +1441,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1480,7 +1480,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1489,7 +1489,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1529,7 +1529,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1538,7 +1538,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1578,14 +1578,14 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1624,7 +1624,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1633,7 +1633,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1672,7 +1672,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1681,7 +1681,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -1721,7 +1721,7 @@ static async Task Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1730,7 +1730,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 6f0131db83..dbf13a6a04 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -45,14 +45,14 @@ foreach (var o in os) else if (t == "float") res = "(float)(sum / count)"; #> - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.res#>> AverageAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task<<#=o.res#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) + static async ValueTask<<#=o.res#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) { <# if (isNullable) @@ -129,7 +129,7 @@ else } } - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -138,7 +138,7 @@ else return Core(source, selector, cancellationToken); - static async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask<<#=o.res#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { <# if (isNullable) @@ -215,7 +215,7 @@ else } } - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -224,7 +224,7 @@ else return Core(source, selector, cancellationToken); - static async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async ValueTask<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { <# if (isNullable) @@ -302,7 +302,7 @@ else } #if !NO_DEEP_CANCELLATION - public static Task<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -311,7 +311,7 @@ else return Core(source, selector, cancellationToken); - static async Task<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async ValueTask<<#=o.res#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { <# if (isNullable) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index c3632769ba..035acd5dc8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -10,11 +10,11 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken = default) => - source is ICollection collection ? Task.FromResult(collection.Contains(value)) : + public static ValueTask ContainsAsync(this IAsyncEnumerable source, TSource value, CancellationToken cancellationToken = default) => + source is ICollection collection ? new ValueTask(collection.Contains(value)) : ContainsAsync(source, value, comparer: null, cancellationToken); - public static Task ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask ContainsAsync(this IAsyncEnumerable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -26,7 +26,7 @@ public static Task ContainsAsync(this IAsyncEnumerable s { return Core(source, value, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { @@ -43,7 +43,7 @@ static async Task Core(IAsyncEnumerable _source, TSource _value, { return Core(source, value, comparer, cancellationToken); - static async Task Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index fd1835f874..1da8cb5fae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -11,7 +11,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task CountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -19,16 +19,16 @@ public static Task CountAsync(this IAsyncEnumerable sourc switch (source) { case ICollection collection: - return Task.FromResult(collection.Count); + return new ValueTask(collection.Count); case IAsyncIListProvider listProv: - return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken).AsTask(); + return listProv.GetCountAsync(onlyIfCheap: false, cancellationToken); case ICollection collection: - return Task.FromResult(collection.Count); + return new ValueTask(collection.Count); } return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var count = 0; @@ -44,7 +44,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - public static Task CountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -53,7 +53,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var count = 0; @@ -72,7 +72,7 @@ static async Task Core(IAsyncEnumerable _source, Func CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -81,7 +81,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0; @@ -101,7 +101,7 @@ static async Task Core(IAsyncEnumerable _source, Func CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -110,7 +110,7 @@ public static Task CountAsync(this IAsyncEnumerable sourc return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs index 372c9779d5..171662a4cd 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAt.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ElementAtAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken = default) + public static ValueTask ElementAtAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, index, cancellationToken); - static async Task Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) { if (_source is IAsyncPartition p) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index 5dd69697fe..b5de954780 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ElementAtOrDefaultAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken = default) + public static ValueTask ElementAtOrDefaultAsync(this IAsyncEnumerable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, index, cancellationToken); - static async Task Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, int _index, CancellationToken _cancellationToken) { if (_source is IAsyncPartition p) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 0a562aaba3..b4fd9cf07a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task FirstAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _cancellationToken).ConfigureAwait(false); @@ -25,7 +25,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task FirstAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -42,7 +42,7 @@ static async Task Core(IAsyncEnumerable _source, Func FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +51,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -60,7 +60,7 @@ static async Task Core(IAsyncEnumerable _source, Func FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -69,7 +69,7 @@ public static Task FirstAsync(this IAsyncEnumerable s return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index b9b53dbaf9..63281cbecc 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _cancellationToken).ConfigureAwait(false); @@ -25,7 +25,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -42,7 +42,7 @@ static async Task Core(IAsyncEnumerable _source, Func FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +51,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -60,7 +60,7 @@ static async Task Core(IAsyncEnumerable _source, Func FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -69,7 +69,7 @@ public static Task FirstOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var first = await TryGetFirst(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -118,7 +118,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, C return new ValueTask>(new Maybe()); } - private static async Task> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async ValueTask> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); @@ -142,7 +142,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< return new Maybe(); } - private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async ValueTask> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); @@ -167,7 +167,7 @@ private static async Task> TryGetFirst(IAsyncEnumerable< } #if !NO_DEEP_CANCELLATION - private static async Task> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async ValueTask> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index e1a4328388..9ea5c3f1ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LastAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _cancellationToken).ConfigureAwait(false); @@ -25,7 +25,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task LastAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static Task LastAsync(this IAsyncEnumerable so return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -42,7 +42,7 @@ static async Task Core(IAsyncEnumerable _source, Func LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +51,7 @@ public static Task LastAsync(this IAsyncEnumerable so return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -60,7 +60,7 @@ static async Task Core(IAsyncEnumerable _source, Func LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -69,7 +69,7 @@ public static Task LastAsync(this IAsyncEnumerable so return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index a93efd53fb..16acfd28a8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LastOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _cancellationToken).ConfigureAwait(false); @@ -25,7 +25,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -42,7 +42,7 @@ static async Task Core(IAsyncEnumerable _source, Func LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -51,7 +51,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -60,7 +60,7 @@ static async Task Core(IAsyncEnumerable _source, Func LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -69,7 +69,7 @@ public static Task LastOrDefaultAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var last = await TryGetLast(_source, _predicate, _cancellationToken).ConfigureAwait(false); @@ -114,7 +114,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, C return new ValueTask>(new Maybe()); } - private static async Task> TryGetLast(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) + private static async ValueTask> TryGetLast(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { var last = default(TSource); var hasLast = false; @@ -131,7 +131,7 @@ private static async Task> TryGetLast(IAsyncEnumerable(last) : new Maybe(); } - private static async Task> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async ValueTask> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var last = default(TSource); var hasLast = false; @@ -149,7 +149,7 @@ private static async Task> TryGetLast(IAsyncEnumerable> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) + private static async ValueTask> TryGetLast(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { var last = default(TSource); var hasLast = false; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index a60240806a..1a10566cae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task LongCountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var count = 0L; @@ -33,7 +33,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToke } } - public static Task LongCountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -42,7 +42,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var count = 0L; @@ -61,7 +61,7 @@ static async Task Core(IAsyncEnumerable _source, Func LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -70,7 +70,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0L; @@ -90,7 +90,7 @@ static async Task Core(IAsyncEnumerable _source, Func LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -99,7 +99,7 @@ public static Task LongCountAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var count = 0L; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index d70bb53cdb..66a3b92de6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -19,7 +19,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou { return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -62,7 +62,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT { return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -98,7 +98,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -109,7 +109,7 @@ public static Task MaxAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -152,7 +152,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -188,7 +188,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -199,7 +199,7 @@ public static Task MaxAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -242,7 +242,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -280,7 +280,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -291,7 +291,7 @@ public static Task MaxAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -334,7 +334,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 4a3ada9021..6dad8039d0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -10,7 +10,7 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -19,7 +19,7 @@ public static Task MinAsync(this IAsyncEnumerable sou { return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -62,7 +62,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT { return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -99,7 +99,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -110,7 +110,7 @@ public static Task MinAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -153,7 +153,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -190,7 +190,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -201,7 +201,7 @@ public static Task MinAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -244,7 +244,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -282,7 +282,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -293,7 +293,7 @@ public static Task MinAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; @@ -336,7 +336,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var comparer = Comparer.Default; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index a1010b8c61..0e19bcdb4b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int value; @@ -50,7 +50,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -59,7 +59,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int value; @@ -92,7 +92,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -101,7 +101,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -135,7 +135,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -144,7 +144,7 @@ public static Task MaxAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -178,14 +178,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int? value = null; @@ -257,7 +257,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -266,7 +266,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int? value = null; @@ -338,7 +338,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -347,7 +347,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -420,7 +420,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -429,7 +429,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -502,14 +502,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long value; @@ -542,7 +542,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -551,7 +551,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long value; @@ -584,7 +584,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -593,7 +593,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -627,7 +627,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -636,7 +636,7 @@ public static Task MaxAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -670,14 +670,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long? value = null; @@ -749,7 +749,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -758,7 +758,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long? value = null; @@ -830,7 +830,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -839,7 +839,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -912,7 +912,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -921,7 +921,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -994,14 +994,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float value; @@ -1049,7 +1049,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1058,7 +1058,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float value; @@ -1106,7 +1106,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1115,7 +1115,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -1164,7 +1164,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1173,7 +1173,7 @@ public static Task MaxAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -1222,14 +1222,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float? value = null; @@ -1297,7 +1297,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1306,7 +1306,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float? value = null; @@ -1374,7 +1374,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1383,7 +1383,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -1452,7 +1452,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1461,7 +1461,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -1530,14 +1530,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double value; @@ -1585,7 +1585,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationTok } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1594,7 +1594,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double value; @@ -1642,7 +1642,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1651,7 +1651,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -1700,7 +1700,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1709,7 +1709,7 @@ public static Task MaxAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -1758,14 +1758,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double? value = null; @@ -1833,7 +1833,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1842,7 +1842,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double? value = null; @@ -1910,7 +1910,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1919,7 +1919,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -1988,7 +1988,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1997,7 +1997,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -2066,14 +2066,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal value; @@ -2106,7 +2106,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2115,7 +2115,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal value; @@ -2148,7 +2148,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2157,7 +2157,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -2191,7 +2191,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2200,7 +2200,7 @@ public static Task MaxAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -2234,14 +2234,14 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal? value = null; @@ -2287,7 +2287,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2296,7 +2296,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -2342,7 +2342,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2351,7 +2351,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -2398,7 +2398,7 @@ static async Task Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2407,7 +2407,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -2454,14 +2454,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int value; @@ -2494,7 +2494,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2503,7 +2503,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int value; @@ -2536,7 +2536,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2545,7 +2545,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -2579,7 +2579,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2588,7 +2588,7 @@ public static Task MinAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int value; @@ -2622,14 +2622,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { int? value = null; @@ -2677,7 +2677,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2686,7 +2686,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { int? value = null; @@ -2734,7 +2734,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2743,7 +2743,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -2792,7 +2792,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2801,7 +2801,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { int? value = null; @@ -2850,14 +2850,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long value; @@ -2890,7 +2890,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2899,7 +2899,7 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long value; @@ -2932,7 +2932,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2941,7 +2941,7 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -2975,7 +2975,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2984,7 +2984,7 @@ public static Task MinAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long value; @@ -3018,14 +3018,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { long? value = null; @@ -3073,7 +3073,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3082,7 +3082,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { long? value = null; @@ -3130,7 +3130,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3139,7 +3139,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -3188,7 +3188,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3197,7 +3197,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { long? value = null; @@ -3246,14 +3246,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float value; @@ -3302,7 +3302,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3311,7 +3311,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float value; @@ -3360,7 +3360,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3369,7 +3369,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -3419,7 +3419,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3428,7 +3428,7 @@ public static Task MinAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float value; @@ -3478,14 +3478,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { float? value = null; @@ -3549,7 +3549,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3558,7 +3558,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { float? value = null; @@ -3622,7 +3622,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3631,7 +3631,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -3696,7 +3696,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3705,7 +3705,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { float? value = null; @@ -3770,14 +3770,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double value; @@ -3826,7 +3826,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationTok } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3835,7 +3835,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double value; @@ -3884,7 +3884,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3893,7 +3893,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -3943,7 +3943,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3952,7 +3952,7 @@ public static Task MinAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double value; @@ -4002,14 +4002,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { double? value = null; @@ -4073,7 +4073,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4082,7 +4082,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { double? value = null; @@ -4146,7 +4146,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4155,7 +4155,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -4220,7 +4220,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4229,7 +4229,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { double? value = null; @@ -4294,14 +4294,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal value; @@ -4334,7 +4334,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4343,7 +4343,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal value; @@ -4376,7 +4376,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4385,7 +4385,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -4419,7 +4419,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4428,7 +4428,7 @@ public static Task MinAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal value; @@ -4462,14 +4462,14 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { decimal? value = null; @@ -4515,7 +4515,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4524,7 +4524,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -4570,7 +4570,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4579,7 +4579,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; @@ -4626,7 +4626,7 @@ static async Task Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4635,7 +4635,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { decimal? value = null; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 49b69f5882..531de965ee 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -28,14 +28,14 @@ foreach (var m in new[] { "Max", "Min" }) var isNullable = t.EndsWith("?"); var shortCircuit = t.StartsWith("decimal"); #> - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken = default) + public static ValueTask<<#=t#>> <#=m#>Async(this IAsyncEnumerable<<#=t#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task<<#=t#>> Core(IAsyncEnumerable<<#=t#>> _source, CancellationToken _cancellationToken) + static async ValueTask<<#=t#>> Core(IAsyncEnumerable<<#=t#>> _source, CancellationToken _cancellationToken) { <# if (!isNullable) @@ -305,7 +305,7 @@ foreach (var overload in new[] { <# } #> - public static Task<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, <#=overload.selector#> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, <#=overload.selector#> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -314,7 +314,7 @@ foreach (var overload in new[] { return Core(source, selector, cancellationToken); - static async Task<<#=t#>> Core(IAsyncEnumerable _source, <#=overload.selector#> _selector, CancellationToken _cancellationToken) + static async ValueTask<<#=t#>> Core(IAsyncEnumerable _source, <#=overload.selector#> _selector, CancellationToken _cancellationToken) { <# if (!isNullable) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs index d0b35fb891..7c3cbfe510 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Reverse.cs @@ -73,7 +73,7 @@ public ValueTask GetCountAsync(bool onlyIfCheap, CancellationToken cancella } } - return new ValueTask(_source.CountAsync(cancellationToken)); + return _source.CountAsync(cancellationToken); } public override AsyncIteratorBase Clone() diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index ede3bf19b4..c19b2d2df9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -10,10 +10,10 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) => + public static ValueTask SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) => SequenceEqualAsync(first, second, comparer: null, cancellationToken); - public static Task SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask SequenceEqualAsync(this IAsyncEnumerable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -29,7 +29,7 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable(false); } if (firstCol is IList firstList && secondCol is IList secondList) @@ -40,17 +40,17 @@ public static Task SequenceEqualAsync(this IAsyncEnumerable(false); } } - return Task.FromResult(true); + return new ValueTask(true); } } return Core(first, second, comparer, cancellationToken); - static async Task Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var e1 = _first.GetConfiguredAsyncEnumerator(_cancellationToken, false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 37a3a85e89..723c7785ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SingleAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { if (_source is IList list) { @@ -55,7 +55,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task SingleAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -64,7 +64,7 @@ public static Task SingleAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -97,7 +97,7 @@ static async Task Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -106,7 +106,7 @@ public static Task SingleAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -140,7 +140,7 @@ static async Task Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -149,7 +149,7 @@ public static Task SingleAsync(this IAsyncEnumerable return Core(source, predicate, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index fe7c076640..4794a4179c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { if (_source is IList list) { @@ -55,7 +55,7 @@ async Task Core(IAsyncEnumerable _source, CancellationToken _c } } - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -64,7 +64,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) + async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -97,7 +97,7 @@ async Task Core(IAsyncEnumerable _source, Func } } - public static Task SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -106,7 +106,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); @@ -140,7 +140,7 @@ async Task Core(IAsyncEnumerable _source, Func SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -149,7 +149,7 @@ public static Task SingleOrDefaultAsync(this IAsyncEnumerable< return Core(source, predicate, cancellationToken); - async Task Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) + async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index dbee6eafae..3f5ed3e67d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -10,14 +10,14 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0; @@ -33,7 +33,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ca } } - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -42,7 +42,7 @@ public static Task SumAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -60,7 +60,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -69,7 +69,7 @@ public static Task SumAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -88,7 +88,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -97,7 +97,7 @@ public static Task SumAsync(this IAsyncEnumerable source, return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -116,14 +116,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0L; @@ -139,7 +139,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken _ } } - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -148,7 +148,7 @@ public static Task SumAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -166,7 +166,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -175,7 +175,7 @@ public static Task SumAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -194,7 +194,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -203,7 +203,7 @@ public static Task SumAsync(this IAsyncEnumerable source return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -222,14 +222,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -242,7 +242,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationToken } } - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -251,7 +251,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -266,7 +266,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -275,7 +275,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -291,7 +291,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -300,7 +300,7 @@ public static Task SumAsync(this IAsyncEnumerable sourc return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -316,14 +316,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0; @@ -336,7 +336,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationTok } } - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -345,7 +345,7 @@ public static Task SumAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -360,7 +360,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -369,7 +369,7 @@ public static Task SumAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -385,7 +385,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -394,7 +394,7 @@ public static Task SumAsync(this IAsyncEnumerable sour return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -410,14 +410,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0m; @@ -430,7 +430,7 @@ static async Task Core(IAsyncEnumerable _source, CancellationT } } - public static Task SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -439,7 +439,7 @@ public static Task SumAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -454,7 +454,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -463,7 +463,7 @@ public static Task SumAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -479,7 +479,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -488,7 +488,7 @@ public static Task SumAsync(this IAsyncEnumerable sou return Core(source, selector, cancellationToken); - static async Task Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -504,14 +504,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0; @@ -527,7 +527,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -536,7 +536,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -554,7 +554,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -563,7 +563,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -582,7 +582,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -591,7 +591,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0; @@ -610,14 +610,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0L; @@ -633,7 +633,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -642,7 +642,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -660,7 +660,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -669,7 +669,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -688,7 +688,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -697,7 +697,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0L; @@ -716,14 +716,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -736,7 +736,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -745,7 +745,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -760,7 +760,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -769,7 +769,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -785,7 +785,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -794,7 +794,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0f; @@ -810,14 +810,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0.0; @@ -830,7 +830,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -839,7 +839,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -854,7 +854,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -863,7 +863,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -879,7 +879,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -888,7 +888,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0.0; @@ -904,14 +904,14 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var sum = 0m; @@ -924,7 +924,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -933,7 +933,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -948,7 +948,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -957,7 +957,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; @@ -973,7 +973,7 @@ static async Task Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -982,7 +982,7 @@ static async Task Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = 0m; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 2f6269d950..4e378bc12f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -35,14 +35,14 @@ foreach (var o in os) { var n = o.type.EndsWith("?") ? ".GetValueOrDefault()" : ""; #> - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.type#>> SumAsync(this IAsyncEnumerable<<#=o.type#>> source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, cancellationToken); - static async Task<<#=o.type#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) + static async ValueTask<<#=o.type#>> Core(IAsyncEnumerable<<#=o.type#>> _source, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; @@ -71,7 +71,7 @@ else } } - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,7 +80,7 @@ else return Core(source, selector, cancellationToken); - static async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) + static async ValueTask<<#=o.type#>> Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; @@ -111,7 +111,7 @@ else } } - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -120,7 +120,7 @@ else return Core(source, selector, cancellationToken); - static async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async ValueTask<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; @@ -152,7 +152,7 @@ else } #if !NO_DEEP_CANCELLATION - public static Task<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -161,7 +161,7 @@ else return Core(source, selector, cancellationToken); - static async Task<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) + static async ValueTask<<#=o.type#>> Core(IAsyncEnumerable _source, Func>> _selector, CancellationToken _cancellationToken) { var sum = <#=o.zero#>; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs index 11d5152dbd..bad8fdab7e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToArray.cs @@ -10,15 +10,15 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task ToArrayAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask ToArrayAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (source is IAsyncIListProvider arrayProvider) - return arrayProvider.ToArrayAsync(cancellationToken).AsTask(); + return arrayProvider.ToArrayAsync(cancellationToken); - return AsyncEnumerableHelpers.ToArray(source, cancellationToken).AsTask(); + return AsyncEnumerableHelpers.ToArray(source, cancellationToken); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index a951bddead..4e36ebdf1a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -10,10 +10,10 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) => ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -22,7 +22,7 @@ public static Task> ToDictionaryAsync(t return Core(source, keySelector, comparer, cancellationToken); - static async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -37,10 +37,10 @@ static async Task> Core(IAsyncEnumerable _sou } } - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -49,7 +49,7 @@ public static Task> ToDictionaryAsync(t return Core(source, keySelector, comparer, cancellationToken); - static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -65,10 +65,10 @@ static async Task> Core(IAsyncEnumerable _sou } #if !NO_DEEP_CANCELLATION - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -77,7 +77,7 @@ public static Task> ToDictionaryAsync(t return Core(source, keySelector, comparer, cancellationToken); - static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -93,10 +93,10 @@ static async Task> Core(IAsyncEnumerable _sou } #endif - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -107,7 +107,7 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -123,10 +123,10 @@ static async Task> Core(IAsyncEnumerable _so } } - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -137,7 +137,7 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); @@ -154,10 +154,10 @@ static async Task> Core(IAsyncEnumerable _so } #if !NO_DEEP_CANCELLATION - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static Task> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -168,7 +168,7 @@ public static Task> ToDictionaryAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var d = new Dictionary(_comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index e2c7aae414..80b4d48362 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -10,17 +10,17 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToHashSetAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) => + public static ValueTask> ToHashSetAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) => ToHashSetAsync(source, comparer: null, cancellationToken); - public static Task> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToHashSetAsync(this IAsyncEnumerable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); return Core(source, comparer, cancellationToken); - static async Task> Core(IAsyncEnumerable _source, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, IEqualityComparer _comparer, CancellationToken _cancellationToken) { var set = new HashSet(_comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index 4595543f3d..e9d48664ed 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -10,17 +10,17 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToListAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) + public static ValueTask> ToListAsync(this IAsyncEnumerable source, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); if (source is IAsyncIListProvider listProvider) - return listProvider.ToListAsync(cancellationToken).AsTask(); + return listProvider.ToListAsync(cancellationToken); return Core(source, cancellationToken); - static async Task> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { var list = new List(); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index 92fa34606c..ffb5c0f848 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -10,10 +10,10 @@ namespace System.Linq { public static partial class AsyncEnumerable { - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, CancellationToken cancellationToken = default) => ToLookupAsync(source, keySelector, comparer: null, cancellationToken); - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -22,16 +22,16 @@ public static Task> ToLookupAsync(this IAs return Core(source, keySelector, comparer, cancellationToken); - static async Task> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.Lookup.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); } } - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAsync(source, keySelector, comparer:null, cancellationToken); - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -40,17 +40,17 @@ public static Task> ToLookupAsync(this IAs return Core(source, keySelector, comparer, cancellationToken); - async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); } } #if !NO_DEEP_CANCELLATION - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAsync(source, keySelector, comparer: null, cancellationToken); - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -59,17 +59,17 @@ public static Task> ToLookupAsync(this IAs return Core(source, keySelector, comparer, cancellationToken); - static async Task> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); } } #endif - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, CancellationToken cancellationToken = default) => ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -80,16 +80,16 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func _keySelector, Func _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.Lookup.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); } } - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -100,17 +100,17 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); } } #if !NO_DEEP_CANCELLATION - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static Task> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -121,7 +121,7 @@ public static Task> ToLookupAsync> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) + static async ValueTask> Core(IAsyncEnumerable _source, Func> _keySelector, Func> _elementSelector, IEqualityComparer _comparer, CancellationToken _cancellationToken) { return await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); } From 16dbc3dd426a9924b9a4f4a7759efbe7c123bde1 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 23:40:44 -0800 Subject: [PATCH 741/862] Remove unused MinusOne. --- .../Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs index 1e2e1655b9..1d76347454 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/TaskExt.cs @@ -6,8 +6,6 @@ namespace System.Threading.Tasks { internal static class TaskExt { - public static readonly Task MinusOne = Task.FromResult(-1); - public static readonly TaskCompletionSource True; static TaskExt() From 1db4db95d358321f94cb9db1dc3d43d9b9868fee Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 12 Feb 2019 23:49:18 -0800 Subject: [PATCH 742/862] Fix AsyncEnumerableQuery to support ValueTask aggregates. --- .../System/Linq/AsyncEnumerableQuery.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs index a1b14c4bec..189d03ce8e 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs @@ -103,7 +103,7 @@ ValueTask IAsyncQueryProvider.ExecuteAsync(Expression expressi throw new ArgumentNullException(nameof(expression)); } - if (!typeof(Task).IsAssignableFrom(expression.Type)) + if (!typeof(ValueTask).IsAssignableFrom(expression.Type)) { throw new ArgumentException("The specified expression is not assignable to the result type.", nameof(expression)); } From 9a77a9c80e8dba38906770743c54396620ccb4bf Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 13 Feb 2019 10:46:02 -0800 Subject: [PATCH 743/862] Fixing global.json to correctly refer to preview 2 --- Ix.NET/Source/global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index f6fec1c73d..8a82c8d690 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.0.100-preview2" + "version": "3.0.100-preview-010184" }, "msbuild-sdks": { "MSBuild.Sdk.Extras": "2.0.0-preview.14" From c129063aa712167f1ebe50e22652c37a988279f5 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 13 Feb 2019 10:49:30 -0800 Subject: [PATCH 744/862] Enabling tests for .NET Core 3.0 --- .../System.Interactive.Async.Providers.Tests.csproj | 2 +- .../System.Interactive.Async.Tests.csproj | 2 +- .../System.Linq.Async.Queryable.Tests.csproj | 2 +- .../System.Linq.Async.Tests/System.Linq.Async.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj index 2bfd2ccfa1..2b422f0f1a 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers.Tests/System.Interactive.Async.Providers.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;net461 + netcoreapp2.1;net461;netcoreapp3.0 $(NoWarn);CS0618 diff --git a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj index c3405f7184..f6aaaea3a5 100644 --- a/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Tests/System.Interactive.Async.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;net461 + netcoreapp2.1;net461;netcoreapp3.0 $(NoWarn);CS0618 diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj index e1c1ca58e1..32eb9f12bb 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/System.Linq.Async.Queryable.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;net461 + netcoreapp2.1;net461;netcoreapp3.0 $(NoWarn);CS0618 diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index 9ce4690a44..e5404a6dc7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;net461 + netcoreapp2.1;net461;netcoreapp3.0 $(NoWarn);CS0618 From 962fc997163ff66b5fa5d3826c22510eb511f5fa Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 13 Feb 2019 16:41:35 -0800 Subject: [PATCH 745/862] Style consistency for new code --- .../System/Linq/Operators/Amb.cs | 2 +- .../System/Linq/Operators/Buffer.cs | 6 ++--- .../System/Linq/Operators/Concat.cs | 12 +++++----- .../System/Linq/Operators/Defer.cs | 6 ++--- .../Linq/Operators/DistinctUntilChanged.cs | 22 +++++++++---------- .../System/Linq/Operators/Expand.cs | 6 ++--- .../System/Linq/Operators/Finally.cs | 4 ++-- .../System/Linq/Operators/Generate.cs | 2 +- .../System/Linq/Operators/Merge.cs | 14 ++++++------ .../System/Linq/Operators/Repeat.cs | 4 ++-- .../System/Linq/Operators/Scan.cs | 18 +++++++-------- .../System/Linq/Operators/Using.cs | 12 +++++----- .../System/Linq/AsyncEnumerableHelpers.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 12 +++++----- .../System/Linq/Operators/All.cs | 6 ++--- .../System/Linq/Operators/Any.cs | 6 ++--- .../System/Linq/Operators/AppendPrepend.cs | 8 +++---- .../System/Linq/Operators/Concat.cs | 2 +- .../System/Linq/Operators/Contains.cs | 4 ++-- .../System/Linq/Operators/Count.cs | 8 +++---- .../System/Linq/Operators/ElementAt.cs | 2 +- .../Linq/Operators/ElementAtOrDefault.cs | 2 +- .../System/Linq/Operators/ForEach.cs | 12 +++++----- .../System/Linq/Operators/LastOrDefault.cs | 8 +++---- .../System/Linq/Operators/LongCount.cs | 8 +++---- .../System/Linq/Operators/Lookup.cs | 18 +++++++-------- .../Linq/Operators/OrderedAsyncEnumerable.cs | 12 +++++----- .../System/Linq/Operators/SequenceEqual.cs | 4 ++-- .../System/Linq/Operators/ToDictionary.cs | 12 +++++----- .../System/Linq/Operators/ToHashSet.cs | 2 +- .../System/Linq/Operators/ToList.cs | 2 +- .../System/Linq/Operators/Union.cs | 2 +- 32 files changed, 120 insertions(+), 120 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index e0a42ebb2b..6ad9c47020 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -191,7 +191,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var winnerIndex = Array.IndexOf(moveNexts, moveNextWinner); - IAsyncEnumerator winner = enumerators[winnerIndex]; + var winner = enumerators[winnerIndex]; var loserCleanupTasks = new List(n - 1); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs index 4ff739b8fe..f58107295c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Buffer.cs @@ -25,7 +25,7 @@ async IAsyncEnumerator> Core(CancellationToken cancellationToken) { var buffer = new List(count); - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { buffer.Add(item); @@ -63,9 +63,9 @@ async IAsyncEnumerator> Core(CancellationToken cancellationToken) { var buffers = new Queue>(); - int index = 0; + var index = 0; - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { if (index++ % skip == 0) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs index 1cf8c8c12c..94d6112a94 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Concat.cs @@ -21,9 +21,9 @@ public static IAsyncEnumerable Concat(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - await foreach (IAsyncEnumerable source in sources.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var source in sources.WithCancellation(cancellationToken).ConfigureAwait(false)) { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -44,9 +44,9 @@ public static IAsyncEnumerable Concat(this IEnumerable Core(CancellationToken cancellationToken) { - foreach (IAsyncEnumerable source in sources) + foreach (var source in sources) { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -67,9 +67,9 @@ public static IAsyncEnumerable Concat(params IAsyncEnumerable< async IAsyncEnumerator Core(CancellationToken cancellationToken) { - foreach (IAsyncEnumerable source in sources) + foreach (var source in sources) { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs index f13347a56c..4949dbfb57 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Defer.cs @@ -21,7 +21,7 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) { - await foreach (TSource item in factory().WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in factory().WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -41,7 +41,7 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) { - await foreach (TSource item in (await factory().ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in (await factory().ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -62,7 +62,7 @@ public static IAsyncEnumerable Defer(Func Core(CancellationToken cancellationToken) { - await foreach (TSource item in (await factory(cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in (await factory(cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 8cb9b730f6..f151ca8d4d 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -112,13 +112,13 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield break; } - TSource latest = e.Current; + var latest = e.Current; yield return latest; while (await e.MoveNextAsync()) { - TSource item = e.Current; + var item = e.Current; if (!comparer.Equals(latest, item)) { @@ -159,9 +159,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield break; } - TSource item = e.Current; + var item = e.Current; - TKey latestKey = keySelector(item); + var latestKey = keySelector(item); yield return item; @@ -169,7 +169,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { item = e.Current; - TKey currentKey = keySelector(item); + var currentKey = keySelector(item); if (!comparer.Equals(latestKey, currentKey)) { @@ -210,9 +210,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield break; } - TSource item = e.Current; + var item = e.Current; - TKey latestKey = await keySelector(item).ConfigureAwait(false); + var latestKey = await keySelector(item).ConfigureAwait(false); yield return item; @@ -220,7 +220,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { item = e.Current; - TKey currentKey = await keySelector(item).ConfigureAwait(false); + var currentKey = await keySelector(item).ConfigureAwait(false); if (!comparer.Equals(latestKey, currentKey)) { @@ -262,9 +262,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield break; } - TSource item = e.Current; + var item = e.Current; - TKey latestKey = await keySelector(item, cancellationToken).ConfigureAwait(false); + var latestKey = await keySelector(item, cancellationToken).ConfigureAwait(false); yield return item; @@ -272,7 +272,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { item = e.Current; - TKey currentKey = await keySelector(item, cancellationToken).ConfigureAwait(false); + var currentKey = await keySelector(item, cancellationToken).ConfigureAwait(false); if (!comparer.Equals(latestKey, currentKey)) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs index dcdf6e6590..d89d7668f7 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Expand.cs @@ -29,7 +29,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (queue.Count > 0) { - await foreach (TSource item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) { queue.Enqueue(selector(item)); @@ -60,7 +60,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (queue.Count > 0) { - await foreach (TSource item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) { queue.Enqueue(await selector(item).ConfigureAwait(false)); @@ -92,7 +92,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (queue.Count > 0) { - await foreach (TSource item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in queue.Dequeue().WithCancellation(cancellationToken).ConfigureAwait(false)) { queue.Enqueue(await selector(item, cancellationToken).ConfigureAwait(false)); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs index d65dfb2a98..b8d7c3ae39 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Finally.cs @@ -25,7 +25,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { try { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -54,7 +54,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { try { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs index 2668862057..83a75254df 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Generate.cs @@ -26,7 +26,7 @@ public static IAsyncEnumerable Generate(TState initial #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously async IAsyncEnumerator Core(CancellationToken cancellationToken) { - for (TState state = initialState; condition(state); state = iterate(state)) + for (var state = initialState; condition(state); state = iterate(state)) { // REVIEW: Check for cancellation? diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs index 954d28029b..0aba29e83a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Merge.cs @@ -184,7 +184,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { for (var i = 0; i < count; i++) { - IAsyncEnumerator enumerator = sources[i].GetAsyncEnumerator(cancellationToken); + var enumerator = sources[i].GetAsyncEnumerator(cancellationToken); enumerators[i] = enumerator; // REVIEW: This follows the lead of the original implementation where we kick off MoveNextAsync @@ -196,7 +196,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) moveNextTasks[i] = enumerator.MoveNextAsync().AsTask(); } - int active = count; + var active = count; while (active > 0) { @@ -211,9 +211,9 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) // the use of IndexOf may pick an element closer to the start of the array because of // reference equality checks and aliasing effects. See GetTaskForResult in the BCL. - int index = Array.IndexOf(moveNextTasks, moveNextTask); + var index = Array.IndexOf(moveNextTasks, moveNextTask); - IAsyncEnumerator enumerator = enumerators[index]; + var enumerator = enumerators[index]; if (!await moveNextTask.ConfigureAwait(false)) { @@ -229,7 +229,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } else { - TSource item = enumerator.Current; + var item = enumerator.Current; moveNextTasks[index] = enumerator.MoveNextAsync().AsTask(); @@ -252,8 +252,8 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) for (var i = count - 1; i >= 0; i--) { - Task moveNextTask = moveNextTasks[i]; - IAsyncEnumerator enumerator = enumerators[i]; + var moveNextTask = moveNextTasks[i]; + var enumerator = enumerators[i]; try { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs index 48128ca66b..e6d08eeb97 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Repeat.cs @@ -44,7 +44,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { while (true) { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -69,7 +69,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { for (var i = 0; i < count; i++) { - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 1b15e64850..e64feaaf46 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -36,7 +36,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield break; } - TSource res = e.Current; + var res = e.Current; while (await e.MoveNextAsync()) { @@ -67,9 +67,9 @@ public static IAsyncEnumerable Scan(this IAsy async IAsyncEnumerator Core(CancellationToken cancellationToken) { - TAccumulate res = seed; + var res = seed; - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { res = accumulator(res, item); @@ -102,7 +102,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield break; } - TSource res = e.Current; + var res = e.Current; while (await e.MoveNextAsync()) { @@ -143,7 +143,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield break; } - TSource res = e.Current; + var res = e.Current; while (await e.MoveNextAsync()) { @@ -175,9 +175,9 @@ public static IAsyncEnumerable Scan(this IAsy async IAsyncEnumerator Core(CancellationToken cancellationToken) { - TAccumulate res = seed; + var res = seed; - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { res = await accumulator(res, item).ConfigureAwait(false); @@ -202,9 +202,9 @@ public static IAsyncEnumerable Scan(this IAsy async IAsyncEnumerator Core(CancellationToken cancellationToken) { - TAccumulate res = seed; + var res = seed; - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { res = await accumulator(res, item, cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs index 60792729bb..40e7c452ad 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Using.cs @@ -25,9 +25,9 @@ public static IAsyncEnumerable Using(Func Core(CancellationToken cancellationToken) { - using (TResource resource = resourceFactory()) + using (var resource = resourceFactory()) { - await foreach (TSource item in enumerableFactory(resource).WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in enumerableFactory(resource).WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -50,9 +50,9 @@ public static IAsyncEnumerable Using(Func Core(CancellationToken cancellationToken) { - using (TResource resource = await resourceFactory().ConfigureAwait(false)) + using (var resource = await resourceFactory().ConfigureAwait(false)) { - await foreach (TSource item in (await enumerableFactory(resource).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in (await enumerableFactory(resource).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } @@ -76,9 +76,9 @@ public static IAsyncEnumerable Using(Func Core(CancellationToken cancellationToken) { - using (TResource resource = await resourceFactory(cancellationToken).ConfigureAwait(false)) + using (var resource = await resourceFactory(cancellationToken).ConfigureAwait(false)) { - await foreach (TSource item in (await enumerableFactory(resource, cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in (await enumerableFactory(resource, cancellationToken).ConfigureAwait(false)).WithCancellation(cancellationToken).ConfigureAwait(false)) { yield return item; } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index 678b90771a..df9624af9a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -112,7 +112,7 @@ internal static async Task> ToSet(IAsyncEnumerable source, IEqualit { var set = new Set(comparer); - await foreach (T item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index cb27ecc568..311e50c2f8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -133,7 +133,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAcc { var acc = _seed; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); } @@ -155,7 +155,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAcc { var acc = _seed; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); } @@ -178,7 +178,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAcc { var acc = _seed; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); } @@ -203,7 +203,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAccumul { var acc = _seed; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = _accumulator(acc, item); } @@ -227,7 +227,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAccumul { var acc = _seed; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item).ConfigureAwait(false); } @@ -252,7 +252,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAccumul { var acc = _seed; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { acc = await _accumulator(acc, item, _cancellationToken).ConfigureAwait(false); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 456164c289..6e596ce44d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -21,7 +21,7 @@ public static ValueTask AllAsync(this IAsyncEnumerable s static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!_predicate(item)) { @@ -44,7 +44,7 @@ public static ValueTask AllAsync(this IAsyncEnumerable s static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!await _predicate(item).ConfigureAwait(false)) { @@ -68,7 +68,7 @@ public static ValueTask AllAsync(this IAsyncEnumerable s static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (!await _predicate(item, _cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 8f8807a16f..96e107d9c5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -43,7 +43,7 @@ public static ValueTask AnyAsync(this IAsyncEnumerable s static async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_predicate(item)) { @@ -66,7 +66,7 @@ public static ValueTask AnyAsync(this IAsyncEnumerable s static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item).ConfigureAwait(false)) { @@ -90,7 +90,7 @@ public static ValueTask AnyAsync(this IAsyncEnumerable s static async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (await _predicate(item, _cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs index c870606e53..a1191c7aab 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs @@ -206,7 +206,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { - await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; ++index; @@ -234,7 +234,7 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(_item); } - await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); } @@ -395,7 +395,7 @@ public override async ValueTask ToArrayAsync(CancellationToken cancel } else { - await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { array[index] = item; ++index; @@ -421,7 +421,7 @@ public override async ValueTask> ToListAsync(CancellationToken can list.Add(n.Item); } - await foreach (TSource item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs index b89979ac81..25ca35bfe2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Concat.cs @@ -84,7 +84,7 @@ public async ValueTask> ToListAsync(CancellationToken cancellation break; } - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { list.Add(item); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs index 035acd5dc8..49737cf254 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Contains.cs @@ -28,7 +28,7 @@ public static ValueTask ContainsAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, TSource _value, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (EqualityComparer.Default.Equals(item, _value)) { @@ -45,7 +45,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TSource _va static async ValueTask Core(IAsyncEnumerable _source, TSource _value, IEqualityComparer _comparer, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_comparer.Equals(item, _value)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 1da8cb5fae..4db1fc2dc5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -32,7 +32,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellation { var count = 0; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked { @@ -57,7 +57,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, int _ind if (_index >= 0) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs index b5de954780..8e469a043b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ElementAtOrDefault.cs @@ -40,7 +40,7 @@ static async ValueTask Core(IAsyncEnumerable _source, int _ind } else { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { if (_index == 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 263d5d3698..718052b5e5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -28,7 +28,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Action _action, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item); } @@ -48,7 +48,7 @@ static async Task Core(IAsyncEnumerable _source, Action _ { var index = 0; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { _action(item, checked(index++)); } @@ -66,7 +66,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item).ConfigureAwait(false); } @@ -79,7 +79,7 @@ public static Task ForEachAsync(this IAsyncEnumerable source, static async Task Core(IAsyncEnumerable _source, Func _action, CancellationToken _cancellationToken) { - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { await _action(item, _cancellationToken).ConfigureAwait(false); } @@ -99,7 +99,7 @@ static async Task Core(IAsyncEnumerable _source, Func _source, Func> Core(IAsyncEnumerable _source, C var last = default(TSource); var hasLast = false; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { hasLast = true; last = item; @@ -119,7 +119,7 @@ private static async ValueTask> TryGetLast(IAsyncEnumera var last = default(TSource); var hasLast = false; - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { if (predicate(item)) { @@ -136,7 +136,7 @@ private static async ValueTask> TryGetLast(IAsyncEnumera var last = default(TSource); var hasLast = false; - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { if (await predicate(item).ConfigureAwait(false)) { @@ -154,7 +154,7 @@ private static async ValueTask> TryGetLast(IAsyncEnumera var last = default(TSource); var hasLast = false; - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { if (await predicate(item, cancellationToken).ConfigureAwait(false)) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 1a10566cae..285be6b997 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -21,7 +21,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellatio { var count = 0L; - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { checked { @@ -46,7 +46,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> CreateAsync(IAsyncEn var lookup = new Lookup(comparer); - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); var group = lookup.GetGrouping(key, create: true); @@ -110,7 +110,7 @@ internal static async Task> CreateAsync(IAsyncEnumerable< var lookup = new Lookup(comparer); - await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); lookup.GetGrouping(key, create: true).Add(item); @@ -123,7 +123,7 @@ internal static async Task> CreateForJoinAsync(IAsyncEnum { var lookup = new Lookup(comparer); - await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = keySelector(item); if (key != null) @@ -356,7 +356,7 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); var group = lookup.GetGrouping(key, create: true); @@ -377,7 +377,7 @@ internal static async Task> CreateAsync( var lookup = new LookupWithTask(comparer); - await foreach (TSource item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); var group = lookup.GetGrouping(key, create: true); @@ -397,7 +397,7 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); - await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(item); @@ -414,7 +414,7 @@ internal static async Task> CreateAsync(IAsyncEnu var lookup = new LookupWithTask(comparer); - await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); lookup.GetGrouping(key, create: true).Add(item); @@ -428,7 +428,7 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); - await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item).ConfigureAwait(false); if (key != null) @@ -445,7 +445,7 @@ internal static async Task> CreateForJoinAsync(IA { var lookup = new LookupWithTask(comparer); - await foreach (TElement item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in source.WithCancellation(cancellationToken).ConfigureAwait(false)) { var key = await keySelector(item, cancellationToken).ConfigureAwait(false); if (key != null) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index 0009a32db0..1f838a50ee 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -273,15 +273,15 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance return new Maybe(); } - TElement value = e.Current; + var value = e.Current; - AsyncCachingComparer comparer = GetComparer(); + var comparer = GetComparer(); await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync()) { - TElement x = e.Current; + var x = e.Current; if (await comparer.Compare(x, cacheLower: true, cancellationToken).ConfigureAwait(false) < 0) { @@ -308,15 +308,15 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel return new Maybe(); } - TElement value = e.Current; + var value = e.Current; - AsyncCachingComparer comparer = GetComparer(); + var comparer = GetComparer(); await comparer.SetElement(value, cancellationToken).ConfigureAwait(false); while (await e.MoveNextAsync()) { - TElement current = e.Current; + var current = e.Current; if (await comparer.Compare(current, cacheLower: false, cancellationToken).ConfigureAwait(false) >= 0) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index c19b2d2df9..b806831e89 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -34,9 +34,9 @@ public static ValueTask SequenceEqualAsync(this IAsyncEnumerable< if (firstCol is IList firstList && secondCol is IList secondList) { - int count = firstCol.Count; + var count = firstCol.Count; - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { if (!comparer.Equals(firstList[i], secondList[i])) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 4e36ebdf1a..0260603008 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -26,7 +26,7 @@ static async ValueTask> Core(IAsyncEnumerable { var d = new Dictionary(_comparer); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); @@ -53,7 +53,7 @@ static async ValueTask> Core(IAsyncEnumerable { var d = new Dictionary(_comparer); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); @@ -81,7 +81,7 @@ static async ValueTask> Core(IAsyncEnumerable { var d = new Dictionary(_comparer); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); @@ -111,7 +111,7 @@ static async ValueTask> Core(IAsyncEnumerable(_comparer); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = _keySelector(item); var value = _elementSelector(item); @@ -141,7 +141,7 @@ static async ValueTask> Core(IAsyncEnumerable(_comparer); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item).ConfigureAwait(false); var value = await _elementSelector(item).ConfigureAwait(false); @@ -172,7 +172,7 @@ static async ValueTask> Core(IAsyncEnumerable(_comparer); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { var key = await _keySelector(item, _cancellationToken).ConfigureAwait(false); var value = await _elementSelector(item, _cancellationToken).ConfigureAwait(false); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs index 80b4d48362..009533a450 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToHashSet.cs @@ -24,7 +24,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, { var set = new HashSet(_comparer); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { set.Add(item); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs index e9d48664ed..7e5537e21f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs @@ -24,7 +24,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, Ca { var list = new List(); - await foreach (TSource item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) + await foreach (var item in _source.WithCancellation(_cancellationToken).ConfigureAwait(false)) { list.Add(item); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs index e938cd6e5b..338da0ed4e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Union.cs @@ -162,7 +162,7 @@ private async Task> FillSetAsync(CancellationToken cancellationToke return set; } - await foreach (TSource item in enumerable.WithCancellation(cancellationToken).ConfigureAwait(false)) + await foreach (var item in enumerable.WithCancellation(cancellationToken).ConfigureAwait(false)) { set.Add(item); } From 50ae7fe6199e4fe550fe409007a2b3d7b503111b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 13 Feb 2019 16:46:44 -0800 Subject: [PATCH 746/862] Update comment to use `await using`. --- .../System/Linq/Operators/Amb.cs | 6 +- .../System/Linq/Operators/Catch.cs | 8 +- .../Linq/Operators/DistinctUntilChanged.cs | 8 +- .../System/Linq/Operators/Do.cs | 6 +- .../System/Linq/Operators/IsEmpty.cs | 2 +- .../System/Linq/Operators/Max.cs | 2 +- .../System/Linq/Operators/Min.cs | 2 +- .../System/Linq/Operators/MinBy.cs | 6 +- .../System/Linq/Operators/Scan.cs | 6 +- .../System/Linq/AsyncEnumerableHelpers.cs | 2 +- .../System/Linq/Operators/Aggregate.cs | 6 +- .../System/Linq/Operators/Any.cs | 2 +- .../Linq/Operators/Average.Generated.cs | 80 ++++----- .../System/Linq/Operators/FirstOrDefault.cs | 8 +- .../System/Linq/Operators/GroupJoin.cs | 6 +- .../System/Linq/Operators/Join.cs | 6 +- .../System/Linq/Operators/Max.cs | 16 +- .../System/Linq/Operators/Min.cs | 16 +- .../System/Linq/Operators/MinMax.Generated.cs | 160 +++++++++--------- .../Linq/Operators/OrderedAsyncEnumerable.cs | 4 +- .../System/Linq/Operators/SequenceEqual.cs | 4 +- .../System/Linq/Operators/Single.cs | 8 +- .../System/Linq/Operators/SingleOrDefault.cs | 8 +- .../System/Linq/Operators/SkipLast.cs | 2 +- .../System/Linq/Operators/SkipWhile.cs | 12 +- .../System/Linq/Operators/TakeLast.cs | 2 +- .../System/Linq/Operators/Zip.cs | 12 +- 27 files changed, 200 insertions(+), 200 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index 6ad9c47020..d84e7b134e 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -95,7 +95,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) try { - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await moveNextWinner.ConfigureAwait(false)) { @@ -208,7 +208,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) try { - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await moveNextWinner.ConfigureAwait(false)) { @@ -254,7 +254,7 @@ private static async Task AwaitMoveNextAsyncAndDispose(Task moveNextAsy { if (enumerator != null) { - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (moveNextAsync != null) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index f21c803f6e..1034af31ac 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -41,7 +41,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (true) { @@ -105,7 +105,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (true) { @@ -170,7 +170,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (true) { @@ -250,7 +250,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { error = null; diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index f151ca8d4d..55118b8385 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -105,7 +105,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -152,7 +152,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -203,7 +203,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -255,7 +255,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index f731896045..860b536979 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -178,7 +178,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (true) { @@ -229,7 +229,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (true) { @@ -284,7 +284,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (true) { diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index cc57d60a40..98f729adc2 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -21,7 +21,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellatio { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { return !await e.MoveNextAsync(); } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 2d2266b230..1628e12478 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -26,7 +26,7 @@ static async ValueTask Core(IAsyncEnumerable _source, ICompare var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) throw Error.NoElements(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index ae8e72d0b0..e94091e2b6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -26,7 +26,7 @@ static async ValueTask Core(IAsyncEnumerable _source, ICompare var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) throw Error.NoElements(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 4a6b5a7139..0808586dba 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -112,7 +112,7 @@ private static async ValueTask> ExtremaBy(IAsyncEn var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -153,7 +153,7 @@ private static async ValueTask> ExtremaBy(IAsyncEn var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -195,7 +195,7 @@ private static async ValueTask> ExtremaBy(IAsyncEn var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) throw Error.NoElements(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index e64feaaf46..9fb094a669 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -29,7 +29,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -95,7 +95,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -136,7 +136,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index df9624af9a..ec1622b414 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -46,7 +46,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE { var en = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await en.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 311e50c2f8..939414912b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -23,7 +23,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellatio { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { return await e.MoveNextAsync(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 453e5bbd5d..3d9cbf8347 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -21,7 +21,7 @@ static async ValueTask Core(IAsyncEnumerable _source, CancellationT { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -61,7 +61,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellation { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -221,7 +221,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellation { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -381,7 +381,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellati { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -541,7 +541,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancella { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -701,7 +701,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> Core(IAsyncEnumerable _source, C { var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await e.MoveNextAsync()) { @@ -122,7 +122,7 @@ private static async ValueTask> TryGetFirst(IAsyncEnumer { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e.MoveNextAsync()) { @@ -146,7 +146,7 @@ private static async ValueTask> TryGetFirst(IAsyncEnumer { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e.MoveNextAsync()) { @@ -171,7 +171,7 @@ private static async ValueTask> TryGetFirst(IAsyncEnumer { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 235b753bd9..da3943d8e9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -33,7 +33,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await e.MoveNextAsync()) { @@ -81,7 +81,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await e.MoveNextAsync()) { @@ -130,7 +130,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 3c4a27e920..4889b6d66c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -34,7 +34,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await e.MoveNextAsync()) { @@ -98,7 +98,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await e.MoveNextAsync()) { @@ -163,7 +163,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 66a3b92de6..f65cc06cf3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -27,7 +27,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { do { @@ -70,7 +70,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -117,7 +117,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancella var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { do { @@ -70,7 +70,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -118,7 +118,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToke var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -65,7 +65,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTo var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -557,7 +557,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellation var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -1064,7 +1064,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellati var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -1600,7 +1600,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancella var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -2121,7 +2121,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToke var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -2509,7 +2509,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTo var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -2905,7 +2905,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellation var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -3317,7 +3317,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellati var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -3841,7 +3841,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancella var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -4349,7 +4349,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> TryGetFirstAsync(CancellationToken cance { var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -301,7 +301,7 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel { var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index b806831e89..52813ef8ec 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -54,11 +54,11 @@ static async ValueTask Core(IAsyncEnumerable _first, IAsyncEnumer { var e1 = _first.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { var e2 = _second.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e1.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 723c7785ae..4e90cf15d7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -32,7 +32,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -68,7 +68,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { @@ -68,7 +68,7 @@ async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(CancellationToken cancellationToken) var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 1f43f4c0a7..84820f1e4c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -25,7 +25,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e.MoveNextAsync()) { @@ -68,7 +68,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { var index = -1; @@ -118,7 +118,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e.MoveNextAsync()) { @@ -162,7 +162,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e.MoveNextAsync()) { @@ -206,7 +206,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { var index = -1; @@ -257,7 +257,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { var index = -1; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 365cb090a4..3d54b780d2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -30,7 +30,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { if (!await e.MoveNextAsync()) { diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 1b18004e5e..33039a1007 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -27,11 +27,11 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { @@ -69,11 +69,11 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { @@ -112,11 +112,11 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { From 0171e2bad00094d37e03b80696f179a58b3e4c52 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 13 Feb 2019 18:13:16 -0800 Subject: [PATCH 747/862] Use await using which now can bind to configured tasks. --- .../System/Linq/Operators/Amb.cs | 18 +- .../System/Linq/Operators/Catch.cs | 32 +- .../Linq/Operators/DistinctUntilChanged.cs | 32 +- .../System/Linq/Operators/Do.cs | 24 +- .../System/Linq/Operators/IsEmpty.cs | 8 +- .../System/Linq/Operators/Max.cs | 8 +- .../System/Linq/Operators/Min.cs | 8 +- .../System/Linq/Operators/MinBy.cs | 24 +- .../System/Linq/Operators/Scan.cs | 24 +- .../System/Linq/AsyncEnumerableHelpers.cs | 8 +- .../System/Linq/Operators/Aggregate.cs | 24 +- .../System/Linq/Operators/Any.cs | 8 +- .../Linq/Operators/Average.Generated.cs | 320 ++------- .../Linq/Operators/Average.Generated.tt | 64 +- .../System/Linq/Operators/FirstOrDefault.cs | 32 +- .../System/Linq/Operators/GroupJoin.cs | 24 +- .../System/Linq/Operators/Join.cs | 24 +- .../System/Linq/Operators/Max.cs | 64 +- .../System/Linq/Operators/Min.cs | 64 +- .../System/Linq/Operators/MinMax.Generated.cs | 640 +++--------------- .../System/Linq/Operators/MinMax.Generated.tt | 32 +- .../Linq/Operators/OrderedAsyncEnumerable.cs | 16 +- .../System/Linq/Operators/SequenceEqual.cs | 16 +- .../System/Linq/Operators/Single.cs | 32 +- .../System/Linq/Operators/SingleOrDefault.cs | 32 +- .../System/Linq/Operators/SkipLast.cs | 8 +- .../System/Linq/Operators/SkipWhile.cs | 48 +- .../System/Linq/Operators/TakeLast.cs | 8 +- .../System/Linq/Operators/Zip.cs | 48 +- 29 files changed, 212 insertions(+), 1478 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs index d84e7b134e..394e1abb0c 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Amb.cs @@ -95,7 +95,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) try { - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (winner.ConfigureAwait(false)) { if (!await moveNextWinner.ConfigureAwait(false)) { @@ -109,10 +109,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return winner.Current; } } - finally - { - await winner.DisposeAsync().ConfigureAwait(false); - } } finally { @@ -208,7 +204,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) try { - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (winner.ConfigureAwait(false)) { if (!await moveNextWinner.ConfigureAwait(false)) { @@ -222,10 +218,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return winner.Current; } } - finally - { - await winner.DisposeAsync().ConfigureAwait(false); - } } finally { @@ -254,17 +246,13 @@ private static async Task AwaitMoveNextAsyncAndDispose(Task moveNextAsy { if (enumerator != null) { - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (enumerator.ConfigureAwait(false)) { if (moveNextAsync != null) { await moveNextAsync.ConfigureAwait(false); } } - finally - { - await enumerator.DisposeAsync().ConfigureAwait(false); - } } } #endif diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs index 1034af31ac..b08ea8afd3 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Catch.cs @@ -39,9 +39,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (true) { @@ -63,10 +61,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return c; } } - finally - { - await e.DisposeAsync(); - } if (err != null) { @@ -103,9 +97,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (true) { @@ -127,10 +119,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return c; } } - finally - { - await e.DisposeAsync(); - } if (err != null) { @@ -168,9 +156,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) var err = default(IAsyncEnumerable); - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (true) { @@ -192,10 +178,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return c; } } - finally - { - await e.DisposeAsync(); - } if (err != null) { @@ -248,9 +230,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) foreach (var source in sources) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { error = null; @@ -277,10 +257,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) if (error == null) break; } - finally - { - await e.DisposeAsync(); - } } error?.Throw(); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs index 55118b8385..f3545829d5 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs @@ -103,9 +103,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore(IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -128,10 +126,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new DistinctUntilChangedAsyncIterator(source, comparer); @@ -150,9 +144,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -179,10 +171,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new DistinctUntilChangedAsyncIterator(source, keySelector, comparer); @@ -201,9 +189,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -230,10 +216,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new DistinctUntilChangedAsyncIteratorWithTask(source, keySelector, comparer); @@ -253,9 +235,7 @@ private static IAsyncEnumerable DistinctUntilChangedCore async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -282,10 +262,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new DistinctUntilChangedAsyncIteratorWithTaskAndCancellation(source, keySelector, comparer); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs index 860b536979..19ee9e02c6 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Do.cs @@ -176,9 +176,7 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (true) { @@ -210,10 +208,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) onCompleted?.Invoke(); } - finally - { - await e.DisposeAsync(); - } } #else return new DoAsyncIterator(source, onNext, onError, onCompleted); @@ -227,9 +221,7 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (true) { @@ -264,10 +256,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) await onCompleted().ConfigureAwait(false); } } - finally - { - await e.DisposeAsync(); - } } #else return new DoAsyncIteratorWithTask(source, onNext, onError, onCompleted); @@ -282,9 +270,7 @@ private static IAsyncEnumerable DoCore(IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (true) { @@ -319,10 +305,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) await onCompleted(cancellationToken).ConfigureAwait(false); } } - finally - { - await e.DisposeAsync(); - } } #else return new DoAsyncIteratorWithTaskAndCancellation(source, onNext, onError, onCompleted); diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs index 98f729adc2..1628bdef32 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/IsEmpty.cs @@ -19,16 +19,10 @@ public static ValueTask IsEmptyAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { return !await e.MoveNextAsync(); } - finally - { - await e.DisposeAsync(); - } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs index 1628e12478..99931b9e2a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Max.cs @@ -24,9 +24,7 @@ static async ValueTask Core(IAsyncEnumerable _source, ICompare _comparer = Comparer.Default; } - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -45,10 +43,6 @@ static async ValueTask Core(IAsyncEnumerable _source, ICompare return max; } - finally - { - await e.DisposeAsync(); - } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs index e94091e2b6..c8581ad542 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Min.cs @@ -24,9 +24,7 @@ static async ValueTask Core(IAsyncEnumerable _source, ICompare _comparer = Comparer.Default; } - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -45,10 +43,6 @@ static async ValueTask Core(IAsyncEnumerable _source, ICompare return min; } - finally - { - await e.DisposeAsync(); - } } } } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs index 0808586dba..c97e8d4455 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/MinBy.cs @@ -110,9 +110,7 @@ private static async ValueTask> ExtremaBy(IAsyncEn { var result = new List(); - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -139,10 +137,6 @@ private static async ValueTask> ExtremaBy(IAsyncEn } } } - finally - { - await e.DisposeAsync(); - } return result; } @@ -151,9 +145,7 @@ private static async ValueTask> ExtremaBy(IAsyncEn { var result = new List(); - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -180,10 +172,6 @@ private static async ValueTask> ExtremaBy(IAsyncEn } } } - finally - { - await e.DisposeAsync(); - } return result; } @@ -193,9 +181,7 @@ private static async ValueTask> ExtremaBy(IAsyncEn { var result = new List(); - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) throw Error.NoElements(); @@ -222,10 +208,6 @@ private static async ValueTask> ExtremaBy(IAsyncEn } } } - finally - { - await e.DisposeAsync(); - } return result; } diff --git a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs index 9fb094a669..4e6f9c9102 100644 --- a/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs +++ b/Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Scan.cs @@ -27,9 +27,7 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -45,10 +43,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return res; } } - finally - { - await e.DisposeAsync(); - } } #else return new ScanAsyncEnumerable(source, accumulator); @@ -93,9 +87,7 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -111,10 +103,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return res; } } - finally - { - await e.DisposeAsync(); - } } #else return new ScanAsyncEnumerableWithTask(source, accumulator); @@ -134,9 +122,7 @@ public static IAsyncEnumerable Scan(this IAsyncEnumerable Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -152,10 +138,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) yield return res; } } - finally - { - await e.DisposeAsync(); - } } #else return new ScanAsyncEnumerableWithTaskAndCancellation(source, accumulator); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs index ec1622b414..d3ad271a03 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerableHelpers.cs @@ -44,9 +44,7 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE } else { - var en = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var en = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (await en.MoveNextAsync()) { @@ -93,10 +91,6 @@ internal static async ValueTask> ToArrayWithLength(IAsyncE return result; } } - finally - { - await en.DisposeAsync(); - } } result.Length = 0; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index 939414912b..8f8009cffa 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -21,9 +21,7 @@ public static ValueTask AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _accumulator, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -39,10 +37,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -75,10 +67,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _accumulator, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -112,10 +98,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable s static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { return await e.MoveNextAsync(); } - finally - { - await e.DisposeAsync(); - } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 3d9cbf8347..2791bf78f5 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -19,9 +19,7 @@ public static ValueTask AverageAsync(this IAsyncEnumerable source, static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -41,10 +39,6 @@ static async ValueTask Core(IAsyncEnumerable _source, CancellationT return (double)sum / count; } - finally - { - await e.DisposeAsync(); - } } } @@ -59,9 +53,7 @@ public static ValueTask AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -81,10 +73,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -121,10 +107,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -162,10 +142,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -201,10 +175,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellation return (double)sum / count; } - finally - { - await e.DisposeAsync(); - } } } @@ -219,9 +189,7 @@ public static ValueTask AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -241,10 +209,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -281,10 +243,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -322,10 +278,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -361,10 +311,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellation return (float)(sum / count); } - finally - { - await e.DisposeAsync(); - } } } @@ -379,9 +325,7 @@ public static ValueTask AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -401,10 +345,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -441,10 +379,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -482,10 +414,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable sourc static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -521,10 +447,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellati return sum / count; } - finally - { - await e.DisposeAsync(); - } } } @@ -539,9 +461,7 @@ public static ValueTask AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -561,10 +481,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -601,10 +515,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -642,10 +550,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable sou static async ValueTask Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -681,10 +583,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella return sum / count; } - finally - { - await e.DisposeAsync(); - } } } @@ -699,9 +597,7 @@ public static ValueTask AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -721,10 +617,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -761,10 +651,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -802,10 +686,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -847,10 +725,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -895,10 +767,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -943,10 +809,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -992,10 +852,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1039,10 +893,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1087,10 +935,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1135,10 +977,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1184,10 +1020,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1231,10 +1061,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1279,10 +1103,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1327,10 +1145,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1376,10 +1188,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1423,10 +1229,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1471,10 +1271,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1519,10 +1313,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1568,10 +1356,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1615,10 +1397,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1663,10 +1439,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1711,10 +1481,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func> _selector, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -1760,10 +1524,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -86,10 +84,6 @@ if (isNullable) } } } - finally - { - await e.DisposeAsync(); - } return null; <# @@ -97,9 +91,7 @@ if (isNullable) else { #> - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -119,10 +111,6 @@ else return <#=res#>; } - finally - { - await e.DisposeAsync(); - } <# } #> @@ -144,9 +132,7 @@ else if (isNullable) { #> - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -172,10 +158,6 @@ if (isNullable) } } } - finally - { - await e.DisposeAsync(); - } return null; <# @@ -183,9 +165,7 @@ if (isNullable) else { #> - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -205,10 +185,6 @@ else return <#=res#>; } - finally - { - await e.DisposeAsync(); - } <# } #> @@ -230,9 +206,7 @@ else if (isNullable) { #> - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -258,10 +232,6 @@ if (isNullable) } } } - finally - { - await e.DisposeAsync(); - } return null; <# @@ -269,9 +239,7 @@ if (isNullable) else { #> - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -291,10 +259,6 @@ else return <#=res#>; } - finally - { - await e.DisposeAsync(); - } <# } #> @@ -317,9 +281,7 @@ else if (isNullable) { #> - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -345,10 +307,6 @@ if (isNullable) } } } - finally - { - await e.DisposeAsync(); - } return null; <# @@ -356,9 +314,7 @@ if (isNullable) else { #> - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -378,10 +334,6 @@ else return <#=res#>; } - finally - { - await e.DisposeAsync(); - } <# } #> diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index ddea9d150c..beda3cd221 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -97,19 +97,13 @@ private static ValueTask> TryGetFirst(IAsyncEnumerable> Core(IAsyncEnumerable _source, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (await e.MoveNextAsync()) { return new Maybe(e.Current); } } - finally - { - await e.DisposeAsync(); - } return new Maybe(); } @@ -120,9 +114,7 @@ static async ValueTask> Core(IAsyncEnumerable _source, C private static async ValueTask> TryGetFirst(IAsyncEnumerable source, Func predicate, CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -134,19 +126,13 @@ private static async ValueTask> TryGetFirst(IAsyncEnumer } } } - finally - { - await e.DisposeAsync(); - } return new Maybe(); } private static async ValueTask> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -158,10 +144,6 @@ private static async ValueTask> TryGetFirst(IAsyncEnumer } } } - finally - { - await e.DisposeAsync(); - } return new Maybe(); } @@ -169,9 +151,7 @@ private static async ValueTask> TryGetFirst(IAsyncEnumer #if !NO_DEEP_CANCELLATION private static async ValueTask> TryGetFirst(IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -183,10 +163,6 @@ private static async ValueTask> TryGetFirst(IAsyncEnumer } } } - finally - { - await e.DisposeAsync(); - } return new Maybe(); } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index da3943d8e9..7ff5a73d5e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -31,9 +31,7 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (await e.MoveNextAsync()) { @@ -48,10 +46,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (await e.MoveNextAsync()); } } - finally - { - await e.DisposeAsync(); - } } #else return new GroupJoinAsyncEnumerable(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -79,9 +73,7 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (await e.MoveNextAsync()) { @@ -96,10 +88,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (await e.MoveNextAsync()); } } - finally - { - await e.DisposeAsync(); - } } #else return new GroupJoinAsyncEnumerableWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -128,9 +116,7 @@ public static IAsyncEnumerable GroupJoin async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (await e.MoveNextAsync()) { @@ -145,10 +131,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) while (await e.MoveNextAsync()); } } - finally - { - await e.DisposeAsync(); - } } #else return new GroupJoinAsyncEnumerableWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index 4889b6d66c..ad2f454330 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -32,9 +32,7 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (await e.MoveNextAsync()) { @@ -65,10 +63,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new JoinAsyncIterator(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -96,9 +90,7 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (await e.MoveNextAsync()) { @@ -129,10 +121,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new JoinAsyncIteratorWithTask(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); @@ -161,9 +149,7 @@ public static IAsyncEnumerable Join(this async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = outer.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (await e.MoveNextAsync()) { @@ -194,10 +180,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new JoinAsyncIteratorWithTaskAndCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index f65cc06cf3..97b6a3d763 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -25,9 +25,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella var value = default(TSource); - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { do { @@ -50,10 +48,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -68,9 +62,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella var value = default(TSource); - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -88,10 +80,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -115,9 +103,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancella var value = default(TSource); - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { do { @@ -50,10 +48,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -68,9 +62,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella var value = default(TSource); - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -89,10 +81,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -116,9 +104,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToke { int value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -41,10 +39,6 @@ static async ValueTask Core(IAsyncEnumerable _source, CancellationToke } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -63,9 +57,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTo { long value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -533,10 +483,6 @@ static async ValueTask Core(IAsyncEnumerable _source, CancellationTo } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -555,9 +501,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellation { float value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -1040,10 +942,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellation } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -1062,9 +960,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellati { double value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -1576,10 +1430,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellati } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -1598,9 +1448,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancella { decimal value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -2097,10 +1903,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -2119,9 +1921,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationToke { int value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -2485,10 +2243,6 @@ static async ValueTask Core(IAsyncEnumerable _source, CancellationToke } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -2507,9 +2261,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTo { long value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -2881,10 +2591,6 @@ static async ValueTask Core(IAsyncEnumerable _source, CancellationTo } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -2903,9 +2609,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellation { float value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -3293,10 +2955,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellation } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -3315,9 +2973,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancellati { double value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -3817,10 +3431,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancellati } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -3839,9 +3449,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Cancella { decimal value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -4325,10 +3891,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella } } } - finally - { - await e.DisposeAsync(); - } return value; } @@ -4347,9 +3909,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, Func <#=t#> value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -108,10 +106,6 @@ foreach (var m in new[] { "Max", "Min" }) #> } } - finally - { - await e.DisposeAsync(); - } return value; <# @@ -121,9 +115,7 @@ foreach (var m in new[] { "Max", "Min" }) #> <#=t#> value = null; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -277,10 +269,6 @@ foreach (var m in new[] { "Max", "Min" }) } #> } - finally - { - await e.DisposeAsync(); - } return value; <# @@ -322,9 +310,7 @@ foreach (var overload in new[] { #> <#=t#> value; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -387,10 +373,6 @@ foreach (var overload in new[] { #> } } - finally - { - await e.DisposeAsync(); - } return value; <# @@ -400,9 +382,7 @@ foreach (var overload in new[] { #> <#=t#> value = null; - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // REVIEW: Can use `await using` if we get pattern bind (HAS_AWAIT_USING_PATTERN_BIND) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { // Start off knowing that we've a non-null value (or exit here, knowing we don't) // so we don't have to keep testing for nullity. @@ -556,10 +536,6 @@ foreach (var overload in new[] { } #> } - finally - { - await e.DisposeAsync(); - } return value; <# diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs index b708d682de..5404dad2f4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderedAsyncEnumerable.cs @@ -264,9 +264,7 @@ private ValueTask SortedMap(TElement[] elements, int count, int minIndexI public async ValueTask> TryGetFirstAsync(CancellationToken cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -291,17 +289,11 @@ public async ValueTask> TryGetFirstAsync(CancellationToken cance return new Maybe(value); } - finally - { - await e.DisposeAsync(); - } } public async ValueTask> TryGetLastAsync(CancellationToken cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -326,10 +318,6 @@ public async ValueTask> TryGetLastAsync(CancellationToken cancel return new Maybe(value); } - finally - { - await e.DisposeAsync(); - } } internal async ValueTask> TryGetLastAsync(int minIndexInclusive, int maxIndexInclusive, CancellationToken cancellationToken) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs index 52813ef8ec..fc2a727144 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SequenceEqual.cs @@ -52,13 +52,9 @@ public static ValueTask SequenceEqualAsync(this IAsyncEnumerable< static async ValueTask Core(IAsyncEnumerable _first, IAsyncEnumerable _second, IEqualityComparer _comparer, CancellationToken _cancellationToken) { - var e1 = _first.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e1 = _first.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { - var e2 = _second.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e2 = _second.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e1.MoveNextAsync()) { @@ -70,14 +66,6 @@ static async ValueTask Core(IAsyncEnumerable _first, IAsyncEnumer return !await e2.MoveNextAsync(); } - finally - { - await e2.DisposeAsync(); - } - } - finally - { - await e1.DisposeAsync(); } } } diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 4e90cf15d7..f248d45a33 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -30,9 +30,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella throw Error.MoreThanOneElement(); } - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -48,10 +46,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Cancella return result; } - finally - { - await e.DisposeAsync(); - } } } @@ -66,9 +60,7 @@ public static ValueTask SingleAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -88,10 +80,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -130,10 +116,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -173,10 +153,6 @@ static async ValueTask Core(IAsyncEnumerable _source, Func Core(IAsyncEnumerable _source, CancellationTok throw Error.MoreThanOneElement(); } - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -46,10 +44,6 @@ async ValueTask Core(IAsyncEnumerable _source, CancellationTok return result; } } - finally - { - await e.DisposeAsync(); - } throw Error.MoreThanOneElement(); } @@ -66,9 +60,7 @@ public static ValueTask SingleOrDefaultAsync(this IAsyncEnumer async ValueTask Core(IAsyncEnumerable _source, Func _predicate, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -88,10 +80,6 @@ async ValueTask Core(IAsyncEnumerable _source, Func SingleOrDefaultAsync(this IAsyncEnumer async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -130,10 +116,6 @@ async ValueTask Core(IAsyncEnumerable _source, Func SingleOrDefaultAsync(this IAsyncEnumer async ValueTask Core(IAsyncEnumerable _source, Func> _predicate, CancellationToken _cancellationToken) { - var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = _source.GetConfiguredAsyncEnumerator(_cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -173,10 +153,6 @@ async ValueTask Core(IAsyncEnumerable _source, Func Core(CancellationToken cancellationToken) { var queue = new Queue(); - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -57,10 +55,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new SkipLastAsyncIterator(source, count); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 84820f1e4c..d32af56f85 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -23,9 +23,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -44,10 +42,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new SkipWhileAsyncIterator(source, predicate); @@ -66,9 +60,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { var index = -1; @@ -94,10 +86,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new SkipWhileWithIndexAsyncIterator(source, predicate); @@ -116,9 +104,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -137,10 +123,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new SkipWhileAsyncIteratorWithTask(source, predicate); @@ -160,9 +142,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e.MoveNextAsync()) { @@ -181,10 +161,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new SkipWhileAsyncIteratorWithTaskAndCancellation(source, predicate); @@ -204,9 +180,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { var index = -1; @@ -232,10 +206,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new SkipWhileWithIndexAsyncIteratorWithTask(source, predicate); @@ -255,9 +225,7 @@ public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { var index = -1; @@ -283,10 +251,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } } #else return new SkipWhileWithIndexAsyncIteratorWithTaskAndCancellation(source, predicate); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs index 3d54b780d2..e5cc370394 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeLast.cs @@ -28,9 +28,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) { Queue queue; - var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e = source.GetConfiguredAsyncEnumerator(cancellationToken, false)) { if (!await e.MoveNextAsync()) { @@ -58,10 +56,6 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } } } - finally - { - await e.DisposeAsync(); - } Debug.Assert(queue.Count <= count); do diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 33039a1007..01984ae609 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -25,27 +25,15 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false)) { - var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { yield return selector(e1.Current, e2.Current); } } - finally - { - await e2.DisposeAsync(); - } - } - finally - { - await e1.DisposeAsync(); } } #else @@ -67,27 +55,15 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false)) { - var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { yield return await selector(e1.Current, e2.Current).ConfigureAwait(false); } } - finally - { - await e2.DisposeAsync(); - } - } - finally - { - await e1.DisposeAsync(); } } #else @@ -110,27 +86,15 @@ public static IAsyncEnumerable Zip(this IAsyn async IAsyncEnumerator Core(CancellationToken cancellationToken) { - var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false)) { - var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false); - - try // TODO: Switch to `await using` in preview 3 (https://github.com/dotnet/roslyn/pull/32731) + await using (var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false)) { while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) { yield return await selector(e1.Current, e2.Current, cancellationToken).ConfigureAwait(false); } } - finally - { - await e2.DisposeAsync(); - } - } - finally - { - await e1.DisposeAsync(); } } #else From 318a9d9d78398637dbd8be26ffbea9db1de1a0da Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Mon, 18 Feb 2019 08:02:57 -0500 Subject: [PATCH 748/862] Update global.json to use latest .NET Core 3 SDK available --- Ix.NET/Source/global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index 8a82c8d690..50c5a4d98e 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.0.100-preview-010184" + "version": "3.0.100-preview" }, "msbuild-sdks": { "MSBuild.Sdk.Extras": "2.0.0-preview.14" From 1af499f2382155155123cbf70b695ee32e1333f9 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Mon, 18 Feb 2019 08:22:29 -0500 Subject: [PATCH 749/862] use latest .NET Core 3 SDK --- Ix.NET/Source/global.json | 4 ++-- azure-pipelines.ix.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index 50c5a4d98e..385f7404b9 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -1,8 +1,8 @@ { "sdk": { - "version": "3.0.100-preview" + "version": "3.0.100-preview4" }, "msbuild-sdks": { - "MSBuild.Sdk.Extras": "2.0.0-preview.14" + "MSBuild.Sdk.Extras": "2.0.0-preview.17" } } diff --git a/azure-pipelines.ix.yml b/azure-pipelines.ix.yml index b80f107f92..8e4397da0d 100644 --- a/azure-pipelines.ix.yml +++ b/azure-pipelines.ix.yml @@ -30,7 +30,7 @@ variables: steps: - task: DotNetCoreInstaller@0 inputs: - version: '3.0.100-preview-010184' + version: '3.0.100-preview4-010374' - task: DotNetCoreCLI@2 inputs: From e6ee66f396d7747cc7b208f6467637c86896c027 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Mon, 18 Feb 2019 08:38:24 -0500 Subject: [PATCH 750/862] use .14 --- Ix.NET/Source/global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/global.json b/Ix.NET/Source/global.json index 385f7404b9..fb2687ba6d 100644 --- a/Ix.NET/Source/global.json +++ b/Ix.NET/Source/global.json @@ -3,6 +3,6 @@ "version": "3.0.100-preview4" }, "msbuild-sdks": { - "MSBuild.Sdk.Extras": "2.0.0-preview.17" + "MSBuild.Sdk.Extras": "2.0.0-preview.14" } } From 1557b303efad620a73f24ded3b2353b56a0aafd1 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Mon, 18 Feb 2019 09:03:06 -0500 Subject: [PATCH 751/862] Update test deps --- Ix.NET/Source/Directory.build.props | 7 +------ Ix.NET/Source/Directory.build.targets | 2 +- .../System.Interactive.Tests.csproj | 6 +++--- .../System/Linq/Operators/Buffer.cs | 2 +- .../System.Linq.Async.Queryable.Tests.csproj | 6 +++--- .../System.Linq.Async.Queryable.csproj | 6 +----- .../System.Linq.Async.Tests.csproj | 6 +++--- Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj | 8 ++------ 8 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Ix.NET/Source/Directory.build.props b/Ix.NET/Source/Directory.build.props index ceaef7610b..ecaa1d8743 100644 --- a/Ix.NET/Source/Directory.build.props +++ b/Ix.NET/Source/Directory.build.props @@ -20,14 +20,9 @@ 8.0 - - - full - - - + diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 41ee048fb2..0e46f61420 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -10,7 +10,7 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION - + From 8582d2a5632edb5b3506d45c4700da254e133140 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:02:52 -0800 Subject: [PATCH 781/862] AggregateAsync code coverage. --- .../System/Linq/Operators/Aggregate.cs | 298 +++++++++++++++++- 1 file changed, 285 insertions(+), 13 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index a9b1b42eb3..b1eb3e2e6d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -15,6 +15,8 @@ public class Aggregate : AsyncEnumerableTests [Fact] public async Task Aggregate_Null() { + // T + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func)).AsTask()); @@ -34,10 +36,56 @@ public async Task Aggregate_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default, CancellationToken.None).AsTask()); + + // ValueTask + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); + +#if !NO_DEEP_CANCELLATION + // CancellationToken, ValueTask + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); +#endif } [Fact] - public async Task Aggregate1Async() + public async Task AggregateAsync_Sync_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync((x, y) => x * y); @@ -45,7 +93,7 @@ public async Task Aggregate1Async() } [Fact] - public async Task Aggregate2Async() + public async Task AggregateAsync_Sync_Empty() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync((x, y) => x * y); @@ -53,7 +101,7 @@ public async Task Aggregate2Async() } [Fact] - public async Task Aggregate3Async() + public async Task AggregateAsync_Sync_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -62,7 +110,7 @@ public async Task Aggregate3Async() } [Fact] - public async Task Aggregate4Async() + public async Task AggregateAsync_Sync_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -71,7 +119,7 @@ public async Task Aggregate4Async() } [Fact] - public async Task Aggregate5Async() + public async Task AggregateAsync_Sync_Seed_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y); @@ -79,7 +127,7 @@ public async Task Aggregate5Async() } [Fact] - public async Task Aggregate6Async() + public async Task AggregateAsync_Sync_Seed_Emtpy() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y); @@ -87,7 +135,7 @@ public async Task Aggregate6Async() } [Fact] - public async Task Aggregate7Async() + public async Task AggregateAsync_Sync_Seed_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -96,7 +144,7 @@ public async Task Aggregate7Async() } [Fact] - public async Task Aggregate8Async() + public async Task AggregateAsync_Sync_Seed_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -105,7 +153,7 @@ public async Task Aggregate8Async() } [Fact] - public async Task Aggregate9Async() + public async Task AggregateAsync_Sync_Seed_Result_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y, x => x + 1); @@ -113,7 +161,7 @@ public async Task Aggregate9Async() } [Fact] - public async Task Aggregate10Async() + public async Task AggregateAsync_Sync_Seed_Result_Empty() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y, x => x + 1); @@ -121,7 +169,7 @@ public async Task Aggregate10Async() } [Fact] - public async Task Aggregate11Async() + public async Task AggregateAsync_Sync_Seed_Result_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -130,7 +178,7 @@ public async Task Aggregate11Async() } [Fact] - public async Task Aggregate12Async() + public async Task AggregateAsync_Sync_Seed_Result_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -139,12 +187,236 @@ public async Task Aggregate12Async() } [Fact] - public async Task Aggregate13Async() + public async Task AggregateAsync_Sync_Seed_Result_Throw_ResultSelector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y, x => { throw ex; }); await AssertThrowsAsync(ys, ex); } + + [Fact] + public async Task AggregateAsync_Async_Simple() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync((x, y) => new ValueTask(x * y)); + Assert.Equal(24, await ys); + } + + [Fact] + public async Task AggregateAsync_Async_Empty() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.AggregateAsync((x, y) => new ValueTask(x * y)); + await AssertThrowsAsync(ys.AsTask()); + } + + [Fact] + public async Task AggregateAsync_Async_Throw_Source() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = xs.AggregateAsync((x, y) => new ValueTask(x * y)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsync_Async_Throw_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(new Func>((x, y) => { throw ex; })); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Simple() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y)); + Assert.Equal(24, await ys); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Emtpy() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y)); + Assert.Equal(1, await ys); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Throw_Source() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Throw_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, new Func>((x, y) => { throw ex; })); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Result_Simple() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); + Assert.Equal(25, await ys); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Result_Empty() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); + Assert.Equal(2, await ys); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Result_Throw_Source() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Result_Throw_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, new Func>((x, y) => { throw ex; }), x => new ValueTask(x + 1)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsync_Async_Seed_Result_Throw_ResultSelector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => { throw ex; }); + await AssertThrowsAsync(ys, ex); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Simple() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); + Assert.Equal(24, await ys); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Empty() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); + await AssertThrowsAsync(ys.AsTask()); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Throw_Source() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Throw_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(new Func>((x, y, ct) => { throw ex; })); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Simple() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); + Assert.Equal(24, await ys); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Emtpy() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); + Assert.Equal(1, await ys); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Throw_Source() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Throw_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, new Func>((x, y, ct) => { throw ex; })); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Simple() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); + Assert.Equal(25, await ys); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Empty() + { + var xs = new int[0].ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); + Assert.Equal(2, await ys); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_Source() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, new Func>((x, y, ct) => { throw ex; }), (x, ct) => new ValueTask(x + 1)); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_ResultSelector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => { throw ex; }); + await AssertThrowsAsync(ys, ex); + } +#endif } } From 902d43149df8e8e81ecc0c23a42a3318338dafa5 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 19 Feb 2019 16:03:11 -0500 Subject: [PATCH 782/862] Add in AsyncIteratorMethodBuilder to support the async iterators on downlevel platforms --- .../Reflection.cs | 117 ------------------ .../System.Linq.Async.Queryable/Reflection.cs | 117 ------------------ .../System/Linq/AsyncEnumerableQuery.cs | 1 + .../System/Linq/AsyncEnumerableRewriter.cs | 10 +- .../System.Linq.Async.csproj | 1 + .../AsyncIteratorMethodBuilder.cs | 95 ++++++++++++++ .../System.Linq.Async.Ref.csproj | 1 + 7 files changed, 103 insertions(+), 239 deletions(-) delete mode 100644 Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs delete mode 100644 Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/AsyncIteratorMethodBuilder.cs diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs b/Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs deleted file mode 100644 index 1094f74f82..0000000000 --- a/Ix.NET/Source/System.Interactive.Async.Providers/Reflection.cs +++ /dev/null @@ -1,117 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -#if CRIPPLED_REFLECTION - -using System.Linq; -using System.Reflection; - -namespace System.Reflection -{ - [Flags] - internal enum BindingFlags - { - Instance = 4, - Static = 8, - Public = 16, - NonPublic = 32, - } -} - -namespace System -{ - internal static class TypeExtensions - { - public static bool IsNestedPrivate(this Type t) - { - return t.GetTypeInfo().IsNestedPrivate; - } - - public static bool IsInterface(this Type t) - { - return t.GetTypeInfo().IsInterface; - } - - public static bool IsGenericType(this Type t) - { - return t.GetTypeInfo().IsGenericType; - } - - public static Type GetBaseType(this Type t) - { - return t.GetTypeInfo().BaseType; - } - - public static Type[] GetGenericArguments(this Type t) - { - // TODO: check what's the right way to support this - return t.GetTypeInfo().GenericTypeParameters.ToArray(); - } - - public static Type[] GetInterfaces(this Type t) - { - return t.GetTypeInfo().ImplementedInterfaces.ToArray(); - } - - public static bool IsAssignableFrom(this Type t1, Type t2) - { - return t1.GetTypeInfo().IsAssignableFrom(t2.GetTypeInfo()); - } - - public static MethodInfo[] GetMethods(this Type t, BindingFlags flags) - { - return t.GetTypeInfo().DeclaredMethods.Where(m => IsVisible(m, flags)).ToArray(); - } - - private static bool IsVisible(MethodInfo method, BindingFlags flags) - { - if ((flags & BindingFlags.Public) != 0 != method.IsPublic) - { - return false; - } - - if ((flags & BindingFlags.NonPublic) == 0 && !method.IsPublic) - { - return false; - } - - if ((flags & BindingFlags.Static) != 0 != method.IsStatic) - { - return false; - } - - return true; - } - } -} - -#else - -namespace System -{ - internal static class TypeExtensions - { - public static bool IsNestedPrivate(this Type t) - { - return t.IsNestedPrivate; - } - - public static bool IsInterface(this Type t) - { - return t.IsInterface; - } - - public static bool IsGenericType(this Type t) - { - return t.IsGenericType; - } - - public static Type GetBaseType(this Type t) - { - return t.BaseType; - } - } -} - -#endif diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs b/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs deleted file mode 100644 index 1094f74f82..0000000000 --- a/Ix.NET/Source/System.Linq.Async.Queryable/Reflection.cs +++ /dev/null @@ -1,117 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -#if CRIPPLED_REFLECTION - -using System.Linq; -using System.Reflection; - -namespace System.Reflection -{ - [Flags] - internal enum BindingFlags - { - Instance = 4, - Static = 8, - Public = 16, - NonPublic = 32, - } -} - -namespace System -{ - internal static class TypeExtensions - { - public static bool IsNestedPrivate(this Type t) - { - return t.GetTypeInfo().IsNestedPrivate; - } - - public static bool IsInterface(this Type t) - { - return t.GetTypeInfo().IsInterface; - } - - public static bool IsGenericType(this Type t) - { - return t.GetTypeInfo().IsGenericType; - } - - public static Type GetBaseType(this Type t) - { - return t.GetTypeInfo().BaseType; - } - - public static Type[] GetGenericArguments(this Type t) - { - // TODO: check what's the right way to support this - return t.GetTypeInfo().GenericTypeParameters.ToArray(); - } - - public static Type[] GetInterfaces(this Type t) - { - return t.GetTypeInfo().ImplementedInterfaces.ToArray(); - } - - public static bool IsAssignableFrom(this Type t1, Type t2) - { - return t1.GetTypeInfo().IsAssignableFrom(t2.GetTypeInfo()); - } - - public static MethodInfo[] GetMethods(this Type t, BindingFlags flags) - { - return t.GetTypeInfo().DeclaredMethods.Where(m => IsVisible(m, flags)).ToArray(); - } - - private static bool IsVisible(MethodInfo method, BindingFlags flags) - { - if ((flags & BindingFlags.Public) != 0 != method.IsPublic) - { - return false; - } - - if ((flags & BindingFlags.NonPublic) == 0 && !method.IsPublic) - { - return false; - } - - if ((flags & BindingFlags.Static) != 0 != method.IsStatic) - { - return false; - } - - return true; - } - } -} - -#else - -namespace System -{ - internal static class TypeExtensions - { - public static bool IsNestedPrivate(this Type t) - { - return t.IsNestedPrivate; - } - - public static bool IsInterface(this Type t) - { - return t.IsInterface; - } - - public static bool IsGenericType(this Type t) - { - return t.IsGenericType; - } - - public static Type GetBaseType(this Type t) - { - return t.BaseType; - } - } -} - -#endif diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs index 189d03ce8e..5e6898187b 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableQuery.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq.Expressions; +using System.Reflection; using System.Threading; using System.Threading.Tasks; diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs index 1a17a634b1..3185277037 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncEnumerableRewriter.cs @@ -110,14 +110,14 @@ protected override Expression VisitParameter(ParameterExpression node) private static Type GetPublicType(Type type) { - if (!type.IsNestedPrivate()) + if (!type.GetTypeInfo().IsNestedPrivate) { return type; } foreach (var ifType in type.GetInterfaces()) { - if (ifType.IsGenericType()) + if (ifType.GetTypeInfo().IsGenericType) { var def = ifType.GetGenericTypeDefinition(); if (def == typeof(IAsyncEnumerable<>) || def == typeof(IAsyncGrouping<,>)) @@ -461,7 +461,7 @@ private static Type FindGenericType(Type definition, Type type) // // If the current type matches the specified definition, return. // - if (type.IsGenericType() && type.GetGenericTypeDefinition() == definition) + if (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == definition) { return type; } @@ -469,7 +469,7 @@ private static Type FindGenericType(Type definition, Type type) // // Probe all interfaces implemented by the current type. // - if (definition.IsInterface()) + if (definition.GetTypeInfo().IsInterface) { foreach (var ifType in type.GetInterfaces()) { @@ -484,7 +484,7 @@ private static Type FindGenericType(Type definition, Type type) // // Continue up the type hierarchy. // - type = type.GetBaseType(); + type = type.GetTypeInfo().BaseType; } return null; diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 3929f0932d..ff40ca539a 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -19,6 +19,7 @@ + diff --git a/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/AsyncIteratorMethodBuilder.cs b/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/AsyncIteratorMethodBuilder.cs new file mode 100644 index 0000000000..0d2c5d2053 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/AsyncIteratorMethodBuilder.cs @@ -0,0 +1,95 @@ +#if !BCL_HAS_CONFIGUREAWAIT + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Runtime.CompilerServices +{ + ///

Represents a builder for asynchronous iterators. + [StructLayout(LayoutKind.Auto)] + public struct AsyncIteratorMethodBuilder + { + // AsyncIteratorMethodBuilder is used by the language compiler as part of generating + // async iterators. For now, the implementation just wraps AsyncTaskMethodBuilder, as + // most of the logic is shared. However, in the future this could be changed and + // optimized. For example, we do need to allocate an object (once) to flow state like + // ExecutionContext, which AsyncTaskMethodBuilder handles, but it handles it by + // allocating a Task-derived object. We could optimize this further by removing + // the Task from the hierarchy, but in doing so we'd also lose a variety of optimizations + // related to it, so we'd need to replicate all of those optimizations (e.g. storing + // that box object directly into a Task's continuation field). + +#pragma warning disable IDE0044 // Add readonly modifier + private AsyncTaskMethodBuilder _methodBuilder; // mutable struct; do not make it readonly +#pragma warning restore IDE0044 // Add readonly modifier + + /// Creates an instance of the struct. + /// The initialized instance. + public static AsyncIteratorMethodBuilder Create() => +#if PROJECTN + // ProjectN's AsyncTaskMethodBuilder.Create() currently does additional debugger-related + // work, so we need to delegate to it. + new AsyncIteratorMethodBuilder() { _methodBuilder = AsyncTaskMethodBuilder.Create() }; +#else + // _methodBuilder should be initialized to AsyncTaskMethodBuilder.Create(), but on coreclr + // that Create() is a nop, so we can just return the default here. + default; +#endif + + /// Invokes on the state machine while guarding the . + /// The type of the state machine. + /// The state machine instance, passed by reference. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void MoveNext(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine => +#if CORERT || !BCL_HAS_CONFIGUREAWAIT + _methodBuilder.Start(ref stateMachine); +#else + AsyncMethodBuilderCore.Start(ref stateMachine); +#endif + + /// Schedules the state machine to proceed to the next action when the specified awaiter completes. + /// The type of the awaiter. + /// The type of the state machine. + /// The awaiter. + /// The state machine. + public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) + where TAwaiter : INotifyCompletion + where TStateMachine : IAsyncStateMachine => + _methodBuilder.AwaitOnCompleted(ref awaiter, ref stateMachine); + + /// Schedules the state machine to proceed to the next action when the specified awaiter completes. + /// The type of the awaiter. + /// The type of the state machine. + /// The awaiter. + /// The state machine. + public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) + where TAwaiter : ICriticalNotifyCompletion + where TStateMachine : IAsyncStateMachine => + _methodBuilder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine); + + /// Marks iteration as being completed, whether successfully or otherwise. + public void Complete() => _methodBuilder.SetResult(); + + /// Gets an object that may be used to uniquely identify this builder to the debugger. + internal object ObjectIdForDebugger => typeof(AsyncTaskMethodBuilder) + .GetProperty("ObjectIdForDebugger", BindingFlags.Instance | BindingFlags.NonPublic) + .GetMethod.Invoke(_methodBuilder, null); + + + } +} + +#else +using System.Runtime.CompilerServices; + +[assembly: TypeForwardedTo(typeof(AsyncIteratorMethodBuilder))] + +#endif diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj index 5eefcb550c..56fb031336 100644 --- a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj +++ b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj @@ -10,6 +10,7 @@ + From c221a0cfeb596efa01df4ab56bb9772b386fee04 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 19 Feb 2019 16:07:35 -0500 Subject: [PATCH 783/862] Remove a dependency on System.Threading.Tasks.Extensions when targeting .NET Core 3 as it's not required --- Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj | 6 ++++-- .../refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index ff40ca539a..dd35f0612f 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -18,8 +18,10 @@ - - + + diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj index 56fb031336..8ad670d668 100644 --- a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj +++ b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj @@ -9,8 +9,10 @@
- - + + From dc5017ba3236c4c9fa4c18e6562d3c92da9daebb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:08:43 -0800 Subject: [PATCH 784/862] Clean up AggregateAsync tests. --- .../System/Linq/Operators/Aggregate.cs | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index b1eb3e2e6d..539ee78140 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -13,10 +13,8 @@ namespace Tests public class Aggregate : AsyncEnumerableTests { [Fact] - public async Task Aggregate_Null() + public async Task AggregateAsync_Sync_Null() { - // T - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func)).AsTask()); @@ -36,9 +34,11 @@ public async Task Aggregate_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default, CancellationToken.None).AsTask()); + } - // ValueTask - + [Fact] + public async Task AggregateAsync_Async_Null() + { await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); @@ -58,10 +58,12 @@ public async Task Aggregate_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); + } #if !NO_DEEP_CANCELLATION - // CancellationToken, ValueTask - + [Fact] + public async Task AggregateAsync_AsyncCancel_Null() + { await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); @@ -308,7 +310,7 @@ public async Task AggregateAsync_Async_Seed_Result_Throw_ResultSelector() #if !NO_DEEP_CANCELLATION [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Simple() + public async Task AggregateAsync_AsyncCancel_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); @@ -316,7 +318,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Simple() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Empty() + public async Task AggregateAsync_AsyncCancel_Empty() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); @@ -324,7 +326,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Empty() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Throw_Source() + public async Task AggregateAsync_AsyncCancel_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -333,7 +335,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Throw_Source() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Throw_Selector() + public async Task AggregateAsync_AsyncCancel_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -342,7 +344,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Throw_Selector() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Simple() + public async Task AggregateAsync_AsyncCancel_Seed_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); @@ -350,7 +352,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Simple() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Emtpy() + public async Task AggregateAsync_AsyncCancel_Seed_Emtpy() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); @@ -358,7 +360,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Emtpy() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Throw_Source() + public async Task AggregateAsync_AsyncCancel_Seed_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -367,7 +369,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Throw_Source() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Throw_Selector() + public async Task AggregateAsync_AsyncCancel_Seed_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -376,7 +378,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Throw_Selector() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Simple() + public async Task AggregateAsync_AsyncCancel_Seed_Result_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); @@ -384,7 +386,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Simple() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Empty() + public async Task AggregateAsync_AsyncCancel_Seed_Result_Empty() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); @@ -392,7 +394,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Empty() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_Source() + public async Task AggregateAsync_AsyncCancel_Seed_Result_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -401,7 +403,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_Source() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_Selector() + public async Task AggregateAsync_AsyncCancel_Seed_Result_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -410,7 +412,7 @@ public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_Selector() } [Fact] - public async Task AggregateAsyncCancel_AsyncCancel_Seed_Result_Throw_ResultSelector() + public async Task AggregateAsync_AsyncCancel_Seed_Result_Throw_ResultSelector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); From f111876e8c5375a3f97930ed51f1733a4b82d1c7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:09:31 -0800 Subject: [PATCH 785/862] Reorder some code. --- .../System/Linq/Operators/Aggregate.cs | 98 +++++++++---------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 539ee78140..0bd8bfbd10 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -36,56 +36,6 @@ public async Task AggregateAsync_Sync_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default, CancellationToken.None).AsTask()); } - [Fact] - public async Task AggregateAsync_Async_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); - } - -#if !NO_DEEP_CANCELLATION - [Fact] - public async Task AggregateAsync_AsyncCancel_Null() - { - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); -#endif - } - [Fact] public async Task AggregateAsync_Sync_Simple() { @@ -197,6 +147,30 @@ public async Task AggregateAsync_Sync_Seed_Result_Throw_ResultSelector() await AssertThrowsAsync(ys, ex); } + [Fact] + public async Task AggregateAsync_Async_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); + } + [Fact] public async Task AggregateAsync_Async_Simple() { @@ -309,6 +283,30 @@ public async Task AggregateAsync_Async_Seed_Result_Throw_ResultSelector() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AggregateAsync_AsyncCancel_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); + } + [Fact] public async Task AggregateAsync_AsyncCancel_Simple() { From de20e2d9acb2e9cd952a3839b5c9aa326ec7c2ab Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:18:00 -0800 Subject: [PATCH 786/862] AllAsync code coverage. --- .../System/Linq/Operators/All.cs | 76 +++++++++++++++---- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 5e7842a416..72164be139 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -13,37 +13,31 @@ namespace Tests public class All : AsyncEnumerableTests { [Fact] - public async Task All_Null() + public async Task AllAsync_Sync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None).AsTask()); } [Fact] - public async Task All1Async() + public async Task AllAsync_Sync_Simple_False() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync(x => x % 2 == 0); Assert.False(await res); } [Fact] - public async Task All2Async() + public async Task AllAsync_Sync_Simple_True() { var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(x => x % 2 == 0); Assert.True(await res); } [Fact] - public async Task All3Async() + public async Task AllAsync_Sync_Throw_Source() { var ex = new Exception("Bang!"); var res = Throw(ex).AllAsync(x => x % 2 == 0); @@ -51,7 +45,7 @@ public async Task All3Async() } [Fact] - public async Task All4Async() + public async Task AllAsync_Sync_Throw_Selector() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func(x => { throw ex; })); @@ -59,21 +53,31 @@ public async Task All4Async() } [Fact] - public async Task All5Async() + public async Task AllAsync_Async_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + } + + [Fact] + public async Task AllAsync_Async_Simple_False() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync(x => new ValueTask(x % 2 == 0)); Assert.False(await res); } [Fact] - public async Task All6Async() + public async Task AllAsync_Async_Simple_True() { var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(x => new ValueTask(x % 2 == 0)); Assert.True(await res); } [Fact] - public async Task All7Async() + public async Task AllAsync_Async_Throw_Source() { var ex = new Exception("Bang!"); var res = Throw(ex).AllAsync(x => new ValueTask(x % 2 == 0)); @@ -81,11 +85,53 @@ public async Task All7Async() } [Fact] - public async Task All8Async() + public async Task AllAsync_Async_Throw_Selector() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func>(x => { throw ex; })); await AssertThrowsAsync(res, ex); } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AllAsync_AsyncCancel_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, (x, ct) => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + } + + [Fact] + public async Task AllAsync_AsyncCancel_Simple_False() + { + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync((x, ct) => new ValueTask(x % 2 == 0)); + Assert.False(await res); + } + + [Fact] + public async Task AllAsync_AsyncCancel_Simple_True() + { + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync((x, ct) => new ValueTask(x % 2 == 0)); + Assert.True(await res); + } + + [Fact] + public async Task AllAsync_AsyncCancel_Throw_Source() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).AllAsync((x, ct) => new ValueTask(x % 2 == 0)); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task AllAsync_AsyncCancel_Throw_Selector() + { + var ex = new Exception("Bang!"); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func>((x, ct) => { throw ex; })); + await AssertThrowsAsync(res, ex); + } +#endif } } From 6a18540ac10ed3e9911172754ea80566ec361773 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:18:08 -0800 Subject: [PATCH 787/862] AnyAsync code coverage. --- .../System/Linq/Operators/Any.cs | 80 +++++++++++++++---- 1 file changed, 63 insertions(+), 17 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index 6aaa538566..dfe096219a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -13,7 +13,7 @@ namespace Tests public class Any : AsyncEnumerableTests { [Fact] - public async Task Any_Null() + public async Task AnyAsync_Sync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, CancellationToken.None).AsTask()); @@ -23,30 +23,24 @@ public async Task Any_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None).AsTask()); } [Fact] - public async Task Any1Async() + public async Task AnyAsync_Simple_True() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync(x => x % 2 == 0); Assert.True(await res); } [Fact] - public async Task Any2Async() + public async Task AnyAsync_Simple_False() { var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(x => x % 2 != 0); Assert.False(await res); } [Fact] - public async Task Any3Async() + public async Task AnyAsync_Throw_Source() { var ex = new Exception("Bang!"); var res = Throw(ex).AnyAsync(x => x % 2 == 0); @@ -54,7 +48,7 @@ public async Task Any3Async() } [Fact] - public async Task Any4Async() + public async Task AnyAsync_Throw_Selector() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(new Func(x => { throw ex; })); @@ -62,35 +56,45 @@ public async Task Any4Async() } [Fact] - public async Task Any5Async() + public async Task AnyAsync_NoSelector_NonEmpty() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync(); Assert.True(await res); } [Fact] - public async Task Any6Async() + public async Task AnyAsync_NoSelector_Empty() { var res = new int[0].ToAsyncEnumerable().AnyAsync(); Assert.False(await res); } [Fact] - public async Task Any7Async() + public async Task AnyAsync_Async_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + } + + [Fact] + public async Task AnyAsync_Async_Simple_True() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync(x => new ValueTask(x % 2 == 0)); Assert.True(await res); } [Fact] - public async Task Any8Async() + public async Task AnyAsync_Async_Simple_False() { var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(x => new ValueTask(x % 2 != 0)); Assert.False(await res); } [Fact] - public async Task Any9Async() + public async Task AnyAsync_Async_Throw_Source() { var ex = new Exception("Bang!"); var res = Throw(ex).AnyAsync(x => new ValueTask(x % 2 == 0)); @@ -98,11 +102,53 @@ public async Task Any9Async() } [Fact] - public async Task Any10Async() + public async Task AnyAsync_Async_Throw_Selector() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(new Func>(x => { throw ex; })); await AssertThrowsAsync(res, ex); } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task AnyAsync_AsyncCancel_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, (x, ct) => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + } + + [Fact] + public async Task AnyAsync_AsyncCancel_Simple_True() + { + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync((x, ct) => new ValueTask(x % 2 == 0)); + Assert.True(await res); + } + + [Fact] + public async Task AnyAsync_AsyncCancel_Simple_False() + { + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync((x, ct) => new ValueTask(x % 2 != 0)); + Assert.False(await res); + } + + [Fact] + public async Task AnyAsync_AsyncCancel_Throw_Source() + { + var ex = new Exception("Bang!"); + var res = Throw(ex).AnyAsync((x, ct) => new ValueTask(x % 2 == 0)); + await AssertThrowsAsync(res, ex); + } + + [Fact] + public async Task AnyAsync_AsyncCancel_Throw_Selector() + { + var ex = new Exception("Bang!"); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(new Func>((x, ct) => { throw ex; })); + await AssertThrowsAsync(res, ex); + } +#endif } } From ccc5d2b3a2ef9ea0a3ed44eb2ee0d7bacc0e60da Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:26:02 -0800 Subject: [PATCH 788/862] Simplify default expression. --- .../System/Linq/Operators/Aggregate.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 0bd8bfbd10..336ebf9c4f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -293,7 +293,7 @@ public async Task AggregateAsync_AsyncCancel_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, (z, ct) => new ValueTask(z)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); @@ -303,7 +303,7 @@ public async Task AggregateAsync_AsyncCancel_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); } From 490e2dd85796835e0b763b448557994a41ab3610 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:34:53 -0800 Subject: [PATCH 789/862] Use async iterators for Cast. --- .../System/Linq/Operators/Cast.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs index 1ac2edec5b..50f221674f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Cast.cs @@ -3,12 +3,16 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { + // NB: This is a non-standard LINQ operator, because we don't have a non-generic IAsyncEnumerable. + // We're keeping it to enable `from T x in xs` binding in C#. + public static IAsyncEnumerable Cast(this IAsyncEnumerable source) { if (source == null) @@ -19,9 +23,22 @@ public static IAsyncEnumerable Cast(this IAsyncEnumerable Core(CancellationToken cancellationToken) + { + await foreach (var obj in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false)) + { + yield return (TResult)obj; + } + } +#else return new CastAsyncIterator(source); +#endif } +#if !USE_ASYNC_ITERATOR private sealed class CastAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _source; @@ -71,5 +88,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 7a0f4fe9573b28354059bfa3f252c87b7acc1879 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:35:02 -0800 Subject: [PATCH 790/862] Use async iterators for OfType. --- .../System/Linq/Operators/OfType.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs index 48a5a757c5..1407754e4d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OfType.cs @@ -3,20 +3,45 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace System.Linq { public static partial class AsyncEnumerable { + // REVIEW: This is a non-standard LINQ operator, because we don't have a non-generic IAsyncEnumerable. + // + // Unfortunately, this has limited use because it requires the source to be IAsyncEnumerable, + // thus it doesn't bind for value types. Adding a first generic parameter for the element type of + // the source is not an option, because it would require users to specify two type arguments, unlike + // what's done in Enumerable.OfType. Should we move this method to Ix, thus doing away with OfType + // in the API surface altogether? + public static IAsyncEnumerable OfType(this IAsyncEnumerable source) { if (source == null) throw Error.ArgumentNull(nameof(source)); +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator Core(CancellationToken cancellationToken) + { + await foreach (var obj in AsyncEnumerableExtensions.WithCancellation(source, cancellationToken).ConfigureAwait(false)) + { + if (obj is TResult result) + { + yield return result; + } + } + } +#else return new OfTypeAsyncIterator(source); +#endif } +#if !USE_ASYNC_ITERATOR private sealed class OfTypeAsyncIterator : AsyncIterator { private readonly IAsyncEnumerable _source; @@ -70,5 +95,6 @@ protected override async ValueTask MoveNextCore() return false; } } +#endif } } From 0d68831e0bd444ea4ac2f72f886fab8e7d22ad6f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:45:19 -0800 Subject: [PATCH 791/862] ContainsAsync code coverage. --- .../System/Linq/Operators/Contains.cs | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs index 2b6bd7276a..f805dac432 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Contains.cs @@ -14,7 +14,7 @@ namespace Tests public class Contains : AsyncEnumerableTests { [Fact] - public async Task Contains_Null() + public async Task ContainsAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ContainsAsync(default, 42, EqualityComparer.Default).AsTask()); @@ -24,7 +24,7 @@ public async Task Contains_Null() } [Fact] - public async Task Contains1Async() + public async Task ContainsAsync_Simple_ICollection_True() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.ContainsAsync(3); @@ -32,7 +32,7 @@ public async Task Contains1Async() } [Fact] - public async Task Contains2Async() + public async Task ContainsAsync_Simple_ICollection_False() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.ContainsAsync(6); @@ -40,7 +40,23 @@ public async Task Contains2Async() } [Fact] - public async Task Contains3Async() + public async Task ContainsAsync_Simple_True() + { + var xs = new[] { 1, 2, 3, 4, 5 }.Select(x => x).ToAsyncEnumerable(); + var ys = xs.ContainsAsync(3); + Assert.True(await ys); + } + + [Fact] + public async Task ContainsAsync_Simple_False() + { + var xs = new[] { 1, 2, 3, 4, 5 }.Select(x => x).ToAsyncEnumerable(); + var ys = xs.ContainsAsync(6); + Assert.False(await ys); + } + + [Fact] + public async Task ContainsAsync_Simple_Comparer_True() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.ContainsAsync(-3, new Eq()); @@ -48,7 +64,7 @@ public async Task Contains3Async() } [Fact] - public async Task Contains4Async() + public async Task ContainsAsync_Simple_Comparer_False() { var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable(); var ys = xs.ContainsAsync(-6, new Eq()); @@ -64,7 +80,7 @@ public bool Equals(int x, int y) public int GetHashCode(int obj) { - return EqualityComparer.Default.GetHashCode(Math.Abs(obj)); + throw new NotImplementedException(); } } } From c210b3f3cf259978f0f8781d018a66580aa4ccd9 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 19 Feb 2019 13:56:42 -0800 Subject: [PATCH 792/862] CountAsync code coverage. --- .../System/Linq/Operators/Count.cs | 97 ++++++++++++++++--- 1 file changed, 84 insertions(+), 13 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 45eb851cfb..207ebb3e28 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -13,33 +13,45 @@ namespace Tests public class Count : AsyncEnumerableTests { [Fact] - public async Task Count_Null() + public async Task CountAsync_Simple_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func), CancellationToken.None).AsTask()); } [Fact] - public async Task Count1() + public async Task CountAsync_Simple() { Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync()); Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync()); } [Fact] - public async Task Count2() + public async Task CountAsync_Simple_Throws_Source() + { + var ex = new Exception("Bang!"); + await AssertThrowsAsync(Throw(ex).CountAsync(), ex); + } + + [Fact] + public async Task CountAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func), CancellationToken.None).AsTask()); + } + + [Fact] + public async Task CountAsync_Predicate() { Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync(x => x < 3)); Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(x => x < 3)); } [Fact] - public async Task Count3Async() + public async Task CountAsync_Predicate_Throws_Predicate() { var ex = new Exception("Bang!"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(new Func(x => { throw ex; })); @@ -47,17 +59,76 @@ public async Task Count3Async() } [Fact] - public async Task Count4Async() + public async Task CountAsync_Predicate_Throws_Source() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).CountAsync(), ex); + await AssertThrowsAsync(Throw(ex).CountAsync(x => x < 3), ex); + } + + [Fact] + public async Task CountAsync_AsyncPredicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + } + + [Fact] + public async Task CountAsync_AsyncPredicate() + { + Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync(x => new ValueTask(x < 3))); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(x => new ValueTask(x < 3))); } [Fact] - public async Task Count5Async() + public async Task CountAsync_AsyncPredicate_Throws_Predicate() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).CountAsync(x => x < 3), ex); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(new Func>(x => { throw ex; })); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task CountAsync_AsyncPredicate_Throws_Source() + { + var ex = new Exception("Bang!"); + await AssertThrowsAsync(Throw(ex).CountAsync(x => new ValueTask(x < 3)), ex); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public async Task CountAsync_AsyncPredicateCancel_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, (x, ct) => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + } + + [Fact] + public async Task CountAsync_AsyncPredicateCancel() + { + Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync((x, ct) => new ValueTask(x < 3))); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync((x, ct) => new ValueTask(x < 3))); + } + + [Fact] + public async Task CountAsync_AsyncPredicateCancel_Throws_Predicate() + { + var ex = new Exception("Bang!"); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(new Func>((x, ct) => { throw ex; })); + await AssertThrowsAsync(ys, ex); + } + + [Fact] + public async Task CountAsync_AsyncPredicateCancel_Throws_Source() + { + var ex = new Exception("Bang!"); + await AssertThrowsAsync(Throw(ex).CountAsync((x, ct) => new ValueTask(x < 3)), ex); } +#endif } } From a6a49d8863ae4df71c29332d675978b0913aed9e Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 19 Feb 2019 17:10:05 -0500 Subject: [PATCH 793/862] enable USE_ASYNC_ITERATOR for .NET 4.6 Add supporting types that were needed. Remove .NET Standard 1.4 due to incompatibility --- Ix.NET/Source/Directory.build.targets | 3 + .../System.Interactive.Async.Providers.csproj | 6 +- .../System.Interactive.Async.csproj | 2 +- .../System.Linq.Async.Queryable.csproj | 2 +- .../System.Linq.Async.csproj | 7 +- .../Diagnostics/StackTraceHiddenAttribute.cs | 16 + .../ConfiguredAsyncDisposable.cs | 2 +- .../Sources/ManualResetValueTaskSourceCore.cs | 292 ++++++++++++++++++ .../System.Linq.Async.Ref.csproj | 4 +- 9 files changed, 318 insertions(+), 16 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Diagnostics/StackTraceHiddenAttribute.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index c6e5bac85c..6a214ca9f3 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -10,6 +10,9 @@ $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION + + $(DefineConstants);USE_ASYNC_ITERATOR + + + + true cobertura From 94606347758de779b3ea7f68fc7f06d971f168c2 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Sun, 24 Feb 2019 08:35:24 -0500 Subject: [PATCH 832/862] remove outdated comment --- Ix.NET/Source/Directory.build.targets | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index 6e02b01b3f..abc51bda18 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -14,11 +14,6 @@ $(DefineConstants);USE_ASYNC_ITERATOR - $(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT From ad784057132c38eb3d0706fa5d49eeb89cf94450 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 25 Feb 2019 13:18:46 -0800 Subject: [PATCH 833/862] Improve tests for GroupBy. --- .../System.Linq.Async.Tests.csproj | 14 + .../Linq/Operators/GroupBy.Generated.cs | 591 ++++++++++++++++++ .../Linq/Operators/GroupBy.Generated.tt | 358 +++++++++++ .../System/Linq/Operators/GroupBy.cs | 2 +- 4 files changed, 964 insertions(+), 1 deletion(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj index d264248e5d..dcbadd0b35 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj +++ b/Ix.NET/Source/System.Linq.Async.Tests/System.Linq.Async.Tests.csproj @@ -19,6 +19,11 @@ True Average.Generated.tt + + True + True + GroupBy.Generated.tt + True True @@ -51,6 +56,10 @@ TextTemplatingFileGenerator Average.Generated.cs + + TextTemplatingFileGenerator + GroupBy.Generated.cs + TextTemplatingFileGenerator MinMax.Generated.cs @@ -71,6 +80,11 @@ True Average.Generated.tt + + True + True + GroupBy.Generated.tt + True True diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs new file mode 100644 index 0000000000..c68f39ef23 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs @@ -0,0 +1,591 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + partial class GroupBy + { + [Fact] + public void KeySelector_Sync_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func))); + } + + [Fact] + public async Task KeySelector_Sync_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name); + var resA = methodsA.GroupBy(m => m.Name); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_Sync_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_Sync_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, eq); + var resA = methodsA.GroupBy(m => m.Name, eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_Sync_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, (int x) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), (int x) => x)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => x, default(Func))); + } + + [Fact] + public async Task KeySelector_ElementSelector_Sync_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper()); + var resA = methodsA.GroupBy(m => m.Name, m => m.Name.ToUpper()); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_Sync_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, (int x) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), (int x) => x, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, default(Func), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_Sync_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); + var resA = methodsA.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_Sync_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, (k, g) => 0)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), (k, g) => 0)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => x, default(Func, int>))); + } + + [Fact] + public async Task KeySelector_ResultSelector_Sync_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count()); + var resA = methodsA.GroupBy(m => m.Name, (k, g) => k + " - " + g.CountAsync().Result); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_Sync_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, (k, g) => 0, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), (k, g) => 0, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, default(Func, int>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ResultSelector_Sync_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy(m => m.Name, (k, g) => k + " - " + g.CountAsync().Result, eq); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_Sync_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, (int x) => x, (k, g) => 0)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), (int x) => x, (k, g) => 0)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => x, default(Func), (k, g) => 0)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => x, (int x) => x, default(Func, int>))); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_Sync_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count()); + var resA = methodsA.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.CountAsync().Result); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_Sync_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, (int x) => x, (k, g) => 0, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), (int x) => x, (k, g) => 0, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, default(Func), (k, g) => 0, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => x, (int x) => x, default(Func, int>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_Sync_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.CountAsync().Result, eq); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_Async_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>))); + } + + [Fact] + public async Task KeySelector_Async_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name)); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_Async_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_Async_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, eq); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name), eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_Async_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), default(Func>))); + } + + [Fact] + public async Task KeySelector_ElementSelector_Async_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper()); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper())); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_Async_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_Async_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_Async_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), default(Func, ValueTask>))); + } + + [Fact] + public async Task KeySelector_ResultSelector_Async_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count()); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name), async (k, g) => k + " - " + await g.CountAsync()); // REVIEW: Ambiguity + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_Async_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func, ValueTask>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ResultSelector_Async_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name), async (k, g) => k + " - " + await g.CountAsync(), eq); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_Async_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), default(Func>), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), (int x) => new ValueTask(x), default(Func, ValueTask>))); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_Async_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count()); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), async (k, g) => k + " - " + await g.CountAsync()); // REVIEW: Ambiguity + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_Async_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func>), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), default(Func, ValueTask>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_Async_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), async (k, g) => k + " - " + await g.CountAsync(), eq); + + await Group_Result_AssertCore(resS, resA); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public void KeySelector_Async_Cancel_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>))); + } + + [Fact] + public async Task KeySelector_Async_Cancel_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name)); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_Async_Cancel_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_Async_Cancel_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, eq); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_Async_Cancel_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func>))); + } + + [Fact] + public async Task KeySelector_ElementSelector_Async_Cancel_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper()); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper())); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_Async_Cancel_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_Async_Cancel_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_Async_Cancel_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>))); + } + + [Fact] + public async Task KeySelector_ResultSelector_Async_Cancel_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count()); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), async (k, g, ct) => k + " - " + await g.CountAsync(ct)); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_Async_Cancel_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ResultSelector_Async_Cancel_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), async (k, g, ct) => k + " - " + await g.CountAsync(ct), eq); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_Async_Cancel_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func>), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>))); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_Async_Cancel_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count()); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), async (k, g, ct) => k + " - " + await g.CountAsync(ct)); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_Async_Cancel_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func>), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_Async_Cancel_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), async (k, g, ct) => k + " - " + await g.CountAsync(ct), eq); + + await Group_Result_AssertCore(resS, resA); + } +#endif + + private async Task Groups_AssertCore(IEnumerable> resS, IAsyncEnumerable> resA) + { + Assert.True(await AsyncEnumerable.SequenceEqualAsync( + resS.Select(g => g.Key).ToAsyncEnumerable(), + resA.Select(g => g.Key) + )); + + // CountAsync + + Assert.Equal(resS.Count(), await resA.CountAsync()); + + // ToArrayAsync + + var resArrS = resS.ToArray(); + var resArrA = await resA.ToArrayAsync(); + + Assert.Equal( + resArrS.Select(g => g.Key), + resArrA.Select(g => g.Key) + ); + + // ToListAsync + + var resLstS = resS.ToList(); + var resLstA = await resA.ToListAsync(); + + Assert.Equal( + resLstS.Select(g => g.Key), + resLstA.Select(g => g.Key) + ); + } + + private async Task Group_Result_AssertCore(IEnumerable resS, IAsyncEnumerable resA) + { + Assert.True(await AsyncEnumerable.SequenceEqualAsync( + resS.ToAsyncEnumerable(), + resA + )); + + // CountAsync + + Assert.Equal(resS.Count(), await resA.CountAsync()); + + // ToArrayAsync + + var resArrS = resS.ToArray(); + var resArrA = await resA.ToArrayAsync(); + + Assert.Equal(resArrS, resArrA); + + // ToListAsync + + var resLstS = resS.ToList(); + var resLstA = await resA.ToListAsync(); + + Assert.Equal(resLstS, resLstA); + } + + private sealed class StringPrefixEqualityComparer : IEqualityComparer + { + private readonly int _n; + + public StringPrefixEqualityComparer(int n) => _n = n; + + public bool Equals(string s1, string s2) => s1.Substring(0, _n) == s2.Substring(0, _n); + + public int GetHashCode(string s) => s.Substring(0, _n).GetHashCode(); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt new file mode 100644 index 0000000000..6e5e416970 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt @@ -0,0 +1,358 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + partial class GroupBy + { +<# +foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) +{ + string keySelectorType, elementSelectorType, resultSelectorType; + string keySelectorFunc, elementSelectorFunc, resultSelectorFunc; + bool isCancel = false; + + switch (kind) + { + case "Sync": + keySelectorType = elementSelectorType = "Func"; + keySelectorFunc = elementSelectorFunc = "(int x) => x"; + resultSelectorType = "Func, int>"; + resultSelectorFunc = "(k, g) => 0"; + break; + case "Async": + keySelectorType = elementSelectorType = "Func>"; + keySelectorFunc = elementSelectorFunc = "(int x) => new ValueTask(x)"; + resultSelectorType = "Func, ValueTask>"; + resultSelectorFunc = "(k, g) => new ValueTask(0)"; + break; + case "Async_Cancel": + keySelectorType = elementSelectorType = "Func>"; + keySelectorFunc = elementSelectorFunc = "(int x, CancellationToken ct) => new ValueTask(x)"; + resultSelectorType = "Func, CancellationToken, ValueTask>"; + resultSelectorFunc = "(k, g, ct) => new ValueTask(0)"; + isCancel = true; + break; + default: + throw new Exception(); + } + + if (isCancel) + { +#> +#if !NO_DEEP_CANCELLATION +<# + } + + string keySelector, elementSelector, resultSelector; + + switch (kind) + { + case "Sync": + keySelector = "m => m.Name"; + elementSelector = "m => m.Name.ToUpper()"; + resultSelector = "(k, g) => k + \" - \" + g.CountAsync().Result"; + break; + case "Async": + keySelector = "m => new ValueTask(m.Name)"; + elementSelector = "m => new ValueTask(m.Name.ToUpper())"; + resultSelector = "async (k, g) => k + \" - \" + await g.CountAsync()"; + break; + case "Async_Cancel": + keySelector = "(m, ct) => new ValueTask(m.Name)"; + elementSelector = "(m, ct) => new ValueTask(m.Name.ToUpper())"; + resultSelector = "async (k, g, ct) => k + \" - \" + await g.CountAsync(ct)"; + break; + default: + throw new Exception(); + } +#> + [Fact] + public void KeySelector_<#=kind#>_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>))); + } + + [Fact] + public async Task KeySelector_<#=kind#>_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name); + var resA = methodsA.GroupBy(<#=keySelector#>); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_<#=kind#>_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_<#=kind#>_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, eq); + var resA = methodsA.GroupBy(<#=keySelector#>, eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_<#=kind#>_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, default(<#=elementSelectorType#>))); + } + + [Fact] + public async Task KeySelector_ElementSelector_<#=kind#>_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper()); + var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_<#=kind#>_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=elementSelectorType#>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_<#=kind#>_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); + var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, eq); + + await Groups_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_<#=kind#>_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, default(<#=resultSelectorType#>))); + } + + [Fact] + public async Task KeySelector_ResultSelector_<#=kind#>_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count()); +<# +if (kind == "Async") +{ +#> + var resA = methodsA.GroupBy(<#=keySelector#>, <#=resultSelector#>); // REVIEW: Ambiguity +<# +} +else +{ +#> + var resA = methodsA.GroupBy(<#=keySelector#>, <#=resultSelector#>); +<# +} +#> + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ResultSelector_<#=kind#>_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=resultSelectorType#>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ResultSelector_<#=kind#>_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy(<#=keySelector#>, <#=resultSelector#>, eq); + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_<#=kind#>_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, default(<#=elementSelectorType#>), <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, <#=elementSelectorFunc#>, default(<#=resultSelectorType#>))); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_<#=kind#>_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count()); +<# +if (kind == "Async") +{ +#> + var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>); // REVIEW: Ambiguity +<# +} +else +{ +#> + var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>); +<# +} +#> + + await Group_Result_AssertCore(resS, resA); + } + + [Fact] + public void KeySelector_ElementSelector_ResultSelector_<#=kind#>_Comparer_Null() + { + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=elementSelectorType#>), <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, default(<#=resultSelectorType#>), EqualityComparer.Default)); + } + + [Fact] + public async Task KeySelector_ElementSelector_ResultSelector_<#=kind#>_Comparer_All() + { + var methodsS = typeof(Enumerable).GetMethods().AsEnumerable(); + var methodsA = methodsS.ToAsyncEnumerable(); + + var eq = new StringPrefixEqualityComparer(1); + + var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count(), eq); + var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>, eq); + + await Group_Result_AssertCore(resS, resA); + } +<# + if (isCancel) + { +#> +#endif +<# + } +#> + +<# +} +#> + private async Task Groups_AssertCore(IEnumerable> resS, IAsyncEnumerable> resA) + { + Assert.True(await AsyncEnumerable.SequenceEqualAsync( + resS.Select(g => g.Key).ToAsyncEnumerable(), + resA.Select(g => g.Key) + )); + + // CountAsync + + Assert.Equal(resS.Count(), await resA.CountAsync()); + + // ToArrayAsync + + var resArrS = resS.ToArray(); + var resArrA = await resA.ToArrayAsync(); + + Assert.Equal( + resArrS.Select(g => g.Key), + resArrA.Select(g => g.Key) + ); + + // ToListAsync + + var resLstS = resS.ToList(); + var resLstA = await resA.ToListAsync(); + + Assert.Equal( + resLstS.Select(g => g.Key), + resLstA.Select(g => g.Key) + ); + } + + private async Task Group_Result_AssertCore(IEnumerable resS, IAsyncEnumerable resA) + { + Assert.True(await AsyncEnumerable.SequenceEqualAsync( + resS.ToAsyncEnumerable(), + resA + )); + + // CountAsync + + Assert.Equal(resS.Count(), await resA.CountAsync()); + + // ToArrayAsync + + var resArrS = resS.ToArray(); + var resArrA = await resA.ToArrayAsync(); + + Assert.Equal(resArrS, resArrA); + + // ToListAsync + + var resLstS = resS.ToList(); + var resLstA = await resA.ToListAsync(); + + Assert.Equal(resLstS, resLstA); + } + + private sealed class StringPrefixEqualityComparer : IEqualityComparer + { + private readonly int _n; + + public StringPrefixEqualityComparer(int n) => _n = n; + + public bool Equals(string s1, string s2) => s1.Substring(0, _n) == s2.Substring(0, _n); + + public int GetHashCode(string s) => s.Substring(0, _n).GetHashCode(); + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 6fd2cf86a5..6d04d8ef96 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -10,7 +10,7 @@ namespace Tests { - public class GroupBy : AsyncEnumerableTests + public partial class GroupBy : AsyncEnumerableTests { [Fact] public void GroupBy_KeySelector_Sync_Null() From d2b8eeae813acbbb5051d016f5a8e6512553cc0d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Mon, 25 Feb 2019 13:33:55 -0800 Subject: [PATCH 834/862] Add comment to SelectMany. --- .../System.Linq.Async/System/Linq/Operators/SelectMany.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 86763b4c17..9c60a7c046 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -21,6 +21,8 @@ public static IAsyncEnumerable SelectMany(this IAsync return new SelectManyAsyncIterator(source, selector); } + // REVIEW: Should we keep these overloads that return ValueTask>? One could argue the selector is async twice. + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) { if (source == null) From 131392c5f792c271bc17d5e37660193842cdc99a Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Mon, 25 Feb 2019 17:17:57 -0500 Subject: [PATCH 835/862] Fix typo --- azure-pipelines.ix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.ix.yml b/azure-pipelines.ix.yml index fb0d9a7863..e62deb84a0 100644 --- a/azure-pipelines.ix.yml +++ b/azure-pipelines.ix.yml @@ -1,4 +1,4 @@ -ntrigger: +trigger: branches: include: - master From 0a1b1003499de0a0400eddfdff5bd7da1401bcff Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Mon, 25 Feb 2019 21:10:38 -0500 Subject: [PATCH 836/862] Update docs --- AUTHORS.txt | 1 + README.md | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 436835fab9..c8966f922a 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -14,6 +14,7 @@ Arthur Watson Gert Drapers Mark Shields Eric Rozell +Oren Novotny Rx.js and Ix.js: Matthew Podwysocki diff --git a/README.md b/README.md index f63ccf9481..68726f028b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,17 @@ Catch us in the #rxnet channel over at http://reactiveui.net/slack ### Get nightly builds - NuGet v3 feed url (VS 2015+): `https://dotnet.myget.org/F/rx/api/v3/index.json` +## System.Linq.Async / System.Interactive.Async / System.Interactive + +### v4.0 changes + +Ix Async 4.0 has a breaking change from prior versions due to being the first LINQ implementation +to support the new C# 8 [async streams](https://github.com/dotnet/csharplang/blob/master/proposals/csharp-8.0/async-streams.md) feature. This means for .NET Standard 2.1 and .NET Core 3 targets, we use the in-box interfaces for `IAsyncEnumerable` and friends. On other platforms, we provide the implementation, so you can use `await foreach` and create async iterators as you would expect. The types will unify to the system ones where the platform provides it. + +The code should be code-compatible, so recompiling should take care of most of it; note that binary compatibility will not work. + +## System.Reactive + ### v4.0 changes Due to the [overwhelming](https://github.com/dotnet/reactive/issues/299) [pain](https://github.com/dotnet/reactive/issues/305) that fixing [#205 - Implement assembly version strategy](https://github.com/dotnet/reactive/issues/205) caused, we have refactored the libraries into a single library `System.Reactive`. To prevent breaking existing code that references the v3 libraries, we have facades with TypeForwarders to the new assembly. If you have a reference to a binary built against v3.0, then use the new `System.Reactive.Compatibility` package. @@ -97,7 +108,7 @@ Contributing ### Source code -* Clone the sources: `git clone https://github.com/dotnet/reactive.git` +* Clone the sources: `git clone https://github.com/dotnet/reactive` * [Building, testing and debugging the sources](https://github.com/dotnet/reactive/wiki/Building%20Testing%20and%20Debugging) ### Contribute! From f2ce04b662665a30060e0eedac8ce1f70e0d7322 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 12:58:00 -0800 Subject: [PATCH 837/862] The Big Rename to avoid ambiguity between sync/async/cancellable overloads of operators. --- .../AsyncQueryableTests.Generated.cs | 2086 +++++------ .../System.Linq.Async.Queryable.csproj | 4 + .../System/Linq/AsyncQueryable.Generated.cs | 1382 +++---- .../System/Linq/AsyncQueryable.Generated.tt | 2 +- .../System/Linq/AsyncEnumerableNamingTests.cs | 84 + .../System/Linq/Operators/Aggregate.cs | 200 +- .../System/Linq/Operators/All.cs | 66 +- .../System/Linq/Operators/Any.cs | 56 +- .../Linq/Operators/Average.Generated.cs | 160 +- .../Linq/Operators/Average.Generated.tt | 32 +- .../System/Linq/Operators/Average.cs | 148 +- .../System/Linq/Operators/Count.cs | 50 +- .../System/Linq/Operators/First.cs | 102 +- .../System/Linq/Operators/FirstOrDefault.cs | 102 +- .../System/Linq/Operators/ForEachAsync.cs | 70 +- .../Linq/Operators/GroupBy.Generated.cs | 128 +- .../Linq/Operators/GroupBy.Generated.tt | 94 +- .../System/Linq/Operators/GroupBy.cs | 2 +- .../System/Linq/Operators/Last.cs | 102 +- .../System/Linq/Operators/LastOrDefault.cs | 102 +- .../System/Linq/Operators/LongCount.cs | 50 +- .../System/Linq/Operators/Max.cs | 204 +- .../System/Linq/Operators/Min.cs | 204 +- .../System/Linq/Operators/MinMax.Generated.cs | 3312 ++++++++--------- .../System/Linq/Operators/MinMax.Generated.tt | 144 +- .../Linq/Operators/OrderBy.Generated.cs | 488 +-- .../Linq/Operators/OrderBy.Generated.tt | 10 + .../System/Linq/Operators/OrderBy.cs | 8 +- .../System/Linq/Operators/Select.cs | 216 +- .../System/Linq/Operators/Single.cs | 66 +- .../System/Linq/Operators/SingleOrDefault.cs | 74 +- .../System/Linq/Operators/SkipWhile.cs | 132 +- .../System/Linq/Operators/Sum.cs | 142 +- .../System/Linq/Operators/TakeWhile.cs | 132 +- .../System/Linq/Operators/ToDictionary.cs | 4 +- .../System/Linq/Operators/ToLookup.cs | 4 +- .../System/Linq/Operators/Where.cs | 114 +- .../System.Linq.Async.csproj | 4 + .../System/Linq/Operators/Aggregate.cs | 12 +- .../System/Linq/Operators/All.cs | 4 +- .../System/Linq/Operators/Any.cs | 4 +- .../Linq/Operators/Average.Generated.cs | 40 +- .../Linq/Operators/Average.Generated.tt | 4 +- .../System/Linq/Operators/Count.cs | 4 +- .../System/Linq/Operators/First.cs | 4 +- .../System/Linq/Operators/FirstOrDefault.cs | 4 +- .../System/Linq/Operators/ForEach.cs | 8 +- .../System/Linq/Operators/GroupBy.cs | 40 +- .../System/Linq/Operators/GroupJoin.cs | 12 +- .../System/Linq/Operators/Join.cs | 12 +- .../System/Linq/Operators/Last.cs | 4 +- .../System/Linq/Operators/LastOrDefault.cs | 4 +- .../System/Linq/Operators/LongCount.cs | 4 +- .../System/Linq/Operators/Max.cs | 4 +- .../System/Linq/Operators/Min.cs | 4 +- .../System/Linq/Operators/MinMax.Generated.cs | 80 +- .../System/Linq/Operators/MinMax.Generated.tt | 4 +- .../System/Linq/Operators/OrderBy.cs | 32 +- .../System/Linq/Operators/Select.cs | 8 +- .../System/Linq/Operators/SelectMany.cs | 16 +- .../System/Linq/Operators/Single.cs | 4 +- .../System/Linq/Operators/SingleOrDefault.cs | 4 +- .../System/Linq/Operators/SkipWhile.cs | 8 +- .../System/Linq/Operators/Sum.Generated.cs | 40 +- .../System/Linq/Operators/Sum.Generated.tt | 4 +- .../System/Linq/Operators/TakeWhile.cs | 8 +- .../System/Linq/Operators/ToDictionary.cs | 24 +- .../System/Linq/Operators/ToLookup.cs | 24 +- .../System/Linq/Operators/Where.cs | 8 +- .../System/Linq/Operators/Zip.cs | 4 +- 70 files changed, 5396 insertions(+), 5320 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableNamingTests.cs diff --git a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs index dfe28b3f75..da980e7326 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable.Tests/AsyncQueryableTests.Generated.cs @@ -27,83 +27,83 @@ public void AggregateAsync1() [Fact] public void AggregateAsync2() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AggregateAsync3() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AggregateAsync4() + public void AggregateAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), CancellationToken.None); + var res = AsyncQueryable.AggregateAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AggregateAsync5() + public void AggregateAwaitAsync2() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AggregateAsync6() + public void AggregateAwaitAsync3() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AggregateAsync7() + public void AggregateAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(int), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.AggregateAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AggregateAsync8() + public void AggregateAwaitWithCancellationAsync2() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), CancellationToken.None), ane => ane.ParamName == "accumulator"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AggregateAsync9() + public void AggregateAwaitWithCancellationAsync3() { - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); - AssertEx.Throws(() => AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "accumulator"); + AssertEx.Throws(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.AggregateAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AggregateAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), 1, (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -118,22 +118,22 @@ public void AllAsync1() } [Fact] - public void AllAsync2() + public void AllAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AllAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AllAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AllAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AllAsync3() + public void AllAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AllAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AllAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AllAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AllAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -157,22 +157,22 @@ public void AnyAsync2() } [Fact] - public void AnyAsync3() + public void AnyAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AnyAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AnyAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AnyAsync4() + public void AnyAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.AnyAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AnyAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.AnyAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AnyAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -279,300 +279,300 @@ public void AverageAsync10() [Fact] public void AverageAsync11() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync12() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync13() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync14() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync15() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync16() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync17() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync18() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync19() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void AverageAsync20() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync21() + public void AverageAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync22() + public void AverageAwaitAsync2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync23() + public void AverageAwaitAsync3() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync24() + public void AverageAwaitAsync4() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync25() + public void AverageAwaitAsync5() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync26() + public void AverageAwaitAsync6() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync27() + public void AverageAwaitAsync7() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync28() + public void AverageAwaitAsync8() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync29() + public void AverageAwaitAsync9() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync30() + public void AverageAwaitAsync10() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync31() + public void AverageAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync32() + public void AverageAwaitWithCancellationAsync2() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync33() + public void AverageAwaitWithCancellationAsync3() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync34() + public void AverageAwaitWithCancellationAsync4() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync35() + public void AverageAwaitWithCancellationAsync5() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync36() + public void AverageAwaitWithCancellationAsync6() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync37() + public void AverageAwaitWithCancellationAsync7() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync38() + public void AverageAwaitWithCancellationAsync8() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync39() + public void AverageAwaitWithCancellationAsync9() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void AverageAsync40() + public void AverageAwaitWithCancellationAsync10() { - AssertEx.Throws(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.AverageAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.AverageAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -635,22 +635,22 @@ public void CountAsync2() } [Fact] - public void CountAsync3() + public void CountAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.CountAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.CountAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void CountAsync4() + public void CountAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.CountAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.CountAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.CountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.CountAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -754,22 +754,22 @@ public void FirstAsync2() } [Fact] - public void FirstAsync3() + public void FirstAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstAsync4() + public void FirstAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -793,22 +793,22 @@ public void FirstOrDefaultAsync2() } [Fact] - public void FirstOrDefaultAsync3() + public void FirstOrDefaultAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void FirstOrDefaultAsync4() + public void FirstOrDefaultAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.FirstOrDefaultAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.FirstOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.FirstOrDefaultAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -826,10 +826,10 @@ public void GroupBy1() [Fact] public void GroupBy2() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -837,10 +837,11 @@ public void GroupBy2() [Fact] public void GroupBy3() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -848,10 +849,11 @@ public void GroupBy3() [Fact] public void GroupBy4() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -859,10 +861,11 @@ public void GroupBy4() [Fact] public void GroupBy5() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -870,10 +873,11 @@ public void GroupBy5() [Fact] public void GroupBy6() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -881,11 +885,12 @@ public void GroupBy6() [Fact] public void GroupBy7() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -893,209 +898,204 @@ public void GroupBy7() [Fact] public void GroupBy8() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int)); + var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy9() + public void GroupByAwait1() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy10() + public void GroupByAwait2() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy11() + public void GroupByAwait3() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy12() + public void GroupByAwait4() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy13() + public void GroupByAwait5() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy14() + public void GroupByAwait6() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy15() + public void GroupByAwait7() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy16() + public void GroupByAwait8() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy17() + public void GroupByAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy18() + public void GroupByAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy19() + public void GroupByAwaitWithCancellation3() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int)); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy20() + public void GroupByAwaitWithCancellation4() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy21() + public void GroupByAwaitWithCancellation5() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy22() + public void GroupByAwaitWithCancellation6() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy23() + public void GroupByAwaitWithCancellation7() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupBy24() + public void GroupByAwaitWithCancellation8() { - AssertEx.Throws(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); - AssertEx.Throws(() => AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1117,69 +1117,69 @@ public void GroupJoin1() [Fact] public void GroupJoin2() { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); + var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupJoin3() + public void GroupJoinAwait1() { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupJoin4() + public void GroupJoinAwait2() { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression, int>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, IAsyncEnumerable arg1) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.GroupJoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupJoin5() + public void GroupJoinAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, IAsyncEnumerable arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void GroupJoin6() + public void GroupJoinAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression, CancellationToken, ValueTask>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.GroupJoin(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.GroupJoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, IAsyncEnumerable arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1223,69 +1223,69 @@ public void Join1() [Fact] public void Join2() { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Join3() + public void JoinAwait1() { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Join4() + public void JoinAwait2() { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), default(Expression>), (int arg0, int arg1) => default(int), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), default(Expression>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(int), (int arg0) => default(int), (int arg0, int arg1) => default(int), EqualityComparer.Default); + var res = AsyncQueryable.JoinAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Join5() + public void JoinAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), default(Expression>>), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), (int arg0, int arg1) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Join6() + public void JoinAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.Join(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); - AssertEx.Throws(() => AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outer"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "inner"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "outerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default), ane => ane.ParamName == "innerKeySelector"); + AssertEx.Throws(() => AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.Join(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); + var res = AsyncQueryable.JoinAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask), EqualityComparer.Default); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -1310,22 +1310,22 @@ public void LastAsync2() } [Fact] - public void LastAsync3() + public void LastAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LastAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastAsync4() + public void LastAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LastAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1349,22 +1349,22 @@ public void LastOrDefaultAsync2() } [Fact] - public void LastOrDefaultAsync3() + public void LastOrDefaultAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LastOrDefaultAsync4() + public void LastOrDefaultAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LastOrDefaultAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LastOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LastOrDefaultAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1388,22 +1388,22 @@ public void LongCountAsync2() } [Fact] - public void LongCountAsync3() + public void LongCountAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCountAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LongCountAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void LongCountAsync4() + public void LongCountAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.LongCountAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.LongCountAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.LongCountAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.LongCountAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1519,320 +1519,320 @@ public void MaxAsync12() [Fact] public void MaxAsync13() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync14() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync15() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync16() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync17() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync18() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync19() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync20() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync21() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MaxAsync22() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync23() + public void MaxAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync24() + public void MaxAwaitAsync2() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync25() + public void MaxAwaitAsync3() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync26() + public void MaxAwaitAsync4() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync27() + public void MaxAwaitAsync5() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync28() + public void MaxAwaitAsync6() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync29() + public void MaxAwaitAsync7() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync30() + public void MaxAwaitAsync8() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync31() + public void MaxAwaitAsync9() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync32() + public void MaxAwaitAsync10() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync33() + public void MaxAwaitAsync11() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync34() + public void MaxAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync35() + public void MaxAwaitWithCancellationAsync2() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync36() + public void MaxAwaitWithCancellationAsync3() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync37() + public void MaxAwaitWithCancellationAsync4() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync38() + public void MaxAwaitWithCancellationAsync5() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync39() + public void MaxAwaitWithCancellationAsync6() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync40() + public void MaxAwaitWithCancellationAsync7() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync41() + public void MaxAwaitWithCancellationAsync8() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync42() + public void MaxAwaitWithCancellationAsync9() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync43() + public void MaxAwaitWithCancellationAsync10() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MaxAsync44() + public void MaxAwaitWithCancellationAsync11() { - AssertEx.Throws(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MaxAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MaxAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -1938,330 +1938,330 @@ public void MinAsync11() [Fact] public void MinAsync12() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync13() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync14() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync15() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync16() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync17() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync18() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync19() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync20() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync21() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void MinAsync22() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync23() + public void MinAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync24() + public void MinAwaitAsync2() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync25() + public void MinAwaitAsync3() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync26() + public void MinAwaitAsync4() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync27() + public void MinAwaitAsync5() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync28() + public void MinAwaitAsync6() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync29() + public void MinAwaitAsync7() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync30() + public void MinAwaitAsync8() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync31() + public void MinAwaitAsync9() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync32() + public void MinAwaitAsync10() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync33() + public void MinAwaitAsync11() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync34() + public void MinAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync35() + public void MinAwaitWithCancellationAsync2() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync36() + public void MinAwaitWithCancellationAsync3() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync37() + public void MinAwaitWithCancellationAsync4() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync38() + public void MinAwaitWithCancellationAsync5() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync39() + public void MinAwaitWithCancellationAsync6() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync40() + public void MinAwaitWithCancellationAsync7() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync41() + public void MinAwaitWithCancellationAsync8() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync42() + public void MinAwaitWithCancellationAsync9() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync43() + public void MinAwaitWithCancellationAsync10() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void MinAsync44() + public void MinAwaitWithCancellationAsync11() { - AssertEx.Throws(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.MinAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.MinAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2287,46 +2287,46 @@ public void OrderBy1() [Fact] public void OrderBy2() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); } [Fact] - public void OrderBy3() + public void OrderByAwait1() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.OrderByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); } [Fact] - public void OrderBy4() + public void OrderByAwait2() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryable.OrderByAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] - public void OrderBy5() + public void OrderByAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.OrderByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] - public void OrderBy6() + public void OrderByAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderBy(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.OrderByAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } [Fact] @@ -2341,46 +2341,46 @@ public void OrderByDescending1() [Fact] public void OrderByDescending2() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); } [Fact] - public void OrderByDescending3() + public void OrderByDescendingAwait1() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.OrderByDescendingAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); } [Fact] - public void OrderByDescending4() + public void OrderByDescendingAwait2() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryable.OrderByDescendingAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] - public void OrderByDescending5() + public void OrderByDescendingAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.OrderByDescendingAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] - public void OrderByDescending6() + public void OrderByDescendingAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.OrderByDescending(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.OrderByDescendingAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } [Fact] @@ -2417,54 +2417,54 @@ public void Select1() [Fact] public void Select2() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Select3() + public void SelectAwait1() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.SelectAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Select4() + public void SelectAwait2() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectAwait(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.SelectAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Select5() + public void SelectAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.SelectAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Select6() + public void SelectAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.Select(default(IAsyncQueryable), (int arg0) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectAwaitWithCancellation(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Select(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int)); + var res = AsyncQueryable.SelectAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -2483,10 +2483,10 @@ public void SelectMany1() [Fact] public void SelectMany2() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -2494,10 +2494,11 @@ public void SelectMany2() [Fact] public void SelectMany3() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "collectionSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>)); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -2505,104 +2506,103 @@ public void SelectMany3() [Fact] public void SelectMany4() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "collectionSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable()); + var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany5() + public void SelectManyAwait1() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>)); + var res = AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany6() + public void SelectManyAwait2() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)); + var res = AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany7() + public void SelectManyAwait3() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "collectionSelector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); + var res = AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany8() + public void SelectManyAwait4() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.SelectManyAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany9() + public void SelectManyAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany10() + public void SelectManyAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, int arg1) => default(int)), ane => ane.ParamName == "collectionSelector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(int)); + var res = AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany11() + public void SelectManyAwaitWithCancellation3() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask>), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SelectMany12() + public void SelectManyAwaitWithCancellation4() { - AssertEx.Throws(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); - AssertEx.Throws(() => AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "collectionSelector"); + AssertEx.Throws(() => AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), default(Expression>>)), ane => ane.ParamName == "resultSelector"); - var res = AsyncQueryable.SelectMany(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.SelectManyAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask>), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -2647,22 +2647,22 @@ public void SingleAsync2() } [Fact] - public void SingleAsync3() + public void SingleAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SingleAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleAsync4() + public void SingleAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SingleAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2686,22 +2686,22 @@ public void SingleOrDefaultAsync2() } [Fact] - public void SingleOrDefaultAsync3() + public void SingleOrDefaultAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SingleOrDefaultAsync4() + public void SingleOrDefaultAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SingleOrDefaultAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SingleOrDefaultAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SingleOrDefaultAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -2748,45 +2748,45 @@ public void SkipWhile2() } [Fact] - public void SkipWhile3() + public void SkipWhileAwait1() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.SkipWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile4() + public void SkipWhileAwait2() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwait(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.SkipWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile5() + public void SkipWhileAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.SkipWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void SkipWhile6() + public void SkipWhileAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwaitWithCancellation(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SkipWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.SkipWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.SkipWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -2884,300 +2884,300 @@ public void SumAsync10() [Fact] public void SumAsync11() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync12() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync13() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(decimal), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(decimal), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync14() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync15() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync16() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync17() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync18() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync19() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void SumAsync20() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync21() + public void SumAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync22() + public void SumAwaitAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync23() + public void SumAwaitAsync3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync24() + public void SumAwaitAsync4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync25() + public void SumAwaitAsync5() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync26() + public void SumAwaitAsync6() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync27() + public void SumAwaitAsync7() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync28() + public void SumAwaitAsync8() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(Nullable), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(Nullable), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync29() + public void SumAwaitAsync9() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync30() + public void SumAwaitAsync10() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync31() + public void SumAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync32() + public void SumAwaitWithCancellationAsync2() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync33() + public void SumAwaitWithCancellationAsync3() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync34() + public void SumAwaitWithCancellationAsync4() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(long), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(long), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync35() + public void SumAwaitWithCancellationAsync5() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync36() + public void SumAwaitWithCancellationAsync6() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync37() + public void SumAwaitWithCancellationAsync7() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(float), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(float), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync38() + public void SumAwaitWithCancellationAsync8() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync39() + public void SumAwaitWithCancellationAsync9() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void SumAsync40() + public void SumAwaitWithCancellationAsync10() { - AssertEx.Throws(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), (int arg0) => default(double), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), CancellationToken.None), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.SumAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(double), CancellationToken.None); + var res = AsyncQueryable.SumAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3224,45 +3224,45 @@ public void TakeWhile2() } [Fact] - public void TakeWhile3() + public void TakeWhileAwait1() { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.TakeWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void TakeWhile4() + public void TakeWhileAwait2() { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwait(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.TakeWhileAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void TakeWhile5() + public void TakeWhileAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.TakeWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void TakeWhile6() + public void TakeWhileAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwaitWithCancellation(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.TakeWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.TakeWhile(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.TakeWhileAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3279,46 +3279,46 @@ public void ThenBy1() [Fact] public void ThenBy2() { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); } [Fact] - public void ThenBy3() + public void ThenByAwait1() { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwait(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.ThenByAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); } [Fact] - public void ThenBy4() + public void ThenByAwait2() { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwait(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryable.ThenByAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] - public void ThenBy5() + public void ThenByAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwaitWithCancellation(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.ThenByAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] - public void ThenBy6() + public void ThenByAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwaitWithCancellation(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenBy(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.ThenByAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } [Fact] @@ -3333,46 +3333,46 @@ public void ThenByDescending1() [Fact] public void ThenByDescending2() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); } [Fact] - public void ThenByDescending3() + public void ThenByDescendingAwait1() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwait(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.ThenByDescendingAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask)); } [Fact] - public void ThenByDescending4() + public void ThenByDescendingAwait2() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(int), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwait(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(int), Comparer.Default); + var res = AsyncQueryable.ThenByDescendingAwait(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); } [Fact] - public void ThenByDescending5() + public void ThenByDescendingAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>)), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.ThenByDescendingAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask)); } [Fact] - public void ThenByDescending6() + public void ThenByDescendingAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(default(IOrderedAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), default(Expression>>), Comparer.Default), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ThenByDescending(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); + var res = AsyncQueryable.ThenByDescendingAwaitWithCancellation(new int[0].ToAsyncEnumerable().AsAsyncQueryable().OrderBy(x => x), (int arg0, CancellationToken arg1) => default(ValueTask), Comparer.Default); } [Fact] @@ -3397,116 +3397,116 @@ public void ToDictionaryAsync1() [Fact] public void ToDictionaryAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionaryAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToDictionaryAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync5() + public void ToDictionaryAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync6() + public void ToDictionaryAwaitAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync7() + public void ToDictionaryAwaitAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync8() + public void ToDictionaryAwaitAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync9() + public void ToDictionaryAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync10() + public void ToDictionaryAwaitWithCancellationAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync11() + public void ToDictionaryAwaitWithCancellationAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToDictionaryAsync12() + public void ToDictionaryAwaitWithCancellationAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToDictionaryAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3550,116 +3550,116 @@ public void ToLookupAsync1() [Fact] public void ToLookupAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToLookupAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] public void ToLookupAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync5() + public void ToLookupAwaitAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync6() + public void ToLookupAwaitAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync7() + public void ToLookupAwaitAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync8() + public void ToLookupAwaitAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync9() + public void ToLookupAwaitWithCancellationAsync1() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync10() + public void ToLookupAwaitWithCancellationAsync2() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), default(Expression>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(int), (int arg0) => default(int), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync11() + public void ToLookupAwaitWithCancellationAsync3() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask), (int arg0) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } [Fact] - public void ToLookupAsync12() + public void ToLookupAwaitWithCancellationAsync4() { - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); - AssertEx.Throws(() => AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "keySelector"); + AssertEx.Throws(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), default(Expression>>), EqualityComparer.Default, CancellationToken.None), ane => ane.ParamName == "elementSelector"); - var res = AsyncQueryable.ToLookupAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); + var res = AsyncQueryable.ToLookupAwaitWithCancellationAsync(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask), (int arg0, CancellationToken arg1) => default(ValueTask), EqualityComparer.Default, CancellationToken.None); AssertEx.SucceedOrFailProper(() => res.Wait()); } @@ -3708,45 +3708,45 @@ public void Where2() } [Fact] - public void Where3() + public void WhereAwait1() { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.WhereAwait(default(IAsyncQueryable), (int arg0) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.WhereAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); + var res = AsyncQueryable.WhereAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Where4() + public void WhereAwait2() { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.WhereAwait(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.WhereAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); + var res = AsyncQueryable.WhereAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Where5() + public void WhereAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.WhereAwaitWithCancellation(default(IAsyncQueryable), (int arg0, CancellationToken arg1) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.WhereAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.WhereAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, CancellationToken arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Where6() + public void WhereAwaitWithCancellation2() { - AssertEx.Throws(() => AsyncQueryable.Where(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); - AssertEx.Throws(() => AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); + AssertEx.Throws(() => AsyncQueryable.WhereAwaitWithCancellation(default(IAsyncQueryable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "source"); + AssertEx.Throws(() => AsyncQueryable.WhereAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(Expression>>)), ane => ane.ParamName == "predicate"); - var res = AsyncQueryable.Where(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.WhereAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } @@ -3764,25 +3764,25 @@ public void Zip1() } [Fact] - public void Zip2() + public void ZipAwait1() { - AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.ZipAwait(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.ZipAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1) => default(ValueTask)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.ZipAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(ValueTask)); + var res = AsyncQueryable.ZipAwait(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } [Fact] - public void Zip3() + public void ZipAwaitWithCancellation1() { - AssertEx.Throws(() => AsyncQueryable.Zip(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "first"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "second"); - AssertEx.Throws(() => AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); + AssertEx.Throws(() => AsyncQueryable.ZipAwaitWithCancellation(default(IAsyncQueryable), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "first"); + AssertEx.Throws(() => AsyncQueryable.ZipAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), default(IAsyncEnumerable), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)), ane => ane.ParamName == "second"); + AssertEx.Throws(() => AsyncQueryable.ZipAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), default(Expression>>)), ane => ane.ParamName == "selector"); - var res = AsyncQueryable.Zip(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); + var res = AsyncQueryable.ZipAwaitWithCancellation(new int[] { default(int) }.ToAsyncEnumerable().AsAsyncQueryable(), new int[] { default(int) }.ToAsyncEnumerable(), (int arg0, int arg1, CancellationToken arg2) => default(ValueTask)); var task = res.ForEachAsync(_ => { }); AssertEx.SucceedOrFailProper(() => task.Wait()); } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index 87a32ad2f9..2684f12139 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -23,4 +23,8 @@ + + + + diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index 1760dd7ba8..da57fd0ac2 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -12,7 +12,7 @@ namespace System.Linq { public static partial class AsyncQueryable { - public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -20,13 +20,13 @@ public static ValueTask AggregateAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -34,27 +34,29 @@ public static ValueTask AggregateAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -62,13 +64,13 @@ public static ValueTask AggregateAsync(this I throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -76,59 +78,57 @@ public static ValueTask AggregateAsync(this I throw new ArgumentNullException(nameof(accumulator)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -138,7 +138,7 @@ public static ValueTask AggregateAsync(t throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -158,7 +158,7 @@ public static ValueTask AllAsync(this IAsyncQueryable so #endif } - public static ValueTask AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -166,13 +166,13 @@ public static ValueTask AllAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AllAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -180,7 +180,7 @@ public static ValueTask AllAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -212,7 +212,7 @@ public static ValueTask AnyAsync(this IAsyncQueryable so #endif } - public static ValueTask AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -220,13 +220,13 @@ public static ValueTask AnyAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AnyAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -234,7 +234,7 @@ public static ValueTask AnyAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -372,7 +372,7 @@ public static ValueTask AverageAsync(this IAsyncQueryable source, #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -380,13 +380,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable source, throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -394,13 +394,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -408,13 +408,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -422,13 +422,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -436,13 +436,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -450,13 +450,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -464,13 +464,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -478,13 +478,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -492,13 +492,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -506,13 +506,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -520,13 +520,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -534,13 +534,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -548,13 +548,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -562,13 +562,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -576,13 +576,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -590,13 +590,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -604,13 +604,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -618,13 +618,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -632,13 +632,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -646,13 +646,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -660,13 +660,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -674,13 +674,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -688,13 +688,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -702,13 +702,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -716,13 +716,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -730,13 +730,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -744,13 +744,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -758,13 +758,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -772,13 +772,13 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask AverageAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -786,7 +786,7 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -868,7 +868,7 @@ public static ValueTask CountAsync(this IAsyncQueryable s #endif } - public static ValueTask CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -876,13 +876,13 @@ public static ValueTask CountAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask CountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -890,7 +890,7 @@ public static ValueTask CountAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1022,7 +1022,7 @@ public static ValueTask FirstAsync(this IAsyncQueryable FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1030,13 +1030,13 @@ public static ValueTask FirstAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask FirstAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1044,7 +1044,7 @@ public static ValueTask FirstAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1076,7 +1076,7 @@ public static ValueTask FirstOrDefaultAsync(this IAsyncQueryab #endif } - public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1084,13 +1084,13 @@ public static ValueTask FirstOrDefaultAsync(this IAsyncQueryab throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1098,13 +1098,13 @@ public static ValueTask FirstOrDefaultAsync(this IAsyncQueryab throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1112,13 +1112,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1126,85 +1126,95 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1212,47 +1222,45 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1262,13 +1270,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1278,13 +1286,13 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1294,13 +1302,13 @@ public static IAsyncQueryable GroupBy(this IAsy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1310,29 +1318,31 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1340,65 +1350,61 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector) + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1406,35 +1412,31 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector) + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1442,17 +1444,15 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(keySelector)); if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1464,13 +1464,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); #endif } - public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1482,13 +1482,13 @@ public static IAsyncQueryable GroupBy throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1502,13 +1502,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1522,13 +1522,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector) + public static IAsyncQueryable GroupJoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1542,13 +1542,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupJoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1562,13 +1562,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupJoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1582,13 +1582,13 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable GroupJoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1602,7 +1602,7 @@ public static IAsyncQueryable GroupJoin( throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -1636,7 +1636,7 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1650,13 +1650,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1670,13 +1670,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) + public static IAsyncQueryable JoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1690,13 +1690,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable JoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1710,13 +1710,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable JoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1730,13 +1730,13 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); #endif } - public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) + public static IAsyncQueryable JoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { if (outer == null) throw new ArgumentNullException(nameof(outer)); @@ -1750,7 +1750,7 @@ public static IAsyncQueryable Join(this throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); + return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #else return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); #endif @@ -1782,7 +1782,7 @@ public static ValueTask LastAsync(this IAsyncQueryable LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1790,13 +1790,13 @@ public static ValueTask LastAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask LastAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1804,7 +1804,7 @@ public static ValueTask LastAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1836,7 +1836,7 @@ public static ValueTask LastOrDefaultAsync(this IAsyncQueryabl #endif } - public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1844,13 +1844,13 @@ public static ValueTask LastOrDefaultAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1858,7 +1858,7 @@ public static ValueTask LastOrDefaultAsync(this IAsyncQueryabl throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -1890,7 +1890,7 @@ public static ValueTask LongCountAsync(this IAsyncQueryable LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1898,13 +1898,13 @@ public static ValueTask LongCountAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask LongCountAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1912,7 +1912,7 @@ public static ValueTask LongCountAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -2050,7 +2050,7 @@ public static ValueTask MaxAsync(this IAsyncQueryable #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2058,13 +2058,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2072,13 +2072,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2086,13 +2086,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2100,13 +2100,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2114,13 +2114,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2128,13 +2128,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2142,13 +2142,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2156,13 +2156,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2170,13 +2170,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2184,13 +2184,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2198,13 +2198,27 @@ public static ValueTask MaxAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#else + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); +#endif + } + + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); + +#if CRIPPLED_REFLECTION + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2212,13 +2226,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2226,13 +2240,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2240,13 +2254,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2254,13 +2268,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2268,13 +2282,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2282,13 +2296,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2296,13 +2310,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2310,13 +2324,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2324,13 +2338,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2338,13 +2352,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2352,13 +2366,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2366,13 +2380,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2380,27 +2394,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif - } - - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) - { - if (source == null) - throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); - -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2408,13 +2408,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2422,13 +2422,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2436,13 +2436,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2450,13 +2450,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2464,13 +2464,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2478,13 +2478,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2492,13 +2492,13 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MaxAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2506,7 +2506,7 @@ public static ValueTask MaxAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -2644,7 +2644,7 @@ public static ValueTask MinAsync(this IAsyncQueryable #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2652,13 +2652,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2666,13 +2666,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2680,13 +2680,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2694,13 +2694,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2708,13 +2708,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2722,13 +2722,13 @@ public static ValueTask MinAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2736,13 +2736,13 @@ public static ValueTask MinAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2750,13 +2750,13 @@ public static ValueTask MinAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2764,13 +2764,13 @@ public static ValueTask MinAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2778,13 +2778,13 @@ public static ValueTask MinAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2792,13 +2792,13 @@ public static ValueTask MinAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2806,13 +2806,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2820,13 +2820,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2834,13 +2834,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2848,13 +2848,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2862,13 +2862,13 @@ public static ValueTask MinAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2876,13 +2876,13 @@ public static ValueTask MinAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2890,13 +2890,13 @@ public static ValueTask MinAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2904,13 +2904,13 @@ public static ValueTask MinAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2918,13 +2918,13 @@ public static ValueTask MinAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2932,13 +2932,13 @@ public static ValueTask MinAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2946,13 +2946,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2960,13 +2960,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2974,13 +2974,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -2988,13 +2988,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3002,13 +3002,13 @@ public static ValueTask MinAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3016,13 +3016,13 @@ public static ValueTask MinAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3030,13 +3030,13 @@ public static ValueTask MinAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3044,13 +3044,13 @@ public static ValueTask MinAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3058,13 +3058,13 @@ public static ValueTask MinAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3072,13 +3072,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3086,13 +3086,13 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask MinAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3100,7 +3100,7 @@ public static ValueTask MinAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -3118,7 +3118,7 @@ public static IAsyncQueryable OfType(this IAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3126,13 +3126,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3140,13 +3140,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderByAwait(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3154,13 +3154,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByAwait(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3168,13 +3168,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwait(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3182,13 +3182,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3196,13 +3196,13 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3210,13 +3210,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3224,13 +3224,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable OrderByDescendingAwait(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3238,13 +3238,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByDescendingAwait(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3252,13 +3252,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwait(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByDescendingAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3266,13 +3266,13 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable OrderByDescendingAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3280,7 +3280,7 @@ public static IOrderedAsyncQueryable OrderByDescending(t throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif @@ -3310,7 +3310,7 @@ public static IAsyncQueryable Reverse(this IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3318,13 +3318,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3332,13 +3332,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SelectAwait(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3346,13 +3346,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectAwait(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3360,13 +3360,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) + public static IAsyncQueryable SelectAwaitWithCancellation(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3374,13 +3374,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable Select(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectAwaitWithCancellation(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3388,13 +3388,13 @@ public static IAsyncQueryable Select(this IAsyncQuery throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3402,13 +3402,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3416,41 +3416,45 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (selector == null) - throw new ArgumentNullException(nameof(selector)); + if (collectionSelector == null) + throw new ArgumentNullException(nameof(collectionSelector)); + if (resultSelector == null) + throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3458,13 +3462,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> selector) + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3472,13 +3476,13 @@ public static IAsyncQueryable SelectMany(this IAsyncQ throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3488,13 +3492,13 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3504,45 +3508,41 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (collectionSelector == null) - throw new ArgumentNullException(nameof(collectionSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); - if (collectionSelector == null) - throw new ArgumentNullException(nameof(collectionSelector)); - if (resultSelector == null) - throw new ArgumentNullException(nameof(resultSelector)); + if (selector == null) + throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); #else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3552,13 +3552,13 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif } - public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3568,7 +3568,7 @@ public static IAsyncQueryable SelectMany throw new ArgumentNullException(nameof(resultSelector)); #if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); #endif @@ -3628,7 +3628,7 @@ public static ValueTask SingleAsync(this IAsyncQueryable SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3636,13 +3636,13 @@ public static ValueTask SingleAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SingleAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3650,7 +3650,7 @@ public static ValueTask SingleAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -3682,7 +3682,7 @@ public static ValueTask SingleOrDefaultAsync(this IAsyncQuerya #endif } - public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3690,13 +3690,13 @@ public static ValueTask SingleOrDefaultAsync(this IAsyncQuerya throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3704,7 +3704,7 @@ public static ValueTask SingleOrDefaultAsync(this IAsyncQuerya throw new ArgumentNullException(nameof(predicate)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -3748,7 +3748,7 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3756,13 +3756,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) + public static IAsyncQueryable SkipWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3770,13 +3770,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3784,13 +3784,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3798,13 +3798,13 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable SkipWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3812,7 +3812,7 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif @@ -3938,7 +3938,7 @@ public static ValueTask SumAsync(this IAsyncQueryable source, Cancel #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3946,13 +3946,13 @@ public static ValueTask SumAsync(this IAsyncQueryable source, Cancel throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3960,13 +3960,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3974,13 +3974,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -3988,13 +3988,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4002,13 +4002,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4016,13 +4016,13 @@ public static ValueTask SumAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4030,13 +4030,13 @@ public static ValueTask SumAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4044,13 +4044,13 @@ public static ValueTask SumAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4058,13 +4058,13 @@ public static ValueTask SumAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4072,13 +4072,13 @@ public static ValueTask SumAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4086,13 +4086,13 @@ public static ValueTask SumAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4100,13 +4100,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4114,13 +4114,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4128,13 +4128,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4142,13 +4142,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4156,13 +4156,13 @@ public static ValueTask SumAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4170,13 +4170,13 @@ public static ValueTask SumAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4184,13 +4184,13 @@ public static ValueTask SumAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4198,13 +4198,13 @@ public static ValueTask SumAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4212,13 +4212,13 @@ public static ValueTask SumAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4226,13 +4226,13 @@ public static ValueTask SumAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4240,13 +4240,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4254,13 +4254,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4268,13 +4268,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4282,13 +4282,13 @@ public static ValueTask SumAsync(this IAsyncQueryable throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4296,13 +4296,13 @@ public static ValueTask SumAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4310,13 +4310,13 @@ public static ValueTask SumAsync(this IAsyncQueryable s throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4324,13 +4324,13 @@ public static ValueTask SumAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4338,13 +4338,13 @@ public static ValueTask SumAsync(this IAsyncQueryable sou throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask SumAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4352,7 +4352,7 @@ public static ValueTask SumAsync(this IAsyncQueryable so throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4396,7 +4396,7 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4404,13 +4404,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) + public static IAsyncQueryable TakeWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4418,13 +4418,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4432,13 +4432,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4446,13 +4446,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable TakeWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4460,13 +4460,13 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4474,13 +4474,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4488,13 +4488,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenByAwait(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4502,13 +4502,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwait(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByAwait(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4516,13 +4516,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwait(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4530,13 +4530,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4544,13 +4544,13 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4558,13 +4558,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4572,13 +4572,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector) + public static IOrderedAsyncQueryable ThenByDescendingAwait(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4586,13 +4586,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwait(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByDescendingAwait(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4600,13 +4600,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwait(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4614,13 +4614,13 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); #else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); #endif } - public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) + public static IOrderedAsyncQueryable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4628,7 +4628,7 @@ public static IOrderedAsyncQueryable ThenByDescending(th throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #else return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); #endif @@ -4646,7 +4646,7 @@ public static ValueTask ToArrayAsync(this IAsyncQueryable> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4654,13 +4654,13 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4668,41 +4668,45 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4710,13 +4714,13 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4724,13 +4728,13 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4740,13 +4744,13 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4756,45 +4760,41 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4804,13 +4804,13 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4820,7 +4820,7 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -4862,7 +4862,7 @@ public static ValueTask> ToListAsync(this IAsyncQueryable #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4870,13 +4870,13 @@ public static ValueTask> ToLookupAsync(thi throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4884,41 +4884,45 @@ public static ValueTask> ToLookupAsync(thi throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); + if (elementSelector == null) + throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4926,13 +4930,13 @@ public static ValueTask> ToLookupAsync(thi throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4940,13 +4944,13 @@ public static ValueTask> ToLookupAsync(thi throw new ArgumentNullException(nameof(keySelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4956,13 +4960,13 @@ public static ValueTask> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -4972,45 +4976,41 @@ public static ValueTask> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - if (elementSelector == null) - throw new ArgumentNullException(nameof(elementSelector)); #if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5020,13 +5020,13 @@ public static ValueTask> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif } - public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5036,7 +5036,7 @@ public static ValueTask> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); + return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #else return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); #endif @@ -5084,7 +5084,7 @@ public static IAsyncQueryable Where(this IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5092,13 +5092,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) + public static IAsyncQueryable WhereAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5106,13 +5106,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable WhereAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5120,13 +5120,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable WhereAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5134,13 +5134,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Where(this IAsyncQueryable source, Expression>> predicate) + public static IAsyncQueryable WhereAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -5148,13 +5148,13 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); + return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); #else return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); #endif } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -5164,13 +5164,13 @@ public static IAsyncQueryable Zip(this IAsync throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); #else return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); #endif } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) + public static IAsyncQueryable ZipAwait(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -5180,13 +5180,13 @@ public static IAsyncQueryable Zip(this IAsync throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ZipAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); #else return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); #endif } - public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) + public static IAsyncQueryable ZipAwaitWithCancellation(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) { if (first == null) throw new ArgumentNullException(nameof(first)); @@ -5196,7 +5196,7 @@ public static IAsyncQueryable Zip(this IAsync throw new ArgumentNullException(nameof(selector)); #if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); + return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ZipAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); #else return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); #endif diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index deb78e6915..3f1079d6ea 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -15,7 +15,7 @@ <#@ output extension=".cs" #> <# var nullableParameterNames = new[] { "comparer" }; -var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; +var exclude = new[] { "ForEachAsync", "ForEachAwaitAsync", "ForEachAwaitWithCancellationAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; var toQuotedImpl = default(Func); toQuotedImpl = (t, i, b) => diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableNamingTests.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableNamingTests.cs new file mode 100644 index 0000000000..6f6baf15de --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableNamingTests.cs @@ -0,0 +1,84 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Tests +{ + public class AsyncEnumerableNamingTests + { + [Fact] + public static void AsyncEnumerable_MethodNames() + { + var methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.Public | BindingFlags.Static); + + // + // Async suffix + // + + var asyncMethodsNoAsyncSuffix = (from m in methods + where IsTaskLike(m.ReturnType) + where !m.Name.EndsWith("Async") + select m.Name) + .ToArray(); + + Assert.Empty(asyncMethodsNoAsyncSuffix); + + // + // Consistency of delegate types and Await[WithCancellation] naming convention + // + + var methodsWithDelegateParameter = (from m in methods + where m.GetParameters().Any(p => IsAsyncDelegate(p.ParameterType)) + select m) + .ToArray(); + + foreach (var m in methodsWithDelegateParameter) + { + var kinds = (from p in m.GetParameters() + where IsDelegate(p.ParameterType) + select GetDelegateKind(p.ParameterType)) + .Distinct(); + + Assert.Single(kinds); + + var suffix = IsTaskLike(m.ReturnType) ? "Async" : ""; + + switch (kinds.Single()) + { + case DelegateKind.Async: + suffix = "Await" + suffix; + break; + case DelegateKind.AsyncCancel: + suffix = "AwaitWithCancellation" + suffix; + break; + } + + Assert.EndsWith(suffix, m.Name); + } + + static bool IsValueTask(Type t) => t == typeof(ValueTask) || (t.IsConstructedGenericType && t.GetGenericTypeDefinition() == typeof(ValueTask<>)); + static bool IsTask(Type t) => typeof(Task).IsAssignableFrom(t); + static bool IsTaskLike(Type t) => IsTask(t) || IsValueTask(t); + + static bool IsDelegate(Type t) => typeof(Delegate).IsAssignableFrom(t); + static bool TryGetInvoke(Type t, out MethodInfo m) => (m = t.GetMethod("Invoke")) != null; + static bool IsAsyncDelegate(Type t) => IsDelegate(t) && TryGetInvoke(t, out var i) && IsTaskLike(i.ReturnType); + static bool IsCancelableDelegate(Type t) => IsDelegate(t) && TryGetInvoke(t, out var i) && i.GetParameters().LastOrDefault()?.ParameterType == typeof(CancellationToken); + static DelegateKind GetDelegateKind(Type t) => IsAsyncDelegate(t) ? (IsCancelableDelegate(t) ? DelegateKind.AsyncCancel : DelegateKind.Async) : DelegateKind.Sync; + } + + private enum DelegateKind + { + Sync, + Async, + AsyncCancel, + } + } +} diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs index 336ebf9c4f..4bed06506f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Aggregate.cs @@ -13,23 +13,23 @@ namespace Tests public class Aggregate : AsyncEnumerableTests { [Fact] - public async Task AggregateAsync_Sync_Null() + public async Task AggregateAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => x + y, default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => x + y, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => x + y, z => z, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, z => z, CancellationToken.None).AsTask()); @@ -37,7 +37,7 @@ public async Task AggregateAsync_Sync_Null() } [Fact] - public async Task AggregateAsync_Sync_Simple() + public async Task AggregateAsync_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync((x, y) => x * y); @@ -45,7 +45,7 @@ public async Task AggregateAsync_Sync_Simple() } [Fact] - public async Task AggregateAsync_Sync_Empty() + public async Task AggregateAsync_Empty() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync((x, y) => x * y); @@ -53,7 +53,7 @@ public async Task AggregateAsync_Sync_Empty() } [Fact] - public async Task AggregateAsync_Sync_Throw_Source() + public async Task AggregateAsync_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -62,7 +62,7 @@ public async Task AggregateAsync_Sync_Throw_Source() } [Fact] - public async Task AggregateAsync_Sync_Throw_Selector() + public async Task AggregateAsync_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -71,7 +71,7 @@ public async Task AggregateAsync_Sync_Throw_Selector() } [Fact] - public async Task AggregateAsync_Sync_Seed_Simple() + public async Task AggregateAsync_Seed_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y); @@ -79,7 +79,7 @@ public async Task AggregateAsync_Sync_Seed_Simple() } [Fact] - public async Task AggregateAsync_Sync_Seed_Emtpy() + public async Task AggregateAsync_Seed_Emtpy() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y); @@ -87,7 +87,7 @@ public async Task AggregateAsync_Sync_Seed_Emtpy() } [Fact] - public async Task AggregateAsync_Sync_Seed_Throw_Source() + public async Task AggregateAsync_Seed_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -96,7 +96,7 @@ public async Task AggregateAsync_Sync_Seed_Throw_Source() } [Fact] - public async Task AggregateAsync_Sync_Seed_Throw_Selector() + public async Task AggregateAsync_Seed_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -105,7 +105,7 @@ public async Task AggregateAsync_Sync_Seed_Throw_Selector() } [Fact] - public async Task AggregateAsync_Sync_Seed_Result_Simple() + public async Task AggregateAsync_Seed_Result_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y, x => x + 1); @@ -113,7 +113,7 @@ public async Task AggregateAsync_Sync_Seed_Result_Simple() } [Fact] - public async Task AggregateAsync_Sync_Seed_Result_Empty() + public async Task AggregateAsync_Seed_Result_Empty() { var xs = new int[0].ToAsyncEnumerable(); var ys = xs.AggregateAsync(1, (x, y) => x * y, x => x + 1); @@ -121,7 +121,7 @@ public async Task AggregateAsync_Sync_Seed_Result_Empty() } [Fact] - public async Task AggregateAsync_Sync_Seed_Result_Throw_Source() + public async Task AggregateAsync_Seed_Result_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -130,7 +130,7 @@ public async Task AggregateAsync_Sync_Seed_Result_Throw_Source() } [Fact] - public async Task AggregateAsync_Sync_Seed_Result_Throw_Selector() + public async Task AggregateAsync_Seed_Result_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -139,7 +139,7 @@ public async Task AggregateAsync_Sync_Seed_Result_Throw_Selector() } [Fact] - public async Task AggregateAsync_Sync_Seed_Result_Throw_ResultSelector() + public async Task AggregateAsync_Seed_Result_Throw_ResultSelector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -148,273 +148,273 @@ public async Task AggregateAsync_Sync_Seed_Result_Throw_ResultSelector() } [Fact] - public async Task AggregateAsync_Async_Null() + public async Task AggregateAwaitAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(default, (x, y) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(default, 0, (x, y) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, 0, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, 0, default, z => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, 0, (x, y) => new ValueTask(x + y), default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(default, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(default, 0, (x, y) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, 0, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), z => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(default, 0, (x, y) => new ValueTask(x + y), z => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, 0, default, z => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitAsync(Return42, 0, (x, y) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); } [Fact] - public async Task AggregateAsync_Async_Simple() + public async Task AggregateAwaitAsync_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync((x, y) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitAsync((x, y) => new ValueTask(x * y)); Assert.Equal(24, await ys); } [Fact] - public async Task AggregateAsync_Async_Empty() + public async Task AggregateAwaitAsync_Empty() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.AggregateAsync((x, y) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitAsync((x, y) => new ValueTask(x * y)); await AssertThrowsAsync(ys.AsTask()); } [Fact] - public async Task AggregateAsync_Async_Throw_Source() + public async Task AggregateAwaitAsync_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.AggregateAsync((x, y) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitAsync((x, y) => new ValueTask(x * y)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_Async_Throw_Selector() + public async Task AggregateAwaitAsync_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(new Func>((x, y) => { throw ex; })); + var ys = xs.AggregateAwaitAsync(new Func>((x, y) => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_Async_Seed_Simple() + public async Task AggregateAwaitAsync_Seed_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitAsync(1, (x, y) => new ValueTask(x * y)); Assert.Equal(24, await ys); } [Fact] - public async Task AggregateAsync_Async_Seed_Emtpy() + public async Task AggregateAwaitAsync_Seed_Emtpy() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitAsync(1, (x, y) => new ValueTask(x * y)); Assert.Equal(1, await ys); } [Fact] - public async Task AggregateAsync_Async_Seed_Throw_Source() + public async Task AggregateAwaitAsync_Seed_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitAsync(1, (x, y) => new ValueTask(x * y)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_Async_Seed_Throw_Selector() + public async Task AggregateAwaitAsync_Seed_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, new Func>((x, y) => { throw ex; })); + var ys = xs.AggregateAwaitAsync(1, new Func>((x, y) => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_Async_Seed_Result_Simple() + public async Task AggregateAwaitAsync_Seed_Result_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); Assert.Equal(25, await ys); } [Fact] - public async Task AggregateAsync_Async_Seed_Result_Empty() + public async Task AggregateAwaitAsync_Seed_Result_Empty() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); Assert.Equal(2, await ys); } [Fact] - public async Task AggregateAsync_Async_Seed_Result_Throw_Source() + public async Task AggregateAwaitAsync_Seed_Result_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitAsync(1, (x, y) => new ValueTask(x * y), x => new ValueTask(x + 1)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_Async_Seed_Result_Throw_Selector() + public async Task AggregateAwaitAsync_Seed_Result_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, new Func>((x, y) => { throw ex; }), x => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitAsync(1, new Func>((x, y) => { throw ex; }), x => new ValueTask(x + 1)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_Async_Seed_Result_Throw_ResultSelector() + public async Task AggregateAwaitAsync_Seed_Result_Throw_ResultSelector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y) => new ValueTask(x * y), x => { throw ex; }); + var ys = xs.AggregateAwaitAsync(1, (x, y) => new ValueTask(x * y), x => { throw ex; }); await AssertThrowsAsync(ys, ex); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AggregateAsync_AsyncCancel_Null() + public async Task AggregateAwaitWithCancellationAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(default, (x, y, ct) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(default, 0, (x, y, ct) => new ValueTask(x + y)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, 0, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, (z, ct) => new ValueTask(z)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, 0, default, (z, ct) => new ValueTask(z)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(default, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(default, 0, (x, y, ct) => new ValueTask(x + y), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, 0, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, default, (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(default, 0, (x, y, ct) => new ValueTask(x + y), (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, 0, default, (z, ct) => new ValueTask(z), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AggregateAwaitWithCancellationAsync(Return42, 0, (x, y, ct) => new ValueTask(x + y), default, CancellationToken.None).AsTask()); } [Fact] - public async Task AggregateAsync_AsyncCancel_Simple() + public async Task AggregateAwaitWithCancellationAsync_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitWithCancellationAsync((x, y, ct) => new ValueTask(x * y)); Assert.Equal(24, await ys); } [Fact] - public async Task AggregateAsync_AsyncCancel_Empty() + public async Task AggregateAwaitWithCancellationAsync_Empty() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitWithCancellationAsync((x, y, ct) => new ValueTask(x * y)); await AssertThrowsAsync(ys.AsTask()); } [Fact] - public async Task AggregateAsync_AsyncCancel_Throw_Source() + public async Task AggregateAwaitWithCancellationAsync_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.AggregateAsync((x, y, ct) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitWithCancellationAsync((x, y, ct) => new ValueTask(x * y)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_AsyncCancel_Throw_Selector() + public async Task AggregateAwaitWithCancellationAsync_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(new Func>((x, y, ct) => { throw ex; })); + var ys = xs.AggregateAwaitWithCancellationAsync(new Func>((x, y, ct) => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Simple() + public async Task AggregateAwaitWithCancellationAsync_Seed_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitWithCancellationAsync(1, (x, y, ct) => new ValueTask(x * y)); Assert.Equal(24, await ys); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Emtpy() + public async Task AggregateAwaitWithCancellationAsync_Seed_Emtpy() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitWithCancellationAsync(1, (x, y, ct) => new ValueTask(x * y)); Assert.Equal(1, await ys); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Throw_Source() + public async Task AggregateAwaitWithCancellationAsync_Seed_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y)); + var ys = xs.AggregateAwaitWithCancellationAsync(1, (x, y, ct) => new ValueTask(x * y)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Throw_Selector() + public async Task AggregateAwaitWithCancellationAsync_Seed_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, new Func>((x, y, ct) => { throw ex; })); + var ys = xs.AggregateAwaitWithCancellationAsync(1, new Func>((x, y, ct) => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Result_Simple() + public async Task AggregateAwaitWithCancellationAsync_Seed_Result_Simple() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitWithCancellationAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); Assert.Equal(25, await ys); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Result_Empty() + public async Task AggregateAwaitWithCancellationAsync_Seed_Result_Empty() { var xs = new int[0].ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitWithCancellationAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); Assert.Equal(2, await ys); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Result_Throw_Source() + public async Task AggregateAwaitWithCancellationAsync_Seed_Result_Throw_Source() { var ex = new Exception("Bang!"); var xs = Throw(ex); - var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitWithCancellationAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => new ValueTask(x + 1)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Result_Throw_Selector() + public async Task AggregateAwaitWithCancellationAsync_Seed_Result_Throw_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, new Func>((x, y, ct) => { throw ex; }), (x, ct) => new ValueTask(x + 1)); + var ys = xs.AggregateAwaitWithCancellationAsync(1, new Func>((x, y, ct) => { throw ex; }), (x, ct) => new ValueTask(x + 1)); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task AggregateAsync_AsyncCancel_Seed_Result_Throw_ResultSelector() + public async Task AggregateAwaitWithCancellationAsync_Seed_Result_Throw_ResultSelector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.AggregateAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => { throw ex; }); + var ys = xs.AggregateAwaitWithCancellationAsync(1, (x, y, ct) => new ValueTask(x * y), (x, ct) => { throw ex; }); await AssertThrowsAsync(ys, ex); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs index 72164be139..332f848b62 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/All.cs @@ -13,31 +13,31 @@ namespace Tests public class All : AsyncEnumerableTests { [Fact] - public async Task AllAsync_Sync_Null() + public async Task AllAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task AllAsync_Sync_Simple_False() + public async Task AllAsync_Simple_False() { var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync(x => x % 2 == 0); Assert.False(await res); } [Fact] - public async Task AllAsync_Sync_Simple_True() + public async Task AllAsync_Simple_True() { var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(x => x % 2 == 0); Assert.True(await res); } [Fact] - public async Task AllAsync_Sync_Throw_Source() + public async Task AllAsync_Throw_Source() { var ex = new Exception("Bang!"); var res = Throw(ex).AllAsync(x => x % 2 == 0); @@ -45,7 +45,7 @@ public async Task AllAsync_Sync_Throw_Source() } [Fact] - public async Task AllAsync_Sync_Throw_Selector() + public async Task AllAsync_Throw_Selector() { var ex = new Exception("Bang!"); var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func(x => { throw ex; })); @@ -53,83 +53,83 @@ public async Task AllAsync_Sync_Throw_Selector() } [Fact] - public async Task AllAsync_Async_Null() + public async Task AllAwaitAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task AllAsync_Async_Simple_False() + public async Task AllAwaitAsync_Simple_False() { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync(x => new ValueTask(x % 2 == 0)); + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.False(await res); } [Fact] - public async Task AllAsync_Async_Simple_True() + public async Task AllAwaitAsync_Simple_True() { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(x => new ValueTask(x % 2 == 0)); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.True(await res); } [Fact] - public async Task AllAsync_Async_Throw_Source() + public async Task AllAwaitAsync_Throw_Source() { var ex = new Exception("Bang!"); - var res = Throw(ex).AllAsync(x => new ValueTask(x % 2 == 0)); + var res = Throw(ex).AllAwaitAsync(x => new ValueTask(x % 2 == 0)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task AllAsync_Async_Throw_Selector() + public async Task AllAwaitAsync_Throw_Selector() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func>(x => { throw ex; })); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAwaitAsync(new Func>(x => { throw ex; })); await AssertThrowsAsync(res, ex); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AllAsync_AsyncCancel_Null() + public async Task AllAwaitWithCancellationAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, (x, ct) => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitWithCancellationAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AllAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AllAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task AllAsync_AsyncCancel_Simple_False() + public async Task AllAwaitWithCancellationAsync_Simple_False() { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAsync((x, ct) => new ValueTask(x % 2 == 0)); + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AllAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0)); Assert.False(await res); } [Fact] - public async Task AllAsync_AsyncCancel_Simple_True() + public async Task AllAwaitWithCancellationAsync_Simple_True() { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync((x, ct) => new ValueTask(x % 2 == 0)); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0)); Assert.True(await res); } [Fact] - public async Task AllAsync_AsyncCancel_Throw_Source() + public async Task AllAwaitWithCancellationAsync_Throw_Source() { var ex = new Exception("Bang!"); - var res = Throw(ex).AllAsync((x, ct) => new ValueTask(x % 2 == 0)); + var res = Throw(ex).AllAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task AllAsync_AsyncCancel_Throw_Selector() + public async Task AllAwaitWithCancellationAsync_Throw_Selector() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAsync(new Func>((x, ct) => { throw ex; })); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AllAwaitWithCancellationAsync(new Func>((x, ct) => { throw ex; })); await AssertThrowsAsync(res, ex); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs index dfe096219a..4f7c5dbcf2 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Any.cs @@ -13,7 +13,7 @@ namespace Tests public class Any : AsyncEnumerableTests { [Fact] - public async Task AnyAsync_Sync_Null() + public async Task AnyAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, CancellationToken.None).AsTask()); @@ -22,7 +22,7 @@ public async Task AnyAsync_Sync_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] @@ -70,83 +70,83 @@ public async Task AnyAsync_NoSelector_Empty() } [Fact] - public async Task AnyAsync_Async_Null() + public async Task AnyAwaitAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task AnyAsync_Async_Simple_True() + public async Task AnyAwaitAsync_Simple_True() { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync(x => new ValueTask(x % 2 == 0)); + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.True(await res); } [Fact] - public async Task AnyAsync_Async_Simple_False() + public async Task AnyAwaitAsync_Simple_False() { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.False(await res); } [Fact] - public async Task AnyAsync_Async_Throw_Source() + public async Task AnyAwaitAsync_Throw_Source() { var ex = new Exception("Bang!"); - var res = Throw(ex).AnyAsync(x => new ValueTask(x % 2 == 0)); + var res = Throw(ex).AnyAwaitAsync(x => new ValueTask(x % 2 == 0)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task AnyAsync_Async_Throw_Selector() + public async Task AnyAwaitAsync_Throw_Selector() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(new Func>(x => { throw ex; })); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAwaitAsync(new Func>(x => { throw ex; })); await AssertThrowsAsync(res, ex); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AnyAsync_AsyncCancel_Null() + public async Task AnyAwaitWithCancellationAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, (x, ct) => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitWithCancellationAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AnyAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task AnyAsync_AsyncCancel_Simple_True() + public async Task AnyAwaitWithCancellationAsync_Simple_True() { - var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAsync((x, ct) => new ValueTask(x % 2 == 0)); + var res = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().AnyAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0)); Assert.True(await res); } [Fact] - public async Task AnyAsync_AsyncCancel_Simple_False() + public async Task AnyAwaitWithCancellationAsync_Simple_False() { - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync((x, ct) => new ValueTask(x % 2 != 0)); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0)); Assert.False(await res); } [Fact] - public async Task AnyAsync_AsyncCancel_Throw_Source() + public async Task AnyAwaitWithCancellationAsync_Throw_Source() { var ex = new Exception("Bang!"); - var res = Throw(ex).AnyAsync((x, ct) => new ValueTask(x % 2 == 0)); + var res = Throw(ex).AnyAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task AnyAsync_AsyncCancel_Throw_Selector() + public async Task AnyAwaitWithCancellationAsync_Throw_Selector() { var ex = new Exception("Bang!"); - var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAsync(new Func>((x, ct) => { throw ex; })); + var res = new[] { 2, 8, 4 }.ToAsyncEnumerable().AnyAwaitWithCancellationAsync(new Func>((x, ct) => { throw ex; })); await AssertThrowsAsync(res, ex); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs index 64d8f38d56..88017bb473 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs @@ -44,34 +44,34 @@ public async Task AverageAsync_Selector_Int32_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Int32_Empty() + public async Task AverageAwaitAsync_Selector_Int32_Empty() { var ys = new int[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitAsync(x => new ValueTask(x)).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelector_Int32_Many() + public async Task AverageAwaitAsync_Selector_Int32_Many() { var xs = new int[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Empty() { var ys = new int[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Many() { var xs = new int[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -106,34 +106,34 @@ public async Task AverageAsync_Selector_Int32_Nullable_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Int32_Nullable_Empty() + public async Task AverageAwaitAsync_Selector_Int32_Nullable_Empty() { var ys = new int?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + Assert.Null(await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] - public async Task AverageAsync_AsyncSelector_Int32_Nullable_Many() + public async Task AverageAwaitAsync_Selector_Int32_Nullable_Many() { var xs = new int?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Nullable_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Nullable_Empty() { var ys = new int?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Null(await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int32_Nullable_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Nullable_Many() { var xs = new int?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -168,34 +168,34 @@ public async Task AverageAsync_Selector_Int64_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Int64_Empty() + public async Task AverageAwaitAsync_Selector_Int64_Empty() { var ys = new long[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitAsync(x => new ValueTask(x)).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelector_Int64_Many() + public async Task AverageAwaitAsync_Selector_Int64_Many() { var xs = new long[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Empty() { var ys = new long[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Many() { var xs = new long[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -230,34 +230,34 @@ public async Task AverageAsync_Selector_Int64_Nullable_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Int64_Nullable_Empty() + public async Task AverageAwaitAsync_Selector_Int64_Nullable_Empty() { var ys = new long?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + Assert.Null(await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] - public async Task AverageAsync_AsyncSelector_Int64_Nullable_Many() + public async Task AverageAwaitAsync_Selector_Int64_Nullable_Many() { var xs = new long?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Nullable_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Nullable_Empty() { var ys = new long?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Null(await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Int64_Nullable_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Nullable_Many() { var xs = new long?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -292,34 +292,34 @@ public async Task AverageAsync_Selector_Single_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Single_Empty() + public async Task AverageAwaitAsync_Selector_Single_Empty() { var ys = new float[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitAsync(x => new ValueTask(x)).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelector_Single_Many() + public async Task AverageAwaitAsync_Selector_Single_Many() { var xs = new float[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Single_Empty() { var ys = new float[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Single_Many() { var xs = new float[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -354,34 +354,34 @@ public async Task AverageAsync_Selector_Single_Nullable_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Single_Nullable_Empty() + public async Task AverageAwaitAsync_Selector_Single_Nullable_Empty() { var ys = new float?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + Assert.Null(await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] - public async Task AverageAsync_AsyncSelector_Single_Nullable_Many() + public async Task AverageAwaitAsync_Selector_Single_Nullable_Many() { var xs = new float?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Nullable_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Single_Nullable_Empty() { var ys = new float?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Null(await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Single_Nullable_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Single_Nullable_Many() { var xs = new float?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -416,34 +416,34 @@ public async Task AverageAsync_Selector_Double_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Double_Empty() + public async Task AverageAwaitAsync_Selector_Double_Empty() { var ys = new double[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitAsync(x => new ValueTask(x)).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelector_Double_Many() + public async Task AverageAwaitAsync_Selector_Double_Many() { var xs = new double[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Double_Empty() { var ys = new double[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Double_Many() { var xs = new double[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -478,34 +478,34 @@ public async Task AverageAsync_Selector_Double_Nullable_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Double_Nullable_Empty() + public async Task AverageAwaitAsync_Selector_Double_Nullable_Empty() { var ys = new double?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + Assert.Null(await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] - public async Task AverageAsync_AsyncSelector_Double_Nullable_Many() + public async Task AverageAwaitAsync_Selector_Double_Nullable_Many() { var xs = new double?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Nullable_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Double_Nullable_Empty() { var ys = new double?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Null(await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Double_Nullable_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Double_Nullable_Many() { var xs = new double?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -540,34 +540,34 @@ public async Task AverageAsync_Selector_Decimal_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Decimal_Empty() + public async Task AverageAwaitAsync_Selector_Decimal_Empty() { var ys = new decimal[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitAsync(x => new ValueTask(x)).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelector_Decimal_Many() + public async Task AverageAwaitAsync_Selector_Decimal_Many() { var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Empty() { var ys = new decimal[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Many() { var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif @@ -602,34 +602,34 @@ public async Task AverageAsync_Selector_Decimal_Nullable_Many() } [Fact] - public async Task AverageAsync_AsyncSelector_Decimal_Nullable_Empty() + public async Task AverageAwaitAsync_Selector_Decimal_Nullable_Empty() { var ys = new decimal?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync(x => new ValueTask(x))); + Assert.Null(await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] - public async Task AverageAsync_AsyncSelector_Decimal_Nullable_Many() + public async Task AverageAwaitAsync_Selector_Decimal_Nullable_Many() { var xs = new decimal?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Nullable_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Nullable_Empty() { var ys = new decimal?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Null(await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_Decimal_Nullable_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Nullable_Many() { var xs = new decimal?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None)); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt index 53eaefcdf6..067549d6a4 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt @@ -74,34 +74,34 @@ foreach (var t in types) } [Fact] - public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Empty() + public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Empty() { var ys = new <#=cs#>[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync(x => new ValueTask<<#=cs#>>(x)).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitAsync(x => new ValueTask<<#=cs#>>(x)).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Many() + public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Many() { var xs = new <#=cs#>[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask<<#=cs#>>(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask<<#=cs#>>(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Empty() { var ys = new <#=cs#>[0].ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None).AsTask()); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Many() { var xs = new <#=cs#>[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None)); } #endif @@ -136,34 +136,34 @@ foreach (var t in types) } [Fact] - public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Nullable_Empty() + public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Nullable_Empty() { var ys = new <#=cs#>?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync(x => new ValueTask<<#=cs#>?>(x))); + Assert.Null(await ys.AverageAwaitAsync(x => new ValueTask<<#=cs#>?>(x))); } [Fact] - public async Task AverageAsync_AsyncSelector_<#=t.Name#>_Nullable_Many() + public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Nullable_Many() { var xs = new <#=cs#>?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask<<#=cs#>?>(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask<<#=cs#>?>(x))); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_Empty() + public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Nullable_Empty() { var ys = new <#=cs#>?[0].ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None)); + Assert.Null(await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None)); } [Fact] - public async Task AverageAsync_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_Many() + public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Nullable_Many() { var xs = new <#=cs#>?[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None)); + Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None)); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs index ccd7c44fa3..f6154e421a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs @@ -79,7 +79,7 @@ public async Task Average_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); @@ -92,76 +92,76 @@ public async Task Average_Null() // Average(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Average(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Average(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } @@ -172,7 +172,7 @@ public async Task Average1() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -182,7 +182,7 @@ public async Task Average2() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -192,7 +192,7 @@ public async Task Average3() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -202,7 +202,7 @@ public async Task Average4() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -212,7 +212,7 @@ public async Task Average5() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -222,7 +222,7 @@ public async Task Average6() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -232,7 +232,7 @@ public async Task Average7() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -242,7 +242,7 @@ public async Task Average8() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -252,7 +252,7 @@ public async Task Average9() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -262,7 +262,7 @@ public async Task Average10() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => new ValueTask(x))); + Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs index 207ebb3e28..e432a727ee 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs @@ -40,7 +40,7 @@ public async Task CountAsync_Predicate_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] @@ -66,68 +66,68 @@ public async Task CountAsync_Predicate_Throws_Source() } [Fact] - public async Task CountAsync_AsyncPredicate_Null() + public async Task CountAwaitAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task CountAsync_AsyncPredicate() + public async Task CountAwaitAsync() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync(x => new ValueTask(x < 3))); - Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(x => new ValueTask(x < 3))); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAwaitAsync(x => new ValueTask(x < 3))); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAwaitAsync(x => new ValueTask(x < 3))); } [Fact] - public async Task CountAsync_AsyncPredicate_Throws_Predicate() + public async Task CountAwaitAsync_Throws_Predicate() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(new Func>(x => { throw ex; })); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAwaitAsync(new Func>(x => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task CountAsync_AsyncPredicate_Throws_Source() + public async Task CountAwaitAsync_Throws_Source() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).CountAsync(x => new ValueTask(x < 3)), ex); + await AssertThrowsAsync(Throw(ex).CountAwaitAsync(x => new ValueTask(x < 3)), ex); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task CountAsync_AsyncPredicateCancel_Null() + public async Task CountAwaitWithCancellationAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, (x, ct) => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitWithCancellationAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.CountAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.CountAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task CountAsync_AsyncPredicateCancel() + public async Task CountAwaitWithCancellationAsync() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAsync((x, ct) => new ValueTask(x < 3))); - Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync((x, ct) => new ValueTask(x < 3))); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().CountAwaitWithCancellationAsync((x, ct) => new ValueTask(x < 3))); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAwaitWithCancellationAsync((x, ct) => new ValueTask(x < 3))); } [Fact] - public async Task CountAsync_AsyncPredicateCancel_Throws_Predicate() + public async Task CountAwaitWithCancellationAsync_Throws_Predicate() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAsync(new Func>((x, ct) => { throw ex; })); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().CountAwaitWithCancellationAsync(new Func>((x, ct) => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task CountAsync_AsyncPredicateCancel_Throws_Source() + public async Task CountAwaitWithCancellationAsync_Throws_Source() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).CountAsync((x, ct) => new ValueTask(x < 3)), ex); + await AssertThrowsAsync(Throw(ex).CountAwaitWithCancellationAsync((x, ct) => new ValueTask(x < 3)), ex); } #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 492499282f..40c047739e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -23,17 +23,17 @@ public async Task FirstAsync_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(Return42, default, CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); #endif } @@ -173,159 +173,159 @@ public async Task FirstAsync_Predicate_PredicateThrows() } [Fact] - public async Task FirstAsync_AsyncPredicate_Empty() + public async Task FirstAwaitAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().FirstAsync(x => new ValueTask(true)); + var res = AsyncEnumerable.Empty().FirstAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicate_Throw() + public async Task FirstAwaitAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstAsync(x => new ValueTask(true)); + var res = Throw(ex).FirstAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task FirstAsync_AsyncPredicate_Single_None() + public async Task FirstAwaitAsync_Predicate_Single_None() { - var res = Return42.FirstAsync(x => new ValueTask(x % 2 != 0)); + var res = Return42.FirstAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicate_Many_IList_None() + public async Task FirstAwaitAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicate_Many_None() + public async Task FirstAwaitAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select(x => x).FirstAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select(x => x).FirstAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicate_Single_Pass() + public async Task FirstAwaitAsync_Predicate_Single_Pass() { - var res = Return42.FirstAsync(x => new ValueTask(x % 2 == 0)); + var res = Return42.FirstAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task FirstAsync_AsyncPredicate_Many_IList_Pass1() + public async Task FirstAwaitAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(43, await res); } [Fact] - public async Task FirstAsync_AsyncPredicate_Many_IList_Pass2() + public async Task FirstAwaitAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task FirstAsync_AsyncPredicate_Many_Pass1() + public async Task FirstAwaitAsync_Predicate_Many_Pass1() { - var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(43, await res); } [Fact] - public async Task FirstAsync_AsyncPredicate_Many_Pass2() + public async Task FirstAwaitAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task FirstAsync_AsyncPredicate_AsyncPredicateThrows() + public async Task FirstAwaitAsync_Predicate_AsyncPredicateThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync(x => new ValueTask(1 / x > 0)); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAwaitAsync(x => new ValueTask(1 / x > 0)); await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Empty() + public async Task FirstAwaitWithCancellationAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().FirstAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = AsyncEnumerable.Empty().FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Throw() + public async Task FirstAwaitWithCancellationAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = Throw(ex).FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res, ex); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Single_None() + public async Task FirstAwaitWithCancellationAsync_Predicate_Single_None() { - var res = Return42.FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = Return42.FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Many_IList_None() + public async Task FirstAwaitWithCancellationAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Many_None() + public async Task FirstAwaitWithCancellationAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select((x, ct) => x).FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().Select((x, ct) => x).FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Single_Pass() + public async Task FirstAwaitWithCancellationAsync_Predicate_Single_Pass() { - var res = Return42.FirstAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); + var res = Return42.FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); Assert.Equal(42, await res); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() + public async Task FirstAwaitWithCancellationAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(43, await res); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + public async Task FirstAwaitWithCancellationAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Many_Pass1() + public async Task FirstAwaitWithCancellationAsync_Predicate_Many_Pass1() { - var res = new[] { 42, 43, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 43, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(43, await res); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_Many_Pass2() + public async Task FirstAwaitWithCancellationAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task FirstAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + public async Task FirstAwaitWithCancellationAsync_Predicate_AsyncPredicateWithCancellationThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstAwaitWithCancellationAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 26e4fa0f7d..5af5877bab 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -23,17 +23,17 @@ public async Task FirstOrDefault_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(Return42, default, CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); #endif } @@ -174,159 +174,159 @@ public async Task FirstOrDefaultAsync_Predicate_PredicateThrows() } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Empty() + public async Task FirstOrDefaultAwaitAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().FirstOrDefaultAsync(x => new ValueTask(true)); + var res = AsyncEnumerable.Empty().FirstOrDefaultAwaitAsync(x => new ValueTask(true)); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Throw() + public async Task FirstOrDefaultAwaitAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstOrDefaultAsync(x => new ValueTask(true)); + var res = Throw(ex).FirstOrDefaultAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Single_None() + public async Task FirstOrDefaultAwaitAsync_Predicate_Single_None() { - var res = Return42.FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = Return42.FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Many_IList_None() + public async Task FirstOrDefaultAwaitAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Many_None() + public async Task FirstOrDefaultAwaitAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Single_Pass() + public async Task FirstOrDefaultAwaitAsync_Predicate_Single_Pass() { - var res = Return42.FirstOrDefaultAsync(x => new ValueTask(x % 2 == 0)); + var res = Return42.FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Many_IList_Pass1() + public async Task FirstOrDefaultAwaitAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(43, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Many_IList_Pass2() + public async Task FirstOrDefaultAwaitAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Many_Pass1() + public async Task FirstOrDefaultAwaitAsync_Predicate_Many_Pass1() { - var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 43, 44 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(43, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_Many_Pass2() + public async Task FirstOrDefaultAwaitAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().FirstOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicate_AsyncPredicateThrows() + public async Task FirstOrDefaultAwaitAsync_Predicate_AsyncPredicateThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync(x => new ValueTask(1 / x > 0)); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAwaitAsync(x => new ValueTask(1 / x > 0)); await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Empty() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().FirstOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = AsyncEnumerable.Empty().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Throw() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).FirstOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = Throw(ex).FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res, ex); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Single_None() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Single_None() { - var res = Return42.FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = Return42.FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_None() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_None() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Single_Pass() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Single_Pass() { - var res = Return42.FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); + var res = Return42.FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); Assert.Equal(42, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 43, 44 }.ToAsyncEnumerable().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(43, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass1() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Many_Pass1() { - var res = new[] { 42, 43, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 43, 44 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(43, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass2() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task FirstOrDefaultAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_AsyncPredicateWithCancellationThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().FirstOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs index 52e9d8a689..e15f4707cc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ForEachAsync.cs @@ -14,7 +14,7 @@ namespace Tests public class ForEachAsync : AsyncEnumerableTests { [Fact] - public async Task ForEachAsync_Sync_Null() + public async Task ForEachAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, x => { })); await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Action))); @@ -28,7 +28,7 @@ public async Task ForEachAsync_Sync_Null() } [Fact] - public async Task ForEachAsync_Sync_Simple() + public async Task ForEachAsync_Simple() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -38,7 +38,7 @@ public async Task ForEachAsync_Sync_Simple() } [Fact] - public async Task ForEachAsync_Sync_Indexed() + public async Task ForEachAsync_Indexed() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -48,7 +48,7 @@ public async Task ForEachAsync_Sync_Indexed() } [Fact] - public async Task ForEachAsync_Sync_Throws_Action() + public async Task ForEachAsync_Throws_Action() { var ex = new Exception("Bang"); var xs = Throw(ex); @@ -57,7 +57,7 @@ public async Task ForEachAsync_Sync_Throws_Action() } [Fact] - public async Task ForEachAsync_Sync_Indexed_Throws_Action() + public async Task ForEachAsync_Indexed_Throws_Action() { var ex = new Exception("Bang"); var xs = Throw(ex); @@ -65,44 +65,42 @@ public async Task ForEachAsync_Sync_Indexed_Throws_Action() await AssertThrowsAsync(xs.ForEachAsync((int x, int i) => { throw ex; }), ex); } - // REVIEW: Overloads with (T, int) and (T, CancellationToken) cause ambiguity. - [Fact] - public async Task ForEachAsync_Async_Null() + public async Task ForEachAwaitAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, x => Task.CompletedTask)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Func))); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (x, i) => Task.CompletedTask)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Func))); - - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, x => Task.CompletedTask, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (int x, int i) => Task.CompletedTask, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(default, x => Task.CompletedTask)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(Return42, default(Func))); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(default, (x, i) => Task.CompletedTask)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(Return42, default(Func))); + + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(default, x => Task.CompletedTask, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(default, (int x, int i) => Task.CompletedTask, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitAsync(Return42, default(Func), CancellationToken.None)); } [Fact] - public async Task ForEachAsync_Async_Simple() + public async Task ForEachAwaitAsync_Simple() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - await xs.ForEachAsync(x => { sum += x; return Task.CompletedTask; }); + await xs.ForEachAwaitAsync(x => { sum += x; return Task.CompletedTask; }); Assert.Equal(10, sum); } [Fact] - public async Task ForEachAsync_Async_Indexed() + public async Task ForEachAwaitAsync_Indexed() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - await xs.ForEachAsync((x, i) => { sum += x * i; return Task.CompletedTask; }); + await xs.ForEachAwaitAsync((x, i) => { sum += x * i; return Task.CompletedTask; }); Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum); } [Fact] - public async Task ForEachAsync_Async_Throws_Action() + public async Task ForEachAwaitAsync_Throws_Action() { var ex = new Exception("Bang"); var xs = Throw(ex); @@ -111,7 +109,7 @@ public async Task ForEachAsync_Async_Throws_Action() } [Fact] - public async Task ForEachAsync_Async_Indexed_Throws_Action() + public async Task ForEachAwaitAsync_Indexed_Throws_Action() { var ex = new Exception("Bang"); var xs = Throw(ex); @@ -120,50 +118,50 @@ public async Task ForEachAsync_Async_Indexed_Throws_Action() } [Fact] - public async Task ForEachAsync_Cancel_Async_Cancel_Null() + public async Task ForEachAwaitWithCancellationAsync_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (int x, CancellationToken ct) => Task.CompletedTask, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Func), CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(default, (x, i, ct) => Task.CompletedTask, CancellationToken.None)); - await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitWithCancellationAsync(default, (int x, CancellationToken ct) => Task.CompletedTask, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitWithCancellationAsync(Return42, default(Func), CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitWithCancellationAsync(default, (x, i, ct) => Task.CompletedTask, CancellationToken.None)); + await Assert.ThrowsAsync(() => AsyncEnumerable.ForEachAwaitWithCancellationAsync(Return42, default(Func), CancellationToken.None)); } [Fact] - public async Task ForEachAsync_Cancel_Async_Cancel_Simple() + public async Task ForEachAwaitWithCancellationAsync_Simple() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - await xs.ForEachAsync((int x, CancellationToken ct) => { sum += x; return Task.CompletedTask; }, CancellationToken.None); + await xs.ForEachAwaitWithCancellationAsync((int x, CancellationToken ct) => { sum += x; return Task.CompletedTask; }, CancellationToken.None); Assert.Equal(10, sum); } [Fact] - public async Task ForEachAsync_Cancel_Async_Cancel_Indexed() + public async Task ForEachAwaitWithCancellationAsync_Indexed() { var sum = 0; var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - await xs.ForEachAsync((x, i, ct) => { sum += x * i; return Task.CompletedTask; }, CancellationToken.None); + await xs.ForEachAwaitWithCancellationAsync((x, i, ct) => { sum += x * i; return Task.CompletedTask; }, CancellationToken.None); Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum); } [Fact] - public async Task ForEachAsync_Cancel_Async_Cancel_Throws_Action() + public async Task ForEachAwaitWithCancellationAsync_Throws_Action() { var ex = new Exception("Bang"); var xs = Throw(ex); - await AssertThrowsAsync(xs.ForEachAsync((int x, CancellationToken ct) => Task.FromException(ex), CancellationToken.None), ex); + await AssertThrowsAsync(xs.ForEachAwaitWithCancellationAsync((int x, CancellationToken ct) => Task.FromException(ex), CancellationToken.None), ex); } [Fact] - public async Task ForEachAsync_Cancel_Async_Cancel_Indexed_Throws_Action() + public async Task ForEachAwaitWithCancellationAsync_Indexed_Throws_Action() { var ex = new Exception("Bang"); var xs = Throw(ex); - await AssertThrowsAsync(xs.ForEachAsync((x, i, ct) => Task.FromException(ex), CancellationToken.None), ex); + await AssertThrowsAsync(xs.ForEachAwaitWithCancellationAsync((x, i, ct) => Task.FromException(ex), CancellationToken.None), ex); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs index c68f39ef23..605cfcac77 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.cs @@ -184,8 +184,8 @@ public async Task KeySelector_ElementSelector_ResultSelector_Sync_Comparer_All() [Fact] public void KeySelector_Async_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>))); } [Fact] @@ -195,7 +195,7 @@ public async Task KeySelector_Async_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name)); + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name)); await Groups_AssertCore(resS, resA); } @@ -203,8 +203,8 @@ public async Task KeySelector_Async_All() [Fact] public void KeySelector_Async_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>), EqualityComparer.Default)); } [Fact] @@ -216,7 +216,7 @@ public async Task KeySelector_Async_Comparer_All() var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, eq); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name), eq); + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name), eq); await Groups_AssertCore(resS, resA); } @@ -224,9 +224,9 @@ public async Task KeySelector_Async_Comparer_All() [Fact] public void KeySelector_ElementSelector_Async_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), default(Func>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>), (int x) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, (int x) => new ValueTask(x), default(Func>))); } [Fact] @@ -236,7 +236,7 @@ public async Task KeySelector_ElementSelector_Async_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper()); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper())); + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper())); await Groups_AssertCore(resS, resA); } @@ -244,9 +244,9 @@ public async Task KeySelector_ElementSelector_Async_All() [Fact] public void KeySelector_ElementSelector_Async_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>), (int x) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func>), EqualityComparer.Default)); } [Fact] @@ -258,7 +258,7 @@ public async Task KeySelector_ElementSelector_Async_Comparer_All() var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), eq); + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), eq); await Groups_AssertCore(resS, resA); } @@ -266,9 +266,9 @@ public async Task KeySelector_ElementSelector_Async_Comparer_All() [Fact] public void KeySelector_ResultSelector_Async_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), default(Func, ValueTask>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, (int x) => new ValueTask(x), default(Func, ValueTask>))); } [Fact] @@ -278,7 +278,7 @@ public async Task KeySelector_ResultSelector_Async_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count()); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name), async (k, g) => k + " - " + await g.CountAsync()); // REVIEW: Ambiguity + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name), async (k, g) => k + " - " + await g.CountAsync()); await Group_Result_AssertCore(resS, resA); } @@ -286,9 +286,9 @@ public async Task KeySelector_ResultSelector_Async_All() [Fact] public void KeySelector_ResultSelector_Async_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func, ValueTask>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func, ValueTask>), EqualityComparer.Default)); } [Fact] @@ -300,7 +300,7 @@ public async Task KeySelector_ResultSelector_Async_Comparer_All() var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count(), eq); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name), async (k, g) => k + " - " + await g.CountAsync(), eq); + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name), async (k, g) => k + " - " + await g.CountAsync(), eq); await Group_Result_AssertCore(resS, resA); } @@ -308,10 +308,10 @@ public async Task KeySelector_ResultSelector_Async_Comparer_All() [Fact] public void KeySelector_ElementSelector_ResultSelector_Async_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), default(Func>), (k, g) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x) => new ValueTask(x), (int x) => new ValueTask(x), default(Func, ValueTask>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>), (int x) => new ValueTask(x), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, (int x) => new ValueTask(x), default(Func>), (k, g) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, (int x) => new ValueTask(x), (int x) => new ValueTask(x), default(Func, ValueTask>))); } [Fact] @@ -321,7 +321,7 @@ public async Task KeySelector_ElementSelector_ResultSelector_Async_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count()); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), async (k, g) => k + " - " + await g.CountAsync()); // REVIEW: Ambiguity + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), async (k, g) => k + " - " + await g.CountAsync()); await Group_Result_AssertCore(resS, resA); } @@ -329,10 +329,10 @@ public async Task KeySelector_ElementSelector_ResultSelector_Async_All() [Fact] public void KeySelector_ElementSelector_ResultSelector_Async_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func>), (k, g) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), default(Func, ValueTask>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(Return42, default(Func>), (int x) => new ValueTask(x), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), default(Func>), (k, g) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwait(default(IAsyncEnumerable), (int x) => new ValueTask(x), (int x) => new ValueTask(x), default(Func, ValueTask>), EqualityComparer.Default)); } [Fact] @@ -344,7 +344,7 @@ public async Task KeySelector_ElementSelector_ResultSelector_Async_Comparer_All( var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count(), eq); - var resA = methodsA.GroupBy(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), async (k, g) => k + " - " + await g.CountAsync(), eq); + var resA = methodsA.GroupByAwait(m => new ValueTask(m.Name), m => new ValueTask(m.Name.ToUpper()), async (k, g) => k + " - " + await g.CountAsync(), eq); await Group_Result_AssertCore(resS, resA); } @@ -353,8 +353,8 @@ public async Task KeySelector_ElementSelector_ResultSelector_Async_Comparer_All( [Fact] public void KeySelector_Async_Cancel_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>))); } [Fact] @@ -364,7 +364,7 @@ public async Task KeySelector_Async_Cancel_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name)); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name)); await Groups_AssertCore(resS, resA); } @@ -372,8 +372,8 @@ public async Task KeySelector_Async_Cancel_All() [Fact] public void KeySelector_Async_Cancel_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>), EqualityComparer.Default)); } [Fact] @@ -385,7 +385,7 @@ public async Task KeySelector_Async_Cancel_Comparer_All() var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, eq); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), eq); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name), eq); await Groups_AssertCore(resS, resA); } @@ -393,9 +393,9 @@ public async Task KeySelector_Async_Cancel_Comparer_All() [Fact] public void KeySelector_ElementSelector_Async_Cancel_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func>))); } [Fact] @@ -405,7 +405,7 @@ public async Task KeySelector_ElementSelector_Async_Cancel_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper()); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper())); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper())); await Groups_AssertCore(resS, resA); } @@ -413,9 +413,9 @@ public async Task KeySelector_ElementSelector_Async_Cancel_All() [Fact] public void KeySelector_ElementSelector_Async_Cancel_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func>), EqualityComparer.Default)); } [Fact] @@ -427,7 +427,7 @@ public async Task KeySelector_ElementSelector_Async_Cancel_Comparer_All() var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), eq); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), eq); await Groups_AssertCore(resS, resA); } @@ -435,9 +435,9 @@ public async Task KeySelector_ElementSelector_Async_Cancel_Comparer_All() [Fact] public void KeySelector_ResultSelector_Async_Cancel_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g, ct) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>))); } [Fact] @@ -447,7 +447,7 @@ public async Task KeySelector_ResultSelector_Async_Cancel_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count()); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), async (k, g, ct) => k + " - " + await g.CountAsync(ct)); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name), async (k, g, ct) => k + " - " + await g.CountAsync(ct)); await Group_Result_AssertCore(resS, resA); } @@ -455,9 +455,9 @@ public async Task KeySelector_ResultSelector_Async_Cancel_All() [Fact] public void KeySelector_ResultSelector_Async_Cancel_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>), EqualityComparer.Default)); } [Fact] @@ -469,7 +469,7 @@ public async Task KeySelector_ResultSelector_Async_Cancel_Comparer_All() var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count(), eq); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), async (k, g, ct) => k + " - " + await g.CountAsync(ct), eq); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name), async (k, g, ct) => k + " - " + await g.CountAsync(ct), eq); await Group_Result_AssertCore(resS, resA); } @@ -477,10 +477,10 @@ public async Task KeySelector_ResultSelector_Async_Cancel_Comparer_All() [Fact] public void KeySelector_ElementSelector_ResultSelector_Async_Cancel_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func>), (k, g, ct) => new ValueTask(0))); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, (int x, CancellationToken ct) => new ValueTask(x), default(Func>), (k, g, ct) => new ValueTask(0))); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>))); } [Fact] @@ -490,7 +490,7 @@ public async Task KeySelector_ElementSelector_ResultSelector_Async_Cancel_All() var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count()); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), async (k, g, ct) => k + " - " + await g.CountAsync(ct)); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), async (k, g, ct) => k + " - " + await g.CountAsync(ct)); await Group_Result_AssertCore(resS, resA); } @@ -498,10 +498,10 @@ public async Task KeySelector_ElementSelector_ResultSelector_Async_Cancel_All() [Fact] public void KeySelector_ElementSelector_ResultSelector_Async_Cancel_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func>), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(Return42, default(Func>), (int x, CancellationToken ct) => new ValueTask(x), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), default(Func>), (k, g, ct) => new ValueTask(0), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupByAwaitWithCancellation(default(IAsyncEnumerable), (int x, CancellationToken ct) => new ValueTask(x), (int x, CancellationToken ct) => new ValueTask(x), default(Func, CancellationToken, ValueTask>), EqualityComparer.Default)); } [Fact] @@ -513,7 +513,7 @@ public async Task KeySelector_ElementSelector_ResultSelector_Async_Cancel_Compar var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count(), eq); - var resA = methodsA.GroupBy((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), async (k, g, ct) => k + " - " + await g.CountAsync(ct), eq); + var resA = methodsA.GroupByAwaitWithCancellation((m, ct) => new ValueTask(m.Name), (m, ct) => new ValueTask(m.Name.ToUpper()), async (k, g, ct) => k + " - " + await g.CountAsync(ct), eq); await Group_Result_AssertCore(resS, resA); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt index 6e5e416970..3cac0da180 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.Generated.tt @@ -24,6 +24,7 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) { string keySelectorType, elementSelectorType, resultSelectorType; string keySelectorFunc, elementSelectorFunc, resultSelectorFunc; + string suffix; bool isCancel = false; switch (kind) @@ -33,18 +34,21 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) keySelectorFunc = elementSelectorFunc = "(int x) => x"; resultSelectorType = "Func, int>"; resultSelectorFunc = "(k, g) => 0"; + suffix = ""; break; case "Async": keySelectorType = elementSelectorType = "Func>"; keySelectorFunc = elementSelectorFunc = "(int x) => new ValueTask(x)"; resultSelectorType = "Func, ValueTask>"; resultSelectorFunc = "(k, g) => new ValueTask(0)"; + suffix = "Await"; break; case "Async_Cancel": keySelectorType = elementSelectorType = "Func>"; keySelectorFunc = elementSelectorFunc = "(int x, CancellationToken ct) => new ValueTask(x)"; resultSelectorType = "Func, CancellationToken, ValueTask>"; resultSelectorFunc = "(k, g, ct) => new ValueTask(0)"; + suffix = "AwaitWithCancellation"; isCancel = true; break; default: @@ -84,8 +88,8 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) [Fact] public void KeySelector_<#=kind#>_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>))); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>))); } [Fact] @@ -95,7 +99,7 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name); - var resA = methodsA.GroupBy(<#=keySelector#>); + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>); await Groups_AssertCore(resS, resA); } @@ -103,8 +107,8 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) [Fact] public void KeySelector_<#=kind#>_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>), EqualityComparer.Default)); } [Fact] @@ -116,7 +120,7 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, eq); - var resA = methodsA.GroupBy(<#=keySelector#>, eq); + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>, eq); await Groups_AssertCore(resS, resA); } @@ -124,9 +128,9 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) [Fact] public void KeySelector_ElementSelector_<#=kind#>_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, default(<#=elementSelectorType#>))); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, <#=keySelectorFunc#>, default(<#=elementSelectorType#>))); } [Fact] @@ -136,7 +140,7 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper()); - var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>); + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>, <#=elementSelector#>); await Groups_AssertCore(resS, resA); } @@ -144,9 +148,9 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) [Fact] public void KeySelector_ElementSelector_<#=kind#>_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=elementSelectorType#>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=elementSelectorType#>), EqualityComparer.Default)); } [Fact] @@ -158,7 +162,7 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), eq); - var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, eq); + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>, <#=elementSelector#>, eq); await Groups_AssertCore(resS, resA); } @@ -166,9 +170,9 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) [Fact] public void KeySelector_ResultSelector_<#=kind#>_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=resultSelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=resultSelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, default(<#=resultSelectorType#>))); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>), <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, <#=keySelectorFunc#>, default(<#=resultSelectorType#>))); } [Fact] @@ -178,20 +182,7 @@ foreach (var kind in new[] { "Sync", "Async", "Async_Cancel" }) var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count()); -<# -if (kind == "Async") -{ -#> - var resA = methodsA.GroupBy(<#=keySelector#>, <#=resultSelector#>); // REVIEW: Ambiguity -<# -} -else -{ -#> - var resA = methodsA.GroupBy(<#=keySelector#>, <#=resultSelector#>); -<# -} -#> + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>, <#=resultSelector#>); await Group_Result_AssertCore(resS, resA); } @@ -199,9 +190,9 @@ else [Fact] public void KeySelector_ResultSelector_<#=kind#>_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=resultSelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=resultSelectorType#>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>), <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=resultSelectorType#>), EqualityComparer.Default)); } [Fact] @@ -213,7 +204,7 @@ else var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, (k, g) => k + " - " + g.Count(), eq); - var resA = methodsA.GroupBy(<#=keySelector#>, <#=resultSelector#>, eq); + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>, <#=resultSelector#>, eq); await Group_Result_AssertCore(resS, resA); } @@ -221,10 +212,10 @@ else [Fact] public void KeySelector_ElementSelector_ResultSelector_<#=kind#>_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, <#=resultSelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, <#=resultSelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, default(<#=elementSelectorType#>), <#=resultSelectorFunc#>)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, <#=keySelectorFunc#>, <#=elementSelectorFunc#>, default(<#=resultSelectorType#>))); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, <#=keySelectorFunc#>, default(<#=elementSelectorType#>), <#=resultSelectorFunc#>)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, <#=keySelectorFunc#>, <#=elementSelectorFunc#>, default(<#=resultSelectorType#>))); } [Fact] @@ -234,20 +225,7 @@ else var methodsA = methodsS.ToAsyncEnumerable(); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count()); -<# -if (kind == "Async") -{ -#> - var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>); // REVIEW: Ambiguity -<# -} -else -{ -#> - var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>); -<# -} -#> + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>); await Group_Result_AssertCore(resS, resA); } @@ -255,10 +233,10 @@ else [Fact] public void KeySelector_ElementSelector_ResultSelector_<#=kind#>_Comparer_Null() { - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=elementSelectorType#>), <#=resultSelectorFunc#>, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, default(<#=resultSelectorType#>), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(Return42, default(<#=keySelectorType#>), <#=elementSelectorFunc#>, <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, default(<#=elementSelectorType#>), <#=resultSelectorFunc#>, EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy<#=suffix#>(default(IAsyncEnumerable), <#=keySelectorFunc#>, <#=elementSelectorFunc#>, default(<#=resultSelectorType#>), EqualityComparer.Default)); } [Fact] @@ -270,7 +248,7 @@ else var eq = new StringPrefixEqualityComparer(1); var resS = methodsS.GroupBy(m => m.Name, m => m.Name.ToUpper(), (k, g) => k + " - " + g.Count(), eq); - var resA = methodsA.GroupBy(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>, eq); + var resA = methodsA.GroupBy<#=suffix#>(<#=keySelector#>, <#=elementSelector#>, <#=resultSelector#>, eq); await Group_Result_AssertCore(resS, resA); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs index 6d04d8ef96..c3249c3221 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/GroupBy.cs @@ -214,7 +214,7 @@ public async Task GroupBy_KeySelector_Sync_SequenceIdentity() public void GroupBy_KeySelector_Sync_Comparer_Null() { Assert.Throws(() => AsyncEnumerable.GroupBy(default, x => x, EqualityComparer.Default)); - Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default(Func), EqualityComparer.Default)); + Assert.Throws(() => AsyncEnumerable.GroupBy(Return42, default, EqualityComparer.Default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index ea470b905f..026ebe24f9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -23,17 +23,17 @@ public async Task Last_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(Return42, default, CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); #endif } @@ -173,159 +173,159 @@ public async Task LastAsync_Predicate_PredicateThrows() } [Fact] - public async Task LastAsync_AsyncPredicate_Empty() + public async Task LastAwaitAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().LastAsync(x => new ValueTask(true)); + var res = AsyncEnumerable.Empty().LastAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicate_Throw() + public async Task LastAwaitAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastAsync(x => new ValueTask(true)); + var res = Throw(ex).LastAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task LastAsync_AsyncPredicate_Single_None() + public async Task LastAwaitAsync_Predicate_Single_None() { - var res = Return42.LastAsync(x => new ValueTask(x % 2 != 0)); + var res = Return42.LastAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicate_Many_IList_None() + public async Task LastAwaitAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicate_Many_None() + public async Task LastAwaitAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicate_Single_Pass() + public async Task LastAwaitAsync_Predicate_Single_Pass() { - var res = Return42.LastAsync(x => new ValueTask(x % 2 == 0)); + var res = Return42.LastAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task LastAsync_AsyncPredicate_Many_IList_Pass1() + public async Task LastAwaitAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicate_Many_IList_Pass2() + public async Task LastAwaitAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicate_Many_Pass1() + public async Task LastAwaitAsync_Predicate_Many_Pass1() { - var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicate_Many_Pass2() + public async Task LastAwaitAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicate_AsyncPredicateThrows() + public async Task LastAwaitAsync_Predicate_AsyncPredicateThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync(x => new ValueTask(1 / x > 0)); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAwaitAsync(x => new ValueTask(1 / x > 0)); await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Empty() + public async Task LastAwaitWithCancellationAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().LastAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = AsyncEnumerable.Empty().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Throw() + public async Task LastAwaitWithCancellationAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = Throw(ex).LastAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res, ex); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Single_None() + public async Task LastAwaitWithCancellationAsync_Predicate_Single_None() { - var res = Return42.LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = Return42.LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Many_IList_None() + public async Task LastAwaitWithCancellationAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Many_None() + public async Task LastAwaitWithCancellationAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Single_Pass() + public async Task LastAwaitWithCancellationAsync_Predicate_Single_Pass() { - var res = Return42.LastAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); + var res = Return42.LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); Assert.Equal(42, await res); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() + public async Task LastAwaitWithCancellationAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + public async Task LastAwaitWithCancellationAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Many_Pass1() + public async Task LastAwaitWithCancellationAsync_Predicate_Many_Pass1() { - var res = new[] { 43, 44, 45 }.Select((x, ct) => x).ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 43, 44, 45 }.Select((x, ct) => x).ToAsyncEnumerable().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_Many_Pass2() + public async Task LastAwaitWithCancellationAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + public async Task LastAwaitWithCancellationAsync_Predicate_AsyncPredicateWithCancellationThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastAwaitWithCancellationAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index bf72fa19c3..9f39b5738e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -23,17 +23,17 @@ public async Task LastOrDefault_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(Return42, default, CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); #endif } @@ -173,159 +173,159 @@ public async Task LastOrDefaultAsync_Predicate_PredicateThrows() } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Empty() + public async Task LastOrDefaultAwaitAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().LastOrDefaultAsync(x => new ValueTask(true)); + var res = AsyncEnumerable.Empty().LastOrDefaultAwaitAsync(x => new ValueTask(true)); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Throw() + public async Task LastOrDefaultAwaitAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastOrDefaultAsync(x => new ValueTask(true)); + var res = Throw(ex).LastOrDefaultAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Single_None() + public async Task LastOrDefaultAwaitAsync_Predicate_Single_None() { - var res = Return42.LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = Return42.LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Many_IList_None() + public async Task LastOrDefaultAwaitAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Many_None() + public async Task LastOrDefaultAwaitAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 40, 42, 44 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Single_Pass() + public async Task LastOrDefaultAwaitAsync_Predicate_Single_Pass() { - var res = Return42.LastOrDefaultAsync(x => new ValueTask(x % 2 == 0)); + var res = Return42.LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Many_IList_Pass1() + public async Task LastOrDefaultAwaitAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Many_IList_Pass2() + public async Task LastOrDefaultAwaitAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Many_Pass1() + public async Task LastOrDefaultAwaitAsync_Predicate_Many_Pass1() { - var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 43, 44, 45 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_Many_Pass2() + public async Task LastOrDefaultAwaitAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.Select(x => x).ToAsyncEnumerable().LastOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicate_AsyncPredicateThrows() + public async Task LastOrDefaultAwaitAsync_Predicate_AsyncPredicateThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync(x => new ValueTask(1 / x > 0)); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAwaitAsync(x => new ValueTask(1 / x > 0)); await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Empty() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().LastOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = AsyncEnumerable.Empty().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Throw() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Throw() { var ex = new Exception("Bang!"); - var res = Throw(ex).LastOrDefaultAsync((x, ct) => new ValueTask(true), CancellationToken.None); + var res = Throw(ex).LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(true), CancellationToken.None); await AssertThrowsAsync(res, ex); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Single_None() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Single_None() { - var res = Return42.LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = Return42.LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_None() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Many_IList_None() { - var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.ToAsyncEnumerable().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_None() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Many_None() { - var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 40, 42, 44 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(0, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Single_Pass() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Single_Pass() { - var res = Return42.LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); + var res = Return42.LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0), CancellationToken.None); Assert.Equal(42, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass1() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Many_IList_Pass1() { - var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 43, 44, 45 }.ToAsyncEnumerable().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_IList_Pass2() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Many_IList_Pass2() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass1() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Many_Pass1() { - var res = new[] { 43, 44, 45 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 43, 44, 45 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_Many_Pass2() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Many_Pass2() { - var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); + var res = new[] { 42, 45, 90 }.Select((x, ct) => x).ToAsyncEnumerable().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0), CancellationToken.None); Assert.Equal(45, await res); } [Fact] - public async Task LastOrDefaultAsync_AsyncPredicateWithCancellation_AsyncPredicateWithCancellationThrows() + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_AsyncPredicateWithCancellationThrows() { - var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); + var res = new[] { 0, 1, 2 }.ToAsyncEnumerable().LastOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(1 / x > 0), CancellationToken.None); await AssertThrowsAsync(res.AsTask()); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs index cc31f9ea83..f38b41735d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs @@ -40,7 +40,7 @@ public async Task LongCountAsync_Predicate_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] @@ -66,68 +66,68 @@ public async Task LongCountAsync_Predicate_Throws_Source() } [Fact] - public async Task LongCountAsync_AsyncPredicate_Null() + public async Task LongCountAwaitAsync_Predicate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task LongCountAsync_AsyncPredicate() + public async Task LongCountAwaitAsync_Predicate() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCountAsync(x => new ValueTask(x < 3))); - Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAsync(x => new ValueTask(x < 3))); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCountAwaitAsync(x => new ValueTask(x < 3))); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAwaitAsync(x => new ValueTask(x < 3))); } [Fact] - public async Task LongCountAsync_AsyncPredicate_Throws_Predicate() + public async Task LongCountAwaitAsync_Predicate_Throws_Predicate() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAsync(new Func>(x => { throw ex; })); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAwaitAsync(new Func>(x => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task LongCountAsync_AsyncPredicate_Throws_Source() + public async Task LongCountAwaitAsync_Predicate_Throws_Source() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).LongCountAsync(x => new ValueTask(x < 3)), ex); + await AssertThrowsAsync(Throw(ex).LongCountAwaitAsync(x => new ValueTask(x < 3)), ex); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task LongCountAsync_AsyncPredicateCancel_Null() + public async Task LongCountAwaitWithCancellationAsync_Predicate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, (x, ct) => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitWithCancellationAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LongCountAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task LongCountAsync_AsyncPredicateCancel() + public async Task LongCountAwaitWithCancellationAsync_Predicate() { - Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCountAsync((x, ct) => new ValueTask(x < 3))); - Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAsync((x, ct) => new ValueTask(x < 3))); + Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCountAwaitWithCancellationAsync((x, ct) => new ValueTask(x < 3))); + Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAwaitWithCancellationAsync((x, ct) => new ValueTask(x < 3))); } [Fact] - public async Task LongCountAsync_AsyncPredicateCancel_Throws_Predicate() + public async Task LongCountAwaitWithCancellationAsync_Predicate_Throws_Predicate() { var ex = new Exception("Bang!"); - var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAsync(new Func>((x, ct) => { throw ex; })); + var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCountAwaitWithCancellationAsync(new Func>((x, ct) => { throw ex; })); await AssertThrowsAsync(ys, ex); } [Fact] - public async Task LongCountAsync_AsyncPredicateCancel_Throws_Source() + public async Task LongCountAwaitWithCancellationAsync_Predicate_Throws_Source() { var ex = new Exception("Bang!"); - await AssertThrowsAsync(Throw(ex).LongCountAsync((x, ct) => new ValueTask(x < 3)), ex); + await AssertThrowsAsync(Throw(ex).LongCountAwaitWithCancellationAsync((x, ct) => new ValueTask(x < 3)), ex); } #endif } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs index fddf2a33fa..449a75331f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Max.cs @@ -79,7 +79,7 @@ public async Task MaxAsync_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); @@ -92,76 +92,76 @@ public async Task MaxAsync_Null() // Max(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif // Max(IAE) @@ -184,19 +184,19 @@ public async Task MaxAsync_Null() // Max(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Max(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MaxAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } @@ -207,9 +207,9 @@ public async Task MaxAsync_Int32() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -220,9 +220,9 @@ public async Task MaxAsync_Nullable_Int32() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -233,9 +233,9 @@ public async Task MaxAsync_Int64() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -246,9 +246,9 @@ public async Task MaxAsync_Nullable_Int64() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -259,9 +259,9 @@ public async Task MaxAsync_Double() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -272,9 +272,9 @@ public async Task MaxAsync_Nullable_Double() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -285,9 +285,9 @@ public async Task MaxAsync_Single() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -298,9 +298,9 @@ public async Task MaxAsync_Nullable_Single() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -311,9 +311,9 @@ public async Task MaxAsync_Decimal() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -324,9 +324,9 @@ public async Task MaxAsync_Nullable_Decimal() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -337,9 +337,9 @@ public async Task MaxAsync_TSource_Value() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -350,9 +350,9 @@ public async Task MaxAsync_TSource_NonValue() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -362,9 +362,9 @@ public async Task MaxAsync_TSource_Value_Empty() var xs = new DateTimeOffset[0].ToAsyncEnumerable(); await AssertThrowsAsync(xs.MaxAsync().AsTask()); await AssertThrowsAsync(xs.MaxAsync(x => x).AsTask()); - await AssertThrowsAsync(xs.MaxAsync(x => new ValueTask(x)).AsTask()); + await AssertThrowsAsync(xs.MaxAwaitAsync(x => new ValueTask(x)).AsTask()); #if !NO_DEEP_CANCELLATION - await AssertThrowsAsync(xs.MaxAsync((x, ct) => new ValueTask(x)).AsTask()); + await AssertThrowsAsync(xs.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x)).AsTask()); #endif } @@ -374,9 +374,9 @@ public async Task MaxAsync_TSource_NonValue_Empty() var xs = new string[0].ToAsyncEnumerable(); Assert.Null(await xs.MaxAsync()); Assert.Null(await xs.MaxAsync(x => x)); - Assert.Null(await xs.MaxAsync(x => new ValueTask(x))); + Assert.Null(await xs.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Null(await xs.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Null(await xs.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -386,9 +386,9 @@ public async Task MaxAsync_TSource_NullableValue_Empty() var xs = new DateTimeOffset?[0].ToAsyncEnumerable(); Assert.Null(await xs.MaxAsync()); Assert.Null(await xs.MaxAsync(x => x)); - Assert.Null(await xs.MaxAsync(x => new ValueTask(x))); + Assert.Null(await xs.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Null(await xs.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Null(await xs.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -399,9 +399,9 @@ public async Task MaxAsync_TSource_NullableValue_SomeNull() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Max(), await ys.MaxAsync()); Assert.Equal(xs.Max(), await ys.MaxAsync(x => x)); - Assert.Equal(xs.Max(), await ys.MaxAsync(x => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Max(), await ys.MaxAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Max(), await ys.MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs index aa8a5fff2d..8fd7f3d6a8 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Min.cs @@ -79,7 +79,7 @@ public async Task MinAsync_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); @@ -92,76 +92,76 @@ public async Task MinAsync_Null() // Min(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif // Min(IAE) @@ -184,19 +184,19 @@ public async Task MinAsync_Null() // Min(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Min(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.MinAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.MinAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } @@ -207,9 +207,9 @@ public async Task MinAsync_Int32() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -220,9 +220,9 @@ public async Task MinAsync_Nullable_Int32() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -233,9 +233,9 @@ public async Task MinAsync_Int64() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -246,9 +246,9 @@ public async Task MinAsync_Nullable_Int64() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -259,9 +259,9 @@ public async Task MinAsync_Double() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -272,9 +272,9 @@ public async Task MinAsync_Nullable_Double() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -285,9 +285,9 @@ public async Task MinAsync_Single() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -298,9 +298,9 @@ public async Task MinAsync_Nullable_Single() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -311,9 +311,9 @@ public async Task MinAsync_Decimal() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -324,9 +324,9 @@ public async Task MinAsync_Nullable_Decimal() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -337,9 +337,9 @@ public async Task MinAsync_TSource_Value() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -350,9 +350,9 @@ public async Task MinAsync_TSource_NonValue() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -362,9 +362,9 @@ public async Task MinAsync_TSource_Value_Empty() var xs = new DateTimeOffset[0].ToAsyncEnumerable(); await AssertThrowsAsync(xs.MinAsync().AsTask()); await AssertThrowsAsync(xs.MinAsync(x => x).AsTask()); - await AssertThrowsAsync(xs.MinAsync(x => new ValueTask(x)).AsTask()); + await AssertThrowsAsync(xs.MinAwaitAsync(x => new ValueTask(x)).AsTask()); #if !NO_DEEP_CANCELLATION - await AssertThrowsAsync(xs.MinAsync((x, ct) => new ValueTask(x)).AsTask()); + await AssertThrowsAsync(xs.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x)).AsTask()); #endif } @@ -374,9 +374,9 @@ public async Task MinAsync_TSource_NonValue_Empty() var xs = new string[0].ToAsyncEnumerable(); Assert.Null(await xs.MinAsync()); Assert.Null(await xs.MinAsync(x => x)); - Assert.Null(await xs.MinAsync(x => new ValueTask(x))); + Assert.Null(await xs.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Null(await xs.MinAsync((x, ct) => new ValueTask(x))); + Assert.Null(await xs.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -386,9 +386,9 @@ public async Task MinAsync_TSource_NullableValue_Empty() var xs = new DateTimeOffset?[0].ToAsyncEnumerable(); Assert.Null(await xs.MinAsync()); Assert.Null(await xs.MinAsync(x => x)); - Assert.Null(await xs.MinAsync(x => new ValueTask(x))); + Assert.Null(await xs.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Null(await xs.MinAsync((x, ct) => new ValueTask(x))); + Assert.Null(await xs.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } @@ -399,9 +399,9 @@ public async Task MinAsync_TSource_NullableValue_SomeNull() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Min(), await ys.MinAsync()); Assert.Equal(xs.Min(), await ys.MinAsync(x => x)); - Assert.Equal(xs.Min(), await ys.MinAsync(x => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitAsync(x => new ValueTask(x))); #if !NO_DEEP_CANCELLATION - Assert.Equal(xs.Min(), await ys.MinAsync((x, ct) => new ValueTask(x))); + Assert.Equal(xs.Min(), await ys.MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x))); #endif } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs index 9eb07b0dee..78ef70542c 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.cs @@ -14,59 +14,59 @@ namespace Tests public class MinMax : AsyncEnumerableTests { [Fact] - public async Task Min_Empty_Int32() + public async Task MinAsync_Empty_Int32() { await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Min_Selector_Empty_Int32() + public async Task MinAsync_Selector_Empty_Int32() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(int), CancellationToken.None).AsTask()); } [Fact] - public async Task Min_AsyncSelector_Empty_Int32() + public async Task MinAwaitAsync_Selector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Int32() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Min_Empty_Nullable_Int32() + public async Task MinAsync_Empty_Nullable_Int32() { Assert.Null(await new int?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); } [Fact] - public async Task Min_Selector_Empty_Nullable_Int32() + public async Task MinAsync_Selector_Empty_Nullable_Int32() { Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(int?), CancellationToken.None)); } [Fact] - public async Task Min_AsyncSelector_Empty_Nullable_Int32() + public async Task MinAwaitAsync_Selector_Empty_Nullable_Int32() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Int32() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Nullable_Int32() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Min_Int32_1() + public async Task MinAsync_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); @@ -81,7 +81,7 @@ public async Task Min_Int32_1() } [Fact] - public async Task Min_Selector_Int32_1() + public async Task MinAsync_Selector_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); @@ -96,14 +96,14 @@ public async Task Min_Selector_Int32_1() } [Fact] - public async Task Min_AsyncSelector_Int32_1() + public async Task MinAwaitAsync_Selector_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -112,14 +112,14 @@ public async Task Min_AsyncSelector_Int32_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_1() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -128,7 +128,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_1() #endif [Fact] - public async Task Min_Int32_Nullable_1_NoNull() + public async Task MinAsync_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -143,7 +143,7 @@ public async Task Min_Int32_Nullable_1_NoNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_1_NoNull() + public async Task MinAsync_Selector_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -158,14 +158,14 @@ public async Task Min_Selector_Int32_Nullable_1_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_1_NoNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -174,14 +174,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -190,7 +190,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_NoNull() #endif [Fact] - public async Task Min_Int32_Nullable_1_AllNull() + public async Task MinAsync_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); @@ -200,7 +200,7 @@ public async Task Min_Int32_Nullable_1_AllNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_1_AllNull() + public async Task MinAsync_Selector_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); @@ -210,29 +210,29 @@ public async Task Min_Selector_Int32_Nullable_1_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_1_AllNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int32_Nullable_1_SomeNull() + public async Task MinAsync_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -247,7 +247,7 @@ public async Task Min_Int32_Nullable_1_SomeNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_1_SomeNull() + public async Task MinAsync_Selector_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -262,14 +262,14 @@ public async Task Min_Selector_Int32_Nullable_1_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_1_SomeNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -278,14 +278,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -294,7 +294,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_1_SomeNull() #endif [Fact] - public async Task Min_Int32_4() + public async Task MinAsync_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -309,7 +309,7 @@ public async Task Min_Int32_4() } [Fact] - public async Task Min_Selector_Int32_4() + public async Task MinAsync_Selector_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -324,14 +324,14 @@ public async Task Min_Selector_Int32_4() } [Fact] - public async Task Min_AsyncSelector_Int32_4() + public async Task MinAwaitAsync_Selector_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -340,14 +340,14 @@ public async Task Min_AsyncSelector_Int32_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_4() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -356,7 +356,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_4() #endif [Fact] - public async Task Min_Int32_Nullable_4_NoNull() + public async Task MinAsync_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -371,7 +371,7 @@ public async Task Min_Int32_Nullable_4_NoNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_4_NoNull() + public async Task MinAsync_Selector_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -386,14 +386,14 @@ public async Task Min_Selector_Int32_Nullable_4_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_4_NoNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -402,14 +402,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -418,7 +418,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_NoNull() #endif [Fact] - public async Task Min_Int32_Nullable_4_AllNull() + public async Task MinAsync_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); @@ -428,7 +428,7 @@ public async Task Min_Int32_Nullable_4_AllNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_4_AllNull() + public async Task MinAsync_Selector_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); @@ -438,29 +438,29 @@ public async Task Min_Selector_Int32_Nullable_4_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_4_AllNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int32_Nullable_4_SomeNull() + public async Task MinAsync_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); @@ -475,7 +475,7 @@ public async Task Min_Int32_Nullable_4_SomeNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_4_SomeNull() + public async Task MinAsync_Selector_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); @@ -490,14 +490,14 @@ public async Task Min_Selector_Int32_Nullable_4_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_4_SomeNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -506,14 +506,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -522,7 +522,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_4_SomeNull() #endif [Fact] - public async Task Min_Int32_8() + public async Task MinAsync_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -537,7 +537,7 @@ public async Task Min_Int32_8() } [Fact] - public async Task Min_Selector_Int32_8() + public async Task MinAsync_Selector_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -552,14 +552,14 @@ public async Task Min_Selector_Int32_8() } [Fact] - public async Task Min_AsyncSelector_Int32_8() + public async Task MinAwaitAsync_Selector_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -568,14 +568,14 @@ public async Task Min_AsyncSelector_Int32_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_8() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -584,7 +584,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_8() #endif [Fact] - public async Task Min_Int32_Nullable_8_NoNull() + public async Task MinAsync_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -599,7 +599,7 @@ public async Task Min_Int32_Nullable_8_NoNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_8_NoNull() + public async Task MinAsync_Selector_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -614,14 +614,14 @@ public async Task Min_Selector_Int32_Nullable_8_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_8_NoNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -630,14 +630,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -646,7 +646,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_NoNull() #endif [Fact] - public async Task Min_Int32_Nullable_8_AllNull() + public async Task MinAsync_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); @@ -656,7 +656,7 @@ public async Task Min_Int32_Nullable_8_AllNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_8_AllNull() + public async Task MinAsync_Selector_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); @@ -666,29 +666,29 @@ public async Task Min_Selector_Int32_Nullable_8_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_8_AllNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int32_Nullable_8_SomeNull() + public async Task MinAsync_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -703,7 +703,7 @@ public async Task Min_Int32_Nullable_8_SomeNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_8_SomeNull() + public async Task MinAsync_Selector_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -718,14 +718,14 @@ public async Task Min_Selector_Int32_Nullable_8_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_8_SomeNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -734,14 +734,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -750,7 +750,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_8_SomeNull() #endif [Fact] - public async Task Min_Int32_16() + public async Task MinAsync_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -765,7 +765,7 @@ public async Task Min_Int32_16() } [Fact] - public async Task Min_Selector_Int32_16() + public async Task MinAsync_Selector_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -780,14 +780,14 @@ public async Task Min_Selector_Int32_16() } [Fact] - public async Task Min_AsyncSelector_Int32_16() + public async Task MinAwaitAsync_Selector_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -796,14 +796,14 @@ public async Task Min_AsyncSelector_Int32_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_16() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -812,7 +812,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_16() #endif [Fact] - public async Task Min_Int32_Nullable_16_NoNull() + public async Task MinAsync_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -827,7 +827,7 @@ public async Task Min_Int32_Nullable_16_NoNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_16_NoNull() + public async Task MinAsync_Selector_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -842,14 +842,14 @@ public async Task Min_Selector_Int32_Nullable_16_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_16_NoNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -858,14 +858,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -874,7 +874,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_NoNull() #endif [Fact] - public async Task Min_Int32_Nullable_16_AllNull() + public async Task MinAsync_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); @@ -884,7 +884,7 @@ public async Task Min_Int32_Nullable_16_AllNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_16_AllNull() + public async Task MinAsync_Selector_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); @@ -894,29 +894,29 @@ public async Task Min_Selector_Int32_Nullable_16_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_16_AllNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int32_Nullable_16_SomeNull() + public async Task MinAsync_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -931,7 +931,7 @@ public async Task Min_Int32_Nullable_16_SomeNull() } [Fact] - public async Task Min_Selector_Int32_Nullable_16_SomeNull() + public async Task MinAsync_Selector_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -946,14 +946,14 @@ public async Task Min_Selector_Int32_Nullable_16_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int32_Nullable_16_SomeNull() + public async Task MinAwaitAsync_Selector_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -962,14 +962,14 @@ public async Task Min_AsyncSelector_Int32_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -978,59 +978,59 @@ public async Task Min_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() #endif [Fact] - public async Task Min_Empty_Int64() + public async Task MinAsync_Empty_Int64() { await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Min_Selector_Empty_Int64() + public async Task MinAsync_Selector_Empty_Int64() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(long), CancellationToken.None).AsTask()); } [Fact] - public async Task Min_AsyncSelector_Empty_Int64() + public async Task MinAwaitAsync_Selector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Int64() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Min_Empty_Nullable_Int64() + public async Task MinAsync_Empty_Nullable_Int64() { Assert.Null(await new long?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); } [Fact] - public async Task Min_Selector_Empty_Nullable_Int64() + public async Task MinAsync_Selector_Empty_Nullable_Int64() { Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(long?), CancellationToken.None)); } [Fact] - public async Task Min_AsyncSelector_Empty_Nullable_Int64() + public async Task MinAwaitAsync_Selector_Empty_Nullable_Int64() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Int64() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Nullable_Int64() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Min_Int64_1() + public async Task MinAsync_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); @@ -1045,7 +1045,7 @@ public async Task Min_Int64_1() } [Fact] - public async Task Min_Selector_Int64_1() + public async Task MinAsync_Selector_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); @@ -1060,14 +1060,14 @@ public async Task Min_Selector_Int64_1() } [Fact] - public async Task Min_AsyncSelector_Int64_1() + public async Task MinAwaitAsync_Selector_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1076,14 +1076,14 @@ public async Task Min_AsyncSelector_Int64_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_1() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1092,7 +1092,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_1() #endif [Fact] - public async Task Min_Int64_Nullable_1_NoNull() + public async Task MinAsync_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -1107,7 +1107,7 @@ public async Task Min_Int64_Nullable_1_NoNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_1_NoNull() + public async Task MinAsync_Selector_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -1122,14 +1122,14 @@ public async Task Min_Selector_Int64_Nullable_1_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_1_NoNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1138,14 +1138,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1154,7 +1154,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_NoNull() #endif [Fact] - public async Task Min_Int64_Nullable_1_AllNull() + public async Task MinAsync_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); @@ -1164,7 +1164,7 @@ public async Task Min_Int64_Nullable_1_AllNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_1_AllNull() + public async Task MinAsync_Selector_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); @@ -1174,29 +1174,29 @@ public async Task Min_Selector_Int64_Nullable_1_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_1_AllNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int64_Nullable_1_SomeNull() + public async Task MinAsync_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -1211,7 +1211,7 @@ public async Task Min_Int64_Nullable_1_SomeNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_1_SomeNull() + public async Task MinAsync_Selector_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -1226,14 +1226,14 @@ public async Task Min_Selector_Int64_Nullable_1_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_1_SomeNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1242,14 +1242,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1258,7 +1258,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_1_SomeNull() #endif [Fact] - public async Task Min_Int64_4() + public async Task MinAsync_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -1273,7 +1273,7 @@ public async Task Min_Int64_4() } [Fact] - public async Task Min_Selector_Int64_4() + public async Task MinAsync_Selector_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -1288,14 +1288,14 @@ public async Task Min_Selector_Int64_4() } [Fact] - public async Task Min_AsyncSelector_Int64_4() + public async Task MinAwaitAsync_Selector_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1304,14 +1304,14 @@ public async Task Min_AsyncSelector_Int64_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_4() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1320,7 +1320,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_4() #endif [Fact] - public async Task Min_Int64_Nullable_4_NoNull() + public async Task MinAsync_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -1335,7 +1335,7 @@ public async Task Min_Int64_Nullable_4_NoNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_4_NoNull() + public async Task MinAsync_Selector_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -1350,14 +1350,14 @@ public async Task Min_Selector_Int64_Nullable_4_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_4_NoNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1366,14 +1366,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1382,7 +1382,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_NoNull() #endif [Fact] - public async Task Min_Int64_Nullable_4_AllNull() + public async Task MinAsync_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); @@ -1392,7 +1392,7 @@ public async Task Min_Int64_Nullable_4_AllNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_4_AllNull() + public async Task MinAsync_Selector_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); @@ -1402,29 +1402,29 @@ public async Task Min_Selector_Int64_Nullable_4_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_4_AllNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int64_Nullable_4_SomeNull() + public async Task MinAsync_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); @@ -1439,7 +1439,7 @@ public async Task Min_Int64_Nullable_4_SomeNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_4_SomeNull() + public async Task MinAsync_Selector_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); @@ -1454,14 +1454,14 @@ public async Task Min_Selector_Int64_Nullable_4_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_4_SomeNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1470,14 +1470,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1486,7 +1486,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_4_SomeNull() #endif [Fact] - public async Task Min_Int64_8() + public async Task MinAsync_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -1501,7 +1501,7 @@ public async Task Min_Int64_8() } [Fact] - public async Task Min_Selector_Int64_8() + public async Task MinAsync_Selector_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -1516,14 +1516,14 @@ public async Task Min_Selector_Int64_8() } [Fact] - public async Task Min_AsyncSelector_Int64_8() + public async Task MinAwaitAsync_Selector_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1532,14 +1532,14 @@ public async Task Min_AsyncSelector_Int64_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_8() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1548,7 +1548,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_8() #endif [Fact] - public async Task Min_Int64_Nullable_8_NoNull() + public async Task MinAsync_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -1563,7 +1563,7 @@ public async Task Min_Int64_Nullable_8_NoNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_8_NoNull() + public async Task MinAsync_Selector_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -1578,14 +1578,14 @@ public async Task Min_Selector_Int64_Nullable_8_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_8_NoNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1594,14 +1594,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1610,7 +1610,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_NoNull() #endif [Fact] - public async Task Min_Int64_Nullable_8_AllNull() + public async Task MinAsync_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); @@ -1620,7 +1620,7 @@ public async Task Min_Int64_Nullable_8_AllNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_8_AllNull() + public async Task MinAsync_Selector_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); @@ -1630,29 +1630,29 @@ public async Task Min_Selector_Int64_Nullable_8_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_8_AllNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int64_Nullable_8_SomeNull() + public async Task MinAsync_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -1667,7 +1667,7 @@ public async Task Min_Int64_Nullable_8_SomeNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_8_SomeNull() + public async Task MinAsync_Selector_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -1682,14 +1682,14 @@ public async Task Min_Selector_Int64_Nullable_8_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_8_SomeNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1698,14 +1698,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1714,7 +1714,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_8_SomeNull() #endif [Fact] - public async Task Min_Int64_16() + public async Task MinAsync_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -1729,7 +1729,7 @@ public async Task Min_Int64_16() } [Fact] - public async Task Min_Selector_Int64_16() + public async Task MinAsync_Selector_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -1744,14 +1744,14 @@ public async Task Min_Selector_Int64_16() } [Fact] - public async Task Min_AsyncSelector_Int64_16() + public async Task MinAwaitAsync_Selector_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1760,14 +1760,14 @@ public async Task Min_AsyncSelector_Int64_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_16() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1776,7 +1776,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_16() #endif [Fact] - public async Task Min_Int64_Nullable_16_NoNull() + public async Task MinAsync_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -1791,7 +1791,7 @@ public async Task Min_Int64_Nullable_16_NoNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_16_NoNull() + public async Task MinAsync_Selector_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -1806,14 +1806,14 @@ public async Task Min_Selector_Int64_Nullable_16_NoNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_16_NoNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1822,14 +1822,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1838,7 +1838,7 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_NoNull() #endif [Fact] - public async Task Min_Int64_Nullable_16_AllNull() + public async Task MinAsync_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); @@ -1848,7 +1848,7 @@ public async Task Min_Int64_Nullable_16_AllNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_16_AllNull() + public async Task MinAsync_Selector_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); @@ -1858,29 +1858,29 @@ public async Task Min_Selector_Int64_Nullable_16_AllNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_16_AllNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Int64_Nullable_16_SomeNull() + public async Task MinAsync_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -1895,7 +1895,7 @@ public async Task Min_Int64_Nullable_16_SomeNull() } [Fact] - public async Task Min_Selector_Int64_Nullable_16_SomeNull() + public async Task MinAsync_Selector_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -1910,14 +1910,14 @@ public async Task Min_Selector_Int64_Nullable_16_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Int64_Nullable_16_SomeNull() + public async Task MinAwaitAsync_Selector_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1926,14 +1926,14 @@ public async Task Min_AsyncSelector_Int64_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -1942,59 +1942,59 @@ public async Task Min_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() #endif [Fact] - public async Task Min_Empty_Single() + public async Task MinAsync_Empty_Single() { await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Min_Selector_Empty_Single() + public async Task MinAsync_Selector_Empty_Single() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(float), CancellationToken.None).AsTask()); } [Fact] - public async Task Min_AsyncSelector_Empty_Single() + public async Task MinAwaitAsync_Selector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Single() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Min_Empty_Nullable_Single() + public async Task MinAsync_Empty_Nullable_Single() { Assert.Null(await new float?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); } [Fact] - public async Task Min_Selector_Empty_Nullable_Single() + public async Task MinAsync_Selector_Empty_Nullable_Single() { Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(float?), CancellationToken.None)); } [Fact] - public async Task Min_AsyncSelector_Empty_Nullable_Single() + public async Task MinAwaitAsync_Selector_Empty_Nullable_Single() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Single() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Nullable_Single() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Min_Single_1() + public async Task MinAsync_Single_1() { var input = new float[] { 33 }.AsEnumerable(); @@ -2009,7 +2009,7 @@ public async Task Min_Single_1() } [Fact] - public async Task Min_Selector_Single_1() + public async Task MinAsync_Selector_Single_1() { var input = new float[] { 33 }.AsEnumerable(); @@ -2024,14 +2024,14 @@ public async Task Min_Selector_Single_1() } [Fact] - public async Task Min_AsyncSelector_Single_1() + public async Task MinAwaitAsync_Selector_Single_1() { var input = new float[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2040,14 +2040,14 @@ public async Task Min_AsyncSelector_Single_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_1() + public async Task MinAwaitWithCancellationAsync_Selector_Single_1() { var input = new float[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2056,7 +2056,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_1() #endif [Fact] - public async Task Min_Single_Nullable_1_NoNull() + public async Task MinAsync_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -2071,7 +2071,7 @@ public async Task Min_Single_Nullable_1_NoNull() } [Fact] - public async Task Min_Selector_Single_Nullable_1_NoNull() + public async Task MinAsync_Selector_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -2086,14 +2086,14 @@ public async Task Min_Selector_Single_Nullable_1_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_1_NoNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2102,14 +2102,14 @@ public async Task Min_AsyncSelector_Single_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2118,7 +2118,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_NoNull() #endif [Fact] - public async Task Min_Single_Nullable_1_AllNull() + public async Task MinAsync_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -2128,7 +2128,7 @@ public async Task Min_Single_Nullable_1_AllNull() } [Fact] - public async Task Min_Selector_Single_Nullable_1_AllNull() + public async Task MinAsync_Selector_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -2138,29 +2138,29 @@ public async Task Min_Selector_Single_Nullable_1_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_1_AllNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_Nullable_1_SomeNull() + public async Task MinAsync_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -2175,7 +2175,7 @@ public async Task Min_Single_Nullable_1_SomeNull() } [Fact] - public async Task Min_Selector_Single_Nullable_1_SomeNull() + public async Task MinAsync_Selector_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -2190,14 +2190,14 @@ public async Task Min_Selector_Single_Nullable_1_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_1_SomeNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2206,14 +2206,14 @@ public async Task Min_AsyncSelector_Single_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2222,7 +2222,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_1_SomeNull() #endif [Fact] - public async Task Min_Single_4() + public async Task MinAsync_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -2237,7 +2237,7 @@ public async Task Min_Single_4() } [Fact] - public async Task Min_Selector_Single_4() + public async Task MinAsync_Selector_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -2252,14 +2252,14 @@ public async Task Min_Selector_Single_4() } [Fact] - public async Task Min_AsyncSelector_Single_4() + public async Task MinAwaitAsync_Selector_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2268,14 +2268,14 @@ public async Task Min_AsyncSelector_Single_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_4() + public async Task MinAwaitWithCancellationAsync_Selector_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2284,7 +2284,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_4() #endif [Fact] - public async Task Min_Single_Nullable_4_NoNull() + public async Task MinAsync_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -2299,7 +2299,7 @@ public async Task Min_Single_Nullable_4_NoNull() } [Fact] - public async Task Min_Selector_Single_Nullable_4_NoNull() + public async Task MinAsync_Selector_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -2314,14 +2314,14 @@ public async Task Min_Selector_Single_Nullable_4_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_4_NoNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2330,14 +2330,14 @@ public async Task Min_AsyncSelector_Single_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2346,7 +2346,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_NoNull() #endif [Fact] - public async Task Min_Single_Nullable_4_AllNull() + public async Task MinAsync_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -2356,7 +2356,7 @@ public async Task Min_Single_Nullable_4_AllNull() } [Fact] - public async Task Min_Selector_Single_Nullable_4_AllNull() + public async Task MinAsync_Selector_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -2366,29 +2366,29 @@ public async Task Min_Selector_Single_Nullable_4_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_4_AllNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_Nullable_4_SomeNull() + public async Task MinAsync_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); @@ -2403,7 +2403,7 @@ public async Task Min_Single_Nullable_4_SomeNull() } [Fact] - public async Task Min_Selector_Single_Nullable_4_SomeNull() + public async Task MinAsync_Selector_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); @@ -2418,14 +2418,14 @@ public async Task Min_Selector_Single_Nullable_4_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_4_SomeNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2434,14 +2434,14 @@ public async Task Min_AsyncSelector_Single_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2450,7 +2450,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_4_SomeNull() #endif [Fact] - public async Task Min_Single_8() + public async Task MinAsync_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -2465,7 +2465,7 @@ public async Task Min_Single_8() } [Fact] - public async Task Min_Selector_Single_8() + public async Task MinAsync_Selector_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -2480,14 +2480,14 @@ public async Task Min_Selector_Single_8() } [Fact] - public async Task Min_AsyncSelector_Single_8() + public async Task MinAwaitAsync_Selector_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2496,14 +2496,14 @@ public async Task Min_AsyncSelector_Single_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_8() + public async Task MinAwaitWithCancellationAsync_Selector_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2512,7 +2512,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_8() #endif [Fact] - public async Task Min_Single_Nullable_8_NoNull() + public async Task MinAsync_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -2527,7 +2527,7 @@ public async Task Min_Single_Nullable_8_NoNull() } [Fact] - public async Task Min_Selector_Single_Nullable_8_NoNull() + public async Task MinAsync_Selector_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -2542,14 +2542,14 @@ public async Task Min_Selector_Single_Nullable_8_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_8_NoNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2558,14 +2558,14 @@ public async Task Min_AsyncSelector_Single_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2574,7 +2574,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_NoNull() #endif [Fact] - public async Task Min_Single_Nullable_8_AllNull() + public async Task MinAsync_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -2584,7 +2584,7 @@ public async Task Min_Single_Nullable_8_AllNull() } [Fact] - public async Task Min_Selector_Single_Nullable_8_AllNull() + public async Task MinAsync_Selector_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -2594,29 +2594,29 @@ public async Task Min_Selector_Single_Nullable_8_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_8_AllNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_Nullable_8_SomeNull() + public async Task MinAsync_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -2631,7 +2631,7 @@ public async Task Min_Single_Nullable_8_SomeNull() } [Fact] - public async Task Min_Selector_Single_Nullable_8_SomeNull() + public async Task MinAsync_Selector_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -2646,14 +2646,14 @@ public async Task Min_Selector_Single_Nullable_8_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_8_SomeNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2662,14 +2662,14 @@ public async Task Min_AsyncSelector_Single_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2678,7 +2678,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_8_SomeNull() #endif [Fact] - public async Task Min_Single_16() + public async Task MinAsync_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -2693,7 +2693,7 @@ public async Task Min_Single_16() } [Fact] - public async Task Min_Selector_Single_16() + public async Task MinAsync_Selector_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -2708,14 +2708,14 @@ public async Task Min_Selector_Single_16() } [Fact] - public async Task Min_AsyncSelector_Single_16() + public async Task MinAwaitAsync_Selector_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2724,14 +2724,14 @@ public async Task Min_AsyncSelector_Single_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_16() + public async Task MinAwaitWithCancellationAsync_Selector_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2740,7 +2740,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_16() #endif [Fact] - public async Task Min_Single_Nullable_16_NoNull() + public async Task MinAsync_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -2755,7 +2755,7 @@ public async Task Min_Single_Nullable_16_NoNull() } [Fact] - public async Task Min_Selector_Single_Nullable_16_NoNull() + public async Task MinAsync_Selector_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -2770,14 +2770,14 @@ public async Task Min_Selector_Single_Nullable_16_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_16_NoNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2786,14 +2786,14 @@ public async Task Min_AsyncSelector_Single_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2802,7 +2802,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_NoNull() #endif [Fact] - public async Task Min_Single_Nullable_16_AllNull() + public async Task MinAsync_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -2812,7 +2812,7 @@ public async Task Min_Single_Nullable_16_AllNull() } [Fact] - public async Task Min_Selector_Single_Nullable_16_AllNull() + public async Task MinAsync_Selector_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -2822,29 +2822,29 @@ public async Task Min_Selector_Single_Nullable_16_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_16_AllNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_Nullable_16_SomeNull() + public async Task MinAsync_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -2859,7 +2859,7 @@ public async Task Min_Single_Nullable_16_SomeNull() } [Fact] - public async Task Min_Selector_Single_Nullable_16_SomeNull() + public async Task MinAsync_Selector_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -2874,14 +2874,14 @@ public async Task Min_Selector_Single_Nullable_16_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_Nullable_16_SomeNull() + public async Task MinAwaitAsync_Selector_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2890,14 +2890,14 @@ public async Task Min_AsyncSelector_Single_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2906,7 +2906,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull( #endif [Fact] - public async Task Min_Single_WithNaN_1() + public async Task MinAsync_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); @@ -2921,7 +2921,7 @@ public async Task Min_Single_WithNaN_1() } [Fact] - public async Task Min_Selector_Single_WithNaN_1() + public async Task MinAsync_Selector_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); @@ -2936,14 +2936,14 @@ public async Task Min_Selector_Single_WithNaN_1() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_1() + public async Task MinAwaitAsync_Selector_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2952,14 +2952,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_1() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -2968,7 +2968,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_1() #endif [Fact] - public async Task Min_Single_WithNaN_1_AllNaN() + public async Task MinAsync_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -2978,7 +2978,7 @@ public async Task Min_Single_WithNaN_1_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_1_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -2988,29 +2988,29 @@ public async Task Min_Selector_Single_WithNaN_1_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_1_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_1_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_1_NoNull() + public async Task MinAsync_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); @@ -3025,7 +3025,7 @@ public async Task Min_Single_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_1_NoNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); @@ -3040,14 +3040,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_1_NoNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3056,14 +3056,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3072,7 +3072,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_No #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_1_AllNull() + public async Task MinAsync_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -3082,7 +3082,7 @@ public async Task Min_Single_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_1_AllNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -3092,29 +3092,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_1_AllNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_1_AllNaN() + public async Task MinAsync_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -3124,7 +3124,7 @@ public async Task Min_Single_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_1_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -3134,29 +3134,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_1_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_1_SomeNull() + public async Task MinAsync_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -3171,7 +3171,7 @@ public async Task Min_Single_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_1_SomeNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -3186,14 +3186,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_1_SomeNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3202,14 +3202,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3217,7 +3217,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_So } #endif [Fact] - public async Task Min_Single_WithNaN_4() + public async Task MinAsync_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -3232,7 +3232,7 @@ public async Task Min_Single_WithNaN_4() } [Fact] - public async Task Min_Selector_Single_WithNaN_4() + public async Task MinAsync_Selector_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -3247,14 +3247,14 @@ public async Task Min_Selector_Single_WithNaN_4() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_4() + public async Task MinAwaitAsync_Selector_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3263,14 +3263,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_4() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3279,7 +3279,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_4() #endif [Fact] - public async Task Min_Single_WithNaN_4_AllNaN() + public async Task MinAsync_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -3289,7 +3289,7 @@ public async Task Min_Single_WithNaN_4_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_4_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -3299,29 +3299,29 @@ public async Task Min_Selector_Single_WithNaN_4_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_4_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_4_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_4_NoNull() + public async Task MinAsync_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -3336,7 +3336,7 @@ public async Task Min_Single_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_4_NoNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -3351,14 +3351,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_4_NoNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3367,14 +3367,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3383,7 +3383,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_No #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_4_AllNull() + public async Task MinAsync_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -3393,7 +3393,7 @@ public async Task Min_Single_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_4_AllNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -3403,29 +3403,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_4_AllNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_4_AllNaN() + public async Task MinAsync_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -3435,7 +3435,7 @@ public async Task Min_Single_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_4_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -3445,29 +3445,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_4_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_4_SomeNull() + public async Task MinAsync_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); @@ -3482,7 +3482,7 @@ public async Task Min_Single_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_4_SomeNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); @@ -3497,14 +3497,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_4_SomeNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3513,14 +3513,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3528,7 +3528,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_So } #endif [Fact] - public async Task Min_Single_WithNaN_8() + public async Task MinAsync_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -3543,7 +3543,7 @@ public async Task Min_Single_WithNaN_8() } [Fact] - public async Task Min_Selector_Single_WithNaN_8() + public async Task MinAsync_Selector_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -3558,14 +3558,14 @@ public async Task Min_Selector_Single_WithNaN_8() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_8() + public async Task MinAwaitAsync_Selector_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3574,14 +3574,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_8() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3590,7 +3590,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_8() #endif [Fact] - public async Task Min_Single_WithNaN_8_AllNaN() + public async Task MinAsync_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -3600,7 +3600,7 @@ public async Task Min_Single_WithNaN_8_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_8_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -3610,29 +3610,29 @@ public async Task Min_Selector_Single_WithNaN_8_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_8_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_8_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_8_NoNull() + public async Task MinAsync_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -3647,7 +3647,7 @@ public async Task Min_Single_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_8_NoNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -3662,14 +3662,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_8_NoNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3678,14 +3678,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3694,7 +3694,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_No #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_8_AllNull() + public async Task MinAsync_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -3704,7 +3704,7 @@ public async Task Min_Single_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_8_AllNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -3714,29 +3714,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_8_AllNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_8_AllNaN() + public async Task MinAsync_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -3746,7 +3746,7 @@ public async Task Min_Single_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_8_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -3756,29 +3756,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_8_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_8_SomeNull() + public async Task MinAsync_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); @@ -3793,7 +3793,7 @@ public async Task Min_Single_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_8_SomeNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); @@ -3808,14 +3808,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_8_SomeNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3824,14 +3824,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3839,7 +3839,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_So } #endif [Fact] - public async Task Min_Single_WithNaN_16() + public async Task MinAsync_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -3854,7 +3854,7 @@ public async Task Min_Single_WithNaN_16() } [Fact] - public async Task Min_Selector_Single_WithNaN_16() + public async Task MinAsync_Selector_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -3869,14 +3869,14 @@ public async Task Min_Selector_Single_WithNaN_16() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_16() + public async Task MinAwaitAsync_Selector_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3885,14 +3885,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_16() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3901,7 +3901,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_16() #endif [Fact] - public async Task Min_Single_WithNaN_16_AllNaN() + public async Task MinAsync_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -3911,7 +3911,7 @@ public async Task Min_Single_WithNaN_16_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_16_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -3921,29 +3921,29 @@ public async Task Min_Selector_Single_WithNaN_16_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_16_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_16_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_16_NoNull() + public async Task MinAsync_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -3958,7 +3958,7 @@ public async Task Min_Single_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_16_NoNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -3973,14 +3973,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_16_NoNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -3989,14 +3989,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4005,7 +4005,7 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_N #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_16_AllNull() + public async Task MinAsync_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -4015,7 +4015,7 @@ public async Task Min_Single_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_16_AllNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -4025,29 +4025,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_16_AllNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_16_AllNaN() + public async Task MinAsync_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -4057,7 +4057,7 @@ public async Task Min_Single_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_16_AllNaN() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -4067,29 +4067,29 @@ public async Task Min_Selector_Single_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_16_AllNaN() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Single_WithNaN_Nullable_16_SomeNull() + public async Task MinAsync_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); @@ -4104,7 +4104,7 @@ public async Task Min_Single_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Min_Selector_Single_WithNaN_Nullable_16_SomeNull() + public async Task MinAsync_Selector_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); @@ -4119,14 +4119,14 @@ public async Task Min_Selector_Single_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Single_WithNaN_Nullable_16_SomeNull() + public async Task MinAwaitAsync_Selector_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4135,14 +4135,14 @@ public async Task Min_AsyncSelector_Single_WithNaN_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4150,59 +4150,59 @@ public async Task Min_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_S } #endif [Fact] - public async Task Min_Empty_Double() + public async Task MinAsync_Empty_Double() { await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Min_Selector_Empty_Double() + public async Task MinAsync_Selector_Empty_Double() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(double), CancellationToken.None).AsTask()); } [Fact] - public async Task Min_AsyncSelector_Empty_Double() + public async Task MinAwaitAsync_Selector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Double() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Min_Empty_Nullable_Double() + public async Task MinAsync_Empty_Nullable_Double() { Assert.Null(await new double?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); } [Fact] - public async Task Min_Selector_Empty_Nullable_Double() + public async Task MinAsync_Selector_Empty_Nullable_Double() { Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(double?), CancellationToken.None)); } [Fact] - public async Task Min_AsyncSelector_Empty_Nullable_Double() + public async Task MinAwaitAsync_Selector_Empty_Nullable_Double() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Double() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Nullable_Double() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Min_Double_1() + public async Task MinAsync_Double_1() { var input = new double[] { 33 }.AsEnumerable(); @@ -4217,7 +4217,7 @@ public async Task Min_Double_1() } [Fact] - public async Task Min_Selector_Double_1() + public async Task MinAsync_Selector_Double_1() { var input = new double[] { 33 }.AsEnumerable(); @@ -4232,14 +4232,14 @@ public async Task Min_Selector_Double_1() } [Fact] - public async Task Min_AsyncSelector_Double_1() + public async Task MinAwaitAsync_Selector_Double_1() { var input = new double[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4248,14 +4248,14 @@ public async Task Min_AsyncSelector_Double_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_1() + public async Task MinAwaitWithCancellationAsync_Selector_Double_1() { var input = new double[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4264,7 +4264,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_1() #endif [Fact] - public async Task Min_Double_Nullable_1_NoNull() + public async Task MinAsync_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -4279,7 +4279,7 @@ public async Task Min_Double_Nullable_1_NoNull() } [Fact] - public async Task Min_Selector_Double_Nullable_1_NoNull() + public async Task MinAsync_Selector_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -4294,14 +4294,14 @@ public async Task Min_Selector_Double_Nullable_1_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_1_NoNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4310,14 +4310,14 @@ public async Task Min_AsyncSelector_Double_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4326,7 +4326,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_NoNull() #endif [Fact] - public async Task Min_Double_Nullable_1_AllNull() + public async Task MinAsync_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -4336,7 +4336,7 @@ public async Task Min_Double_Nullable_1_AllNull() } [Fact] - public async Task Min_Selector_Double_Nullable_1_AllNull() + public async Task MinAsync_Selector_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -4346,29 +4346,29 @@ public async Task Min_Selector_Double_Nullable_1_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_1_AllNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_Nullable_1_SomeNull() + public async Task MinAsync_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -4383,7 +4383,7 @@ public async Task Min_Double_Nullable_1_SomeNull() } [Fact] - public async Task Min_Selector_Double_Nullable_1_SomeNull() + public async Task MinAsync_Selector_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -4398,14 +4398,14 @@ public async Task Min_Selector_Double_Nullable_1_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_1_SomeNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4414,14 +4414,14 @@ public async Task Min_AsyncSelector_Double_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4430,7 +4430,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_1_SomeNull() #endif [Fact] - public async Task Min_Double_4() + public async Task MinAsync_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -4445,7 +4445,7 @@ public async Task Min_Double_4() } [Fact] - public async Task Min_Selector_Double_4() + public async Task MinAsync_Selector_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -4460,14 +4460,14 @@ public async Task Min_Selector_Double_4() } [Fact] - public async Task Min_AsyncSelector_Double_4() + public async Task MinAwaitAsync_Selector_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4476,14 +4476,14 @@ public async Task Min_AsyncSelector_Double_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_4() + public async Task MinAwaitWithCancellationAsync_Selector_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4492,7 +4492,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_4() #endif [Fact] - public async Task Min_Double_Nullable_4_NoNull() + public async Task MinAsync_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -4507,7 +4507,7 @@ public async Task Min_Double_Nullable_4_NoNull() } [Fact] - public async Task Min_Selector_Double_Nullable_4_NoNull() + public async Task MinAsync_Selector_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -4522,14 +4522,14 @@ public async Task Min_Selector_Double_Nullable_4_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_4_NoNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4538,14 +4538,14 @@ public async Task Min_AsyncSelector_Double_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4554,7 +4554,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_NoNull() #endif [Fact] - public async Task Min_Double_Nullable_4_AllNull() + public async Task MinAsync_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -4564,7 +4564,7 @@ public async Task Min_Double_Nullable_4_AllNull() } [Fact] - public async Task Min_Selector_Double_Nullable_4_AllNull() + public async Task MinAsync_Selector_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -4574,29 +4574,29 @@ public async Task Min_Selector_Double_Nullable_4_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_4_AllNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_Nullable_4_SomeNull() + public async Task MinAsync_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); @@ -4611,7 +4611,7 @@ public async Task Min_Double_Nullable_4_SomeNull() } [Fact] - public async Task Min_Selector_Double_Nullable_4_SomeNull() + public async Task MinAsync_Selector_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); @@ -4626,14 +4626,14 @@ public async Task Min_Selector_Double_Nullable_4_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_4_SomeNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4642,14 +4642,14 @@ public async Task Min_AsyncSelector_Double_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4658,7 +4658,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_4_SomeNull() #endif [Fact] - public async Task Min_Double_8() + public async Task MinAsync_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -4673,7 +4673,7 @@ public async Task Min_Double_8() } [Fact] - public async Task Min_Selector_Double_8() + public async Task MinAsync_Selector_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -4688,14 +4688,14 @@ public async Task Min_Selector_Double_8() } [Fact] - public async Task Min_AsyncSelector_Double_8() + public async Task MinAwaitAsync_Selector_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4704,14 +4704,14 @@ public async Task Min_AsyncSelector_Double_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_8() + public async Task MinAwaitWithCancellationAsync_Selector_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4720,7 +4720,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_8() #endif [Fact] - public async Task Min_Double_Nullable_8_NoNull() + public async Task MinAsync_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -4735,7 +4735,7 @@ public async Task Min_Double_Nullable_8_NoNull() } [Fact] - public async Task Min_Selector_Double_Nullable_8_NoNull() + public async Task MinAsync_Selector_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -4750,14 +4750,14 @@ public async Task Min_Selector_Double_Nullable_8_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_8_NoNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4766,14 +4766,14 @@ public async Task Min_AsyncSelector_Double_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4782,7 +4782,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_NoNull() #endif [Fact] - public async Task Min_Double_Nullable_8_AllNull() + public async Task MinAsync_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -4792,7 +4792,7 @@ public async Task Min_Double_Nullable_8_AllNull() } [Fact] - public async Task Min_Selector_Double_Nullable_8_AllNull() + public async Task MinAsync_Selector_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -4802,29 +4802,29 @@ public async Task Min_Selector_Double_Nullable_8_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_8_AllNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_Nullable_8_SomeNull() + public async Task MinAsync_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -4839,7 +4839,7 @@ public async Task Min_Double_Nullable_8_SomeNull() } [Fact] - public async Task Min_Selector_Double_Nullable_8_SomeNull() + public async Task MinAsync_Selector_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -4854,14 +4854,14 @@ public async Task Min_Selector_Double_Nullable_8_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_8_SomeNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4870,14 +4870,14 @@ public async Task Min_AsyncSelector_Double_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4886,7 +4886,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_8_SomeNull() #endif [Fact] - public async Task Min_Double_16() + public async Task MinAsync_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -4901,7 +4901,7 @@ public async Task Min_Double_16() } [Fact] - public async Task Min_Selector_Double_16() + public async Task MinAsync_Selector_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -4916,14 +4916,14 @@ public async Task Min_Selector_Double_16() } [Fact] - public async Task Min_AsyncSelector_Double_16() + public async Task MinAwaitAsync_Selector_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4932,14 +4932,14 @@ public async Task Min_AsyncSelector_Double_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_16() + public async Task MinAwaitWithCancellationAsync_Selector_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4948,7 +4948,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_16() #endif [Fact] - public async Task Min_Double_Nullable_16_NoNull() + public async Task MinAsync_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -4963,7 +4963,7 @@ public async Task Min_Double_Nullable_16_NoNull() } [Fact] - public async Task Min_Selector_Double_Nullable_16_NoNull() + public async Task MinAsync_Selector_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -4978,14 +4978,14 @@ public async Task Min_Selector_Double_Nullable_16_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_16_NoNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -4994,14 +4994,14 @@ public async Task Min_AsyncSelector_Double_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5010,7 +5010,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_NoNull() #endif [Fact] - public async Task Min_Double_Nullable_16_AllNull() + public async Task MinAsync_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -5020,7 +5020,7 @@ public async Task Min_Double_Nullable_16_AllNull() } [Fact] - public async Task Min_Selector_Double_Nullable_16_AllNull() + public async Task MinAsync_Selector_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -5030,29 +5030,29 @@ public async Task Min_Selector_Double_Nullable_16_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_16_AllNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_Nullable_16_SomeNull() + public async Task MinAsync_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -5067,7 +5067,7 @@ public async Task Min_Double_Nullable_16_SomeNull() } [Fact] - public async Task Min_Selector_Double_Nullable_16_SomeNull() + public async Task MinAsync_Selector_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -5082,14 +5082,14 @@ public async Task Min_Selector_Double_Nullable_16_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_Nullable_16_SomeNull() + public async Task MinAwaitAsync_Selector_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5098,14 +5098,14 @@ public async Task Min_AsyncSelector_Double_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5114,7 +5114,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull( #endif [Fact] - public async Task Min_Double_WithNaN_1() + public async Task MinAsync_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); @@ -5129,7 +5129,7 @@ public async Task Min_Double_WithNaN_1() } [Fact] - public async Task Min_Selector_Double_WithNaN_1() + public async Task MinAsync_Selector_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); @@ -5144,14 +5144,14 @@ public async Task Min_Selector_Double_WithNaN_1() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_1() + public async Task MinAwaitAsync_Selector_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5160,14 +5160,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_1() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5176,7 +5176,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_1() #endif [Fact] - public async Task Min_Double_WithNaN_1_AllNaN() + public async Task MinAsync_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -5186,7 +5186,7 @@ public async Task Min_Double_WithNaN_1_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_1_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -5196,29 +5196,29 @@ public async Task Min_Selector_Double_WithNaN_1_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_1_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_1_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_1_NoNull() + public async Task MinAsync_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); @@ -5233,7 +5233,7 @@ public async Task Min_Double_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_1_NoNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); @@ -5248,14 +5248,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_1_NoNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5264,14 +5264,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5280,7 +5280,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_No #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_1_AllNull() + public async Task MinAsync_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -5290,7 +5290,7 @@ public async Task Min_Double_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_1_AllNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -5300,29 +5300,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_1_AllNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_1_AllNaN() + public async Task MinAsync_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -5332,7 +5332,7 @@ public async Task Min_Double_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_1_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -5342,29 +5342,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_1_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_1_SomeNull() + public async Task MinAsync_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -5379,7 +5379,7 @@ public async Task Min_Double_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_1_SomeNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -5394,14 +5394,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_1_SomeNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5410,14 +5410,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5425,7 +5425,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_So } #endif [Fact] - public async Task Min_Double_WithNaN_4() + public async Task MinAsync_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -5440,7 +5440,7 @@ public async Task Min_Double_WithNaN_4() } [Fact] - public async Task Min_Selector_Double_WithNaN_4() + public async Task MinAsync_Selector_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -5455,14 +5455,14 @@ public async Task Min_Selector_Double_WithNaN_4() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_4() + public async Task MinAwaitAsync_Selector_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5471,14 +5471,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_4() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5487,7 +5487,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_4() #endif [Fact] - public async Task Min_Double_WithNaN_4_AllNaN() + public async Task MinAsync_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -5497,7 +5497,7 @@ public async Task Min_Double_WithNaN_4_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_4_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -5507,29 +5507,29 @@ public async Task Min_Selector_Double_WithNaN_4_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_4_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_4_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_4_NoNull() + public async Task MinAsync_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -5544,7 +5544,7 @@ public async Task Min_Double_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_4_NoNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -5559,14 +5559,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_4_NoNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5575,14 +5575,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5591,7 +5591,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_No #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_4_AllNull() + public async Task MinAsync_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -5601,7 +5601,7 @@ public async Task Min_Double_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_4_AllNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -5611,29 +5611,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_4_AllNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_4_AllNaN() + public async Task MinAsync_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -5643,7 +5643,7 @@ public async Task Min_Double_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_4_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -5653,29 +5653,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_4_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_4_SomeNull() + public async Task MinAsync_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); @@ -5690,7 +5690,7 @@ public async Task Min_Double_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_4_SomeNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); @@ -5705,14 +5705,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_4_SomeNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5721,14 +5721,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5736,7 +5736,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_So } #endif [Fact] - public async Task Min_Double_WithNaN_8() + public async Task MinAsync_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -5751,7 +5751,7 @@ public async Task Min_Double_WithNaN_8() } [Fact] - public async Task Min_Selector_Double_WithNaN_8() + public async Task MinAsync_Selector_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -5766,14 +5766,14 @@ public async Task Min_Selector_Double_WithNaN_8() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_8() + public async Task MinAwaitAsync_Selector_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5782,14 +5782,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_8() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5798,7 +5798,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_8() #endif [Fact] - public async Task Min_Double_WithNaN_8_AllNaN() + public async Task MinAsync_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -5808,7 +5808,7 @@ public async Task Min_Double_WithNaN_8_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_8_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -5818,29 +5818,29 @@ public async Task Min_Selector_Double_WithNaN_8_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_8_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_8_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_8_NoNull() + public async Task MinAsync_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -5855,7 +5855,7 @@ public async Task Min_Double_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_8_NoNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -5870,14 +5870,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_8_NoNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5886,14 +5886,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -5902,7 +5902,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_No #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_8_AllNull() + public async Task MinAsync_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -5912,7 +5912,7 @@ public async Task Min_Double_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_8_AllNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -5922,29 +5922,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_8_AllNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_8_AllNaN() + public async Task MinAsync_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -5954,7 +5954,7 @@ public async Task Min_Double_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_8_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -5964,29 +5964,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_8_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_8_SomeNull() + public async Task MinAsync_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); @@ -6001,7 +6001,7 @@ public async Task Min_Double_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_8_SomeNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); @@ -6016,14 +6016,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_8_SomeNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6032,14 +6032,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6047,7 +6047,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_So } #endif [Fact] - public async Task Min_Double_WithNaN_16() + public async Task MinAsync_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -6062,7 +6062,7 @@ public async Task Min_Double_WithNaN_16() } [Fact] - public async Task Min_Selector_Double_WithNaN_16() + public async Task MinAsync_Selector_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -6077,14 +6077,14 @@ public async Task Min_Selector_Double_WithNaN_16() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_16() + public async Task MinAwaitAsync_Selector_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6093,14 +6093,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_16() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6109,7 +6109,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_16() #endif [Fact] - public async Task Min_Double_WithNaN_16_AllNaN() + public async Task MinAsync_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -6119,7 +6119,7 @@ public async Task Min_Double_WithNaN_16_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_16_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -6129,29 +6129,29 @@ public async Task Min_Selector_Double_WithNaN_16_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_16_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_16_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_16_NoNull() + public async Task MinAsync_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -6166,7 +6166,7 @@ public async Task Min_Double_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_16_NoNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -6181,14 +6181,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_16_NoNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6197,14 +6197,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6213,7 +6213,7 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_N #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_16_AllNull() + public async Task MinAsync_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -6223,7 +6223,7 @@ public async Task Min_Double_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_16_AllNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -6233,29 +6233,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_16_AllNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_16_AllNaN() + public async Task MinAsync_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -6265,7 +6265,7 @@ public async Task Min_Double_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_16_AllNaN() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -6275,29 +6275,29 @@ public async Task Min_Selector_Double_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_16_AllNaN() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_AllNaN() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Double_WithNaN_Nullable_16_SomeNull() + public async Task MinAsync_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); @@ -6312,7 +6312,7 @@ public async Task Min_Double_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Min_Selector_Double_WithNaN_Nullable_16_SomeNull() + public async Task MinAsync_Selector_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); @@ -6327,14 +6327,14 @@ public async Task Min_Selector_Double_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Double_WithNaN_Nullable_16_SomeNull() + public async Task MinAwaitAsync_Selector_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6343,14 +6343,14 @@ public async Task Min_AsyncSelector_Double_WithNaN_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6358,59 +6358,59 @@ public async Task Min_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_S } #endif [Fact] - public async Task Min_Empty_Decimal() + public async Task MinAsync_Empty_Decimal() { await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MinAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Min_Selector_Empty_Decimal() + public async Task MinAsync_Selector_Empty_Decimal() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(decimal), CancellationToken.None).AsTask()); } [Fact] - public async Task Min_AsyncSelector_Empty_Decimal() + public async Task MinAwaitAsync_Selector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Decimal() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Min_Empty_Nullable_Decimal() + public async Task MinAsync_Empty_Nullable_Decimal() { Assert.Null(await new decimal?[0].ToAsyncEnumerable().MinAsync(CancellationToken.None)); } [Fact] - public async Task Min_Selector_Empty_Nullable_Decimal() + public async Task MinAsync_Selector_Empty_Nullable_Decimal() { Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(decimal?), CancellationToken.None)); } [Fact] - public async Task Min_AsyncSelector_Empty_Nullable_Decimal() + public async Task MinAwaitAsync_Selector_Empty_Nullable_Decimal() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Empty_Nullable_Decimal() + public async Task MinAwaitWithCancellationAsync_Selector_Empty_Nullable_Decimal() { - Assert.Null(await new object[0].ToAsyncEnumerable().MinAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Min_Decimal_1() + public async Task MinAsync_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); @@ -6425,7 +6425,7 @@ public async Task Min_Decimal_1() } [Fact] - public async Task Min_Selector_Decimal_1() + public async Task MinAsync_Selector_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); @@ -6440,14 +6440,14 @@ public async Task Min_Selector_Decimal_1() } [Fact] - public async Task Min_AsyncSelector_Decimal_1() + public async Task MinAwaitAsync_Selector_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6456,14 +6456,14 @@ public async Task Min_AsyncSelector_Decimal_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_1() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6472,7 +6472,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_1() #endif [Fact] - public async Task Min_Decimal_Nullable_1_NoNull() + public async Task MinAsync_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -6487,7 +6487,7 @@ public async Task Min_Decimal_Nullable_1_NoNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_1_NoNull() + public async Task MinAsync_Selector_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -6502,14 +6502,14 @@ public async Task Min_Selector_Decimal_Nullable_1_NoNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_1_NoNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6518,14 +6518,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6534,7 +6534,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_NoNull() #endif [Fact] - public async Task Min_Decimal_Nullable_1_AllNull() + public async Task MinAsync_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); @@ -6544,7 +6544,7 @@ public async Task Min_Decimal_Nullable_1_AllNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_1_AllNull() + public async Task MinAsync_Selector_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); @@ -6554,29 +6554,29 @@ public async Task Min_Selector_Decimal_Nullable_1_AllNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_1_AllNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Decimal_Nullable_1_SomeNull() + public async Task MinAsync_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -6591,7 +6591,7 @@ public async Task Min_Decimal_Nullable_1_SomeNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_1_SomeNull() + public async Task MinAsync_Selector_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -6606,14 +6606,14 @@ public async Task Min_Selector_Decimal_Nullable_1_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_1_SomeNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6622,14 +6622,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6638,7 +6638,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_1_SomeNull( #endif [Fact] - public async Task Min_Decimal_4() + public async Task MinAsync_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -6653,7 +6653,7 @@ public async Task Min_Decimal_4() } [Fact] - public async Task Min_Selector_Decimal_4() + public async Task MinAsync_Selector_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -6668,14 +6668,14 @@ public async Task Min_Selector_Decimal_4() } [Fact] - public async Task Min_AsyncSelector_Decimal_4() + public async Task MinAwaitAsync_Selector_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6684,14 +6684,14 @@ public async Task Min_AsyncSelector_Decimal_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_4() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6700,7 +6700,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_4() #endif [Fact] - public async Task Min_Decimal_Nullable_4_NoNull() + public async Task MinAsync_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -6715,7 +6715,7 @@ public async Task Min_Decimal_Nullable_4_NoNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_4_NoNull() + public async Task MinAsync_Selector_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -6730,14 +6730,14 @@ public async Task Min_Selector_Decimal_Nullable_4_NoNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_4_NoNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6746,14 +6746,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6762,7 +6762,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_NoNull() #endif [Fact] - public async Task Min_Decimal_Nullable_4_AllNull() + public async Task MinAsync_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); @@ -6772,7 +6772,7 @@ public async Task Min_Decimal_Nullable_4_AllNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_4_AllNull() + public async Task MinAsync_Selector_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); @@ -6782,29 +6782,29 @@ public async Task Min_Selector_Decimal_Nullable_4_AllNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_4_AllNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Decimal_Nullable_4_SomeNull() + public async Task MinAsync_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); @@ -6819,7 +6819,7 @@ public async Task Min_Decimal_Nullable_4_SomeNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_4_SomeNull() + public async Task MinAsync_Selector_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); @@ -6834,14 +6834,14 @@ public async Task Min_Selector_Decimal_Nullable_4_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_4_SomeNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6850,14 +6850,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6866,7 +6866,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_4_SomeNull( #endif [Fact] - public async Task Min_Decimal_8() + public async Task MinAsync_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -6881,7 +6881,7 @@ public async Task Min_Decimal_8() } [Fact] - public async Task Min_Selector_Decimal_8() + public async Task MinAsync_Selector_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -6896,14 +6896,14 @@ public async Task Min_Selector_Decimal_8() } [Fact] - public async Task Min_AsyncSelector_Decimal_8() + public async Task MinAwaitAsync_Selector_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6912,14 +6912,14 @@ public async Task Min_AsyncSelector_Decimal_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_8() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6928,7 +6928,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_8() #endif [Fact] - public async Task Min_Decimal_Nullable_8_NoNull() + public async Task MinAsync_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -6943,7 +6943,7 @@ public async Task Min_Decimal_Nullable_8_NoNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_8_NoNull() + public async Task MinAsync_Selector_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -6958,14 +6958,14 @@ public async Task Min_Selector_Decimal_Nullable_8_NoNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_8_NoNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6974,14 +6974,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -6990,7 +6990,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_NoNull() #endif [Fact] - public async Task Min_Decimal_Nullable_8_AllNull() + public async Task MinAsync_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); @@ -7000,7 +7000,7 @@ public async Task Min_Decimal_Nullable_8_AllNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_8_AllNull() + public async Task MinAsync_Selector_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); @@ -7010,29 +7010,29 @@ public async Task Min_Selector_Decimal_Nullable_8_AllNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_8_AllNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Decimal_Nullable_8_SomeNull() + public async Task MinAsync_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -7047,7 +7047,7 @@ public async Task Min_Decimal_Nullable_8_SomeNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_8_SomeNull() + public async Task MinAsync_Selector_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -7062,14 +7062,14 @@ public async Task Min_Selector_Decimal_Nullable_8_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_8_SomeNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7078,14 +7078,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7094,7 +7094,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_8_SomeNull( #endif [Fact] - public async Task Min_Decimal_16() + public async Task MinAsync_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -7109,7 +7109,7 @@ public async Task Min_Decimal_16() } [Fact] - public async Task Min_Selector_Decimal_16() + public async Task MinAsync_Selector_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -7124,14 +7124,14 @@ public async Task Min_Selector_Decimal_16() } [Fact] - public async Task Min_AsyncSelector_Decimal_16() + public async Task MinAwaitAsync_Selector_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7140,14 +7140,14 @@ public async Task Min_AsyncSelector_Decimal_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_16() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7156,7 +7156,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_16() #endif [Fact] - public async Task Min_Decimal_Nullable_16_NoNull() + public async Task MinAsync_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -7171,7 +7171,7 @@ public async Task Min_Decimal_Nullable_16_NoNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_16_NoNull() + public async Task MinAsync_Selector_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -7186,14 +7186,14 @@ public async Task Min_Selector_Decimal_Nullable_16_NoNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_16_NoNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7202,14 +7202,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_NoNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7218,7 +7218,7 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_NoNull() #endif [Fact] - public async Task Min_Decimal_Nullable_16_AllNull() + public async Task MinAsync_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); @@ -7228,7 +7228,7 @@ public async Task Min_Decimal_Nullable_16_AllNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_16_AllNull() + public async Task MinAsync_Selector_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); @@ -7238,29 +7238,29 @@ public async Task Min_Selector_Decimal_Nullable_16_AllNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_16_AllNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_AllNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Min_Decimal_Nullable_16_SomeNull() + public async Task MinAsync_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -7275,7 +7275,7 @@ public async Task Min_Decimal_Nullable_16_SomeNull() } [Fact] - public async Task Min_Selector_Decimal_Nullable_16_SomeNull() + public async Task MinAsync_Selector_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -7290,14 +7290,14 @@ public async Task Min_Selector_Decimal_Nullable_16_SomeNull() } [Fact] - public async Task Min_AsyncSelector_Decimal_Nullable_16_SomeNull() + public async Task MinAwaitAsync_Selector_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7306,14 +7306,14 @@ public async Task Min_AsyncSelector_Decimal_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_SomeNull() + public async Task MinAwaitWithCancellationAsync_Selector_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Min(); - var actual = await input.ToAsyncEnumerable().MinAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MinAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7322,59 +7322,59 @@ public async Task Min_AsyncSelectorWithCancellation_Decimal_Nullable_16_SomeNull #endif [Fact] - public async Task Max_Empty_Int32() + public async Task MaxAsync_Empty_Int32() { await AssertThrowsAsync(new int[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Max_Selector_Empty_Int32() + public async Task MaxAsync_Selector_Empty_Int32() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(int), CancellationToken.None).AsTask()); } [Fact] - public async Task Max_AsyncSelector_Empty_Int32() + public async Task MaxAwaitAsync_Selector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Int32() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Int32() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Max_Empty_Nullable_Int32() + public async Task MaxAsync_Empty_Nullable_Int32() { Assert.Null(await new int?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); } [Fact] - public async Task Max_Selector_Empty_Nullable_Int32() + public async Task MaxAsync_Selector_Empty_Nullable_Int32() { Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(int?), CancellationToken.None)); } [Fact] - public async Task Max_AsyncSelector_Empty_Nullable_Int32() + public async Task MaxAwaitAsync_Selector_Empty_Nullable_Int32() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Int32() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Nullable_Int32() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Max_Int32_1() + public async Task MaxAsync_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); @@ -7389,7 +7389,7 @@ public async Task Max_Int32_1() } [Fact] - public async Task Max_Selector_Int32_1() + public async Task MaxAsync_Selector_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); @@ -7404,14 +7404,14 @@ public async Task Max_Selector_Int32_1() } [Fact] - public async Task Max_AsyncSelector_Int32_1() + public async Task MaxAwaitAsync_Selector_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7420,14 +7420,14 @@ public async Task Max_AsyncSelector_Int32_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_1() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_1() { var input = new int[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7436,7 +7436,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_1() #endif [Fact] - public async Task Max_Int32_Nullable_1_NoNull() + public async Task MaxAsync_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -7451,7 +7451,7 @@ public async Task Max_Int32_Nullable_1_NoNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_1_NoNull() + public async Task MaxAsync_Selector_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -7466,14 +7466,14 @@ public async Task Max_Selector_Int32_Nullable_1_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_1_NoNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7482,14 +7482,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_1_NoNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7498,7 +7498,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_NoNull() #endif [Fact] - public async Task Max_Int32_Nullable_1_AllNull() + public async Task MaxAsync_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); @@ -7508,7 +7508,7 @@ public async Task Max_Int32_Nullable_1_AllNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_1_AllNull() + public async Task MaxAsync_Selector_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); @@ -7518,29 +7518,29 @@ public async Task Max_Selector_Int32_Nullable_1_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_1_AllNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(int?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int32_Nullable_1_SomeNull() + public async Task MaxAsync_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -7555,7 +7555,7 @@ public async Task Max_Int32_Nullable_1_SomeNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_1_SomeNull() + public async Task MaxAsync_Selector_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); @@ -7570,14 +7570,14 @@ public async Task Max_Selector_Int32_Nullable_1_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_1_SomeNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7586,14 +7586,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_1_SomeNull() { var input = new int?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7602,7 +7602,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_1_SomeNull() #endif [Fact] - public async Task Max_Int32_4() + public async Task MaxAsync_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -7617,7 +7617,7 @@ public async Task Max_Int32_4() } [Fact] - public async Task Max_Selector_Int32_4() + public async Task MaxAsync_Selector_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -7632,14 +7632,14 @@ public async Task Max_Selector_Int32_4() } [Fact] - public async Task Max_AsyncSelector_Int32_4() + public async Task MaxAwaitAsync_Selector_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7648,14 +7648,14 @@ public async Task Max_AsyncSelector_Int32_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_4() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_4() { var input = new int[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7664,7 +7664,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_4() #endif [Fact] - public async Task Max_Int32_Nullable_4_NoNull() + public async Task MaxAsync_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -7679,7 +7679,7 @@ public async Task Max_Int32_Nullable_4_NoNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_4_NoNull() + public async Task MaxAsync_Selector_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -7694,14 +7694,14 @@ public async Task Max_Selector_Int32_Nullable_4_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_4_NoNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7710,14 +7710,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_4_NoNull() { var input = new int?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7726,7 +7726,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_NoNull() #endif [Fact] - public async Task Max_Int32_Nullable_4_AllNull() + public async Task MaxAsync_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); @@ -7736,7 +7736,7 @@ public async Task Max_Int32_Nullable_4_AllNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_4_AllNull() + public async Task MaxAsync_Selector_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); @@ -7746,29 +7746,29 @@ public async Task Max_Selector_Int32_Nullable_4_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_4_AllNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(int?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int32_Nullable_4_SomeNull() + public async Task MaxAsync_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); @@ -7783,7 +7783,7 @@ public async Task Max_Int32_Nullable_4_SomeNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_4_SomeNull() + public async Task MaxAsync_Selector_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); @@ -7798,14 +7798,14 @@ public async Task Max_Selector_Int32_Nullable_4_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_4_SomeNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7814,14 +7814,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_4_SomeNull() { var input = new int?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7830,7 +7830,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_4_SomeNull() #endif [Fact] - public async Task Max_Int32_8() + public async Task MaxAsync_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -7845,7 +7845,7 @@ public async Task Max_Int32_8() } [Fact] - public async Task Max_Selector_Int32_8() + public async Task MaxAsync_Selector_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -7860,14 +7860,14 @@ public async Task Max_Selector_Int32_8() } [Fact] - public async Task Max_AsyncSelector_Int32_8() + public async Task MaxAwaitAsync_Selector_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7876,14 +7876,14 @@ public async Task Max_AsyncSelector_Int32_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_8() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_8() { var input = new int[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7892,7 +7892,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_8() #endif [Fact] - public async Task Max_Int32_Nullable_8_NoNull() + public async Task MaxAsync_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -7907,7 +7907,7 @@ public async Task Max_Int32_Nullable_8_NoNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_8_NoNull() + public async Task MaxAsync_Selector_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -7922,14 +7922,14 @@ public async Task Max_Selector_Int32_Nullable_8_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_8_NoNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7938,14 +7938,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_8_NoNull() { var input = new int?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -7954,7 +7954,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_NoNull() #endif [Fact] - public async Task Max_Int32_Nullable_8_AllNull() + public async Task MaxAsync_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); @@ -7964,7 +7964,7 @@ public async Task Max_Int32_Nullable_8_AllNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_8_AllNull() + public async Task MaxAsync_Selector_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); @@ -7974,29 +7974,29 @@ public async Task Max_Selector_Int32_Nullable_8_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_8_AllNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(int?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int32_Nullable_8_SomeNull() + public async Task MaxAsync_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -8011,7 +8011,7 @@ public async Task Max_Int32_Nullable_8_SomeNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_8_SomeNull() + public async Task MaxAsync_Selector_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -8026,14 +8026,14 @@ public async Task Max_Selector_Int32_Nullable_8_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_8_SomeNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8042,14 +8042,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_8_SomeNull() { var input = new int?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8058,7 +8058,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_8_SomeNull() #endif [Fact] - public async Task Max_Int32_16() + public async Task MaxAsync_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -8073,7 +8073,7 @@ public async Task Max_Int32_16() } [Fact] - public async Task Max_Selector_Int32_16() + public async Task MaxAsync_Selector_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -8088,14 +8088,14 @@ public async Task Max_Selector_Int32_16() } [Fact] - public async Task Max_AsyncSelector_Int32_16() + public async Task MaxAwaitAsync_Selector_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8104,14 +8104,14 @@ public async Task Max_AsyncSelector_Int32_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_16() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_16() { var input = new int[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8120,7 +8120,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_16() #endif [Fact] - public async Task Max_Int32_Nullable_16_NoNull() + public async Task MaxAsync_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -8135,7 +8135,7 @@ public async Task Max_Int32_Nullable_16_NoNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_16_NoNull() + public async Task MaxAsync_Selector_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -8150,14 +8150,14 @@ public async Task Max_Selector_Int32_Nullable_16_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_16_NoNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8166,14 +8166,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_16_NoNull() { var input = new int?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8182,7 +8182,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_NoNull() #endif [Fact] - public async Task Max_Int32_Nullable_16_AllNull() + public async Task MaxAsync_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); @@ -8192,7 +8192,7 @@ public async Task Max_Int32_Nullable_16_AllNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_16_AllNull() + public async Task MaxAsync_Selector_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); @@ -8202,29 +8202,29 @@ public async Task Max_Selector_Int32_Nullable_16_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_16_AllNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(int?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int32_Nullable_16_SomeNull() + public async Task MaxAsync_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -8239,7 +8239,7 @@ public async Task Max_Int32_Nullable_16_SomeNull() } [Fact] - public async Task Max_Selector_Int32_Nullable_16_SomeNull() + public async Task MaxAsync_Selector_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -8254,14 +8254,14 @@ public async Task Max_Selector_Int32_Nullable_16_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int32_Nullable_16_SomeNull() + public async Task MaxAwaitAsync_Selector_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8270,14 +8270,14 @@ public async Task Max_AsyncSelector_Int32_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int32_Nullable_16_SomeNull() { var input = new int?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8286,59 +8286,59 @@ public async Task Max_AsyncSelectorWithCancellation_Int32_Nullable_16_SomeNull() #endif [Fact] - public async Task Max_Empty_Int64() + public async Task MaxAsync_Empty_Int64() { await AssertThrowsAsync(new long[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Max_Selector_Empty_Int64() + public async Task MaxAsync_Selector_Empty_Int64() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(long), CancellationToken.None).AsTask()); } [Fact] - public async Task Max_AsyncSelector_Empty_Int64() + public async Task MaxAwaitAsync_Selector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Int64() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Int64() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Max_Empty_Nullable_Int64() + public async Task MaxAsync_Empty_Nullable_Int64() { Assert.Null(await new long?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); } [Fact] - public async Task Max_Selector_Empty_Nullable_Int64() + public async Task MaxAsync_Selector_Empty_Nullable_Int64() { Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(long?), CancellationToken.None)); } [Fact] - public async Task Max_AsyncSelector_Empty_Nullable_Int64() + public async Task MaxAwaitAsync_Selector_Empty_Nullable_Int64() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Int64() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Nullable_Int64() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Max_Int64_1() + public async Task MaxAsync_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); @@ -8353,7 +8353,7 @@ public async Task Max_Int64_1() } [Fact] - public async Task Max_Selector_Int64_1() + public async Task MaxAsync_Selector_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); @@ -8368,14 +8368,14 @@ public async Task Max_Selector_Int64_1() } [Fact] - public async Task Max_AsyncSelector_Int64_1() + public async Task MaxAwaitAsync_Selector_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8384,14 +8384,14 @@ public async Task Max_AsyncSelector_Int64_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_1() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_1() { var input = new long[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8400,7 +8400,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_1() #endif [Fact] - public async Task Max_Int64_Nullable_1_NoNull() + public async Task MaxAsync_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -8415,7 +8415,7 @@ public async Task Max_Int64_Nullable_1_NoNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_1_NoNull() + public async Task MaxAsync_Selector_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -8430,14 +8430,14 @@ public async Task Max_Selector_Int64_Nullable_1_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_1_NoNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8446,14 +8446,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_1_NoNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8462,7 +8462,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_NoNull() #endif [Fact] - public async Task Max_Int64_Nullable_1_AllNull() + public async Task MaxAsync_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); @@ -8472,7 +8472,7 @@ public async Task Max_Int64_Nullable_1_AllNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_1_AllNull() + public async Task MaxAsync_Selector_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); @@ -8482,29 +8482,29 @@ public async Task Max_Selector_Int64_Nullable_1_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_1_AllNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(long?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int64_Nullable_1_SomeNull() + public async Task MaxAsync_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -8519,7 +8519,7 @@ public async Task Max_Int64_Nullable_1_SomeNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_1_SomeNull() + public async Task MaxAsync_Selector_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); @@ -8534,14 +8534,14 @@ public async Task Max_Selector_Int64_Nullable_1_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_1_SomeNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8550,14 +8550,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_1_SomeNull() { var input = new long?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8566,7 +8566,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_1_SomeNull() #endif [Fact] - public async Task Max_Int64_4() + public async Task MaxAsync_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -8581,7 +8581,7 @@ public async Task Max_Int64_4() } [Fact] - public async Task Max_Selector_Int64_4() + public async Task MaxAsync_Selector_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -8596,14 +8596,14 @@ public async Task Max_Selector_Int64_4() } [Fact] - public async Task Max_AsyncSelector_Int64_4() + public async Task MaxAwaitAsync_Selector_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8612,14 +8612,14 @@ public async Task Max_AsyncSelector_Int64_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_4() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_4() { var input = new long[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8628,7 +8628,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_4() #endif [Fact] - public async Task Max_Int64_Nullable_4_NoNull() + public async Task MaxAsync_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -8643,7 +8643,7 @@ public async Task Max_Int64_Nullable_4_NoNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_4_NoNull() + public async Task MaxAsync_Selector_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -8658,14 +8658,14 @@ public async Task Max_Selector_Int64_Nullable_4_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_4_NoNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8674,14 +8674,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_4_NoNull() { var input = new long?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8690,7 +8690,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_NoNull() #endif [Fact] - public async Task Max_Int64_Nullable_4_AllNull() + public async Task MaxAsync_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); @@ -8700,7 +8700,7 @@ public async Task Max_Int64_Nullable_4_AllNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_4_AllNull() + public async Task MaxAsync_Selector_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); @@ -8710,29 +8710,29 @@ public async Task Max_Selector_Int64_Nullable_4_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_4_AllNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(long?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int64_Nullable_4_SomeNull() + public async Task MaxAsync_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); @@ -8747,7 +8747,7 @@ public async Task Max_Int64_Nullable_4_SomeNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_4_SomeNull() + public async Task MaxAsync_Selector_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); @@ -8762,14 +8762,14 @@ public async Task Max_Selector_Int64_Nullable_4_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_4_SomeNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8778,14 +8778,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_4_SomeNull() { var input = new long?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8794,7 +8794,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_4_SomeNull() #endif [Fact] - public async Task Max_Int64_8() + public async Task MaxAsync_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -8809,7 +8809,7 @@ public async Task Max_Int64_8() } [Fact] - public async Task Max_Selector_Int64_8() + public async Task MaxAsync_Selector_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -8824,14 +8824,14 @@ public async Task Max_Selector_Int64_8() } [Fact] - public async Task Max_AsyncSelector_Int64_8() + public async Task MaxAwaitAsync_Selector_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8840,14 +8840,14 @@ public async Task Max_AsyncSelector_Int64_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_8() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_8() { var input = new long[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8856,7 +8856,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_8() #endif [Fact] - public async Task Max_Int64_Nullable_8_NoNull() + public async Task MaxAsync_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -8871,7 +8871,7 @@ public async Task Max_Int64_Nullable_8_NoNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_8_NoNull() + public async Task MaxAsync_Selector_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -8886,14 +8886,14 @@ public async Task Max_Selector_Int64_Nullable_8_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_8_NoNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8902,14 +8902,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_8_NoNull() { var input = new long?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -8918,7 +8918,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_NoNull() #endif [Fact] - public async Task Max_Int64_Nullable_8_AllNull() + public async Task MaxAsync_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); @@ -8928,7 +8928,7 @@ public async Task Max_Int64_Nullable_8_AllNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_8_AllNull() + public async Task MaxAsync_Selector_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); @@ -8938,29 +8938,29 @@ public async Task Max_Selector_Int64_Nullable_8_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_8_AllNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(long?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int64_Nullable_8_SomeNull() + public async Task MaxAsync_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -8975,7 +8975,7 @@ public async Task Max_Int64_Nullable_8_SomeNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_8_SomeNull() + public async Task MaxAsync_Selector_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -8990,14 +8990,14 @@ public async Task Max_Selector_Int64_Nullable_8_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_8_SomeNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9006,14 +9006,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_8_SomeNull() { var input = new long?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9022,7 +9022,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_8_SomeNull() #endif [Fact] - public async Task Max_Int64_16() + public async Task MaxAsync_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -9037,7 +9037,7 @@ public async Task Max_Int64_16() } [Fact] - public async Task Max_Selector_Int64_16() + public async Task MaxAsync_Selector_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -9052,14 +9052,14 @@ public async Task Max_Selector_Int64_16() } [Fact] - public async Task Max_AsyncSelector_Int64_16() + public async Task MaxAwaitAsync_Selector_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9068,14 +9068,14 @@ public async Task Max_AsyncSelector_Int64_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_16() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_16() { var input = new long[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9084,7 +9084,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_16() #endif [Fact] - public async Task Max_Int64_Nullable_16_NoNull() + public async Task MaxAsync_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -9099,7 +9099,7 @@ public async Task Max_Int64_Nullable_16_NoNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_16_NoNull() + public async Task MaxAsync_Selector_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -9114,14 +9114,14 @@ public async Task Max_Selector_Int64_Nullable_16_NoNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_16_NoNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9130,14 +9130,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_16_NoNull() { var input = new long?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9146,7 +9146,7 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_NoNull() #endif [Fact] - public async Task Max_Int64_Nullable_16_AllNull() + public async Task MaxAsync_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); @@ -9156,7 +9156,7 @@ public async Task Max_Int64_Nullable_16_AllNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_16_AllNull() + public async Task MaxAsync_Selector_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); @@ -9166,29 +9166,29 @@ public async Task Max_Selector_Int64_Nullable_16_AllNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_16_AllNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(long?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Int64_Nullable_16_SomeNull() + public async Task MaxAsync_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -9203,7 +9203,7 @@ public async Task Max_Int64_Nullable_16_SomeNull() } [Fact] - public async Task Max_Selector_Int64_Nullable_16_SomeNull() + public async Task MaxAsync_Selector_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -9218,14 +9218,14 @@ public async Task Max_Selector_Int64_Nullable_16_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Int64_Nullable_16_SomeNull() + public async Task MaxAwaitAsync_Selector_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9234,14 +9234,14 @@ public async Task Max_AsyncSelector_Int64_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Int64_Nullable_16_SomeNull() { var input = new long?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9250,59 +9250,59 @@ public async Task Max_AsyncSelectorWithCancellation_Int64_Nullable_16_SomeNull() #endif [Fact] - public async Task Max_Empty_Single() + public async Task MaxAsync_Empty_Single() { await AssertThrowsAsync(new float[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Max_Selector_Empty_Single() + public async Task MaxAsync_Selector_Empty_Single() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(float), CancellationToken.None).AsTask()); } [Fact] - public async Task Max_AsyncSelector_Empty_Single() + public async Task MaxAwaitAsync_Selector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Single() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Single() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Max_Empty_Nullable_Single() + public async Task MaxAsync_Empty_Nullable_Single() { Assert.Null(await new float?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); } [Fact] - public async Task Max_Selector_Empty_Nullable_Single() + public async Task MaxAsync_Selector_Empty_Nullable_Single() { Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(float?), CancellationToken.None)); } [Fact] - public async Task Max_AsyncSelector_Empty_Nullable_Single() + public async Task MaxAwaitAsync_Selector_Empty_Nullable_Single() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Single() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Nullable_Single() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Max_Single_1() + public async Task MaxAsync_Single_1() { var input = new float[] { 33 }.AsEnumerable(); @@ -9317,7 +9317,7 @@ public async Task Max_Single_1() } [Fact] - public async Task Max_Selector_Single_1() + public async Task MaxAsync_Selector_Single_1() { var input = new float[] { 33 }.AsEnumerable(); @@ -9332,14 +9332,14 @@ public async Task Max_Selector_Single_1() } [Fact] - public async Task Max_AsyncSelector_Single_1() + public async Task MaxAwaitAsync_Selector_Single_1() { var input = new float[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9348,14 +9348,14 @@ public async Task Max_AsyncSelector_Single_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_1() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_1() { var input = new float[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9364,7 +9364,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_1() #endif [Fact] - public async Task Max_Single_Nullable_1_NoNull() + public async Task MaxAsync_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -9379,7 +9379,7 @@ public async Task Max_Single_Nullable_1_NoNull() } [Fact] - public async Task Max_Selector_Single_Nullable_1_NoNull() + public async Task MaxAsync_Selector_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -9394,14 +9394,14 @@ public async Task Max_Selector_Single_Nullable_1_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_1_NoNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9410,14 +9410,14 @@ public async Task Max_AsyncSelector_Single_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_1_NoNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9426,7 +9426,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_NoNull() #endif [Fact] - public async Task Max_Single_Nullable_1_AllNull() + public async Task MaxAsync_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -9436,7 +9436,7 @@ public async Task Max_Single_Nullable_1_AllNull() } [Fact] - public async Task Max_Selector_Single_Nullable_1_AllNull() + public async Task MaxAsync_Selector_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -9446,29 +9446,29 @@ public async Task Max_Selector_Single_Nullable_1_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_1_AllNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_Nullable_1_SomeNull() + public async Task MaxAsync_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -9483,7 +9483,7 @@ public async Task Max_Single_Nullable_1_SomeNull() } [Fact] - public async Task Max_Selector_Single_Nullable_1_SomeNull() + public async Task MaxAsync_Selector_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -9498,14 +9498,14 @@ public async Task Max_Selector_Single_Nullable_1_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_1_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9514,14 +9514,14 @@ public async Task Max_AsyncSelector_Single_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9530,7 +9530,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_1_SomeNull() #endif [Fact] - public async Task Max_Single_4() + public async Task MaxAsync_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -9545,7 +9545,7 @@ public async Task Max_Single_4() } [Fact] - public async Task Max_Selector_Single_4() + public async Task MaxAsync_Selector_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -9560,14 +9560,14 @@ public async Task Max_Selector_Single_4() } [Fact] - public async Task Max_AsyncSelector_Single_4() + public async Task MaxAwaitAsync_Selector_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9576,14 +9576,14 @@ public async Task Max_AsyncSelector_Single_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_4() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_4() { var input = new float[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9592,7 +9592,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_4() #endif [Fact] - public async Task Max_Single_Nullable_4_NoNull() + public async Task MaxAsync_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -9607,7 +9607,7 @@ public async Task Max_Single_Nullable_4_NoNull() } [Fact] - public async Task Max_Selector_Single_Nullable_4_NoNull() + public async Task MaxAsync_Selector_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -9622,14 +9622,14 @@ public async Task Max_Selector_Single_Nullable_4_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_4_NoNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9638,14 +9638,14 @@ public async Task Max_AsyncSelector_Single_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_4_NoNull() { var input = new float?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9654,7 +9654,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_NoNull() #endif [Fact] - public async Task Max_Single_Nullable_4_AllNull() + public async Task MaxAsync_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -9664,7 +9664,7 @@ public async Task Max_Single_Nullable_4_AllNull() } [Fact] - public async Task Max_Selector_Single_Nullable_4_AllNull() + public async Task MaxAsync_Selector_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -9674,29 +9674,29 @@ public async Task Max_Selector_Single_Nullable_4_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_4_AllNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_Nullable_4_SomeNull() + public async Task MaxAsync_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); @@ -9711,7 +9711,7 @@ public async Task Max_Single_Nullable_4_SomeNull() } [Fact] - public async Task Max_Selector_Single_Nullable_4_SomeNull() + public async Task MaxAsync_Selector_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); @@ -9726,14 +9726,14 @@ public async Task Max_Selector_Single_Nullable_4_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_4_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9742,14 +9742,14 @@ public async Task Max_AsyncSelector_Single_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_4_SomeNull() { var input = new float?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9758,7 +9758,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_4_SomeNull() #endif [Fact] - public async Task Max_Single_8() + public async Task MaxAsync_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -9773,7 +9773,7 @@ public async Task Max_Single_8() } [Fact] - public async Task Max_Selector_Single_8() + public async Task MaxAsync_Selector_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -9788,14 +9788,14 @@ public async Task Max_Selector_Single_8() } [Fact] - public async Task Max_AsyncSelector_Single_8() + public async Task MaxAwaitAsync_Selector_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9804,14 +9804,14 @@ public async Task Max_AsyncSelector_Single_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_8() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_8() { var input = new float[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9820,7 +9820,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_8() #endif [Fact] - public async Task Max_Single_Nullable_8_NoNull() + public async Task MaxAsync_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -9835,7 +9835,7 @@ public async Task Max_Single_Nullable_8_NoNull() } [Fact] - public async Task Max_Selector_Single_Nullable_8_NoNull() + public async Task MaxAsync_Selector_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -9850,14 +9850,14 @@ public async Task Max_Selector_Single_Nullable_8_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_8_NoNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9866,14 +9866,14 @@ public async Task Max_AsyncSelector_Single_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_8_NoNull() { var input = new float?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9882,7 +9882,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_NoNull() #endif [Fact] - public async Task Max_Single_Nullable_8_AllNull() + public async Task MaxAsync_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -9892,7 +9892,7 @@ public async Task Max_Single_Nullable_8_AllNull() } [Fact] - public async Task Max_Selector_Single_Nullable_8_AllNull() + public async Task MaxAsync_Selector_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -9902,29 +9902,29 @@ public async Task Max_Selector_Single_Nullable_8_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_8_AllNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_Nullable_8_SomeNull() + public async Task MaxAsync_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -9939,7 +9939,7 @@ public async Task Max_Single_Nullable_8_SomeNull() } [Fact] - public async Task Max_Selector_Single_Nullable_8_SomeNull() + public async Task MaxAsync_Selector_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -9954,14 +9954,14 @@ public async Task Max_Selector_Single_Nullable_8_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_8_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9970,14 +9970,14 @@ public async Task Max_AsyncSelector_Single_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_8_SomeNull() { var input = new float?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -9986,7 +9986,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_8_SomeNull() #endif [Fact] - public async Task Max_Single_16() + public async Task MaxAsync_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -10001,7 +10001,7 @@ public async Task Max_Single_16() } [Fact] - public async Task Max_Selector_Single_16() + public async Task MaxAsync_Selector_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -10016,14 +10016,14 @@ public async Task Max_Selector_Single_16() } [Fact] - public async Task Max_AsyncSelector_Single_16() + public async Task MaxAwaitAsync_Selector_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10032,14 +10032,14 @@ public async Task Max_AsyncSelector_Single_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_16() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_16() { var input = new float[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10048,7 +10048,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_16() #endif [Fact] - public async Task Max_Single_Nullable_16_NoNull() + public async Task MaxAsync_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -10063,7 +10063,7 @@ public async Task Max_Single_Nullable_16_NoNull() } [Fact] - public async Task Max_Selector_Single_Nullable_16_NoNull() + public async Task MaxAsync_Selector_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -10078,14 +10078,14 @@ public async Task Max_Selector_Single_Nullable_16_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_16_NoNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10094,14 +10094,14 @@ public async Task Max_AsyncSelector_Single_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_16_NoNull() { var input = new float?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10110,7 +10110,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_NoNull() #endif [Fact] - public async Task Max_Single_Nullable_16_AllNull() + public async Task MaxAsync_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -10120,7 +10120,7 @@ public async Task Max_Single_Nullable_16_AllNull() } [Fact] - public async Task Max_Selector_Single_Nullable_16_AllNull() + public async Task MaxAsync_Selector_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -10130,29 +10130,29 @@ public async Task Max_Selector_Single_Nullable_16_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_16_AllNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_Nullable_16_SomeNull() + public async Task MaxAsync_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -10167,7 +10167,7 @@ public async Task Max_Single_Nullable_16_SomeNull() } [Fact] - public async Task Max_Selector_Single_Nullable_16_SomeNull() + public async Task MaxAsync_Selector_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -10182,14 +10182,14 @@ public async Task Max_Selector_Single_Nullable_16_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_Nullable_16_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10198,14 +10198,14 @@ public async Task Max_AsyncSelector_Single_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_Nullable_16_SomeNull() { var input = new float?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10214,7 +10214,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_Nullable_16_SomeNull( #endif [Fact] - public async Task Max_Single_WithNaN_1() + public async Task MaxAsync_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); @@ -10229,7 +10229,7 @@ public async Task Max_Single_WithNaN_1() } [Fact] - public async Task Max_Selector_Single_WithNaN_1() + public async Task MaxAsync_Selector_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); @@ -10244,14 +10244,14 @@ public async Task Max_Selector_Single_WithNaN_1() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_1() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10260,14 +10260,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_1() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_1() { var input = new float[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10276,7 +10276,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_1() #endif [Fact] - public async Task Max_Single_WithNaN_1_AllNaN() + public async Task MaxAsync_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -10286,7 +10286,7 @@ public async Task Max_Single_WithNaN_1_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_1_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -10296,29 +10296,29 @@ public async Task Max_Selector_Single_WithNaN_1_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_1_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_1_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_1_NoNull() + public async Task MaxAsync_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); @@ -10333,7 +10333,7 @@ public async Task Max_Single_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_1_NoNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); @@ -10348,14 +10348,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_1_NoNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10364,14 +10364,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_NoNull() { var input = new float?[] { float.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10380,7 +10380,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_No #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_1_AllNull() + public async Task MaxAsync_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -10390,7 +10390,7 @@ public async Task Max_Single_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_1_AllNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); @@ -10400,29 +10400,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_1_AllNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(float?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_1_AllNaN() + public async Task MaxAsync_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -10432,7 +10432,7 @@ public async Task Max_Single_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_1_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); @@ -10442,29 +10442,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_1_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(float.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_1_SomeNull() + public async Task MaxAsync_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -10479,7 +10479,7 @@ public async Task Max_Single_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_1_SomeNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); @@ -10494,14 +10494,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_1_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10510,14 +10510,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_1_SomeNull() { var input = new float?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10525,7 +10525,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_1_So } #endif [Fact] - public async Task Max_Single_WithNaN_4() + public async Task MaxAsync_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -10540,7 +10540,7 @@ public async Task Max_Single_WithNaN_4() } [Fact] - public async Task Max_Selector_Single_WithNaN_4() + public async Task MaxAsync_Selector_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -10555,14 +10555,14 @@ public async Task Max_Selector_Single_WithNaN_4() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_4() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10571,14 +10571,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_4() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_4() { var input = new float[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10587,7 +10587,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_4() #endif [Fact] - public async Task Max_Single_WithNaN_4_AllNaN() + public async Task MaxAsync_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -10597,7 +10597,7 @@ public async Task Max_Single_WithNaN_4_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_4_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -10607,29 +10607,29 @@ public async Task Max_Selector_Single_WithNaN_4_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_4_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_4_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_4_NoNull() + public async Task MaxAsync_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -10644,7 +10644,7 @@ public async Task Max_Single_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_4_NoNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); @@ -10659,14 +10659,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_4_NoNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10675,14 +10675,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_NoNull() { var input = new float?[] { float.NaN, -78, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10691,7 +10691,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_No #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_4_AllNull() + public async Task MaxAsync_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -10701,7 +10701,7 @@ public async Task Max_Single_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_4_AllNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); @@ -10711,29 +10711,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_4_AllNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(float?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_4_AllNaN() + public async Task MaxAsync_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -10743,7 +10743,7 @@ public async Task Max_Single_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_4_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); @@ -10753,29 +10753,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_4_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(float.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_4_SomeNull() + public async Task MaxAsync_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); @@ -10790,7 +10790,7 @@ public async Task Max_Single_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_4_SomeNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); @@ -10805,14 +10805,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_4_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10821,14 +10821,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_4_SomeNull() { var input = new float?[] { -2, null, float.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10836,7 +10836,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_4_So } #endif [Fact] - public async Task Max_Single_WithNaN_8() + public async Task MaxAsync_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -10851,7 +10851,7 @@ public async Task Max_Single_WithNaN_8() } [Fact] - public async Task Max_Selector_Single_WithNaN_8() + public async Task MaxAsync_Selector_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -10866,14 +10866,14 @@ public async Task Max_Selector_Single_WithNaN_8() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_8() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10882,14 +10882,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_8() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_8() { var input = new float[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10898,7 +10898,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_8() #endif [Fact] - public async Task Max_Single_WithNaN_8_AllNaN() + public async Task MaxAsync_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -10908,7 +10908,7 @@ public async Task Max_Single_WithNaN_8_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_8_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -10918,29 +10918,29 @@ public async Task Max_Selector_Single_WithNaN_8_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_8_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_8_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_8_NoNull() + public async Task MaxAsync_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -10955,7 +10955,7 @@ public async Task Max_Single_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_8_NoNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); @@ -10970,14 +10970,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_8_NoNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -10986,14 +10986,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_NoNull() { var input = new float?[] { float.NaN, -19, float.NaN, -46, float.NaN, -63, float.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11002,7 +11002,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_No #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_8_AllNull() + public async Task MaxAsync_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -11012,7 +11012,7 @@ public async Task Max_Single_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_8_AllNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); @@ -11022,29 +11022,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_8_AllNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(float?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_8_AllNaN() + public async Task MaxAsync_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -11054,7 +11054,7 @@ public async Task Max_Single_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_8_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); @@ -11064,29 +11064,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_8_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(float.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_8_SomeNull() + public async Task MaxAsync_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); @@ -11101,7 +11101,7 @@ public async Task Max_Single_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_8_SomeNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); @@ -11116,14 +11116,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_8_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11132,14 +11132,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_8_SomeNull() { var input = new float?[] { -48, null, float.NaN, -46, null, float.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11147,7 +11147,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_8_So } #endif [Fact] - public async Task Max_Single_WithNaN_16() + public async Task MaxAsync_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -11162,7 +11162,7 @@ public async Task Max_Single_WithNaN_16() } [Fact] - public async Task Max_Selector_Single_WithNaN_16() + public async Task MaxAsync_Selector_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -11177,14 +11177,14 @@ public async Task Max_Selector_Single_WithNaN_16() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_16() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11193,14 +11193,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_16() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_16() { var input = new float[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11209,7 +11209,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_16() #endif [Fact] - public async Task Max_Single_WithNaN_16_AllNaN() + public async Task MaxAsync_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -11219,7 +11219,7 @@ public async Task Max_Single_WithNaN_16_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_16_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -11229,29 +11229,29 @@ public async Task Max_Selector_Single_WithNaN_16_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_16_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_16_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_16_NoNull() + public async Task MaxAsync_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -11266,7 +11266,7 @@ public async Task Max_Single_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_16_NoNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); @@ -11281,14 +11281,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_16_NoNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11297,14 +11297,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_NoNull() { var input = new float?[] { float.NaN, 98, float.NaN, 98, float.NaN, 63, float.NaN, 14, float.NaN, -86, float.NaN, -79, float.NaN, -84, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11313,7 +11313,7 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_N #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_16_AllNull() + public async Task MaxAsync_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -11323,7 +11323,7 @@ public async Task Max_Single_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_16_AllNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); @@ -11333,29 +11333,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_16_AllNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(float?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_16_AllNaN() + public async Task MaxAsync_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -11365,7 +11365,7 @@ public async Task Max_Single_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_16_AllNaN() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); @@ -11375,29 +11375,29 @@ public async Task Max_Selector_Single_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_16_AllNaN() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(float.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Single_WithNaN_Nullable_16_SomeNull() + public async Task MaxAsync_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); @@ -11412,7 +11412,7 @@ public async Task Max_Single_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Max_Selector_Single_WithNaN_Nullable_16_SomeNull() + public async Task MaxAsync_Selector_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); @@ -11427,14 +11427,14 @@ public async Task Max_Selector_Single_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Single_WithNaN_Nullable_16_SomeNull() + public async Task MaxAwaitAsync_Selector_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11443,14 +11443,14 @@ public async Task Max_AsyncSelector_Single_WithNaN_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Single_WithNaN_Nullable_16_SomeNull() { var input = new float?[] { 59, null, float.NaN, 98, null, float.NaN, -100, null, float.NaN, -86, null, float.NaN, 19, null, float.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11458,59 +11458,59 @@ public async Task Max_AsyncSelectorWithCancellation_Single_WithNaN_Nullable_16_S } #endif [Fact] - public async Task Max_Empty_Double() + public async Task MaxAsync_Empty_Double() { await AssertThrowsAsync(new double[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Max_Selector_Empty_Double() + public async Task MaxAsync_Selector_Empty_Double() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(double), CancellationToken.None).AsTask()); } [Fact] - public async Task Max_AsyncSelector_Empty_Double() + public async Task MaxAwaitAsync_Selector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Double() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Double() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Max_Empty_Nullable_Double() + public async Task MaxAsync_Empty_Nullable_Double() { Assert.Null(await new double?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); } [Fact] - public async Task Max_Selector_Empty_Nullable_Double() + public async Task MaxAsync_Selector_Empty_Nullable_Double() { Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(double?), CancellationToken.None)); } [Fact] - public async Task Max_AsyncSelector_Empty_Nullable_Double() + public async Task MaxAwaitAsync_Selector_Empty_Nullable_Double() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Double() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Nullable_Double() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Max_Double_1() + public async Task MaxAsync_Double_1() { var input = new double[] { 33 }.AsEnumerable(); @@ -11525,7 +11525,7 @@ public async Task Max_Double_1() } [Fact] - public async Task Max_Selector_Double_1() + public async Task MaxAsync_Selector_Double_1() { var input = new double[] { 33 }.AsEnumerable(); @@ -11540,14 +11540,14 @@ public async Task Max_Selector_Double_1() } [Fact] - public async Task Max_AsyncSelector_Double_1() + public async Task MaxAwaitAsync_Selector_Double_1() { var input = new double[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11556,14 +11556,14 @@ public async Task Max_AsyncSelector_Double_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_1() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_1() { var input = new double[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11572,7 +11572,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_1() #endif [Fact] - public async Task Max_Double_Nullable_1_NoNull() + public async Task MaxAsync_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -11587,7 +11587,7 @@ public async Task Max_Double_Nullable_1_NoNull() } [Fact] - public async Task Max_Selector_Double_Nullable_1_NoNull() + public async Task MaxAsync_Selector_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -11602,14 +11602,14 @@ public async Task Max_Selector_Double_Nullable_1_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_1_NoNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11618,14 +11618,14 @@ public async Task Max_AsyncSelector_Double_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_1_NoNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11634,7 +11634,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_NoNull() #endif [Fact] - public async Task Max_Double_Nullable_1_AllNull() + public async Task MaxAsync_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -11644,7 +11644,7 @@ public async Task Max_Double_Nullable_1_AllNull() } [Fact] - public async Task Max_Selector_Double_Nullable_1_AllNull() + public async Task MaxAsync_Selector_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -11654,29 +11654,29 @@ public async Task Max_Selector_Double_Nullable_1_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_1_AllNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_Nullable_1_SomeNull() + public async Task MaxAsync_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -11691,7 +11691,7 @@ public async Task Max_Double_Nullable_1_SomeNull() } [Fact] - public async Task Max_Selector_Double_Nullable_1_SomeNull() + public async Task MaxAsync_Selector_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -11706,14 +11706,14 @@ public async Task Max_Selector_Double_Nullable_1_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_1_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11722,14 +11722,14 @@ public async Task Max_AsyncSelector_Double_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11738,7 +11738,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_1_SomeNull() #endif [Fact] - public async Task Max_Double_4() + public async Task MaxAsync_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -11753,7 +11753,7 @@ public async Task Max_Double_4() } [Fact] - public async Task Max_Selector_Double_4() + public async Task MaxAsync_Selector_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -11768,14 +11768,14 @@ public async Task Max_Selector_Double_4() } [Fact] - public async Task Max_AsyncSelector_Double_4() + public async Task MaxAwaitAsync_Selector_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11784,14 +11784,14 @@ public async Task Max_AsyncSelector_Double_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_4() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_4() { var input = new double[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11800,7 +11800,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_4() #endif [Fact] - public async Task Max_Double_Nullable_4_NoNull() + public async Task MaxAsync_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -11815,7 +11815,7 @@ public async Task Max_Double_Nullable_4_NoNull() } [Fact] - public async Task Max_Selector_Double_Nullable_4_NoNull() + public async Task MaxAsync_Selector_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -11830,14 +11830,14 @@ public async Task Max_Selector_Double_Nullable_4_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_4_NoNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11846,14 +11846,14 @@ public async Task Max_AsyncSelector_Double_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_4_NoNull() { var input = new double?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11862,7 +11862,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_NoNull() #endif [Fact] - public async Task Max_Double_Nullable_4_AllNull() + public async Task MaxAsync_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -11872,7 +11872,7 @@ public async Task Max_Double_Nullable_4_AllNull() } [Fact] - public async Task Max_Selector_Double_Nullable_4_AllNull() + public async Task MaxAsync_Selector_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -11882,29 +11882,29 @@ public async Task Max_Selector_Double_Nullable_4_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_4_AllNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_Nullable_4_SomeNull() + public async Task MaxAsync_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); @@ -11919,7 +11919,7 @@ public async Task Max_Double_Nullable_4_SomeNull() } [Fact] - public async Task Max_Selector_Double_Nullable_4_SomeNull() + public async Task MaxAsync_Selector_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); @@ -11934,14 +11934,14 @@ public async Task Max_Selector_Double_Nullable_4_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_4_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11950,14 +11950,14 @@ public async Task Max_AsyncSelector_Double_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_4_SomeNull() { var input = new double?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -11966,7 +11966,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_4_SomeNull() #endif [Fact] - public async Task Max_Double_8() + public async Task MaxAsync_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -11981,7 +11981,7 @@ public async Task Max_Double_8() } [Fact] - public async Task Max_Selector_Double_8() + public async Task MaxAsync_Selector_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -11996,14 +11996,14 @@ public async Task Max_Selector_Double_8() } [Fact] - public async Task Max_AsyncSelector_Double_8() + public async Task MaxAwaitAsync_Selector_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12012,14 +12012,14 @@ public async Task Max_AsyncSelector_Double_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_8() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_8() { var input = new double[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12028,7 +12028,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_8() #endif [Fact] - public async Task Max_Double_Nullable_8_NoNull() + public async Task MaxAsync_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -12043,7 +12043,7 @@ public async Task Max_Double_Nullable_8_NoNull() } [Fact] - public async Task Max_Selector_Double_Nullable_8_NoNull() + public async Task MaxAsync_Selector_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -12058,14 +12058,14 @@ public async Task Max_Selector_Double_Nullable_8_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_8_NoNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12074,14 +12074,14 @@ public async Task Max_AsyncSelector_Double_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_8_NoNull() { var input = new double?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12090,7 +12090,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_NoNull() #endif [Fact] - public async Task Max_Double_Nullable_8_AllNull() + public async Task MaxAsync_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -12100,7 +12100,7 @@ public async Task Max_Double_Nullable_8_AllNull() } [Fact] - public async Task Max_Selector_Double_Nullable_8_AllNull() + public async Task MaxAsync_Selector_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -12110,29 +12110,29 @@ public async Task Max_Selector_Double_Nullable_8_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_8_AllNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_Nullable_8_SomeNull() + public async Task MaxAsync_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -12147,7 +12147,7 @@ public async Task Max_Double_Nullable_8_SomeNull() } [Fact] - public async Task Max_Selector_Double_Nullable_8_SomeNull() + public async Task MaxAsync_Selector_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -12162,14 +12162,14 @@ public async Task Max_Selector_Double_Nullable_8_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_8_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12178,14 +12178,14 @@ public async Task Max_AsyncSelector_Double_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_8_SomeNull() { var input = new double?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12194,7 +12194,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_8_SomeNull() #endif [Fact] - public async Task Max_Double_16() + public async Task MaxAsync_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -12209,7 +12209,7 @@ public async Task Max_Double_16() } [Fact] - public async Task Max_Selector_Double_16() + public async Task MaxAsync_Selector_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -12224,14 +12224,14 @@ public async Task Max_Selector_Double_16() } [Fact] - public async Task Max_AsyncSelector_Double_16() + public async Task MaxAwaitAsync_Selector_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12240,14 +12240,14 @@ public async Task Max_AsyncSelector_Double_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_16() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_16() { var input = new double[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12256,7 +12256,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_16() #endif [Fact] - public async Task Max_Double_Nullable_16_NoNull() + public async Task MaxAsync_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -12271,7 +12271,7 @@ public async Task Max_Double_Nullable_16_NoNull() } [Fact] - public async Task Max_Selector_Double_Nullable_16_NoNull() + public async Task MaxAsync_Selector_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -12286,14 +12286,14 @@ public async Task Max_Selector_Double_Nullable_16_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_16_NoNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12302,14 +12302,14 @@ public async Task Max_AsyncSelector_Double_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_16_NoNull() { var input = new double?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12318,7 +12318,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_NoNull() #endif [Fact] - public async Task Max_Double_Nullable_16_AllNull() + public async Task MaxAsync_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -12328,7 +12328,7 @@ public async Task Max_Double_Nullable_16_AllNull() } [Fact] - public async Task Max_Selector_Double_Nullable_16_AllNull() + public async Task MaxAsync_Selector_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -12338,29 +12338,29 @@ public async Task Max_Selector_Double_Nullable_16_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_16_AllNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_Nullable_16_SomeNull() + public async Task MaxAsync_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -12375,7 +12375,7 @@ public async Task Max_Double_Nullable_16_SomeNull() } [Fact] - public async Task Max_Selector_Double_Nullable_16_SomeNull() + public async Task MaxAsync_Selector_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -12390,14 +12390,14 @@ public async Task Max_Selector_Double_Nullable_16_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_Nullable_16_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12406,14 +12406,14 @@ public async Task Max_AsyncSelector_Double_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_Nullable_16_SomeNull() { var input = new double?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12422,7 +12422,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_Nullable_16_SomeNull( #endif [Fact] - public async Task Max_Double_WithNaN_1() + public async Task MaxAsync_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); @@ -12437,7 +12437,7 @@ public async Task Max_Double_WithNaN_1() } [Fact] - public async Task Max_Selector_Double_WithNaN_1() + public async Task MaxAsync_Selector_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); @@ -12452,14 +12452,14 @@ public async Task Max_Selector_Double_WithNaN_1() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_1() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12468,14 +12468,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_1() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_1() { var input = new double[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12484,7 +12484,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_1() #endif [Fact] - public async Task Max_Double_WithNaN_1_AllNaN() + public async Task MaxAsync_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -12494,7 +12494,7 @@ public async Task Max_Double_WithNaN_1_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_1_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -12504,29 +12504,29 @@ public async Task Max_Selector_Double_WithNaN_1_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_1_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_1_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_1_NoNull() + public async Task MaxAsync_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); @@ -12541,7 +12541,7 @@ public async Task Max_Double_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_1_NoNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); @@ -12556,14 +12556,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_1_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_1_NoNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12572,14 +12572,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_NoNull() { var input = new double?[] { double.NaN }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12588,7 +12588,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_No #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_1_AllNull() + public async Task MaxAsync_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -12598,7 +12598,7 @@ public async Task Max_Double_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_1_AllNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); @@ -12608,29 +12608,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_1_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_1_AllNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(double?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_1_AllNaN() + public async Task MaxAsync_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -12640,7 +12640,7 @@ public async Task Max_Double_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_1_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); @@ -12650,29 +12650,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_1_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_1_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_AllNaN() { var input = Enumerable.Repeat(double.NaN, 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_1_SomeNull() + public async Task MaxAsync_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -12687,7 +12687,7 @@ public async Task Max_Double_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_1_SomeNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); @@ -12702,14 +12702,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_1_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_1_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12718,14 +12718,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_1_SomeNull() { var input = new double?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12733,7 +12733,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_1_So } #endif [Fact] - public async Task Max_Double_WithNaN_4() + public async Task MaxAsync_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -12748,7 +12748,7 @@ public async Task Max_Double_WithNaN_4() } [Fact] - public async Task Max_Selector_Double_WithNaN_4() + public async Task MaxAsync_Selector_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -12763,14 +12763,14 @@ public async Task Max_Selector_Double_WithNaN_4() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_4() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12779,14 +12779,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_4() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_4() { var input = new double[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12795,7 +12795,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_4() #endif [Fact] - public async Task Max_Double_WithNaN_4_AllNaN() + public async Task MaxAsync_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -12805,7 +12805,7 @@ public async Task Max_Double_WithNaN_4_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_4_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -12815,29 +12815,29 @@ public async Task Max_Selector_Double_WithNaN_4_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_4_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_4_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_4_NoNull() + public async Task MaxAsync_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -12852,7 +12852,7 @@ public async Task Max_Double_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_4_NoNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); @@ -12867,14 +12867,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_4_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_4_NoNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12883,14 +12883,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_NoNull() { var input = new double?[] { double.NaN, -78, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -12899,7 +12899,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_No #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_4_AllNull() + public async Task MaxAsync_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -12909,7 +12909,7 @@ public async Task Max_Double_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_4_AllNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); @@ -12919,29 +12919,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_4_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_4_AllNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(double?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_4_AllNaN() + public async Task MaxAsync_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -12951,7 +12951,7 @@ public async Task Max_Double_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_4_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); @@ -12961,29 +12961,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_4_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_4_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_AllNaN() { var input = Enumerable.Repeat(double.NaN, 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_4_SomeNull() + public async Task MaxAsync_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); @@ -12998,7 +12998,7 @@ public async Task Max_Double_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_4_SomeNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); @@ -13013,14 +13013,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_4_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_4_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13029,14 +13029,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_4_SomeNull() { var input = new double?[] { -2, null, double.NaN, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13044,7 +13044,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_4_So } #endif [Fact] - public async Task Max_Double_WithNaN_8() + public async Task MaxAsync_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -13059,7 +13059,7 @@ public async Task Max_Double_WithNaN_8() } [Fact] - public async Task Max_Selector_Double_WithNaN_8() + public async Task MaxAsync_Selector_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -13074,14 +13074,14 @@ public async Task Max_Selector_Double_WithNaN_8() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_8() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13090,14 +13090,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_8() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_8() { var input = new double[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13106,7 +13106,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_8() #endif [Fact] - public async Task Max_Double_WithNaN_8_AllNaN() + public async Task MaxAsync_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -13116,7 +13116,7 @@ public async Task Max_Double_WithNaN_8_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_8_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -13126,29 +13126,29 @@ public async Task Max_Selector_Double_WithNaN_8_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_8_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_8_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_8_NoNull() + public async Task MaxAsync_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -13163,7 +13163,7 @@ public async Task Max_Double_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_8_NoNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); @@ -13178,14 +13178,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_8_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_8_NoNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13194,14 +13194,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_NoNull() { var input = new double?[] { double.NaN, -19, double.NaN, -46, double.NaN, -63, double.NaN, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13210,7 +13210,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_No #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_8_AllNull() + public async Task MaxAsync_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -13220,7 +13220,7 @@ public async Task Max_Double_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_8_AllNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); @@ -13230,29 +13230,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_8_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_8_AllNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(double?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_8_AllNaN() + public async Task MaxAsync_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -13262,7 +13262,7 @@ public async Task Max_Double_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_8_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); @@ -13272,29 +13272,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_8_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_8_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_AllNaN() { var input = Enumerable.Repeat(double.NaN, 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_8_SomeNull() + public async Task MaxAsync_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); @@ -13309,7 +13309,7 @@ public async Task Max_Double_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_8_SomeNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); @@ -13324,14 +13324,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_8_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_8_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13340,14 +13340,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_8_SomeNull() { var input = new double?[] { -48, null, double.NaN, -46, null, double.NaN, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13355,7 +13355,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_8_So } #endif [Fact] - public async Task Max_Double_WithNaN_16() + public async Task MaxAsync_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -13370,7 +13370,7 @@ public async Task Max_Double_WithNaN_16() } [Fact] - public async Task Max_Selector_Double_WithNaN_16() + public async Task MaxAsync_Selector_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -13385,14 +13385,14 @@ public async Task Max_Selector_Double_WithNaN_16() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_16() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13401,14 +13401,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_16() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_16() { var input = new double[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13417,7 +13417,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_16() #endif [Fact] - public async Task Max_Double_WithNaN_16_AllNaN() + public async Task MaxAsync_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -13427,7 +13427,7 @@ public async Task Max_Double_WithNaN_16_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_16_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -13437,29 +13437,29 @@ public async Task Max_Selector_Double_WithNaN_16_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_16_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_16_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_16_NoNull() + public async Task MaxAsync_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -13474,7 +13474,7 @@ public async Task Max_Double_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_16_NoNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); @@ -13489,14 +13489,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_16_NoNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_16_NoNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13505,14 +13505,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_NoNull() { var input = new double?[] { double.NaN, 98, double.NaN, 98, double.NaN, 63, double.NaN, 14, double.NaN, -86, double.NaN, -79, double.NaN, -84, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13521,7 +13521,7 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_N #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_16_AllNull() + public async Task MaxAsync_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -13531,7 +13531,7 @@ public async Task Max_Double_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_16_AllNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); @@ -13541,29 +13541,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_16_AllNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_16_AllNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(double?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_16_AllNaN() + public async Task MaxAsync_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -13573,7 +13573,7 @@ public async Task Max_Double_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_16_AllNaN() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); @@ -13583,29 +13583,29 @@ public async Task Max_Selector_Double_WithNaN_Nullable_16_AllNaN() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_16_AllNaN() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_AllNaN() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_AllNaN() { var input = Enumerable.Repeat(double.NaN, 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Double_WithNaN_Nullable_16_SomeNull() + public async Task MaxAsync_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); @@ -13620,7 +13620,7 @@ public async Task Max_Double_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Max_Selector_Double_WithNaN_Nullable_16_SomeNull() + public async Task MaxAsync_Selector_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); @@ -13635,14 +13635,14 @@ public async Task Max_Selector_Double_WithNaN_Nullable_16_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Double_WithNaN_Nullable_16_SomeNull() + public async Task MaxAwaitAsync_Selector_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13651,14 +13651,14 @@ public async Task Max_AsyncSelector_Double_WithNaN_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Double_WithNaN_Nullable_16_SomeNull() { var input = new double?[] { 59, null, double.NaN, 98, null, double.NaN, -100, null, double.NaN, -86, null, double.NaN, 19, null, double.NaN, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13666,59 +13666,59 @@ public async Task Max_AsyncSelectorWithCancellation_Double_WithNaN_Nullable_16_S } #endif [Fact] - public async Task Max_Empty_Decimal() + public async Task MaxAsync_Empty_Decimal() { await AssertThrowsAsync(new decimal[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None).AsTask()); } [Fact] - public async Task Max_Selector_Empty_Decimal() + public async Task MaxAsync_Selector_Empty_Decimal() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(decimal), CancellationToken.None).AsTask()); } [Fact] - public async Task Max_AsyncSelector_Empty_Decimal() + public async Task MaxAwaitAsync_Selector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Decimal() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Decimal() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task Max_Empty_Nullable_Decimal() + public async Task MaxAsync_Empty_Nullable_Decimal() { Assert.Null(await new decimal?[0].ToAsyncEnumerable().MaxAsync(CancellationToken.None)); } [Fact] - public async Task Max_Selector_Empty_Nullable_Decimal() + public async Task MaxAsync_Selector_Empty_Nullable_Decimal() { Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(decimal?), CancellationToken.None)); } [Fact] - public async Task Max_AsyncSelector_Empty_Nullable_Decimal() + public async Task MaxAwaitAsync_Selector_Empty_Nullable_Decimal() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync(_ => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitAsync(_ => default(ValueTask), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Empty_Nullable_Decimal() + public async Task MaxAwaitWithCancellationAsync_Selector_Empty_Nullable_Decimal() { - Assert.Null(await new object[0].ToAsyncEnumerable().MaxAsync((x, ct) => default(ValueTask), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => default(ValueTask), CancellationToken.None)); } #endif [Fact] - public async Task Max_Decimal_1() + public async Task MaxAsync_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); @@ -13733,7 +13733,7 @@ public async Task Max_Decimal_1() } [Fact] - public async Task Max_Selector_Decimal_1() + public async Task MaxAsync_Selector_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); @@ -13748,14 +13748,14 @@ public async Task Max_Selector_Decimal_1() } [Fact] - public async Task Max_AsyncSelector_Decimal_1() + public async Task MaxAwaitAsync_Selector_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13764,14 +13764,14 @@ public async Task Max_AsyncSelector_Decimal_1() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_1() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_1() { var input = new decimal[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13780,7 +13780,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_1() #endif [Fact] - public async Task Max_Decimal_Nullable_1_NoNull() + public async Task MaxAsync_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -13795,7 +13795,7 @@ public async Task Max_Decimal_Nullable_1_NoNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_1_NoNull() + public async Task MaxAsync_Selector_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -13810,14 +13810,14 @@ public async Task Max_Selector_Decimal_Nullable_1_NoNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_1_NoNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13826,14 +13826,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_1_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_1_NoNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13842,7 +13842,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_NoNull() #endif [Fact] - public async Task Max_Decimal_Nullable_1_AllNull() + public async Task MaxAsync_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); @@ -13852,7 +13852,7 @@ public async Task Max_Decimal_Nullable_1_AllNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_1_AllNull() + public async Task MaxAsync_Selector_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); @@ -13862,29 +13862,29 @@ public async Task Max_Selector_Decimal_Nullable_1_AllNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_1_AllNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_1_AllNull() { var input = Enumerable.Repeat(default(decimal?), 1); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Decimal_Nullable_1_SomeNull() + public async Task MaxAsync_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -13899,7 +13899,7 @@ public async Task Max_Decimal_Nullable_1_SomeNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_1_SomeNull() + public async Task MaxAsync_Selector_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); @@ -13914,14 +13914,14 @@ public async Task Max_Selector_Decimal_Nullable_1_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_1_SomeNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13930,14 +13930,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_1_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_1_SomeNull() { var input = new decimal?[] { 33 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13946,7 +13946,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_1_SomeNull( #endif [Fact] - public async Task Max_Decimal_4() + public async Task MaxAsync_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -13961,7 +13961,7 @@ public async Task Max_Decimal_4() } [Fact] - public async Task Max_Selector_Decimal_4() + public async Task MaxAsync_Selector_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -13976,14 +13976,14 @@ public async Task Max_Selector_Decimal_4() } [Fact] - public async Task Max_AsyncSelector_Decimal_4() + public async Task MaxAwaitAsync_Selector_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -13992,14 +13992,14 @@ public async Task Max_AsyncSelector_Decimal_4() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_4() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_4() { var input = new decimal[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14008,7 +14008,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_4() #endif [Fact] - public async Task Max_Decimal_Nullable_4_NoNull() + public async Task MaxAsync_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -14023,7 +14023,7 @@ public async Task Max_Decimal_Nullable_4_NoNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_4_NoNull() + public async Task MaxAsync_Selector_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); @@ -14038,14 +14038,14 @@ public async Task Max_Selector_Decimal_Nullable_4_NoNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_4_NoNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14054,14 +14054,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_4_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_4_NoNull() { var input = new decimal?[] { -2, -78, -61, -17 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14070,7 +14070,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_NoNull() #endif [Fact] - public async Task Max_Decimal_Nullable_4_AllNull() + public async Task MaxAsync_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); @@ -14080,7 +14080,7 @@ public async Task Max_Decimal_Nullable_4_AllNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_4_AllNull() + public async Task MaxAsync_Selector_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); @@ -14090,29 +14090,29 @@ public async Task Max_Selector_Decimal_Nullable_4_AllNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_4_AllNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_4_AllNull() { var input = Enumerable.Repeat(default(decimal?), 4); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Decimal_Nullable_4_SomeNull() + public async Task MaxAsync_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); @@ -14127,7 +14127,7 @@ public async Task Max_Decimal_Nullable_4_SomeNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_4_SomeNull() + public async Task MaxAsync_Selector_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); @@ -14142,14 +14142,14 @@ public async Task Max_Selector_Decimal_Nullable_4_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_4_SomeNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14158,14 +14158,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_4_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_4_SomeNull() { var input = new decimal?[] { -2, null, -61, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14174,7 +14174,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_4_SomeNull( #endif [Fact] - public async Task Max_Decimal_8() + public async Task MaxAsync_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -14189,7 +14189,7 @@ public async Task Max_Decimal_8() } [Fact] - public async Task Max_Selector_Decimal_8() + public async Task MaxAsync_Selector_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -14204,14 +14204,14 @@ public async Task Max_Selector_Decimal_8() } [Fact] - public async Task Max_AsyncSelector_Decimal_8() + public async Task MaxAwaitAsync_Selector_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14220,14 +14220,14 @@ public async Task Max_AsyncSelector_Decimal_8() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_8() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_8() { var input = new decimal[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14236,7 +14236,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_8() #endif [Fact] - public async Task Max_Decimal_Nullable_8_NoNull() + public async Task MaxAsync_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -14251,7 +14251,7 @@ public async Task Max_Decimal_Nullable_8_NoNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_8_NoNull() + public async Task MaxAsync_Selector_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); @@ -14266,14 +14266,14 @@ public async Task Max_Selector_Decimal_Nullable_8_NoNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_8_NoNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14282,14 +14282,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_8_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_8_NoNull() { var input = new decimal?[] { -48, -19, 25, -46, 81, -63, -10, -99 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14298,7 +14298,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_NoNull() #endif [Fact] - public async Task Max_Decimal_Nullable_8_AllNull() + public async Task MaxAsync_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); @@ -14308,7 +14308,7 @@ public async Task Max_Decimal_Nullable_8_AllNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_8_AllNull() + public async Task MaxAsync_Selector_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); @@ -14318,29 +14318,29 @@ public async Task Max_Selector_Decimal_Nullable_8_AllNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_8_AllNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_8_AllNull() { var input = Enumerable.Repeat(default(decimal?), 8); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Decimal_Nullable_8_SomeNull() + public async Task MaxAsync_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -14355,7 +14355,7 @@ public async Task Max_Decimal_Nullable_8_SomeNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_8_SomeNull() + public async Task MaxAsync_Selector_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); @@ -14370,14 +14370,14 @@ public async Task Max_Selector_Decimal_Nullable_8_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_8_SomeNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14386,14 +14386,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_8_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_8_SomeNull() { var input = new decimal?[] { -48, null, 25, null, 81, null, -10, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14402,7 +14402,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_8_SomeNull( #endif [Fact] - public async Task Max_Decimal_16() + public async Task MaxAsync_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -14417,7 +14417,7 @@ public async Task Max_Decimal_16() } [Fact] - public async Task Max_Selector_Decimal_16() + public async Task MaxAsync_Selector_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -14432,14 +14432,14 @@ public async Task Max_Selector_Decimal_16() } [Fact] - public async Task Max_AsyncSelector_Decimal_16() + public async Task MaxAwaitAsync_Selector_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14448,14 +14448,14 @@ public async Task Max_AsyncSelector_Decimal_16() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_16() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_16() { var input = new decimal[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14464,7 +14464,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_16() #endif [Fact] - public async Task Max_Decimal_Nullable_16_NoNull() + public async Task MaxAsync_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -14479,7 +14479,7 @@ public async Task Max_Decimal_Nullable_16_NoNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_16_NoNull() + public async Task MaxAsync_Selector_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); @@ -14494,14 +14494,14 @@ public async Task Max_Selector_Decimal_Nullable_16_NoNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_16_NoNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14510,14 +14510,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_16_NoNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_16_NoNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_16_NoNull() { var input = new decimal?[] { 59, 98, -3, 98, 20, 63, -100, 14, -77, -86, -26, -79, 19, -84, -28, 41 }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14526,7 +14526,7 @@ public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_16_NoNull() #endif [Fact] - public async Task Max_Decimal_Nullable_16_AllNull() + public async Task MaxAsync_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); @@ -14536,7 +14536,7 @@ public async Task Max_Decimal_Nullable_16_AllNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_16_AllNull() + public async Task MaxAsync_Selector_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); @@ -14546,29 +14546,29 @@ public async Task Max_Selector_Decimal_Nullable_16_AllNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_16_AllNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_16_AllNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_16_AllNull() { var input = Enumerable.Repeat(default(decimal?), 16); var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task Max_Decimal_Nullable_16_SomeNull() + public async Task MaxAsync_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -14583,7 +14583,7 @@ public async Task Max_Decimal_Nullable_16_SomeNull() } [Fact] - public async Task Max_Selector_Decimal_Nullable_16_SomeNull() + public async Task MaxAsync_Selector_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); @@ -14598,14 +14598,14 @@ public async Task Max_Selector_Decimal_Nullable_16_SomeNull() } [Fact] - public async Task Max_AsyncSelector_Decimal_Nullable_16_SomeNull() + public async Task MaxAwaitAsync_Selector_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync(x => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitAsync(x => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -14614,14 +14614,14 @@ public async Task Max_AsyncSelector_Decimal_Nullable_16_SomeNull() #if !NO_DEEP_CANCELLATION [Fact] - public async Task Max_AsyncSelectorWithCancellation_Decimal_Nullable_16_SomeNull() + public async Task MaxAwaitWithCancellationAsync_Selector_Decimal_Nullable_16_SomeNull() { var input = new decimal?[] { 59, null, -3, null, 20, null, -100, null, -77, null, -26, null, 19, null, -28, null }.AsEnumerable(); for (var i = 0; i < 4; i++) { var expected = input.Max(); - var actual = await input.ToAsyncEnumerable().MaxAsync((x, ct) => new ValueTask(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().MaxAwaitWithCancellationAsync((x, ct) => new ValueTask(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt index 9bc33cfd80..49ed2efd4e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/MinMax.Generated.tt @@ -54,54 +54,54 @@ foreach (var op in new[] { "Min", "Max" }) var cs = toCSharp(t); #> [Fact] - public async Task <#=op#>_Empty_<#=t.Name#>() + public async Task <#=op#>Async_Empty_<#=t.Name#>() { await AssertThrowsAsync(new <#=cs#>[0].ToAsyncEnumerable().<#=op#>Async(CancellationToken.None).AsTask()); } [Fact] - public async Task <#=op#>_Selector_Empty_<#=t.Name#>() + public async Task <#=op#>Async_Selector_Empty_<#=t.Name#>() { await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(<#=cs#>), CancellationToken.None).AsTask()); } [Fact] - public async Task <#=op#>_AsyncSelector_Empty_<#=t.Name#>() + public async Task <#=op#>AwaitAsync_Selector_Empty_<#=t.Name#>() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(ValueTask<<#=cs#>>), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>AwaitAsync(_ => default(ValueTask<<#=cs#>>), CancellationToken.None).AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_Empty_<#=t.Name#>() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_Empty_<#=t.Name#>() { - await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>Async((x, ct) => default(ValueTask<<#=cs#>>), CancellationToken.None).AsTask()); + await AssertThrowsAsync(new object[0].ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => default(ValueTask<<#=cs#>>), CancellationToken.None).AsTask()); } #endif [Fact] - public async Task <#=op#>_Empty_Nullable_<#=t.Name#>() + public async Task <#=op#>Async_Empty_Nullable_<#=t.Name#>() { Assert.Null(await new <#=cs#>?[0].ToAsyncEnumerable().<#=op#>Async(CancellationToken.None)); } [Fact] - public async Task <#=op#>_Selector_Empty_Nullable_<#=t.Name#>() + public async Task <#=op#>Async_Selector_Empty_Nullable_<#=t.Name#>() { Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(<#=cs#>?), CancellationToken.None)); } [Fact] - public async Task <#=op#>_AsyncSelector_Empty_Nullable_<#=t.Name#>() + public async Task <#=op#>AwaitAsync_Selector_Empty_Nullable_<#=t.Name#>() { - Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>Async(_ => default(ValueTask<<#=cs#>?>), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>AwaitAsync(_ => default(ValueTask<<#=cs#>?>), CancellationToken.None)); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_Empty_Nullable_<#=t.Name#>() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_Empty_Nullable_<#=t.Name#>() { - Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>Async((x, ct) => default(ValueTask<<#=cs#>?>), CancellationToken.None)); + Assert.Null(await new object[0].ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => default(ValueTask<<#=cs#>?>), CancellationToken.None)); } #endif @@ -112,7 +112,7 @@ foreach (var op in new[] { "Min", "Max" }) var valuesWithNull = string.Join(", ", getRandom(n * 42, n, -100, 100).Select((x, i) => i % 2 == 0 ? x.ToString() : "null")); #> [Fact] - public async Task <#=op#>_<#=t.Name#>_<#=n#>() + public async Task <#=op#>Async_<#=t.Name#>_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); @@ -127,7 +127,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_<#=n#>() + public async Task <#=op#>Async_Selector_<#=t.Name#>_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); @@ -142,14 +142,14 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_<#=n#>() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -158,14 +158,14 @@ foreach (var op in new[] { "Min", "Max" }) #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_<#=n#>() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -174,7 +174,7 @@ foreach (var op in new[] { "Min", "Max" }) #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_Nullable_<#=n#>_NoNull() + public async Task <#=op#>Async_<#=t.Name#>_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); @@ -189,7 +189,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_Nullable_<#=n#>_NoNull() + public async Task <#=op#>Async_Selector_<#=t.Name#>_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); @@ -204,14 +204,14 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_Nullable_<#=n#>_NoNull() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -220,14 +220,14 @@ foreach (var op in new[] { "Min", "Max" }) #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_<#=n#>_NoNull() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -236,7 +236,7 @@ foreach (var op in new[] { "Min", "Max" }) #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_Nullable_<#=n#>_AllNull() + public async Task <#=op#>Async_<#=t.Name#>_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); @@ -246,7 +246,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_Nullable_<#=n#>_AllNull() + public async Task <#=op#>Async_Selector_<#=t.Name#>_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); @@ -256,29 +256,29 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_Nullable_<#=n#>_AllNull() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_<#=n#>_AllNull() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>Async_<#=t.Name#>_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); @@ -293,7 +293,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>Async_Selector_<#=t.Name#>_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); @@ -308,14 +308,14 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -324,14 +324,14 @@ foreach (var op in new[] { "Min", "Max" }) #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -350,7 +350,7 @@ foreach (var op in new[] { "Min", "Max" }) var valuesWithNull = string.Join(", ", getRandom(n * 42, n, -100, 100).Select((x, i) => i % 3 == 0 ? x.ToString() : (i % 3 == 1 ? "null" : toCSharp(t) + ".NaN"))); #> [Fact] - public async Task <#=op#>_<#=t.Name#>_WithNaN_<#=n#>() + public async Task <#=op#>Async_<#=t.Name#>_WithNaN_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); @@ -365,7 +365,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_WithNaN_<#=n#>() + public async Task <#=op#>Async_Selector_<#=t.Name#>_WithNaN_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); @@ -380,14 +380,14 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_WithNaN_<#=n#>() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_WithNaN_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -396,14 +396,14 @@ foreach (var op in new[] { "Min", "Max" }) #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_WithNaN_<#=n#>() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_WithNaN_<#=n#>() { var input = new <#=cs#>[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -412,7 +412,7 @@ foreach (var op in new[] { "Min", "Max" }) #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() + public async Task <#=op#>Async_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() { var input = Enumerable.Repeat(<#=toCSharp(t)#>.NaN, <#=n#>); @@ -422,7 +422,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() + public async Task <#=op#>Async_Selector_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() { var input = Enumerable.Repeat(<#=toCSharp(t)#>.NaN, <#=n#>); @@ -432,29 +432,29 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() { var input = Enumerable.Repeat(<#=toCSharp(t)#>.NaN, <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_WithNaN_<#=n#>_AllNaN() { var input = Enumerable.Repeat(<#=toCSharp(t)#>.NaN, <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() + public async Task <#=op#>Async_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); @@ -469,7 +469,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() + public async Task <#=op#>Async_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); @@ -484,14 +484,14 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -500,14 +500,14 @@ foreach (var op in new[] { "Min", "Max" }) #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_NoNull() { var input = new <#=cs#>?[] { <#=values#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -516,7 +516,7 @@ foreach (var op in new[] { "Min", "Max" }) #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() + public async Task <#=op#>Async_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); @@ -526,7 +526,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() + public async Task <#=op#>Async_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); @@ -536,29 +536,29 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNull() { var input = Enumerable.Repeat(default(<#=cs#>?), <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() + public async Task <#=op#>Async_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() { var input = Enumerable.Repeat<<#=toCSharp(t)#>?>(<#=toCSharp(t)#>.NaN, <#=n#>); @@ -568,7 +568,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() + public async Task <#=op#>Async_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() { var input = Enumerable.Repeat<<#=toCSharp(t)#>?>(<#=toCSharp(t)#>.NaN, <#=n#>); @@ -578,29 +578,29 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() { var input = Enumerable.Repeat<<#=toCSharp(t)#>?>(<#=toCSharp(t)#>.NaN, <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_AllNaN() { var input = Enumerable.Repeat<<#=toCSharp(t)#>?>(<#=toCSharp(t)#>.NaN, <#=n#>); var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); } #endif [Fact] - public async Task <#=op#>_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>Async_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); @@ -615,7 +615,7 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>Async_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); @@ -630,14 +630,14 @@ foreach (var op in new[] { "Min", "Max" }) } [Fact] - public async Task <#=op#>_AsyncSelector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>AwaitAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitAsync(x => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); @@ -646,14 +646,14 @@ foreach (var op in new[] { "Min", "Max" }) #if !NO_DEEP_CANCELLATION [Fact] - public async Task <#=op#>_AsyncSelectorWithCancellation_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() + public async Task <#=op#>AwaitWithCancellationAsync_Selector_<#=t.Name#>_WithNaN_Nullable_<#=n#>_SomeNull() { var input = new <#=cs#>?[] { <#=valuesWithNull#> }.AsEnumerable(); for (var i = 0; i < <#=ShuffleCount#>; i++) { var expected = input.<#=op#>(); - var actual = await input.ToAsyncEnumerable().<#=op#>Async((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); + var actual = await input.ToAsyncEnumerable().<#=op#>AwaitWithCancellationAsync((x, ct) => new ValueTask<<#=cs#>?>(x), CancellationToken.None); Assert.Equal(expected, actual); input = Shuffle(input); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs index 736a8fb09d..39d26a44f0 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.cs @@ -47,7 +47,7 @@ public async Task OrderBy_OrderByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)); var syncRes = xs.OrderBy(x => x % 2); await AssertSorted(asyncRes, syncRes); @@ -76,7 +76,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)); var syncRes = xs.OrderBy(x => x % 2); await AssertSorted(asyncRes, syncRes); @@ -134,7 +134,7 @@ public async Task OrderBy_OrderByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)); var syncRes = xs.OrderByDescending(x => x % 2); await AssertSorted(asyncRes, syncRes); @@ -163,7 +163,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)); var syncRes = xs.OrderByDescending(x => x % 2); await AssertSorted(asyncRes, syncRes); @@ -221,7 +221,7 @@ public async Task OrderBy_OrderBy_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -250,7 +250,7 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -308,7 +308,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -337,7 +337,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -366,7 +366,7 @@ public async Task OrderBy_OrderByAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -395,7 +395,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -424,7 +424,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -453,7 +453,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -482,7 +482,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -511,7 +511,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -540,7 +540,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -569,7 +569,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -598,7 +598,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -627,7 +627,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -656,7 +656,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -685,7 +685,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -743,7 +743,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -772,7 +772,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -830,7 +830,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -859,7 +859,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -888,7 +888,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -917,7 +917,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -946,7 +946,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -975,7 +975,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1004,7 +1004,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1033,7 +1033,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1062,7 +1062,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1091,7 +1091,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1120,7 +1120,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1149,7 +1149,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1178,7 +1178,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1207,7 +1207,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3); await AssertSorted(asyncRes, syncRes); @@ -1265,7 +1265,7 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1294,7 +1294,7 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1352,7 +1352,7 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1381,7 +1381,7 @@ public async Task OrderBy_OrderBy_ThenBy_ThenByDescendingAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1410,7 +1410,7 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1439,7 +1439,7 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1468,7 +1468,7 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1497,7 +1497,7 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1526,7 +1526,7 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1555,7 +1555,7 @@ public async Task OrderBy_OrderBy_ThenByAsync_ThenByDescendingAsyncWithCancellat var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1584,7 +1584,7 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1613,7 +1613,7 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1642,7 +1642,7 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByAsyncWithCan var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1671,7 +1671,7 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1700,7 +1700,7 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescendingAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1729,7 +1729,7 @@ public async Task OrderBy_OrderBy_ThenByAsyncWithCancellation_ThenByDescendingAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1787,7 +1787,7 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1816,7 +1816,7 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1874,7 +1874,7 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1903,7 +1903,7 @@ public async Task OrderBy_OrderBy_ThenByDescending_ThenByDescendingAsyncWithCanc var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1932,7 +1932,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1961,7 +1961,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -1990,7 +1990,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByAsyncWithCancellat var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2019,7 +2019,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2048,7 +2048,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2077,7 +2077,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsync_ThenByDescendingAsyncWit var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2106,7 +2106,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2135,7 +2135,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2164,7 +2164,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2193,7 +2193,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2222,7 +2222,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2251,7 +2251,7 @@ public async Task OrderBy_OrderBy_ThenByDescendingAsyncWithCancellation_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2280,7 +2280,7 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2309,7 +2309,7 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2338,7 +2338,7 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2367,7 +2367,7 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2396,7 +2396,7 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2425,7 +2425,7 @@ public async Task OrderBy_OrderByAsync_ThenBy_ThenByDescendingAsyncWithCancellat var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2454,7 +2454,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2483,7 +2483,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2512,7 +2512,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2541,7 +2541,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2570,7 +2570,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2599,7 +2599,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsync_ThenByDescendingAsyncWithCanc var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2628,7 +2628,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2657,7 +2657,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2686,7 +2686,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByAsyncWi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2715,7 +2715,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescend var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2744,7 +2744,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescend var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2773,7 +2773,7 @@ public async Task OrderBy_OrderByAsync_ThenByAsyncWithCancellation_ThenByDescend var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2802,7 +2802,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2831,7 +2831,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2860,7 +2860,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByAsyncWithCancellat var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2889,7 +2889,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2918,7 +2918,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2947,7 +2947,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescending_ThenByDescendingAsyncWit var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -2976,7 +2976,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3005,7 +3005,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3034,7 +3034,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByAsyncWithCanc var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3063,7 +3063,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3092,7 +3092,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescendingAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3121,7 +3121,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsync_ThenByDescendingAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3150,7 +3150,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3179,7 +3179,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3208,7 +3208,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3237,7 +3237,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3266,7 +3266,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3295,7 +3295,7 @@ public async Task OrderBy_OrderByAsync_ThenByDescendingAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3324,7 +3324,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3353,7 +3353,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3382,7 +3382,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByAsyncWithCan var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3411,7 +3411,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3440,7 +3440,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescendingAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3469,7 +3469,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenBy_ThenByDescendingAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3498,7 +3498,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3527,7 +3527,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3556,7 +3556,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByAsyncWi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3585,7 +3585,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescend var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3614,7 +3614,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescend var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3643,7 +3643,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsync_ThenByDescend var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3672,7 +3672,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3701,7 +3701,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3730,7 +3730,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3759,7 +3759,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3788,7 +3788,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3817,7 +3817,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByAsyncWithCancellati var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3846,7 +3846,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3875,7 +3875,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3904,7 +3904,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3933,7 +3933,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3962,7 +3962,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -3991,7 +3991,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescending_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4020,7 +4020,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4049,7 +4049,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4078,7 +4078,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4107,7 +4107,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4136,7 +4136,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4165,7 +4165,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4194,7 +4194,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4223,7 +4223,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4252,7 +4252,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4281,7 +4281,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4310,7 +4310,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4339,7 +4339,7 @@ public async Task OrderBy_OrderByAsyncWithCancellation_ThenByDescendingAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderBy((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderBy(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4397,7 +4397,7 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4426,7 +4426,7 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByAsyncWithCancellation() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4484,7 +4484,7 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4513,7 +4513,7 @@ public async Task OrderBy_OrderByDescending_ThenBy_ThenByDescendingAsyncWithCanc var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4542,7 +4542,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4571,7 +4571,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4600,7 +4600,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByAsyncWithCancellat var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4629,7 +4629,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4658,7 +4658,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4687,7 +4687,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsync_ThenByDescendingAsyncWit var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4716,7 +4716,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4745,7 +4745,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4774,7 +4774,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4803,7 +4803,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4832,7 +4832,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4861,7 +4861,7 @@ public async Task OrderBy_OrderByDescending_ThenByAsyncWithCancellation_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4919,7 +4919,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -4948,7 +4948,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByAsyncWithCanc var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5006,7 +5006,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescendingAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5035,7 +5035,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescending_ThenByDescendingAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5064,7 +5064,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5093,7 +5093,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5122,7 +5122,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByAsyncWit var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5151,7 +5151,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5180,7 +5180,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5209,7 +5209,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsync_ThenByDescendi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5238,7 +5238,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5267,7 +5267,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5296,7 +5296,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5325,7 +5325,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5354,7 +5354,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5383,7 +5383,7 @@ public async Task OrderBy_OrderByDescending_ThenByDescendingAsyncWithCancellatio var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => x % 2).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5412,7 +5412,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5441,7 +5441,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5470,7 +5470,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByAsyncWithCancellat var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5499,7 +5499,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5528,7 +5528,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescendingAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5557,7 +5557,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenBy_ThenByDescendingAsyncWit var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5586,7 +5586,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5615,7 +5615,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5644,7 +5644,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByAsyncWithCanc var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5673,7 +5673,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescending() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5702,7 +5702,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescendingAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5731,7 +5731,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsync_ThenByDescendingAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5760,7 +5760,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5789,7 +5789,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5818,7 +5818,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5847,7 +5847,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5876,7 +5876,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5905,7 +5905,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByAsyncWithCancellation_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5934,7 +5934,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5963,7 +5963,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByAsync() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -5992,7 +5992,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByAsyncWit var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6021,7 +6021,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6050,7 +6050,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6079,7 +6079,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescending_ThenByDescendi var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6108,7 +6108,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6137,7 +6137,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6166,7 +6166,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByAsy var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6195,7 +6195,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDes var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6224,7 +6224,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDes var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6253,7 +6253,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsync_ThenByDes var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6282,7 +6282,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6311,7 +6311,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6340,7 +6340,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6369,7 +6369,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6398,7 +6398,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6427,7 +6427,7 @@ public async Task OrderBy_OrderByDescendingAsync_ThenByDescendingAsyncWithCancel var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending(x => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwait(x => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6456,7 +6456,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenBy() var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6485,7 +6485,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6514,7 +6514,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByAs var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6543,7 +6543,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6572,7 +6572,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6601,7 +6601,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenBy_ThenByDe var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenBy(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6630,7 +6630,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6659,7 +6659,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6688,7 +6688,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6717,7 +6717,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6746,7 +6746,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6775,7 +6775,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsync_The var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6804,7 +6804,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6833,7 +6833,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6862,7 +6862,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6891,7 +6891,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6920,7 +6920,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6949,7 +6949,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByAsyncWith var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenBy((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenBy(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -6978,7 +6978,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7007,7 +7007,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7036,7 +7036,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7065,7 +7065,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7094,7 +7094,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7123,7 +7123,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => x % 3).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7152,7 +7152,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7181,7 +7181,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7210,7 +7210,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7239,7 +7239,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7268,7 +7268,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7297,7 +7297,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending(x => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwait(x => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7326,7 +7326,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenBy(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7355,7 +7355,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7384,7 +7384,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenBy((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenBy(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7413,7 +7413,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => x % 4); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7442,7 +7442,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending(x => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwait(x => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); @@ -7471,7 +7471,7 @@ public async Task OrderBy_OrderByDescendingAsyncWithCancellation_ThenByDescendin var rand = new Random(42); var xs = Enumerable.Range(0, 100).Select(x => rand.Next(0, 100)).ToArray().Select(x => x); - var asyncRes = xs.ToAsyncEnumerable().OrderByDescending((x, ct) => new ValueTask(x % 2)).ThenByDescending((x, ct) => new ValueTask(x % 3)).ThenByDescending((x, ct) => new ValueTask(x % 4)); + var asyncRes = xs.ToAsyncEnumerable().OrderByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 2)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 3)).ThenByDescendingAwaitWithCancellation((x, ct) => new ValueTask(x % 4)); var syncRes = xs.OrderByDescending(x => x % 2).ThenByDescending(x => x % 3).ThenByDescending(x => x % 4); await AssertSorted(asyncRes, syncRes); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt index ec37fc84eb..189fee594a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.Generated.tt @@ -15,6 +15,16 @@ Func getAsyncMethod = (then, desc, async var arg = async ? (cancel ? "(x, ct) => " : "x => ") + "new ValueTask(" + body + ")" : "x => " + body; + if (async) + { + mtd += "Await"; + + if (cancel) + { + mtd += "WithCancellation"; + } + } + return "." + mtd + "(" + arg + ")"; }; diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs index f84f63edd2..80ee6b3147 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OrderBy.cs @@ -19,13 +19,13 @@ public void OrderBy_Null() Assert.Throws(() => AsyncEnumerable.OrderBy(Return42, default(Func))); Assert.Throws(() => AsyncEnumerable.OrderBy(default, x => x, Comparer.Default)); - Assert.Throws(() => AsyncEnumerable.OrderBy(Return42, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.OrderBy(Return42, default, Comparer.Default)); Assert.Throws(() => AsyncEnumerable.OrderByDescending(default, x => x)); Assert.Throws(() => AsyncEnumerable.OrderByDescending(Return42, default(Func))); Assert.Throws(() => AsyncEnumerable.OrderByDescending(default, x => x, Comparer.Default)); - Assert.Throws(() => AsyncEnumerable.OrderByDescending(Return42, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.OrderByDescending(Return42, default, Comparer.Default)); var xs = Return42.OrderBy(x => x); @@ -33,13 +33,13 @@ public void OrderBy_Null() Assert.Throws(() => AsyncEnumerable.ThenBy(xs, default(Func))); Assert.Throws(() => AsyncEnumerable.ThenBy(default, x => x, Comparer.Default)); - Assert.Throws(() => AsyncEnumerable.ThenBy(xs, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.ThenBy(xs, default, Comparer.Default)); Assert.Throws(() => AsyncEnumerable.ThenByDescending(default, x => x)); Assert.Throws(() => AsyncEnumerable.ThenByDescending(xs, default(Func))); Assert.Throws(() => AsyncEnumerable.ThenByDescending(default, x => x, Comparer.Default)); - Assert.Throws(() => AsyncEnumerable.ThenByDescending(xs, default(Func), Comparer.Default)); + Assert.Throws(() => AsyncEnumerable.ThenByDescending(xs, default, Comparer.Default)); } [Fact] diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs index ec6ecf89bb..146ef04604 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Select.cs @@ -188,7 +188,7 @@ public async Task Select_Sync_SelectSelect_IList() } [Fact] - public async Task Select_Sync_SelectSelect_AsyncIterator() + public async Task Select_Sync_SelectSelectAwaitIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x)); @@ -282,19 +282,19 @@ public async Task Select_Sync_IList_ToArray() } [Fact] - public void Select_Async_Null() + public void SelectAwait_Null() { - Assert.Throws(() => AsyncEnumerable.Select(default, x => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.Select(default, (int x, int i) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.Select(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.Select(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SelectAwait(default, x => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.SelectAwait(default, (int x, int i) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.SelectAwait(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SelectAwait(Return42, default(Func>))); } [Fact] - public async Task Select_Async_Simple() + public async Task SelectAwait_Simple() { var xs = ToAsyncEnumerable(new[] { 0, 1, 2 }); - var ys = xs.Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(x => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -304,10 +304,10 @@ public async Task Select_Async_Simple() } [Fact] - public async Task Select_Async_Simple_IList() + public async Task SelectAwait_Simple_IList() { var xs = ToAsyncEnumerableIList(new[] { 0, 1, 2 }); - var ys = xs.Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(x => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -317,10 +317,10 @@ public async Task Select_Async_Simple_IList() } [Fact] - public async Task Select_Async_Simple_AsyncIterator() + public async Task SelectAwait_Simple_AsyncIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(x => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -330,10 +330,10 @@ public async Task Select_Async_Simple_AsyncIterator() } [Fact] - public async Task Select_Async_Indexed() + public async Task SelectAwait_Indexed() { var xs = ToAsyncEnumerable(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwait((x, i) => new ValueTask((char)('a' + i))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -343,10 +343,10 @@ public async Task Select_Async_Indexed() } [Fact] - public async Task Select_Async_Indexed_IList() + public async Task SelectAwait_Indexed_IList() { var xs = ToAsyncEnumerableIList(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwait((x, i) => new ValueTask((char)('a' + i))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -356,10 +356,10 @@ public async Task Select_Async_Indexed_IList() } [Fact] - public async Task Select_Async_Indexed_AsyncIterator() + public async Task SelectAwait_Indexed_AsyncIterator() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwait((x, i) => new ValueTask((char)('a' + i))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -369,70 +369,70 @@ public async Task Select_Async_Indexed_AsyncIterator() } [Fact] - public async Task Select_Async_Throws_Selector() + public async Task SelectAwait_Throws_Selector() { var xs = ToAsyncEnumerable(new[] { 0, 1, 2 }); - var ys = xs.Select(x => new ValueTask(1 / x)); + var ys = xs.SelectAwait(x => new ValueTask(1 / x)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Throws_Selector_IList() + public async Task SelectAwait_Throws_Selector_IList() { var xs = ToAsyncEnumerableIList(new[] { 0, 1, 2 }); - var ys = xs.Select(x => new ValueTask(1 / x)); + var ys = xs.SelectAwait(x => new ValueTask(1 / x)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Throws_Selector_AsyncIterator() + public async Task SelectAwait_Throws_Selector_AsyncIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(x => new ValueTask(1 / x)); + var ys = xs.SelectAwait(x => new ValueTask(1 / x)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Indexed_Throws_Selector() + public async Task SelectAwait_Indexed_Throws_Selector() { var xs = ToAsyncEnumerable(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i) => new ValueTask(1 / i)); + var ys = xs.SelectAwait((x, i) => new ValueTask(1 / i)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Indexed_Throws_Selector_IList() + public async Task SelectAwait_Indexed_Throws_Selector_IList() { var xs = ToAsyncEnumerableIList(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i) => new ValueTask(1 / i)); + var ys = xs.SelectAwait((x, i) => new ValueTask(1 / i)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Indexed_Throws_Selector_AsyncIterator() + public async Task SelectAwait_Indexed_Throws_Selector_AsyncIterator() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i) => new ValueTask(1 / i)); + var ys = xs.SelectAwait((x, i) => new ValueTask(1 / i)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_SelectSelect() + public async Task SelectAwait_SelectSelect() { var xs = ToAsyncEnumerable(new[] { 0, 1, 2 }); - var ys = xs.Select(i => new ValueTask(i + 3)).Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(i => new ValueTask(i + 3)).SelectAwait(x => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'd'); @@ -442,10 +442,10 @@ public async Task Select_Async_SelectSelect() } [Fact] - public async Task Select_Async_SelectSelect_IList() + public async Task SelectAwait_SelectSelect_IList() { var xs = ToAsyncEnumerableIList(new[] { 0, 1, 2 }); - var ys = xs.Select(i => new ValueTask(i + 3)).Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(i => new ValueTask(i + 3)).SelectAwait(x => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'd'); @@ -455,10 +455,10 @@ public async Task Select_Async_SelectSelect_IList() } [Fact] - public async Task Select_Async_SelectSelect_AsyncIterator() + public async Task SelectAwait_SelectSelectAwaitIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(i => new ValueTask(i + 3)).Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(i => new ValueTask(i + 3)).SelectAwait(x => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'd'); @@ -468,104 +468,102 @@ public async Task Select_Async_SelectSelect_AsyncIterator() } [Fact] - public async Task Select_Async_SequenceIdentity() + public async Task SelectAwait_SequenceIdentity() { var xs = ToAsyncEnumerable(new[] { 1, 2, 3 }); - var ys = xs.Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(x => new ValueTask((char)('a' + x))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_SequenceIdentity_IList() + public async Task SelectAwait_SequenceIdentity_IList() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3 }); - var ys = xs.Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(x => new ValueTask((char)('a' + x))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_SequenceIdentity_AsyncIterator() + public async Task SelectAwait_SequenceIdentity_AsyncIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select(x => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwait(x => new ValueTask((char)('a' + x))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Indexed_SequenceIdentity() + public async Task SelectAwait_Indexed_SequenceIdentity() { var xs = ToAsyncEnumerable(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwait((x, i) => new ValueTask((char)('a' + i))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Indexed_SequenceIdentity_IList() + public async Task SelectAwait_Indexed_SequenceIdentity_IList() { var xs = ToAsyncEnumerableIList(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwait((x, i) => new ValueTask((char)('a' + i))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Indexed_SequenceIdentity_AsyncIterator() + public async Task SelectAwait_Indexed_SequenceIdentity_AsyncIterator() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwait((x, i) => new ValueTask((char)('a' + i))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_IList_Count() + public async Task SelectAwait_IList_Count() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3, 4, 5 }); - var ys = xs.Select(x => new ValueTask(x * 2)); + var ys = xs.SelectAwait(x => new ValueTask(x * 2)); Assert.Equal(5, await ys.CountAsync()); } [Fact] - public async Task Select_Async_IList_ToList() + public async Task SelectAwait_IList_ToList() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3, 4, 5 }); - var ys = xs.Select(x => new ValueTask(x * 2)); + var ys = xs.SelectAwait(x => new ValueTask(x * 2)); Assert.Equal(new[] { 2, 4, 6, 8, 10 }, await ys.ToListAsync()); } [Fact] - public async Task Select_Async_IList_ToArray() + public async Task SelectAwait_IList_ToArray() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3, 4, 5 }); - var ys = xs.Select(x => new ValueTask(x * 2)); + var ys = xs.SelectAwait(x => new ValueTask(x * 2)); Assert.Equal(new[] { 2, 4, 6, 8, 10 }, await ys.ToArrayAsync()); } #if !NO_DEEP_CANCELLATION - // REVIEW: These overloads are problematic for type inference. E.g. xs.Select((x, ct) => ...) is ambiguous. - [Fact] - public void Select_Async_Cancel_Null() + public void SelectAwaitWithCancellation_Null() { - Assert.Throws(() => AsyncEnumerable.Select(default, (int x, CancellationToken ct) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.Select(default, (int x, int i, CancellationToken ct) => new ValueTask(x))); - Assert.Throws(() => AsyncEnumerable.Select(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.Select(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SelectAwaitWithCancellation(default, (int x, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.SelectAwaitWithCancellation(default, (int x, int i, CancellationToken ct) => new ValueTask(x))); + Assert.Throws(() => AsyncEnumerable.SelectAwaitWithCancellation(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SelectAwaitWithCancellation(Return42, default(Func>))); } [Fact] - public async Task Select_Async_Cancel_Simple() + public async Task SelectAwaitWithCancellation_Simple() { var xs = ToAsyncEnumerable(new[] { 0, 1, 2 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -575,10 +573,10 @@ public async Task Select_Async_Cancel_Simple() } [Fact] - public async Task Select_Async_Cancel_Simple_IList() + public async Task SelectAwaitWithCancellation_Simple_IList() { var xs = ToAsyncEnumerableIList(new[] { 0, 1, 2 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -588,10 +586,10 @@ public async Task Select_Async_Cancel_Simple_IList() } [Fact] - public async Task Select_Async_Cancel_Simple_Async_CancelIterator() + public async Task SelectAwaitWithCancellation_Simple_Async_CancelIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -601,10 +599,10 @@ public async Task Select_Async_Cancel_Simple_Async_CancelIterator() } [Fact] - public async Task Select_Async_Cancel_Indexed() + public async Task SelectAwaitWithCancellation_Indexed() { var xs = ToAsyncEnumerable(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i, ct) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask((char)('a' + i))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -614,10 +612,10 @@ public async Task Select_Async_Cancel_Indexed() } [Fact] - public async Task Select_Async_Cancel_Indexed_IList() + public async Task SelectAwaitWithCancellation_Indexed_IList() { var xs = ToAsyncEnumerableIList(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i, ct) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask((char)('a' + i))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -627,10 +625,10 @@ public async Task Select_Async_Cancel_Indexed_IList() } [Fact] - public async Task Select_Async_Cancel_Indexed_Async_CancelIterator() + public async Task SelectAwaitWithCancellation_Indexed_Async_CancelIterator() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i, ct) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask((char)('a' + i))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'a'); @@ -640,70 +638,70 @@ public async Task Select_Async_Cancel_Indexed_Async_CancelIterator() } [Fact] - public async Task Select_Async_Cancel_Throws_Selector() + public async Task SelectAwaitWithCancellation_Throws_Selector() { var xs = ToAsyncEnumerable(new[] { 0, 1, 2 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask(1 / x)); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(1 / x)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Cancel_Throws_Selector_IList() + public async Task SelectAwaitWithCancellation_Throws_Selector_IList() { var xs = ToAsyncEnumerableIList(new[] { 0, 1, 2 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask(1 / x)); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(1 / x)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Cancel_Throws_Selector_Async_CancelIterator() + public async Task SelectAwaitWithCancellation_Throws_Selector_Async_CancelIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask(1 / x)); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(1 / x)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Cancel_Indexed_Throws_Selector() + public async Task SelectAwaitWithCancellation_Indexed_Throws_Selector() { var xs = ToAsyncEnumerable(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i, ct) => new ValueTask(1 / i)); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask(1 / i)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Cancel_Indexed_Throws_Selector_IList() + public async Task SelectAwaitWithCancellation_Indexed_Throws_Selector_IList() { var xs = ToAsyncEnumerableIList(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i, ct) => new ValueTask(1 / i)); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask(1 / i)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Cancel_Indexed_Throws_Selector_Async_CancelIterator() + public async Task SelectAwaitWithCancellation_Indexed_Throws_Selector_Async_CancelIterator() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i, ct) => new ValueTask(1 / i)); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask(1 / i)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync().AsTask()); } [Fact] - public async Task Select_Async_Cancel_SelectSelect() + public async Task SelectAwaitWithCancellation_SelectSelect() { var xs = ToAsyncEnumerable(new[] { 0, 1, 2 }); - var ys = xs.Select((int i, CancellationToken ct) => new ValueTask(i + 3)).Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int i, CancellationToken ct) => new ValueTask(i + 3)).SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'd'); @@ -713,10 +711,10 @@ public async Task Select_Async_Cancel_SelectSelect() } [Fact] - public async Task Select_Async_Cancel_SelectSelect_IList() + public async Task SelectAwaitWithCancellation_SelectSelect_IList() { var xs = ToAsyncEnumerableIList(new[] { 0, 1, 2 }); - var ys = xs.Select((int i, CancellationToken ct) => new ValueTask(i + 3)).Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int i, CancellationToken ct) => new ValueTask(i + 3)).SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'd'); @@ -726,10 +724,10 @@ public async Task Select_Async_Cancel_SelectSelect_IList() } [Fact] - public async Task Select_Async_Cancel_SelectSelect_Async_CancelIterator() + public async Task SelectAwaitWithCancellation_SelectSelectAwait_CancelIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select((int i, CancellationToken ct) => new ValueTask(i + 3)).Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int i, CancellationToken ct) => new ValueTask(i + 3)).SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 'd'); @@ -739,82 +737,82 @@ public async Task Select_Async_Cancel_SelectSelect_Async_CancelIterator() } [Fact] - public async Task Select_Async_Cancel_SequenceIdentity() + public async Task SelectAwaitWithCancellation_SequenceIdentity() { var xs = ToAsyncEnumerable(new[] { 1, 2, 3 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Cancel_SequenceIdentity_IList() + public async Task SelectAwaitWithCancellation_SequenceIdentity_IList() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Cancel_SequenceIdentity_Async_CancelIterator() + public async Task SelectAwaitWithCancellation_SequenceIdentity_Async_CancelIterator() { var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable(); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask((char)('a' + x))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Cancel_Indexed_SequenceIdentity() + public async Task SelectAwaitWithCancellation_Indexed_SequenceIdentity() { var xs = ToAsyncEnumerable(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i, ct) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask((char)('a' + i))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Cancel_Indexed_SequenceIdentity_IList() + public async Task SelectAwaitWithCancellation_Indexed_SequenceIdentity_IList() { var xs = ToAsyncEnumerableIList(new[] { 8, 5, 7 }); - var ys = xs.Select((x, i, ct) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask((char)('a' + i))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Cancel_Indexed_SequenceIdentity_Async_CancelIterator() + public async Task SelectAwaitWithCancellation_Indexed_SequenceIdentity_Async_CancelIterator() { var xs = new[] { 8, 5, 7 }.ToAsyncEnumerable(); - var ys = xs.Select((x, i, ct) => new ValueTask((char)('a' + i))); + var ys = xs.SelectAwaitWithCancellation((x, i, ct) => new ValueTask((char)('a' + i))); await SequenceIdentity(ys); } [Fact] - public async Task Select_Async_Cancel_IList_Count() + public async Task SelectAwaitWithCancellation_IList_Count() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3, 4, 5 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask(x * 2)); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x * 2)); Assert.Equal(5, await ys.CountAsync()); } [Fact] - public async Task Select_Async_Cancel_IList_ToList() + public async Task SelectAwaitWithCancellation_IList_ToList() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3, 4, 5 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask(x * 2)); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x * 2)); Assert.Equal(new[] { 2, 4, 6, 8, 10 }, await ys.ToListAsync()); } [Fact] - public async Task Select_Async_Cancel_IList_ToArray() + public async Task SelectAwaitWithCancellation_IList_ToArray() { var xs = ToAsyncEnumerableIList(new[] { 1, 2, 3, 4, 5 }); - var ys = xs.Select((int x, CancellationToken ct) => new ValueTask(x * 2)); + var ys = xs.SelectAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x * 2)); Assert.Equal(new[] { 2, 4, 6, 8, 10 }, await ys.ToArrayAsync()); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs index 8a4db6a857..b23398541a 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Single.cs @@ -76,7 +76,7 @@ public async Task SingleAsync_Predicate_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] @@ -123,106 +123,106 @@ public async Task SingleAsync_Predicate_Throw_MoreThanOne() } [Fact] - public async Task SingleAsync_AsyncPredicate_Null() + public async Task SingleAwaitAsync_Predicate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAwaitAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task SingleAsync_AsyncPredicate_Empty() + public async Task SingleAwaitAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().SingleAsync(x => new ValueTask(true)); + var res = AsyncEnumerable.Empty().SingleAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task SingleAsync_AsyncPredicate_NoMatch() + public async Task SingleAwaitAsync_Predicate_NoMatch() { - var res = Return42.SingleAsync(x => new ValueTask(x % 2 != 0)); + var res = Return42.SingleAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task SingleAsync_AsyncPredicate_Simple() + public async Task SingleAwaitAsync_Predicate_Simple() { - var res = Return42.SingleAsync(x => new ValueTask(x % 2 == 0)); + var res = Return42.SingleAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task SingleAsync_AsyncPredicate_Throws() + public async Task SingleAwaitAsync_Predicate_Throws() { var ex = new Exception("Bang!"); - var res = Throw(ex).SingleAsync(x => new ValueTask(true)); + var res = Throw(ex).SingleAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task SingleAsync_AsyncPredicate_OneMatch() + public async Task SingleAwaitAsync_Predicate_OneMatch() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task SingleAsync_AsyncPredicate_Throw_MoreThanOne() + public async Task SingleAwaitAsync_Predicate_Throw_MoreThanOne() { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().SingleAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().SingleAwaitAsync(x => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task SingleAsync_AsyncPredicate_Cancel_Null() + public async Task SingleAwaitWithCancellationAsync_Predicate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task SingleAsync_AsyncPredicate_Cancel_Empty() + public async Task SingleAwaitWithCancellationAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().SingleAsync((x, ct) => new ValueTask(true)); + var res = AsyncEnumerable.Empty().SingleAwaitWithCancellationAsync((x, ct) => new ValueTask(true)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task SingleAsync_AsyncPredicate_Cancel_NoMatch() + public async Task SingleAwaitWithCancellationAsync_Predicate_NoMatch() { - var res = Return42.SingleAsync((x, ct) => new ValueTask(x % 2 != 0)); + var res = Return42.SingleAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task SingleAsync_AsyncPredicate_Cancel_Simple() + public async Task SingleAwaitWithCancellationAsync_Predicate_Simple() { - var res = Return42.SingleAsync((x, ct) => new ValueTask(x % 2 == 0)); + var res = Return42.SingleAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task SingleAsync_AsyncPredicate_Cancel_Throws() + public async Task SingleAwaitWithCancellationAsync_Predicate_Throws() { var ex = new Exception("Bang!"); - var res = Throw(ex).SingleAsync((x, ct) => new ValueTask(true)); + var res = Throw(ex).SingleAwaitWithCancellationAsync((x, ct) => new ValueTask(true)); await AssertThrowsAsync(res, ex); } [Fact] - public async Task SingleAsync_AsyncPredicate_Cancel_OneMatch() + public async Task SingleAwaitWithCancellationAsync_Predicate_OneMatch() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleAsync((x, ct) => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task SingleAsync_AsyncPredicate_Cancel_Throw_MoreThanOne() + public async Task SingleAwaitWithCancellationAsync_Predicate_Throw_MoreThanOne() { - var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().SingleAsync((x, ct) => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 23, 45, 90 }.ToAsyncEnumerable().SingleAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0)); await AssertThrowsAsync(res.AsTask()); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs index 1e88d185bc..06f2e48ac7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SingleOrDefault.cs @@ -76,7 +76,7 @@ public async Task SingleOrDefaultAsync_Predicate_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] @@ -130,120 +130,120 @@ public async Task SingleOrDefaultAsync_Predicate_Throws_Source() } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Null() + public async Task SingleOrDefaultAwaitAsync_Predicate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAwaitAsync(Return42, default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAwaitAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Empty() + public async Task SingleOrDefaultAwaitAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().SingleOrDefaultAsync(x => new ValueTask(true)); + var res = AsyncEnumerable.Empty().SingleOrDefaultAwaitAsync(x => new ValueTask(true)); Assert.Equal(0, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_NoMatch_Single() + public async Task SingleOrDefaultAwaitAsync_Predicate_NoMatch_Single() { - var res = Return42.SingleOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = Return42.SingleOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_OneMatch_Single() + public async Task SingleOrDefaultAwaitAsync_Predicate_OneMatch_Single() { - var res = Return42.SingleOrDefaultAsync(x => new ValueTask(x % 2 == 0)); + var res = Return42.SingleOrDefaultAwaitAsync(x => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_OneMatch_Many() + public async Task SingleOrDefaultAwaitAsync_Predicate_OneMatch_Many() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(x => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAwaitAsync(x => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_NoMatch_Many() + public async Task SingleOrDefaultAwaitAsync_Predicate_NoMatch_Many() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(x => new ValueTask(x < 10)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAwaitAsync(x => new ValueTask(x < 10)); Assert.Equal(0, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_MoreThanOne() + public async Task SingleOrDefaultAwaitAsync_Predicate_MoreThanOne() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync(x => new ValueTask(true)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Throws_Source() + public async Task SingleOrDefaultAwaitAsync_Predicate_Throws_Source() { var ex = new Exception("Bang!"); - var res = Throw(ex).SingleOrDefaultAsync(x => new ValueTask(true)); + var res = Throw(ex).SingleOrDefaultAwaitAsync(x => new ValueTask(true)); await AssertThrowsAsync(res, ex); } #if !NO_DEEP_CANCELLATION [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_Null() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_Null() { - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAsync(Return42, default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SingleOrDefaultAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_Empty() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_Empty() { - var res = AsyncEnumerable.Empty().SingleOrDefaultAsync((x, ct) => new ValueTask(true)); + var res = AsyncEnumerable.Empty().SingleOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(true)); Assert.Equal(0, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_NoMatch_Single() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_NoMatch_Single() { - var res = Return42.SingleOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0)); + var res = Return42.SingleOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0)); Assert.Equal(0, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_OneMatch_Single() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_OneMatch_Single() { - var res = Return42.SingleOrDefaultAsync((x, ct) => new ValueTask(x % 2 == 0)); + var res = Return42.SingleOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 == 0)); Assert.Equal(42, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_OneMatch_Many() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_OneMatch_Many() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync((x, ct) => new ValueTask(x % 2 != 0)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x % 2 != 0)); Assert.Equal(45, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_NoMatch_Many() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_NoMatch_Many() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync((x, ct) => new ValueTask(x < 10)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(x < 10)); Assert.Equal(0, await res); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_MoreThanOne() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_MoreThanOne() { - var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAsync((x, ct) => new ValueTask(true)); + var res = new[] { 42, 45, 90 }.ToAsyncEnumerable().SingleOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(true)); await AssertThrowsAsync(res.AsTask()); } [Fact] - public async Task SingleOrDefaultAsync_AsyncPredicate_Cancel_Throws_Source() + public async Task SingleOrDefaultAwaitWithCancellationAsync_Predicate_Throws_Source() { var ex = new Exception("Bang!"); - var res = Throw(ex).SingleOrDefaultAsync((x, ct) => new ValueTask(true)); + var res = Throw(ex).SingleOrDefaultAwaitWithCancellationAsync((x, ct) => new ValueTask(true)); await AssertThrowsAsync(res, ex); } #endif diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs index a7434a9c0c..cb6118a2d5 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipWhile.cs @@ -13,7 +13,7 @@ namespace Tests public class SkipWhile : AsyncEnumerableTests { [Fact] - public void SkipWhile_Sync_Null() + public void SkipWhile_Null() { Assert.Throws(() => AsyncEnumerable.SkipWhile(default, x => true)); Assert.Throws(() => AsyncEnumerable.SkipWhile(default, (x, i) => true)); @@ -22,7 +22,7 @@ public void SkipWhile_Sync_Null() } [Fact] - public async Task SkipWhile_Sync_Simple1() + public async Task SkipWhile_Simple1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => x < 3); @@ -34,7 +34,7 @@ public async Task SkipWhile_Sync_Simple1() } [Fact] - public async Task SkipWhile_Sync_Simple2() + public async Task SkipWhile_Simple2() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => x < 3); @@ -49,7 +49,7 @@ public async Task SkipWhile_Sync_Simple2() } [Fact] - public async Task SkipWhile_Sync_False() + public async Task SkipWhile_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => false); @@ -63,7 +63,7 @@ public async Task SkipWhile_Sync_False() } [Fact] - public async Task SkipWhile_Sync_True() + public async Task SkipWhile_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => true); @@ -73,7 +73,7 @@ public async Task SkipWhile_Sync_True() } [Fact] - public async Task SkipWhile_Sync_Throws_Predicate() + public async Task SkipWhile_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -84,7 +84,7 @@ public async Task SkipWhile_Sync_Throws_Predicate() } [Fact] - public async Task SkipWhile_Sync_Indexed() + public async Task SkipWhile_Indexed() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => i < 2); @@ -96,7 +96,7 @@ public async Task SkipWhile_Sync_Indexed() } [Fact] - public async Task SkipWhile_Sync_Indexed_False() + public async Task SkipWhile_Indexed_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => false); @@ -110,7 +110,7 @@ public async Task SkipWhile_Sync_Indexed_False() } [Fact] - public async Task SkipWhile_Sync_Indexed_True() + public async Task SkipWhile_Indexed_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => true); @@ -120,7 +120,7 @@ public async Task SkipWhile_Sync_Indexed_True() } [Fact] - public async Task SkipWhile_Sync_Indexed_Throws_Predicate() + public async Task SkipWhile_Indexed_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -131,7 +131,7 @@ public async Task SkipWhile_Sync_Indexed_Throws_Predicate() } [Fact] - public async Task SkipWhile_Sync_SequenceIdentity() + public async Task SkipWhile_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile(x => x < 3); @@ -140,7 +140,7 @@ public async Task SkipWhile_Sync_SequenceIdentity() } [Fact] - public async Task SkipWhile_Sync_Indexed_SequenceIdentity() + public async Task SkipWhile_Indexed_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.SkipWhile((x, i) => false); @@ -149,19 +149,19 @@ public async Task SkipWhile_Sync_Indexed_SequenceIdentity() } [Fact] - public void SkipWhile_Async_Null() + public void SkipWhileAwait_Null() { - Assert.Throws(() => AsyncEnumerable.SkipWhile(default, x => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.SkipWhile(default, (int x, int i) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.SkipWhile(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.SkipWhile(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwait(default, x => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwait(default, (int x, int i) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwait(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwait(Return42, default(Func>))); } [Fact] - public async Task SkipWhile_Async_Simple1() + public async Task SkipWhileAwait_Simple1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => new ValueTask(x < 3)); + var ys = xs.SkipWhileAwait(x => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 3); @@ -170,10 +170,10 @@ public async Task SkipWhile_Async_Simple1() } [Fact] - public async Task SkipWhile_Async_Simple2() + public async Task SkipWhileAwait_Simple2() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => new ValueTask(x < 3)); + var ys = xs.SkipWhileAwait(x => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 3); @@ -185,10 +185,10 @@ public async Task SkipWhile_Async_Simple2() } [Fact] - public async Task SkipWhile_Async_False() + public async Task SkipWhileAwait_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => new ValueTask(false)); + var ys = xs.SkipWhileAwait(x => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -199,31 +199,31 @@ public async Task SkipWhile_Async_False() } [Fact] - public async Task SkipWhile_Async_True() + public async Task SkipWhileAwait_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => new ValueTask(true)); + var ys = xs.SkipWhileAwait(x => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task SkipWhile_Async_Throws_Predicate() + public async Task SkipWhileAwait_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(new Func>(x => { throw ex; })); + var ys = xs.SkipWhileAwait(new Func>(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task SkipWhile_Async_Indexed() + public async Task SkipWhileAwait_Indexed() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i) => new ValueTask(i < 2)); + var ys = xs.SkipWhileAwait((x, i) => new ValueTask(i < 2)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 3); @@ -232,10 +232,10 @@ public async Task SkipWhile_Async_Indexed() } [Fact] - public async Task SkipWhile_Async_Indexed_False() + public async Task SkipWhileAwait_Indexed_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, int i) => new ValueTask(false)); + var ys = xs.SkipWhileAwait((int x, int i) => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -246,40 +246,40 @@ public async Task SkipWhile_Async_Indexed_False() } [Fact] - public async Task SkipWhile_Async_Indexed_True() + public async Task SkipWhileAwait_Indexed_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, int i) => new ValueTask(true)); + var ys = xs.SkipWhileAwait((int x, int i) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task SkipWhile_Async_Indexed_Throws_Predicate() + public async Task SkipWhileAwait_Indexed_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(new Func>((x, i) => { throw ex; })); + var ys = xs.SkipWhileAwait(new Func>((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task SkipWhile_Async_SequenceIdentity() + public async Task SkipWhileAwait_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(x => new ValueTask(x < 3)); + var ys = xs.SkipWhileAwait(x => new ValueTask(x < 3)); await SequenceIdentity(ys); } [Fact] - public async Task SkipWhile_Async_Indexed_SequenceIdentity() + public async Task SkipWhileAwait_Indexed_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, int i) => new ValueTask(false)); + var ys = xs.SkipWhileAwait((int x, int i) => new ValueTask(false)); await SequenceIdentity(ys); } @@ -287,19 +287,19 @@ public async Task SkipWhile_Async_Indexed_SequenceIdentity() #if !NO_DEEP_CANCELLATION [Fact] - public void SkipWhile_Async_Cancel_Null() + public void SkipWhileAwaitWithCancellation_Null() { - Assert.Throws(() => AsyncEnumerable.SkipWhile(default, (int x, CancellationToken ct) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.SkipWhile(default, (x, i, ct) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.SkipWhile(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.SkipWhile(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwaitWithCancellation(default, (int x, CancellationToken ct) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwaitWithCancellation(default, (x, i, ct) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwaitWithCancellation(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.SkipWhileAwaitWithCancellation(Return42, default(Func>))); } [Fact] - public async Task SkipWhile_Async_Cancel_Simple1() + public async Task SkipWhileAwaitWithCancellation_Simple1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, CancellationToken ct) => new ValueTask(x < 3)); + var ys = xs.SkipWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 3); @@ -308,10 +308,10 @@ public async Task SkipWhile_Async_Cancel_Simple1() } [Fact] - public async Task SkipWhile_Async_Cancel_Simple2() + public async Task SkipWhileAwaitWithCancellation_Simple2() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, CancellationToken ct) => new ValueTask(x < 3)); + var ys = xs.SkipWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 3); @@ -323,10 +323,10 @@ public async Task SkipWhile_Async_Cancel_Simple2() } [Fact] - public async Task SkipWhile_Async_Cancel_False() + public async Task SkipWhileAwaitWithCancellation_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, CancellationToken ct) => new ValueTask(false)); + var ys = xs.SkipWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -337,31 +337,31 @@ public async Task SkipWhile_Async_Cancel_False() } [Fact] - public async Task SkipWhile_Async_Cancel_True() + public async Task SkipWhileAwaitWithCancellation_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, CancellationToken ct) => new ValueTask(true)); + var ys = xs.SkipWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task SkipWhile_Async_Cancel_Throws_Predicate() + public async Task SkipWhileAwaitWithCancellation_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(new Func>((x, ct) => { throw ex; })); + var ys = xs.SkipWhileAwaitWithCancellation(new Func>((x, ct) => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task SkipWhile_Async_Cancel_Indexed() + public async Task SkipWhileAwaitWithCancellation_Indexed() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i, ct) => new ValueTask(i < 2)); + var ys = xs.SkipWhileAwaitWithCancellation((x, i, ct) => new ValueTask(i < 2)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 3); @@ -370,10 +370,10 @@ public async Task SkipWhile_Async_Cancel_Indexed() } [Fact] - public async Task SkipWhile_Async_Cancel_Indexed_False() + public async Task SkipWhileAwaitWithCancellation_Indexed_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i, ct) => new ValueTask(false)); + var ys = xs.SkipWhileAwaitWithCancellation((x, i, ct) => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -384,40 +384,40 @@ public async Task SkipWhile_Async_Cancel_Indexed_False() } [Fact] - public async Task SkipWhile_Async_Cancel_Indexed_True() + public async Task SkipWhileAwaitWithCancellation_Indexed_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i, ct) => new ValueTask(true)); + var ys = xs.SkipWhileAwaitWithCancellation((x, i, ct) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task SkipWhile_Async_Cancel_Indexed_Throws_Predicate() + public async Task SkipWhileAwaitWithCancellation_Indexed_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile(new Func>((x, i, ct) => { throw ex; })); + var ys = xs.SkipWhileAwaitWithCancellation(new Func>((x, i, ct) => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task SkipWhile_Async_Cancel_SequenceIdentity() + public async Task SkipWhileAwaitWithCancellation_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((int x, CancellationToken ct) => new ValueTask(x < 3)); + var ys = xs.SkipWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x < 3)); await SequenceIdentity(ys); } [Fact] - public async Task SkipWhile_Async_Cancel_Indexed_SequenceIdentity() + public async Task SkipWhileAwaitWithCancellation_Indexed_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.SkipWhile((x, i, ct) => new ValueTask(false)); + var ys = xs.SkipWhileAwaitWithCancellation((x, i, ct) => new ValueTask(false)); await SequenceIdentity(ys); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs index c70cb0bb48..b495e0c0f9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Sum.cs @@ -79,7 +79,7 @@ public async Task Sum_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); @@ -92,76 +92,76 @@ public async Task Sum_Null() // Sum(IAE, Func>) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); // Sum(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #if !NO_DEEP_CANCELLATION // Sum(IAE, Func>, CT) - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.SumAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.SumAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); #endif } @@ -172,7 +172,7 @@ public async Task Sum1Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -182,7 +182,7 @@ public async Task Sum2Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -192,7 +192,7 @@ public async Task Sum3Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -202,7 +202,7 @@ public async Task Sum4Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -212,7 +212,7 @@ public async Task Sum5Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -222,7 +222,7 @@ public async Task Sum6Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -232,7 +232,7 @@ public async Task Sum7Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -242,7 +242,7 @@ public async Task Sum8Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -252,7 +252,7 @@ public async Task Sum9Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } [Fact] @@ -262,7 +262,7 @@ public async Task Sum10Async() var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Sum(), await ys.SumAsync()); Assert.Equal(xs.Sum(), await ys.SumAsync(x => x)); - Assert.Equal(xs.Sum(), await ys.SumAsync(x => new ValueTask(x))); + Assert.Equal(xs.Sum(), await ys.SumAwaitAsync(x => new ValueTask(x))); } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs index 57c397650f..d8ae67acd9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeWhile.cs @@ -13,7 +13,7 @@ namespace Tests public class TakeWhile : AsyncEnumerableTests { [Fact] - public void TakeWhile_Sync_Null() + public void TakeWhile_Null() { Assert.Throws(() => AsyncEnumerable.TakeWhile(default, x => true)); Assert.Throws(() => AsyncEnumerable.TakeWhile(default, (x, i) => true)); @@ -22,7 +22,7 @@ public void TakeWhile_Sync_Null() } [Fact] - public async Task TakeWhile_Sync_Simple1() + public async Task TakeWhile_Simple1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => x < 3); @@ -34,7 +34,7 @@ public async Task TakeWhile_Sync_Simple1() } [Fact] - public async Task TakeWhile_Sync_Simple2() + public async Task TakeWhile_Simple2() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => x < 3); @@ -46,7 +46,7 @@ public async Task TakeWhile_Sync_Simple2() } [Fact] - public async Task TakeWhile_Sync_False() + public async Task TakeWhile_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => false); @@ -56,7 +56,7 @@ public async Task TakeWhile_Sync_False() } [Fact] - public async Task TakeWhile_Sync_True() + public async Task TakeWhile_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => true); @@ -70,7 +70,7 @@ public async Task TakeWhile_Sync_True() } [Fact] - public async Task TakeWhile_Sync_Throws_Predicate() + public async Task TakeWhile_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -81,7 +81,7 @@ public async Task TakeWhile_Sync_Throws_Predicate() } [Fact] - public async Task TakeWhile_Sync_Indexed() + public async Task TakeWhile_Indexed() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => i < 2); @@ -93,7 +93,7 @@ public async Task TakeWhile_Sync_Indexed() } [Fact] - public async Task TakeWhile_Sync_Indexed_False() + public async Task TakeWhile_Indexed_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => false); @@ -103,7 +103,7 @@ public async Task TakeWhile_Sync_Indexed_False() } [Fact] - public async Task TakeWhile_Sync_Indexed_True() + public async Task TakeWhile_Indexed_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => true); @@ -117,7 +117,7 @@ public async Task TakeWhile_Sync_Indexed_True() } [Fact] - public async Task TakeWhile_Sync_Indexed_Throws_Predicate() + public async Task TakeWhile_Indexed_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -128,7 +128,7 @@ public async Task TakeWhile_Sync_Indexed_Throws_Predicate() } [Fact] - public async Task TakeWhile_Sync_SequenceIdentity() + public async Task TakeWhile_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile(x => x < 3); @@ -137,7 +137,7 @@ public async Task TakeWhile_Sync_SequenceIdentity() } [Fact] - public async Task TakeWhile_Sync_Indexed_SequenceIdentity() + public async Task TakeWhile_Indexed_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.TakeWhile((x, i) => i < 2); @@ -146,19 +146,19 @@ public async Task TakeWhile_Sync_Indexed_SequenceIdentity() } [Fact] - public void TakeWhile_Async_Null() + public void TakeWhileAwait_Null() { - Assert.Throws(() => AsyncEnumerable.TakeWhile(default, x => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.TakeWhile(default, (int x, int i) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.TakeWhile(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.TakeWhile(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwait(default, x => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwait(default, (int x, int i) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwait(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwait(Return42, default(Func>))); } [Fact] - public async Task TakeWhile_Async_Simple1() + public async Task TakeWhileAwait_Simple1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => new ValueTask(x < 3)); + var ys = xs.TakeWhileAwait(x => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -167,10 +167,10 @@ public async Task TakeWhile_Async_Simple1() } [Fact] - public async Task TakeWhile_Async_Simple2() + public async Task TakeWhileAwait_Simple2() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => new ValueTask(x < 3)); + var ys = xs.TakeWhileAwait(x => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -179,20 +179,20 @@ public async Task TakeWhile_Async_Simple2() } [Fact] - public async Task TakeWhile_Async_False() + public async Task TakeWhileAwait_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => new ValueTask(false)); + var ys = xs.TakeWhileAwait(x => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task TakeWhile_Async_True() + public async Task TakeWhileAwait_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => new ValueTask(true)); + var ys = xs.TakeWhileAwait(x => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -203,21 +203,21 @@ public async Task TakeWhile_Async_True() } [Fact] - public async Task TakeWhile_Async_Throws_Predicate() + public async Task TakeWhileAwait_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(new Func>(x => { throw ex; })); + var ys = xs.TakeWhileAwait(new Func>(x => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task TakeWhile_Async_Indexed() + public async Task TakeWhileAwait_Indexed() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i) => new ValueTask(i < 2)); + var ys = xs.TakeWhileAwait((x, i) => new ValueTask(i < 2)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -226,20 +226,20 @@ public async Task TakeWhile_Async_Indexed() } [Fact] - public async Task TakeWhile_Async_Indexed_False() + public async Task TakeWhileAwait_Indexed_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((int x, int i) => new ValueTask(false)); + var ys = xs.TakeWhileAwait((int x, int i) => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task TakeWhile_Async_Indexed_True() + public async Task TakeWhileAwait_Indexed_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((int x, int i) => new ValueTask(true)); + var ys = xs.TakeWhileAwait((int x, int i) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -250,30 +250,30 @@ public async Task TakeWhile_Async_Indexed_True() } [Fact] - public async Task TakeWhile_Async_Indexed_Throws_Predicate() + public async Task TakeWhileAwait_Indexed_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(new Func>((x, i) => { throw ex; })); + var ys = xs.TakeWhileAwait(new Func>((x, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task TakeWhile_Async_SequenceIdentity() + public async Task TakeWhileAwait_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(x => new ValueTask(x < 3)); + var ys = xs.TakeWhileAwait(x => new ValueTask(x < 3)); await SequenceIdentity(ys); } [Fact] - public async Task TakeWhile_Async_Indexed_SequenceIdentity() + public async Task TakeWhileAwait_Indexed_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i) => new ValueTask(i < 2)); + var ys = xs.TakeWhileAwait((x, i) => new ValueTask(i < 2)); await SequenceIdentity(ys); } @@ -281,19 +281,19 @@ public async Task TakeWhile_Async_Indexed_SequenceIdentity() #if !NO_DEEP_CANCELLATION [Fact] - public void TakeWhile_Async_Cancel_Null() + public void TakeWhileAwaitWithCancellation_Null() { - Assert.Throws(() => AsyncEnumerable.TakeWhile(default, (int x, CancellationToken ct) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.TakeWhile(default, (x, i, ct) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.TakeWhile(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.TakeWhile(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwaitWithCancellation(default, (int x, CancellationToken ct) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwaitWithCancellation(default, (x, i, ct) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwaitWithCancellation(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.TakeWhileAwaitWithCancellation(Return42, default(Func>))); } [Fact] - public async Task TakeWhile_Async_Cancel_Simple1() + public async Task TakeWhileAwaitWithCancellation_Simple1() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((int x, CancellationToken ct) => new ValueTask(x < 3)); + var ys = xs.TakeWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -302,10 +302,10 @@ public async Task TakeWhile_Async_Cancel_Simple1() } [Fact] - public async Task TakeWhile_Async_Cancel_Simple2() + public async Task TakeWhileAwaitWithCancellation_Simple2() { var xs = new[] { 1, 2, 3, 4, 3, 2, 1 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((int x, CancellationToken ct) => new ValueTask(x < 3)); + var ys = xs.TakeWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x < 3)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -314,20 +314,20 @@ public async Task TakeWhile_Async_Cancel_Simple2() } [Fact] - public async Task TakeWhile_Async_Cancel_False() + public async Task TakeWhileAwaitWithCancellation_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((int x, CancellationToken ct) => new ValueTask(false)); + var ys = xs.TakeWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task TakeWhile_Async_Cancel_True() + public async Task TakeWhileAwaitWithCancellation_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((int x, CancellationToken ct) => new ValueTask(true)); + var ys = xs.TakeWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -338,21 +338,21 @@ public async Task TakeWhile_Async_Cancel_True() } [Fact] - public async Task TakeWhile_Async_Cancel_Throws_Predicate() + public async Task TakeWhileAwaitWithCancellation_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(new Func>((x, ct) => { throw ex; })); + var ys = xs.TakeWhileAwaitWithCancellation(new Func>((x, ct) => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task TakeWhile_Async_Cancel_Indexed() + public async Task TakeWhileAwaitWithCancellation_Indexed() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i, ct) => new ValueTask(i < 2)); + var ys = xs.TakeWhileAwaitWithCancellation((x, i, ct) => new ValueTask(i < 2)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -361,20 +361,20 @@ public async Task TakeWhile_Async_Cancel_Indexed() } [Fact] - public async Task TakeWhile_Async_Cancel_Indexed_False() + public async Task TakeWhileAwaitWithCancellation_Indexed_False() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i, ct) => new ValueTask(false)); + var ys = xs.TakeWhileAwaitWithCancellation((x, i, ct) => new ValueTask(false)); var e = ys.GetAsyncEnumerator(); await NoNextAsync(e); } [Fact] - public async Task TakeWhile_Async_Cancel_Indexed_True() + public async Task TakeWhileAwaitWithCancellation_Indexed_True() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i, ct) => new ValueTask(true)); + var ys = xs.TakeWhileAwaitWithCancellation((x, i, ct) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); @@ -385,30 +385,30 @@ public async Task TakeWhile_Async_Cancel_Indexed_True() } [Fact] - public async Task TakeWhile_Async_Cancel_Indexed_Throws_Predicate() + public async Task TakeWhileAwaitWithCancellation_Indexed_Throws_Predicate() { var ex = new Exception("Bang"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile(new Func>((x, ct, i) => { throw ex; })); + var ys = xs.TakeWhileAwaitWithCancellation(new Func>((x, ct, i) => { throw ex; })); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task TakeWhile_Async_Cancel_SequenceIdentity() + public async Task TakeWhileAwaitWithCancellation_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((int x, CancellationToken ct) => new ValueTask(x < 3)); + var ys = xs.TakeWhileAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x < 3)); await SequenceIdentity(ys); } [Fact] - public async Task TakeWhile_Async_Cancel_Indexed_SequenceIdentity() + public async Task TakeWhileAwaitWithCancellation_Indexed_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - var ys = xs.TakeWhile((x, i, ct) => new ValueTask(i < 2)); + var ys = xs.TakeWhileAwaitWithCancellation((x, i, ct) => new ValueTask(i < 2)); await SequenceIdentity(ys); } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs index c5e99d2982..6f2d4ef65b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToDictionary.cs @@ -20,7 +20,7 @@ public async Task ToDictionary_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, EqualityComparer.Default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0).AsTask()); @@ -34,7 +34,7 @@ public async Task ToDictionary_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, EqualityComparer.Default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(default, x => 0, x => 0, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToDictionaryAsync(Return42, default, x => 0, CancellationToken.None).AsTask()); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs index 0a95b6bfbb..f7b2cd86ea 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToLookup.cs @@ -21,7 +21,7 @@ public async Task ToLookup_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func)).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, EqualityComparer.Default).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0).AsTask()); @@ -35,7 +35,7 @@ public async Task ToLookup_Null() await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, EqualityComparer.Default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default(Func), EqualityComparer.Default, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, EqualityComparer.Default, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(default, x => 0, x => 0, CancellationToken.None).AsTask()); await Assert.ThrowsAsync(() => AsyncEnumerable.ToLookupAsync(Return42, default, x => 0, CancellationToken.None).AsTask()); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs index 4bfceb30c1..b8eb4c299d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Where.cs @@ -13,7 +13,7 @@ namespace Tests public class Where : AsyncEnumerableTests { [Fact] - public void Where_Sync_Null() + public void Where_Null() { Assert.Throws(() => AsyncEnumerable.Where(default, x => true)); Assert.Throws(() => AsyncEnumerable.Where(default, (x, i) => true)); @@ -22,7 +22,7 @@ public void Where_Sync_Null() } [Fact] - public async Task Where_Sync_Simple() + public async Task Where_Simple() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0); @@ -36,7 +36,7 @@ public async Task Where_Sync_Simple() } [Fact] - public async Task Where_Sync_Indexed() + public async Task Where_Indexed() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where((x, i) => i % 2 == 0); @@ -51,7 +51,7 @@ public async Task Where_Sync_Indexed() } [Fact] - public async Task Where_Sync_Throws_Predicate() + public async Task Where_Throws_Predicate() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); @@ -65,7 +65,7 @@ public async Task Where_Sync_Throws_Predicate() } [Fact] - public async Task Where_Sync_Indexed_Throws_Predicate() + public async Task Where_Indexed_Throws_Predicate() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); @@ -79,7 +79,7 @@ public async Task Where_Sync_Indexed_Throws_Predicate() } [Fact] - public async Task Where_Sync_Throws_Source() + public async Task Where_Throws_Source() { var ex = new Exception("Bang"); var xs = Throw(ex); @@ -90,7 +90,7 @@ public async Task Where_Sync_Throws_Source() } [Fact] - public async Task Where_Sync_Indexed_Throws_Source() + public async Task Where_Indexed_Throws_Source() { var ex = new Exception("Bang"); var xs = Throw(ex); @@ -101,7 +101,7 @@ public async Task Where_Sync_Indexed_Throws_Source() } [Fact] - public async Task Where_Sync_WhereWhere() + public async Task Where_WhereWhere() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0).Where(x => x > 5); @@ -112,7 +112,7 @@ public async Task Where_Sync_WhereWhere() } [Fact] - public async Task Where_Sync_SequenceIdentity() + public async Task Where_SequenceIdentity() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where(x => x % 2 == 0); @@ -121,7 +121,7 @@ public async Task Where_Sync_SequenceIdentity() } [Fact] - public async Task Where_Sync_Indexed_SequenceIdentity() + public async Task Where_Indexed_SequenceIdentity() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ys = xs.Where((x, i) => i % 2 == 0); @@ -130,19 +130,19 @@ public async Task Where_Sync_Indexed_SequenceIdentity() } [Fact] - public void Where_Async_Null() + public void WhereAwait_Null() { - Assert.Throws(() => AsyncEnumerable.Where(default, x => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.Where(default, (int x, int i) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.Where(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.Where(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.WhereAwait(default, x => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.WhereAwait(default, (int x, int i) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.WhereAwait(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.WhereAwait(Return42, default(Func>))); } [Fact] - public async Task Where_Async_Simple() + public async Task WhereAwait_Simple() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where(x => new ValueTask(x % 2 == 0)); + var ys = xs.WhereAwait(x => new ValueTask(x % 2 == 0)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); await HasNextAsync(e, 4); @@ -153,10 +153,10 @@ public async Task Where_Async_Simple() } [Fact] - public async Task Where_Async_Indexed() + public async Task WhereAwait_Indexed() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((x, i) => new ValueTask(i % 2 == 0)); + var ys = xs.WhereAwait((x, i) => new ValueTask(i % 2 == 0)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); @@ -168,11 +168,11 @@ public async Task Where_Async_Indexed() } [Fact] - public async Task Where_Async_Throws_Predicate() + public async Task WhereAwait_Throws_Predicate() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); - var ys = xs.Where(x => { if (x == 4) throw ex; return new ValueTask(true); }); + var ys = xs.WhereAwait(x => { if (x == 4) throw ex; return new ValueTask(true); }); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); @@ -182,11 +182,11 @@ public async Task Where_Async_Throws_Predicate() } [Fact] - public async Task Where_Async_Indexed_Throws_Predicate() + public async Task WhereAwait_Indexed_Throws_Predicate() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); - var ys = xs.Where((x, i) => { if (i == 3) throw ex; return new ValueTask(true); }); + var ys = xs.WhereAwait((x, i) => { if (i == 3) throw ex; return new ValueTask(true); }); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); @@ -196,32 +196,32 @@ public async Task Where_Async_Indexed_Throws_Predicate() } [Fact] - public async Task Where_Async_Throws_Source() + public async Task WhereAwait_Throws_Source() { var ex = new Exception("Bang"); var xs = Throw(ex); - var ys = xs.Where(x => new ValueTask(true)); + var ys = xs.WhereAwait(x => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task Where_Async_Indexed_Throws_Source() + public async Task WhereAwait_Indexed_Throws_Source() { var ex = new Exception("Bang"); var xs = Throw(ex); - var ys = xs.Where((int x, int i) => new ValueTask(true)); + var ys = xs.WhereAwait((int x, int i) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task Where_Async_WhereWhere() + public async Task WhereAwait_WhereWhere() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where(x => new ValueTask(x % 2 == 0)).Where(x => new ValueTask(x > 5)); + var ys = xs.WhereAwait(x => new ValueTask(x % 2 == 0)).WhereAwait(x => new ValueTask(x > 5)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); await HasNextAsync(e, 6); @@ -229,41 +229,39 @@ public async Task Where_Async_WhereWhere() } [Fact] - public async Task Where_Async_SequenceIdentity() + public async Task WhereAwait_SequenceIdentity() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where(x => new ValueTask(x % 2 == 0)); + var ys = xs.WhereAwait(x => new ValueTask(x % 2 == 0)); await SequenceIdentity(ys); } [Fact] - public async Task Where_Async_Indexed_SequenceIdentity() + public async Task WhereAwait_Indexed_SequenceIdentity() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((x, i) => new ValueTask(i % 2 == 0)); + var ys = xs.WhereAwait((x, i) => new ValueTask(i % 2 == 0)); await SequenceIdentity(ys); } #if !NO_DEEP_CANCELLATION - // REVIEW: These overloads are problematic for type inference. E.g. xs.Where((x, ct) => ...) is ambiguous. - [Fact] - public void Where_Async_Cancel_Null() + public void WhereAwaitWithCancellation_Null() { - Assert.Throws(() => AsyncEnumerable.Where(default, (int x, CancellationToken ct) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.Where(default, (x, i, ct) => new ValueTask(true))); - Assert.Throws(() => AsyncEnumerable.Where(Return42, default(Func>))); - Assert.Throws(() => AsyncEnumerable.Where(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.WhereAwaitWithCancellation(default, (int x, CancellationToken ct) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.WhereAwaitWithCancellation(default, (x, i, ct) => new ValueTask(true))); + Assert.Throws(() => AsyncEnumerable.WhereAwaitWithCancellation(Return42, default(Func>))); + Assert.Throws(() => AsyncEnumerable.WhereAwaitWithCancellation(Return42, default(Func>))); } [Fact] - public async Task Where_Async_Cancel_Simple() + public async Task WhereAwaitWithCancellation_Simple() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((int x, CancellationToken ct) => new ValueTask(x % 2 == 0)); + var ys = xs.WhereAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x % 2 == 0)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); await HasNextAsync(e, 4); @@ -274,10 +272,10 @@ public async Task Where_Async_Cancel_Simple() } [Fact] - public async Task Where_Async_Cancel_Indexed() + public async Task WhereAwaitWithCancellation_Indexed() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((x, i, ct) => new ValueTask(i % 2 == 0)); + var ys = xs.WhereAwaitWithCancellation((x, i, ct) => new ValueTask(i % 2 == 0)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); @@ -289,11 +287,11 @@ public async Task Where_Async_Cancel_Indexed() } [Fact] - public async Task Where_Async_Cancel_Throws_Predicate() + public async Task WhereAwaitWithCancellation_Throws_Predicate() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); - var ys = xs.Where((int x, CancellationToken ct) => { if (x == 4) throw ex; return new ValueTask(true); }); + var ys = xs.WhereAwaitWithCancellation((int x, CancellationToken ct) => { if (x == 4) throw ex; return new ValueTask(true); }); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); @@ -303,11 +301,11 @@ public async Task Where_Async_Cancel_Throws_Predicate() } [Fact] - public async Task Where_Async_Cancel_Indexed_Throws_Predicate() + public async Task WhereAwaitWithCancellation_Indexed_Throws_Predicate() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); var ex = new Exception("Bang"); - var ys = xs.Where((x, i, ct) => { if (i == 3) throw ex; return new ValueTask(true); }); + var ys = xs.WhereAwaitWithCancellation((x, i, ct) => { if (i == 3) throw ex; return new ValueTask(true); }); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); @@ -317,32 +315,32 @@ public async Task Where_Async_Cancel_Indexed_Throws_Predicate() } [Fact] - public async Task Where_Async_Cancel_Throws_Source() + public async Task WhereAwaitWithCancellation_Throws_Source() { var ex = new Exception("Bang"); var xs = Throw(ex); - var ys = xs.Where((int x, CancellationToken ct) => new ValueTask(true)); + var ys = xs.WhereAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task Where_Async_Cancel_Indexed_Throws_Source() + public async Task WhereAwaitWithCancellation_Indexed_Throws_Source() { var ex = new Exception("Bang"); var xs = Throw(ex); - var ys = xs.Where((x, i, ct) => new ValueTask(true)); + var ys = xs.WhereAwaitWithCancellation((x, i, ct) => new ValueTask(true)); var e = ys.GetAsyncEnumerator(); await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task Where_Async_Cancel_WhereWhere() + public async Task WhereAwaitWithCancellation_WhereWhere() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((int x, CancellationToken ct) => new ValueTask(x % 2 == 0)).Where((int x, CancellationToken ct) => new ValueTask(x > 5)); + var ys = xs.WhereAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x % 2 == 0)).WhereAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x > 5)); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 8); await HasNextAsync(e, 6); @@ -350,19 +348,19 @@ public async Task Where_Async_Cancel_WhereWhere() } [Fact] - public async Task Where_Async_Cancel_SequenceIdentity() + public async Task WhereAwaitWithCancellation_SequenceIdentity() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((int x, CancellationToken ct) => new ValueTask(x % 2 == 0)); + var ys = xs.WhereAwaitWithCancellation((int x, CancellationToken ct) => new ValueTask(x % 2 == 0)); await SequenceIdentity(ys); } [Fact] - public async Task Where_Async_Cancel_Indexed_SequenceIdentity() + public async Task WhereAwaitWithCancellation_Indexed_SequenceIdentity() { var xs = new[] { 8, 5, 7, 4, 6, 9, 2, 1, 0 }.ToAsyncEnumerable(); - var ys = xs.Where((x, i, ct) => new ValueTask(i % 2 == 0)); + var ys = xs.WhereAwaitWithCancellation((x, i, ct) => new ValueTask(i % 2 == 0)); await SequenceIdentity(ys); } diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 59613ea86f..53e0269662 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -73,4 +73,8 @@ + + + + diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index bd2680a526..d2dab5cc1a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -40,7 +40,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,7 +71,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -124,7 +124,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAcc } } - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -147,7 +147,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAcc } #if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -194,7 +194,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAccumul } } - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -219,7 +219,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAccumul } #if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 10d5591ab0..46041173f8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -33,7 +33,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,7 +57,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AllAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index cad05f66aa..550581f028 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -49,7 +49,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -73,7 +73,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask AnyAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index 2791bf78f5..d6aa470397 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -76,7 +76,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -111,7 +111,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -212,7 +212,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -247,7 +247,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -348,7 +348,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -383,7 +383,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -484,7 +484,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -519,7 +519,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -620,7 +620,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -655,7 +655,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -772,7 +772,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -815,7 +815,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -940,7 +940,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -983,7 +983,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1108,7 +1108,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1151,7 +1151,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1276,7 +1276,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1319,7 +1319,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1444,7 +1444,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1487,7 +1487,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index 38b3a28aa0..e7a0ef8393 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -191,7 +191,7 @@ else } } - public static ValueTask<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.res#>> AverageAwaitAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -266,7 +266,7 @@ else } #if !NO_DEEP_CANCELLATION - public static ValueTask<<#=o.res#>> AverageAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.res#>> AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index 55da75f217..f0ac22ddf9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -72,7 +72,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -101,7 +101,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask CountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index b4fd9cf07a..98f06c9f95 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index beda3cd221..2869761cb7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index f2be60a6cc..8e68b35990 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -55,7 +55,7 @@ static async Task Core(IAsyncEnumerable _source, Action _ } } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) + public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -73,7 +73,7 @@ static async Task Core(IAsyncEnumerable _source, Func _a } } - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -91,7 +91,7 @@ static async Task Core(IAsyncEnumerable _source, Func(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) + public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -111,7 +111,7 @@ static async Task Core(IAsyncEnumerable _source, Func(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index 4fa54a5c7b..c4477ce4d0 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -16,17 +16,17 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerable(source, keySelector, comparer); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer: null); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer); #endif @@ -36,17 +36,17 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer: null); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer); #endif @@ -56,17 +56,17 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer); #endif @@ -76,17 +76,17 @@ public static IAsyncEnumerable GroupBy GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerable(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer); #endif @@ -220,7 +220,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -310,7 +310,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -493,7 +493,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -585,7 +585,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.Select(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index 7ff5a73d5e..c9415468ae 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -52,10 +52,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => - GroupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => + GroupJoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -95,10 +95,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => - GroupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => + GroupJoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index ad2f454330..b00948e7b8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -69,10 +69,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => - Join(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + JoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -128,10 +128,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => - Join(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + JoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 9ea5c3f1ae..45e1d101b9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index 456fa982f1..cf8b15e19f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LastOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 90d7cc681a..3a7134e022 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -61,7 +61,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -90,7 +90,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask LongCountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 97b6a3d763..4d61d9f082 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -164,7 +164,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -244,7 +244,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index b90382fbb7..9a7889e8ed 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -166,7 +166,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -246,7 +246,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index 748a6f3c36..c8770a7e2d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -80,7 +80,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -117,7 +117,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -302,7 +302,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -378,7 +378,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -524,7 +524,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -561,7 +561,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -746,7 +746,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -822,7 +822,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -998,7 +998,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1050,7 +1050,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1242,7 +1242,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1314,7 +1314,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1486,7 +1486,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1538,7 +1538,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1730,7 +1730,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1802,7 +1802,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1944,7 +1944,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1981,7 +1981,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2114,7 +2114,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2164,7 +2164,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2284,7 +2284,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2321,7 +2321,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2458,7 +2458,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2510,7 +2510,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2632,7 +2632,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2669,7 +2669,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2806,7 +2806,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2858,7 +2858,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3012,7 +3012,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3065,7 +3065,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3250,7 +3250,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3318,7 +3318,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3488,7 +3488,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3541,7 +3541,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3726,7 +3726,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3794,7 +3794,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3932,7 +3932,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3969,7 +3969,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4102,7 +4102,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4152,7 +4152,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 919cf5c721..6022691633 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -285,15 +285,17 @@ foreach (var overload in new[] { }) { var isDeepCancellation = overload.selector.Contains("CancellationToken"); + var suffix = overload.invoke.StartsWith("await") ? "Await" : ""; if (isDeepCancellation) { + suffix += "WithCancellation"; #> #if !NO_DEEP_CANCELLATION <# } #> - public static ValueTask<<#=t#>> <#=m#>Async(this IAsyncEnumerable source, <#=overload.selector#> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=t#>> <#=m#><#=suffix#>Async(this IAsyncEnumerable source, <#=overload.selector#> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index eff7657af9..34d2e8dd6c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -13,44 +13,44 @@ public static partial class AsyncEnumerable public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) => new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: false, parent: null); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => + public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => + public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: false, parent: null); #endif public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: false, parent: null); #endif public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) => new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: true, parent: null); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => + public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => + public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: true, parent: null); #endif public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: true, parent: null); #endif @@ -62,7 +62,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: false); } - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,7 +71,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder } #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -88,7 +88,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -97,7 +97,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder } #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: true); } - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -123,7 +123,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t } #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) + public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -140,7 +140,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -149,7 +149,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t } #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index bacd4d572c..b84d1edc73 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -58,7 +58,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + public static IAsyncEnumerable SelectAwait(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -77,7 +77,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -96,7 +96,7 @@ public static IAsyncEnumerable Select(this IAsyncEnum } #endif - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + public static IAsyncEnumerable SelectAwait(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) + public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index 9c60a7c046..eb209f270c 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -23,7 +23,7 @@ public static IAsyncEnumerable SelectMany(this IAsync // REVIEW: Should we keep these overloads that return ValueTask>? One could argue the selector is async twice. - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static IAsyncEnumerable SelectMany(this IAsync } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -79,7 +79,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -178,7 +178,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -208,7 +208,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -274,7 +274,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -311,7 +311,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index f248d45a33..609ed5885a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -85,7 +85,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -122,7 +122,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index ae68be83c0..b5ac28f153 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -85,7 +85,7 @@ async ValueTask Core(IAsyncEnumerable _source, Func SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -122,7 +122,7 @@ async ValueTask Core(IAsyncEnumerable _source, Func SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index d32af56f85..46b968a06f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -92,7 +92,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -130,7 +130,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -168,7 +168,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -213,7 +213,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index 5b3737da57..bb0f4da0d8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -88,7 +88,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -166,7 +166,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -194,7 +194,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -266,7 +266,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -291,7 +291,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -360,7 +360,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -385,7 +385,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -454,7 +454,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -479,7 +479,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -554,7 +554,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -582,7 +582,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -660,7 +660,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -688,7 +688,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -760,7 +760,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -785,7 +785,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -854,7 +854,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -879,7 +879,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -948,7 +948,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -973,7 +973,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 89801302cd..8233e40832 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -111,7 +111,7 @@ else } } - public static ValueTask<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.type#>> SumAwaitAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -152,7 +152,7 @@ else } #if !NO_DEEP_CANCELLATION - public static ValueTask<<#=o.type#>> SumAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + public static ValueTask<<#=o.type#>> SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 8c346f0da0..9ddd1a2c31 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -72,7 +72,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -100,7 +100,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -128,7 +128,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -163,7 +163,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index 9b330ac649..f91dc4fea1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -37,10 +37,10 @@ static async ValueTask> Core(IAsyncEnumerable } } - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitAsync(source, keySelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -65,10 +65,10 @@ static async ValueTask> Core(IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToDictionaryAsync(source, keySelector, comparer: null, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitWithCancellationAsync(source, keySelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -123,10 +123,10 @@ static async ValueTask> Core(IAsyncEnumerable> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -154,10 +154,10 @@ static async ValueTask> Core(IAsyncEnumerable> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index ffb5c0f848..eaa65d9690 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -28,10 +28,10 @@ static async ValueTask> Core(IAsyncEnumerable _s } } - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToLookupAsync(source, keySelector, comparer:null, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToLookupAwaitAsync(source, keySelector, comparer:null, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -47,10 +47,10 @@ async ValueTask> Core(IAsyncEnumerable _source, } #if !NO_DEEP_CANCELLATION - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToLookupAsync(source, keySelector, comparer: null, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToLookupAwaitWithCancellationAsync(source, keySelector, comparer: null, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -86,10 +86,10 @@ static async ValueTask> Core(IAsyncEnumerable _ } } - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToLookupAwaitAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -107,10 +107,10 @@ static async ValueTask> Core(IAsyncEnumerable _ } #if !NO_DEEP_CANCELLATION - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index b78098a68d..2c307bd2d3 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -59,7 +59,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -76,7 +76,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -93,7 +93,7 @@ public static IAsyncEnumerable Where(this IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) + public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 01984ae609..827a4b3042 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -41,7 +41,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + public static IAsyncEnumerable ZipAwait(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -72,7 +72,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + public static IAsyncEnumerable ZipAwaitWithCancellation(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) throw Error.ArgumentNull(nameof(first)); From 5da0a5aa0748545d3aeb43d9b0b35edee85cd292 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 13:33:09 -0800 Subject: [PATCH 838/862] Add Zip with ValueTuple return type. --- Ix.NET/Source/Directory.build.targets | 2 +- .../System/Linq/AsyncQueryable.cs | 16 ++++++++++ .../System/Linq/Operators/Zip.cs | 30 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index abc51bda18..a6f37d3ad1 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -14,7 +14,7 @@ $(DefineConstants);USE_ASYNC_ITERATOR - $(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT + $(DefineConstants);USE_ASYNC_ITERATOR;HAS_ASYNCENUMERABLE;HAS_ASYNCDISPOSABLE;BCL_HAS_CONFIGUREAWAIT;HAS_VALUETUPLE diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs index db5e2d79fb..5f3731d8fc 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs @@ -34,6 +34,22 @@ public static IAsyncQueryable AsAsyncQueryable(this IAsyncEn return new AsyncEnumerableQuery(source); } +#if HAS_VALUETUPLE + public static IAsyncQueryable<(TFirst First, TSecond Second)> Zip(this IAsyncQueryable first, IAsyncEnumerable second) + { + if (first == null) + throw new ArgumentNullException(nameof(first)); + if (second == null) + throw new ArgumentNullException(nameof(second)); + +#if CRIPPLED_REFLECTION + return first.Provider.CreateQuery<(TFirst, TSecond)>(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); +#else + return first.Provider.CreateQuery<(TFirst, TSecond)>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond)), first.Expression, GetSourceExpression(second))); +#endif + } +#endif + private static Expression GetSourceExpression(IAsyncEnumerable source) { if (source is IAsyncQueryable queryable) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index 827a4b3042..cef5bf0947 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -11,6 +11,36 @@ namespace System.Linq { public static partial class AsyncEnumerable { +#if HAS_VALUETUPLE + public static IAsyncEnumerable<(TFirst First, TSecond Second)> Zip(this IAsyncEnumerable first, IAsyncEnumerable second) + { + if (first == null) + throw Error.ArgumentNull(nameof(first)); + if (second == null) + throw Error.ArgumentNull(nameof(second)); + +#if USE_ASYNC_ITERATOR + return Create(Core); + + async IAsyncEnumerator<(TFirst, TSecond)> Core(CancellationToken cancellationToken) + { + await using (var e1 = first.GetConfiguredAsyncEnumerator(cancellationToken, false)) + { + await using (var e2 = second.GetConfiguredAsyncEnumerator(cancellationToken, false)) + { + while (await e1.MoveNextAsync() && await e2.MoveNextAsync()) + { + yield return (e1.Current, e2.Current); + } + } + } + } +#else + return new ZipAsyncIterator(first, second, (first, second) => (first, second)); +#endif + } +#endif + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func selector) { if (first == null) From 0a2d6371d62af871bc8274e7b29833dbd67ce09a Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 26 Feb 2019 16:37:00 -0500 Subject: [PATCH 839/862] Switch to use .NET Standard 2.1 instead of netcoreapp3.0 for broader support --- .../System.Interactive.Async.Providers.csproj | 2 +- .../System.Interactive.Async/System.Interactive.Async.csproj | 2 +- .../System.Linq.Async.Queryable.csproj | 2 +- Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj | 5 +++-- Ix.NET/Source/refs/Directory.build.props | 2 -- .../refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj | 4 ++-- azure-pipelines.ix.yml | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index 6cc02b024b..9873816a3b 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Providers Library used to build query providers and express queries over async enumerable sequences. Interactive Extensions - Async Providers Library - net45;net46;netstandard2.0;netcoreapp3.0 + net45;net46;netstandard2.0;netstandard2.1 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index 557cb529b2..ba5153043f 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. Interactive Extensions - Async Library - net45;net46;netstandard2.0;netcoreapp3.0 + net45;net46;netstandard2.0;netstandard2.1 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index 87a32ad2f9..4e38a54bda 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -1,7 +1,7 @@  - net45;net46;netstandard2.0;netcoreapp3.0 + net45;net46;netstandard2.0;netstandard2.1 diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 59613ea86f..755a463141 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -1,7 +1,7 @@  - net45;net46;netstandard2.0;netcoreapp3.0 + net45;net46;netstandard2.0;netstandard2.1 @@ -18,7 +18,8 @@ - + diff --git a/Ix.NET/Source/refs/Directory.build.props b/Ix.NET/Source/refs/Directory.build.props index 613a4047db..fcf8236361 100644 --- a/Ix.NET/Source/refs/Directory.build.props +++ b/Ix.NET/Source/refs/Directory.build.props @@ -3,8 +3,6 @@ - - 2.1 $(DefineConstants);REFERENCE_ASSEMBLY diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj index 5097ad2e91..5882f0ce41 100644 --- a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj +++ b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj @@ -4,12 +4,12 @@ LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. System.Linq.Async Microsoft - net45;netstandard2.0;netcoreapp3.0 + net45;netstandard2.0;netstandard2.1 Enumerable;Asynchronous;LINQ - diff --git a/azure-pipelines.ix.yml b/azure-pipelines.ix.yml index e62deb84a0..f08fa4c1fc 100644 --- a/azure-pipelines.ix.yml +++ b/azure-pipelines.ix.yml @@ -30,7 +30,7 @@ variables: steps: - task: DotNetCoreInstaller@0 inputs: - version: '3.0.100-preview4-010374' + version: '3.0.100-preview4-010530' - task: DotNetCoreCLI@2 inputs: From d57055d5b74e06b017021d239808d6c0c462c9c9 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 26 Feb 2019 18:26:07 -0500 Subject: [PATCH 840/862] Add back .NET Core 3 target until .NET Core 3 runtime has the latest netstandard dll in it. --- .../System.Interactive.Async.Providers.csproj | 2 +- .../System.Interactive.Async/System.Interactive.Async.csproj | 2 +- .../System.Linq.Async.Queryable.csproj | 2 +- Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj | 2 +- .../refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index 9873816a3b..e58a12550e 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Providers Library used to build query providers and express queries over async enumerable sequences. Interactive Extensions - Async Providers Library - net45;net46;netstandard2.0;netstandard2.1 + net45;net46;netstandard2.0;netstandard2.1;netcoreapp3.0 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index ba5153043f..c485c1bf0a 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -3,7 +3,7 @@ Interactive Extensions Async Library used to express queries over asynchronous enumerable sequences. Interactive Extensions - Async Library - net45;net46;netstandard2.0;netstandard2.1 + net45;net46;netstandard2.0;netstandard2.1;netcoreapp3.0 Ix;Interactive;Extensions;Enumerable;Asynchronous diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj index 4e38a54bda..e82b948be2 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System.Linq.Async.Queryable.csproj @@ -1,7 +1,7 @@  - net45;net46;netstandard2.0;netstandard2.1 + net45;net46;netstandard2.0;netstandard2.1;netcoreapp3.0 diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 755a463141..3277968c20 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -1,7 +1,7 @@  - net45;net46;netstandard2.0;netstandard2.1 + net45;net46;netstandard2.0;netstandard2.1;netcoreapp3.0 diff --git a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj index 5882f0ce41..34058f451f 100644 --- a/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj +++ b/Ix.NET/Source/refs/System.Linq.Async.Ref/System.Linq.Async.Ref.csproj @@ -4,7 +4,7 @@ LINQ Standard Query Operators used to express queries over asynchronous enumerable sequences. System.Linq.Async Microsoft - net45;netstandard2.0;netstandard2.1 + net45;netstandard2.0;netstandard2.1;netcoreapp3.0 Enumerable;Asynchronous;LINQ From 3051508376ff9b7a2b2f4b475164efa0affa9819 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Tue, 26 Feb 2019 21:50:54 -0500 Subject: [PATCH 841/862] Get rid of junk in project files --- .../System.Interactive.Async.Providers.csproj | 4 ---- .../System.Interactive.Async/System.Interactive.Async.csproj | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj index e58a12550e..4a73d82cde 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System.Interactive.Async.Providers.csproj @@ -21,8 +21,4 @@ - - - - diff --git a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj index c485c1bf0a..0c8b157532 100644 --- a/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj +++ b/Ix.NET/Source/System.Interactive.Async/System.Interactive.Async.csproj @@ -22,9 +22,5 @@ - - - - From 905f456e378e29073ab351b68423722f409384c2 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 20:52:08 -0800 Subject: [PATCH 842/862] Use cached refletion info for AsyncQueryable[Ex]. --- Ix.NET/Source/AsyncQueryableGenerator.t4 | 321 ++ Ix.NET/Source/Directory.build.targets | 4 +- Ix.NET/Source/Ix.Async.NET.sln | 5 +- .../System/Linq/AsyncQueryableEx.Generated.cs | 854 ++-- .../System/Linq/AsyncQueryableEx.Generated.tt | 287 +- .../System/Linq/AsyncQueryableEx.cs | 6 - .../System/Linq/AsyncQueryable.Generated.cs | 4430 ++++++++++------- .../System/Linq/AsyncQueryable.Generated.tt | 285 +- .../System/Linq/AsyncQueryable.cs | 17 +- 9 files changed, 3422 insertions(+), 2787 deletions(-) create mode 100644 Ix.NET/Source/AsyncQueryableGenerator.t4 diff --git a/Ix.NET/Source/AsyncQueryableGenerator.t4 b/Ix.NET/Source/AsyncQueryableGenerator.t4 new file mode 100644 index 0000000000..04c4412019 --- /dev/null +++ b/Ix.NET/Source/AsyncQueryableGenerator.t4 @@ -0,0 +1,321 @@ +<#@ assembly name="System.Core" #> +<#@ assembly name="System.Runtime" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Threading" #> +<#@ import namespace="System.Threading.Tasks" #> +<#@ import namespace="System.Collections.Generic" #> +<# +var infoFieldNames = new Dictionary(); + +var toQuotedImpl = default(Func); +toQuotedImpl = (t, i, b) => +{ +var name = t.Name; + +if (t.IsGenericType) +{ + var genDef = t.GetGenericTypeDefinition(); + name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); + + var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; + + if (b) + { + if (name == "Func" || name == "Action") + { + name = "Expression<" + name + genArgs + ">"; + } + else if (name == "IAsyncEnumerable" && i == 0) + { + name = "IAsyncQueryable" + genArgs; + } + else if (name == "IOrderedAsyncEnumerable" && i == 0) + { + name = "IOrderedAsyncQueryable" + genArgs; + } + else + { + name += genArgs; + } + } + else + { + if (name == "Nullable") + { + name = genArgs.Substring(1, genArgs.Length - 2) + "?"; + } + else + { + name += genArgs; + } + } +} +else if (t.IsArray) +{ + var elem = toQuotedImpl(t.GetElementType(), i, b); + name = elem + "[]"; +} +else +{ + if (t == typeof(int)) + { + name = "int"; + } + else if (t == typeof(long)) + { + name = "long"; + } + else if (t == typeof(float)) + { + name = "float"; + } + else if (t == typeof(double)) + { + name = "double"; + } + else if (t == typeof(decimal)) + { + name = "decimal"; + } + else if (t == typeof(bool)) + { + name = "bool"; + } + else if (t == typeof(object)) + { + name = "object"; + } +} + +return name; +}; + +var toQuoted = new Func((t, i) => toQuotedImpl(t, i, true)); +#> +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + public static partial class <#=className#> + { +<# +// NOTE: Just including extension methods +foreach (var m in asyncEnumerableType.GetMethods() + .Where(m => m.IsStatic) + .Where(m => !exclude.Contains(m.Name)) + .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + .Where(m => + { + var p0 = m.GetParameters()[0].ParameterType; + if (p0.IsGenericType) + { + var p0d = p0.GetGenericTypeDefinition(); + return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); + } + + return false; + }) + .OrderBy(m => m.Name) + .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) + .ThenBy(m => m.GetParameters().Length) + .ThenBy(m => string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i) + " " + p.Name)))) +{ + var genArgs = m.GetGenericArguments(); + + var ret = toQuoted(m.ReturnType, 0); + var name = m.Name; + + if (genArgs.Length > 0) + { + name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; + } + + var isParams = false; + var lastParameterDefault = false; + var parCount = m.GetParameters().Length; + + if (parCount != 0) + { + var lastParam = m.GetParameters().Last(); + + if (lastParam.IsDefined(typeof(ParamArrayAttribute), true)) + { + isParams = true; + } + + if (lastParam.ParameterType == typeof(CancellationToken)) + { + lastParameterDefault = true; + } + } + + var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name + (i == parCount - 1 && lastParameterDefault ? " = default" : ""))); + var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); + + if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) + { + pars = "this " + pars; + } + + var infoName = m.Name; + var infoTypeArgs = ""; + var infoToGeneric = ""; + var infoMakeGeneric = ""; + var infoGenArgs = ""; + + if (genArgs.Length > 0) + { + infoName += "__" + string.Join("_", genArgs.Select(a => a.Name)); + infoTypeArgs = "(" + string.Join(", ", genArgs.Select(a => "Type " + a.Name)) + ")"; + infoToGeneric = ".GetGenericMethodDefinition()"; + infoMakeGeneric = ".MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => a.Name)) + ")"; + infoGenArgs = "<" + string.Join(", ", genArgs.Select(_ => "object")) + ">"; + } + + infoName += "__" + parCount + "__"; + + int infoNameCount; + if (!infoFieldNames.TryGetValue(infoName, out infoNameCount)) + { + infoNameCount = 0; + } + + var infoNameId = infoNameCount++; + + infoFieldNames[infoName] = infoNameCount; + + infoName += infoNameId; + + var infoSignature = string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i)).Concat(new[] { toQuoted(m.ReturnType, 0) })); + + foreach (var genArg in genArgs) + { + infoSignature = infoSignature.Replace(genArg.Name, "object"); + } + + var mtd = infoName; + + if (m.IsGenericMethod) + { + mtd += "(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; + } + + var provider = m.GetParameters()[0].Name + ".Provider"; + var factory = ""; + var rem = ""; + var cast = ""; + var quotedArgs = new List(); + + if (m.ReturnType.IsGenericType) + { + var td = m.ReturnType.GetGenericTypeDefinition(); + + if (td.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask + { + factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + var last = m.GetParameters().Last(); + if (last.ParameterType == typeof(CancellationToken)) + { + rem = ", " + last.Name; + } + else + { + rem = ", CancellationToken.None"; + } + } + else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) + { + factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; + + if (td == typeof(IOrderedAsyncEnumerable<>)) + { + cast = "(" + toQuoted(m.ReturnType, 0) + ")"; + } + } + } + + var n = 0; + foreach (var p in m.GetParameters()) + { + var pt = p.ParameterType; + + var add = false; + + if (pt.IsGenericType) + { + var ptd = pt.GetGenericTypeDefinition(); + + if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) + { + if (n == 0) + { + quotedArgs.Add(p.Name + ".Expression"); + } + else + { + quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); + } + add = true; + } + else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) + { + quotedArgs.Add(p.Name); + add = true; + } + } + + if (!add) + { + quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); + } + + n++; + } + + var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; +#> + private static MethodInfo s_<#=infoName#>; + + private static MethodInfo <#=infoName#><#=infoTypeArgs#> => + (s_<#=infoName#> ?? + (s_<#=infoName#> = new Func<<#=infoSignature#>>(<#=m.Name#><#=infoGenArgs#>).GetMethodInfo()<#=infoToGeneric#>))<#=infoMakeGeneric#>; + + public static <#=ret#> <#=name#>(<#=pars#>) + { +<# +var any = false; +foreach (var p in m.GetParameters()) +{ + if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) + { + any = true; +#> + if (<#=p.Name#> == null) + throw new ArgumentNullException(nameof(<#=p.Name#>)); +<# + } +} +#> +<# +if (any) +{ +#> + +<# +} + +#> + return <#=cast#><#=provider#>.<#=factory#>(<#=expr#><#=rem#>); + } + +<# +} +#> + } +} \ No newline at end of file diff --git a/Ix.NET/Source/Directory.build.targets b/Ix.NET/Source/Directory.build.targets index a6f37d3ad1..7c39361150 100644 --- a/Ix.NET/Source/Directory.build.targets +++ b/Ix.NET/Source/Directory.build.targets @@ -2,10 +2,10 @@ - $(DefineConstants);NO_ARRAY_EMPTY;NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION + $(DefineConstants);NO_ARRAY_EMPTY;NO_CODE_COVERAGE_ATTRIBUTE - $(DefineConstants);NO_CODE_COVERAGE_ATTRIBUTE;CRIPPLED_REFLECTION + $(DefineConstants);NO_CODE_COVERAGE_ATTRIBUTE $(DefineConstants);NO_ARRAY_EMPTY;NO_TASK_FROMEXCEPTION diff --git a/Ix.NET/Source/Ix.Async.NET.sln b/Ix.NET/Source/Ix.Async.NET.sln index 3cf8c2088d..09d6fadf4d 100644 --- a/Ix.NET/Source/Ix.Async.NET.sln +++ b/Ix.NET/Source/Ix.Async.NET.sln @@ -1,13 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26730.3 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28606.126 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{87534290-A7A6-47A4-9A3A-D0D21A9AD1D4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B733D97A-F1ED-4FC3-BF8E-9AC47A89DE96}" ProjectSection(SolutionItems) = preProject ..\..\.editorconfig = ..\..\.editorconfig + AsyncQueryableGenerator.t4 = AsyncQueryableGenerator.t4 ..\..\azure-pipelines.ix.yml = ..\..\azure-pipelines.ix.yml CodeCoverage.runsettings = CodeCoverage.runsettings Directory.build.props = Directory.build.props diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs index 1fec3b22cc..3a19d17011 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.cs @@ -12,6 +12,12 @@ namespace System.Linq { public static partial class AsyncQueryableEx { + private static MethodInfo s_Amb__TSource__2__0; + + private static MethodInfo Amb__TSource__2__0(Type TSource) => + (s_Amb__TSource__2__0 ?? + (s_Amb__TSource__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(Amb).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Amb(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -19,37 +25,43 @@ public static IAsyncQueryable Amb(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Amb(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery(Expression.Call(Amb__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } + private static MethodInfo s_Buffer__TSource__2__0; + + private static MethodInfo Buffer__TSource__2__0(Type TSource) => + (s_Buffer__TSource__2__0 ?? + (s_Buffer__TSource__2__0 = new Func, int, IAsyncQueryable>>(Buffer).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryableEx.Buffer(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(Buffer__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } + private static MethodInfo s_Buffer__TSource__3__0; + + private static MethodInfo Buffer__TSource__3__0(Type TSource) => + (s_Buffer__TSource__3__0 ?? + (s_Buffer__TSource__3__0 = new Func, int, int, IAsyncQueryable>>(Buffer).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable> Buffer(this IAsyncQueryable source, int count, int skip) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryableEx.Buffer(default(IAsyncQueryable), default(int), default(int))), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(Buffer__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int)))); } + private static MethodInfo s_Catch__TSource__2__0; + + private static MethodInfo Catch__TSource__2__0(Type TSource) => + (s_Catch__TSource__2__0 ?? + (s_Catch__TSource__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(Catch).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Catch(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -57,13 +69,15 @@ public static IAsyncQueryable Catch(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery(Expression.Call(Catch__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } + private static MethodInfo s_Catch__TSource_TException__2__0; + + private static MethodInfo Catch__TSource_TException__2__0(Type TSource, Type TException) => + (s_Catch__TSource_TException__2__0 ?? + (s_Catch__TSource_TException__2__0 = new Func, Expression>>>, IAsyncQueryable>(Catch).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TException); + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) { if (source == null) @@ -71,13 +85,15 @@ public static IAsyncQueryable Catch(this IAsyncQue if (handler == null) throw new ArgumentNullException(nameof(handler)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); -#endif + return source.Provider.CreateQuery(Expression.Call(Catch__TSource_TException__2__0(typeof(TSource), typeof(TException)), source.Expression, handler)); } + private static MethodInfo s_Catch__TSource_TException__2__1; + + private static MethodInfo Catch__TSource_TException__2__1(Type TSource, Type TException) => + (s_Catch__TSource_TException__2__1 ?? + (s_Catch__TSource_TException__2__1 = new Func, Expression>>, IAsyncQueryable>(Catch).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TException); + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>> handler) { if (source == null) @@ -85,13 +101,15 @@ public static IAsyncQueryable Catch(this IAsyncQue if (handler == null) throw new ArgumentNullException(nameof(handler)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>))), source.Expression, handler)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); -#endif + return source.Provider.CreateQuery(Expression.Call(Catch__TSource_TException__2__1(typeof(TSource), typeof(TException)), source.Expression, handler)); } + private static MethodInfo s_Catch__TSource_TException__2__2; + + private static MethodInfo Catch__TSource_TException__2__2(Type TSource, Type TException) => + (s_Catch__TSource_TException__2__2 ?? + (s_Catch__TSource_TException__2__2 = new Func, Expression>>>, IAsyncQueryable>(Catch).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TException); + public static IAsyncQueryable Catch(this IAsyncQueryable source, Expression>>> handler) { if (source == null) @@ -99,25 +117,29 @@ public static IAsyncQueryable Catch(this IAsyncQue if (handler == null) throw new ArgumentNullException(nameof(handler)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch(default(IAsyncQueryable), default(Expression>>>))), source.Expression, handler)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler)); -#endif + return source.Provider.CreateQuery(Expression.Call(Catch__TSource_TException__2__2(typeof(TSource), typeof(TException)), source.Expression, handler)); } + private static MethodInfo s_Concat__TSource__1__0; + + private static MethodInfo Concat__TSource__1__0(Type TSource) => + (s_Concat__TSource__1__0 ?? + (s_Concat__TSource__1__0 = new Func>, IAsyncQueryable>(Concat).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Concat(this IAsyncQueryable> sources) { if (sources == null) throw new ArgumentNullException(nameof(sources)); -#if CRIPPLED_REFLECTION - return sources.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Concat(default(IAsyncQueryable>))), sources.Expression)); -#else - return sources.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), sources.Expression)); -#endif + return sources.Provider.CreateQuery(Expression.Call(Concat__TSource__1__0(typeof(TSource)), sources.Expression)); } + private static MethodInfo s_Distinct__TSource_TKey__2__0; + + private static MethodInfo Distinct__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__2__0 ?? + (s_Distinct__TSource_TKey__2__0 = new Func, Expression>>, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -125,13 +147,15 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_Distinct__TSource_TKey__2__1; + + private static MethodInfo Distinct__TSource_TKey__2__1(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__2__1 ?? + (s_Distinct__TSource_TKey__2__1 = new Func, Expression>, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -139,13 +163,15 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__2__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_Distinct__TSource_TKey__2__2; + + private static MethodInfo Distinct__TSource_TKey__2__2(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__2__2 ?? + (s_Distinct__TSource_TKey__2__2 = new Func, Expression>>, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -153,13 +179,15 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__2__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_Distinct__TSource_TKey__3__0; + + private static MethodInfo Distinct__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__3__0 ?? + (s_Distinct__TSource_TKey__3__0 = new Func, Expression>>, IEqualityComparer, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) @@ -167,13 +195,15 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_Distinct__TSource_TKey__3__1; + + private static MethodInfo Distinct__TSource_TKey__3__1(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__3__1 ?? + (s_Distinct__TSource_TKey__3__1 = new Func, Expression>, IEqualityComparer, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) @@ -181,13 +211,15 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__3__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_Distinct__TSource_TKey__3__2; + + private static MethodInfo Distinct__TSource_TKey__3__2(Type TSource, Type TKey) => + (s_Distinct__TSource_TKey__3__2 ?? + (s_Distinct__TSource_TKey__3__2 = new Func, Expression>>, IEqualityComparer, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) @@ -195,37 +227,43 @@ public static IAsyncQueryable Distinct(this IAsyncQuerya if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource_TKey__3__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_DistinctUntilChanged__TSource__1__0; + + private static MethodInfo DistinctUntilChanged__TSource__1__0(Type TSource) => + (s_DistinctUntilChanged__TSource__1__0 ?? + (s_DistinctUntilChanged__TSource__1__0 = new Func, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource__1__0(typeof(TSource)), source.Expression)); } + private static MethodInfo s_DistinctUntilChanged__TSource__2__0; + + private static MethodInfo DistinctUntilChanged__TSource__2__0(Type TSource) => + (s_DistinctUntilChanged__TSource__2__0 ?? + (s_DistinctUntilChanged__TSource__2__0 = new Func, IEqualityComparer, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__2__0; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__2__0 ?? + (s_DistinctUntilChanged__TSource_TKey__2__0 = new Func, Expression>>, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -233,13 +271,15 @@ public static IAsyncQueryable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__2__1; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__2__1(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__2__1 ?? + (s_DistinctUntilChanged__TSource_TKey__2__1 = new Func, Expression>, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -247,13 +287,15 @@ public static IAsyncQueryable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__2__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__2__2; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__2__2(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__2__2 ?? + (s_DistinctUntilChanged__TSource_TKey__2__2 = new Func, Expression>>, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -261,13 +303,15 @@ public static IAsyncQueryable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__2__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__3__0; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__3__0 ?? + (s_DistinctUntilChanged__TSource_TKey__3__0 = new Func, Expression>>, IEqualityComparer, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) @@ -275,13 +319,15 @@ public static IAsyncQueryable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__3__1; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__3__1(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__3__1 ?? + (s_DistinctUntilChanged__TSource_TKey__3__1 = new Func, Expression>, IEqualityComparer, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) @@ -289,13 +335,15 @@ public static IAsyncQueryable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__3__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_DistinctUntilChanged__TSource_TKey__3__2; + + private static MethodInfo DistinctUntilChanged__TSource_TKey__3__2(Type TSource, Type TKey) => + (s_DistinctUntilChanged__TSource_TKey__3__2 ?? + (s_DistinctUntilChanged__TSource_TKey__3__2 = new Func, Expression>>, IEqualityComparer, IAsyncQueryable>(DistinctUntilChanged).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable DistinctUntilChanged(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) @@ -303,13 +351,15 @@ public static IAsyncQueryable DistinctUntilChanged(this if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(DistinctUntilChanged__TSource_TKey__3__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_Do__TSource__2__0; + + private static MethodInfo Do__TSource__2__0(Type TSource) => + (s_Do__TSource__2__0 ?? + (s_Do__TSource__2__0 = new Func, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) @@ -317,13 +367,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onNext == null) throw new ArgumentNullException(nameof(onNext)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__2__0(typeof(TSource)), source.Expression, onNext)); } + private static MethodInfo s_Do__TSource__2__1; + + private static MethodInfo Do__TSource__2__1(Type TSource) => + (s_Do__TSource__2__1 ?? + (s_Do__TSource__2__1 = new Func, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) @@ -331,13 +383,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onNext == null) throw new ArgumentNullException(nameof(onNext)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__2__1(typeof(TSource)), source.Expression, onNext)); } + private static MethodInfo s_Do__TSource__2__2; + + private static MethodInfo Do__TSource__2__2(Type TSource) => + (s_Do__TSource__2__2 ?? + (s_Do__TSource__2__2 = new Func, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext) { if (source == null) @@ -345,13 +399,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onNext == null) throw new ArgumentNullException(nameof(onNext)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>))), source.Expression, onNext)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__2__2(typeof(TSource)), source.Expression, onNext)); } + private static MethodInfo s_Do__TSource__2__3; + + private static MethodInfo Do__TSource__2__3(Type TSource) => + (s_Do__TSource__2__3 ?? + (s_Do__TSource__2__3 = new Func, IObserver, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, IObserver observer) { if (source == null) @@ -359,13 +415,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (observer == null) throw new ArgumentNullException(nameof(observer)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(IObserver))), source.Expression, Expression.Constant(observer, typeof(IObserver)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__2__3(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver)))); } + private static MethodInfo s_Do__TSource__3__0; + + private static MethodInfo Do__TSource__3__0(Type TSource) => + (s_Do__TSource__3__0 ?? + (s_Do__TSource__3__0 = new Func, Expression>, Action, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Action onCompleted) { if (source == null) @@ -375,13 +433,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__0(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action)))); } + private static MethodInfo s_Do__TSource__3__1; + + private static MethodInfo Do__TSource__3__1(Type TSource) => + (s_Do__TSource__3__1 ?? + (s_Do__TSource__3__1 = new Func, Expression>, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) @@ -391,13 +451,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onError == null) throw new ArgumentNullException(nameof(onError)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__1(typeof(TSource)), source.Expression, onNext, onError)); } + private static MethodInfo s_Do__TSource__3__2; + + private static MethodInfo Do__TSource__3__2(Type TSource) => + (s_Do__TSource__3__2 ?? + (s_Do__TSource__3__2 = new Func, Expression>, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) { if (source == null) @@ -407,13 +469,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__2(typeof(TSource)), source.Expression, onNext, onCompleted)); } + private static MethodInfo s_Do__TSource__3__3; + + private static MethodInfo Do__TSource__3__3(Type TSource) => + (s_Do__TSource__3__3 ?? + (s_Do__TSource__3__3 = new Func, Expression>, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) @@ -423,13 +487,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onError == null) throw new ArgumentNullException(nameof(onError)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__3(typeof(TSource)), source.Expression, onNext, onError)); } + private static MethodInfo s_Do__TSource__3__4; + + private static MethodInfo Do__TSource__3__4(Type TSource) => + (s_Do__TSource__3__4 ?? + (s_Do__TSource__3__4 = new Func, Expression>, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError) { if (source == null) @@ -439,13 +505,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onError == null) throw new ArgumentNullException(nameof(onError)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onError)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__4(typeof(TSource)), source.Expression, onNext, onError)); } + private static MethodInfo s_Do__TSource__3__5; + + private static MethodInfo Do__TSource__3__5(Type TSource) => + (s_Do__TSource__3__5 ?? + (s_Do__TSource__3__5 = new Func, Expression>, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onCompleted) { if (source == null) @@ -455,13 +523,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, onNext, onCompleted)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__3__5(typeof(TSource)), source.Expression, onNext, onCompleted)); } + private static MethodInfo s_Do__TSource__4__0; + + private static MethodInfo Do__TSource__4__0(Type TSource) => + (s_Do__TSource__4__0 ?? + (s_Do__TSource__4__0 = new Func, Expression>, Expression>, Action, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Action onCompleted) { if (source == null) @@ -473,13 +543,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Action))), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__4__0(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action)))); } + private static MethodInfo s_Do__TSource__4__1; + + private static MethodInfo Do__TSource__4__1(Type TSource) => + (s_Do__TSource__4__1 ?? + (s_Do__TSource__4__1 = new Func, Expression>, Expression>, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) { if (source == null) @@ -491,13 +563,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__4__1(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); } + private static MethodInfo s_Do__TSource__4__2; + + private static MethodInfo Do__TSource__4__2(Type TSource) => + (s_Do__TSource__4__2 ?? + (s_Do__TSource__4__2 = new Func, Expression>, Expression>, Expression>, IAsyncQueryable>(Do).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Do(this IAsyncQueryable source, Expression> onNext, Expression> onError, Expression> onCompleted) { if (source == null) @@ -509,13 +583,15 @@ public static IAsyncQueryable Do(this IAsyncQueryable if (onCompleted == null) throw new ArgumentNullException(nameof(onCompleted)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Do(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression>))), source.Expression, onNext, onError, onCompleted)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); -#endif + return source.Provider.CreateQuery(Expression.Call(Do__TSource__4__2(typeof(TSource)), source.Expression, onNext, onError, onCompleted)); } + private static MethodInfo s_Expand__TSource__2__0; + + private static MethodInfo Expand__TSource__2__0(Type TSource) => + (s_Expand__TSource__2__0 ?? + (s_Expand__TSource__2__0 = new Func, Expression>>>, IAsyncQueryable>(Expand).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) { if (source == null) @@ -523,13 +599,15 @@ public static IAsyncQueryable Expand(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Expand__TSource__2__0(typeof(TSource)), source.Expression, selector)); } + private static MethodInfo s_Expand__TSource__2__1; + + private static MethodInfo Expand__TSource__2__1(Type TSource) => + (s_Expand__TSource__2__1 ?? + (s_Expand__TSource__2__1 = new Func, Expression>>, IAsyncQueryable>(Expand).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -537,13 +615,15 @@ public static IAsyncQueryable Expand(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Expand__TSource__2__1(typeof(TSource)), source.Expression, selector)); } + private static MethodInfo s_Expand__TSource__2__2; + + private static MethodInfo Expand__TSource__2__2(Type TSource) => + (s_Expand__TSource__2__2 ?? + (s_Expand__TSource__2__2 = new Func, Expression>>>, IAsyncQueryable>(Expand).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Expand(this IAsyncQueryable source, Expression>>> selector) { if (source == null) @@ -551,13 +631,15 @@ public static IAsyncQueryable Expand(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Expand__TSource__2__2(typeof(TSource)), source.Expression, selector)); } + private static MethodInfo s_Finally__TSource__2__0; + + private static MethodInfo Finally__TSource__2__0(Type TSource) => + (s_Finally__TSource__2__0 ?? + (s_Finally__TSource__2__0 = new Func, Action, IAsyncQueryable>(Finally).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Finally(this IAsyncQueryable source, Action finallyAction) { if (source == null) @@ -565,13 +647,15 @@ public static IAsyncQueryable Finally(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Finally(default(IAsyncQueryable), default(Action))), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Finally__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action)))); } + private static MethodInfo s_Finally__TSource__2__1; + + private static MethodInfo Finally__TSource__2__1(Type TSource) => + (s_Finally__TSource__2__1 ?? + (s_Finally__TSource__2__1 = new Func, Expression>, IAsyncQueryable>(Finally).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Finally(this IAsyncQueryable source, Expression> finallyAction) { if (source == null) @@ -579,49 +663,57 @@ public static IAsyncQueryable Finally(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Finally(default(IAsyncQueryable), default(Expression>))), source.Expression, finallyAction)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, finallyAction)); -#endif + return source.Provider.CreateQuery(Expression.Call(Finally__TSource__2__1(typeof(TSource)), source.Expression, finallyAction)); } + private static MethodInfo s_IgnoreElements__TSource__1__0; + + private static MethodInfo IgnoreElements__TSource__1__0(Type TSource) => + (s_IgnoreElements__TSource__1__0 ?? + (s_IgnoreElements__TSource__1__0 = new Func, IAsyncQueryable>(IgnoreElements).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable IgnoreElements(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.IgnoreElements(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(IgnoreElements__TSource__1__0(typeof(TSource)), source.Expression)); } + private static MethodInfo s_IsEmptyAsync__TSource__2__0; + + private static MethodInfo IsEmptyAsync__TSource__2__0(Type TSource) => + (s_IsEmptyAsync__TSource__2__0 ?? + (s_IsEmptyAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(IsEmptyAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask IsEmptyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmptyAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(IsEmptyAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__0; + + private static MethodInfo MaxAsync__TSource__3__0(Type TSource) => + (s_MaxAsync__TSource__3__0 ?? + (s_MaxAsync__TSource__3__0 = new Func, IComparer, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxAsync(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxByAsync__TSource_TKey__3__0; + + private static MethodInfo MaxByAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_MaxByAsync__TSource_TKey__3__0 ?? + (s_MaxByAsync__TSource_TKey__3__0 = new Func, Expression>>, CancellationToken, ValueTask>>(MaxByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -629,13 +721,15 @@ public static ValueTask> MaxByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MaxByAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxByAsync__TSource_TKey__3__1; + + private static MethodInfo MaxByAsync__TSource_TKey__3__1(Type TSource, Type TKey) => + (s_MaxByAsync__TSource_TKey__3__1 ?? + (s_MaxByAsync__TSource_TKey__3__1 = new Func, Expression>, CancellationToken, ValueTask>>(MaxByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -643,13 +737,15 @@ public static ValueTask> MaxByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MaxByAsync__TSource_TKey__3__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxByAsync__TSource_TKey__3__2; + + private static MethodInfo MaxByAsync__TSource_TKey__3__2(Type TSource, Type TKey) => + (s_MaxByAsync__TSource_TKey__3__2 ?? + (s_MaxByAsync__TSource_TKey__3__2 = new Func, Expression>>, CancellationToken, ValueTask>>(MaxByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -657,13 +753,15 @@ public static ValueTask> MaxByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MaxByAsync__TSource_TKey__3__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxByAsync__TSource_TKey__4__0; + + private static MethodInfo MaxByAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_MaxByAsync__TSource_TKey__4__0 ?? + (s_MaxByAsync__TSource_TKey__4__0 = new Func, Expression>>, IComparer, CancellationToken, ValueTask>>(MaxByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -671,13 +769,15 @@ public static ValueTask> MaxByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MaxByAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxByAsync__TSource_TKey__4__1; + + private static MethodInfo MaxByAsync__TSource_TKey__4__1(Type TSource, Type TKey) => + (s_MaxByAsync__TSource_TKey__4__1 ?? + (s_MaxByAsync__TSource_TKey__4__1 = new Func, Expression>, IComparer, CancellationToken, ValueTask>>(MaxByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -685,13 +785,15 @@ public static ValueTask> MaxByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MaxByAsync__TSource_TKey__4__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxByAsync__TSource_TKey__4__2; + + private static MethodInfo MaxByAsync__TSource_TKey__4__2(Type TSource, Type TKey) => + (s_MaxByAsync__TSource_TKey__4__2 ?? + (s_MaxByAsync__TSource_TKey__4__2 = new Func, Expression>>, IComparer, CancellationToken, ValueTask>>(MaxByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MaxByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -699,37 +801,43 @@ public static ValueTask> MaxByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MaxByAsync__TSource_TKey__4__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_Merge__TSource__1__0; + + private static MethodInfo Merge__TSource__1__0(Type TSource) => + (s_Merge__TSource__1__0 ?? + (s_Merge__TSource__1__0 = new Func>, IAsyncQueryable>(Merge).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Merge(this IAsyncQueryable> sources) { if (sources == null) throw new ArgumentNullException(nameof(sources)); -#if CRIPPLED_REFLECTION - return sources.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Merge(default(IAsyncQueryable>))), sources.Expression)); -#else - return sources.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), sources.Expression)); -#endif + return sources.Provider.CreateQuery(Expression.Call(Merge__TSource__1__0(typeof(TSource)), sources.Expression)); } + private static MethodInfo s_MinAsync__TSource__3__0; + + private static MethodInfo MinAsync__TSource__3__0(Type TSource) => + (s_MinAsync__TSource__3__0 ?? + (s_MinAsync__TSource__3__0 = new Func, IComparer, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryableEx.MinAsync(default(IAsyncQueryable), default(IComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinByAsync__TSource_TKey__3__0; + + private static MethodInfo MinByAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_MinByAsync__TSource_TKey__3__0 ?? + (s_MinByAsync__TSource_TKey__3__0 = new Func, Expression>>, CancellationToken, ValueTask>>(MinByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -737,13 +845,15 @@ public static ValueTask> MinByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MinByAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinByAsync__TSource_TKey__3__1; + + private static MethodInfo MinByAsync__TSource_TKey__3__1(Type TSource, Type TKey) => + (s_MinByAsync__TSource_TKey__3__1 ?? + (s_MinByAsync__TSource_TKey__3__1 = new Func, Expression>, CancellationToken, ValueTask>>(MinByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -751,13 +861,15 @@ public static ValueTask> MinByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MinByAsync__TSource_TKey__3__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinByAsync__TSource_TKey__3__2; + + private static MethodInfo MinByAsync__TSource_TKey__3__2(Type TSource, Type TKey) => + (s_MinByAsync__TSource_TKey__3__2 ?? + (s_MinByAsync__TSource_TKey__3__2 = new Func, Expression>>, CancellationToken, ValueTask>>(MinByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -765,13 +877,15 @@ public static ValueTask> MinByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MinByAsync__TSource_TKey__3__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinByAsync__TSource_TKey__4__0; + + private static MethodInfo MinByAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_MinByAsync__TSource_TKey__4__0 ?? + (s_MinByAsync__TSource_TKey__4__0 = new Func, Expression>>, IComparer, CancellationToken, ValueTask>>(MinByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -779,13 +893,15 @@ public static ValueTask> MinByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MinByAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinByAsync__TSource_TKey__4__1; + + private static MethodInfo MinByAsync__TSource_TKey__4__1(Type TSource, Type TKey) => + (s_MinByAsync__TSource_TKey__4__1 ?? + (s_MinByAsync__TSource_TKey__4__1 = new Func, Expression>, IComparer, CancellationToken, ValueTask>>(MinByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -793,13 +909,15 @@ public static ValueTask> MinByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MinByAsync__TSource_TKey__4__1(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinByAsync__TSource_TKey__4__2; + + private static MethodInfo MinByAsync__TSource_TKey__4__2(Type TSource, Type TKey) => + (s_MinByAsync__TSource_TKey__4__2 ?? + (s_MinByAsync__TSource_TKey__4__2 = new Func, Expression>>, IComparer, CancellationToken, ValueTask>>(MinByAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> MinByAsync(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -807,13 +925,15 @@ public static ValueTask> MinByAsync(this IAsyncQue if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinByAsync(default(IAsyncQueryable), default(Expression>>), default(IComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(MinByAsync__TSource_TKey__4__2(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_OnErrorResumeNext__TSource__2__0; + + private static MethodInfo OnErrorResumeNext__TSource__2__0(Type TSource) => + (s_OnErrorResumeNext__TSource__2__0 ?? + (s_OnErrorResumeNext__TSource__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(OnErrorResumeNext).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable OnErrorResumeNext(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -821,61 +941,71 @@ public static IAsyncQueryable OnErrorResumeNext(this IAsyncQue if (second == null) throw new ArgumentNullException(nameof(second)); -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.OnErrorResumeNext(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery(Expression.Call(OnErrorResumeNext__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } + private static MethodInfo s_Repeat__TSource__1__0; + + private static MethodInfo Repeat__TSource__1__0(Type TSource) => + (s_Repeat__TSource__1__0 ?? + (s_Repeat__TSource__1__0 = new Func, IAsyncQueryable>(Repeat).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Repeat(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Repeat(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(Repeat__TSource__1__0(typeof(TSource)), source.Expression)); } + private static MethodInfo s_Repeat__TSource__2__0; + + private static MethodInfo Repeat__TSource__2__0(Type TSource) => + (s_Repeat__TSource__2__0 ?? + (s_Repeat__TSource__2__0 = new Func, int, IAsyncQueryable>(Repeat).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Repeat(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Repeat(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Repeat__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } + private static MethodInfo s_Retry__TSource__1__0; + + private static MethodInfo Retry__TSource__1__0(Type TSource) => + (s_Retry__TSource__1__0 ?? + (s_Retry__TSource__1__0 = new Func, IAsyncQueryable>(Retry).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Retry(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Retry(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(Retry__TSource__1__0(typeof(TSource)), source.Expression)); } + private static MethodInfo s_Retry__TSource__2__0; + + private static MethodInfo Retry__TSource__2__0(Type TSource) => + (s_Retry__TSource__2__0 ?? + (s_Retry__TSource__2__0 = new Func, int, IAsyncQueryable>(Retry).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Retry(this IAsyncQueryable source, int retryCount) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Retry(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(retryCount, typeof(int)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Retry__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int)))); } + private static MethodInfo s_Scan__TSource__2__0; + + private static MethodInfo Scan__TSource__2__0(Type TSource) => + (s_Scan__TSource__2__0 ?? + (s_Scan__TSource__2__0 = new Func, Expression>>, IAsyncQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) @@ -883,13 +1013,15 @@ public static IAsyncQueryable Scan(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); -#endif + return source.Provider.CreateQuery(Expression.Call(Scan__TSource__2__0(typeof(TSource)), source.Expression, accumulator)); } + private static MethodInfo s_Scan__TSource__2__1; + + private static MethodInfo Scan__TSource__2__1(Type TSource) => + (s_Scan__TSource__2__1 ?? + (s_Scan__TSource__2__1 = new Func, Expression>, IAsyncQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression> accumulator) { if (source == null) @@ -897,13 +1029,15 @@ public static IAsyncQueryable Scan(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>))), source.Expression, accumulator)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); -#endif + return source.Provider.CreateQuery(Expression.Call(Scan__TSource__2__1(typeof(TSource)), source.Expression, accumulator)); } + private static MethodInfo s_Scan__TSource__2__2; + + private static MethodInfo Scan__TSource__2__2(Type TSource) => + (s_Scan__TSource__2__2 ?? + (s_Scan__TSource__2__2 = new Func, Expression>>, IAsyncQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Scan(this IAsyncQueryable source, Expression>> accumulator) { if (source == null) @@ -911,13 +1045,15 @@ public static IAsyncQueryable Scan(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(Expression>>))), source.Expression, accumulator)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator)); -#endif + return source.Provider.CreateQuery(Expression.Call(Scan__TSource__2__2(typeof(TSource)), source.Expression, accumulator)); } + private static MethodInfo s_Scan__TSource_TAccumulate__3__0; + + private static MethodInfo Scan__TSource_TAccumulate__3__0(Type TSource, Type TAccumulate) => + (s_Scan__TSource_TAccumulate__3__0 ?? + (s_Scan__TSource_TAccumulate__3__0 = new Func, object, Expression>>, IAsyncQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate); + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) { if (source == null) @@ -925,13 +1061,15 @@ public static IAsyncQueryable Scan(this IAsyn if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); -#endif + return source.Provider.CreateQuery(Expression.Call(Scan__TSource_TAccumulate__3__0(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); } + private static MethodInfo s_Scan__TSource_TAccumulate__3__1; + + private static MethodInfo Scan__TSource_TAccumulate__3__1(Type TSource, Type TAccumulate) => + (s_Scan__TSource_TAccumulate__3__1 ?? + (s_Scan__TSource_TAccumulate__3__1 = new Func, object, Expression>, IAsyncQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate); + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator) { if (source == null) @@ -939,13 +1077,15 @@ public static IAsyncQueryable Scan(this IAsyn if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); -#endif + return source.Provider.CreateQuery(Expression.Call(Scan__TSource_TAccumulate__3__1(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); } + private static MethodInfo s_Scan__TSource_TAccumulate__3__2; + + private static MethodInfo Scan__TSource_TAccumulate__3__2(Type TSource, Type TAccumulate) => + (s_Scan__TSource_TAccumulate__3__2 ?? + (s_Scan__TSource_TAccumulate__3__2 = new Func, object, Expression>>, IAsyncQueryable>(Scan).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate); + public static IAsyncQueryable Scan(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator) { if (source == null) @@ -953,13 +1093,15 @@ public static IAsyncQueryable Scan(this IAsyn if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan(default(IAsyncQueryable), default(TAccumulate), default(Expression>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); -#endif + return source.Provider.CreateQuery(Expression.Call(Scan__TSource_TAccumulate__3__2(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator)); } + private static MethodInfo s_SelectMany__TSource_TOther__2__0; + + private static MethodInfo SelectMany__TSource_TOther__2__0(Type TSource, Type TOther) => + (s_SelectMany__TSource_TOther__2__0 ?? + (s_SelectMany__TSource_TOther__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(SelectMany).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TOther); + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, IAsyncEnumerable other) { if (source == null) @@ -967,13 +1109,15 @@ public static IAsyncQueryable SelectMany(this IAsyncQue if (other == null) throw new ArgumentNullException(nameof(other)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.SelectMany(default(IAsyncQueryable), default(IAsyncEnumerable))), source.Expression, GetSourceExpression(other))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other))); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectMany__TSource_TOther__2__0(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other))); } + private static MethodInfo s_StartWith__TSource__2__0; + + private static MethodInfo StartWith__TSource__2__0(Type TSource) => + (s_StartWith__TSource__2__0 ?? + (s_StartWith__TSource__2__0 = new Func, object[], IAsyncQueryable>(StartWith).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable StartWith(this IAsyncQueryable source, params TSource[] values) { if (source == null) @@ -981,24 +1125,22 @@ public static IAsyncQueryable StartWith(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryableEx.StartWith(default(IAsyncQueryable), default(TSource[]))), source.Expression, Expression.Constant(values, typeof(TSource[])))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[])))); -#endif + return source.Provider.CreateQuery(Expression.Call(StartWith__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[])))); } + private static MethodInfo s_Timeout__TSource__2__0; + + private static MethodInfo Timeout__TSource__2__0(Type TSource) => + (s_Timeout__TSource__2__0 ?? + (s_Timeout__TSource__2__0 = new Func, TimeSpan, IAsyncQueryable>(Timeout).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Timeout(this IAsyncQueryable source, TimeSpan timeout) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryableEx.Timeout(default(IAsyncQueryable), default(TimeSpan))), source.Expression, Expression.Constant(timeout, typeof(TimeSpan)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(timeout, typeof(TimeSpan)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Timeout__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(timeout, typeof(TimeSpan)))); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt index 75c0d4238e..2580817564 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.Generated.tt @@ -3,293 +3,14 @@ // See the LICENSE file in the project root for more information. <#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ assembly name="System.Runtime" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Interactive.Async\bin\$(Configuration)\net46\System.Interactive.Async.dll" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Threading" #> -<#@ import namespace="System.Threading.Tasks" #> -<#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# +var asyncEnumerableType = typeof(AsyncEnumerableEx); +var className = "AsyncQueryableEx"; var nullableParameterNames = new[] { "comparer" }; -var exclude = new[] { "ForEach", "ForEachAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable" }; - -var toQuotedImpl = default(Func); -toQuotedImpl = (t, i, b) => -{ -var name = t.Name; - -if (t.IsGenericType) -{ - var genDef = t.GetGenericTypeDefinition(); - name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); - - var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; - - if (b) - { - if (name == "Func" || name == "Action") - { - name = "Expression<" + name + genArgs + ">"; - } - else if (name == "IAsyncEnumerable" && i == 0) - { - name = "IAsyncQueryable" + genArgs; - } - else if (name == "IOrderedAsyncEnumerable" && i == 0) - { - name = "IOrderedAsyncQueryable" + genArgs; - } - else - { - name += genArgs; - } - } - else - { - if (name == "Nullable") - { - name = genArgs.Substring(1, genArgs.Length - 2) + "?"; - } - else - { - name += genArgs; - } - } -} -else if (t.IsArray) -{ - var elem = toQuotedImpl(t.GetElementType(), i, b); - name = elem + "[]"; -} -else -{ - if (t == typeof(int)) - { - name = "int"; - } - else if (t == typeof(long)) - { - name = "long"; - } - else if (t == typeof(float)) - { - name = "float"; - } - else if (t == typeof(double)) - { - name = "double"; - } - else if (t == typeof(decimal)) - { - name = "decimal"; - } - else if (t == typeof(bool)) - { - name = "bool"; - } - else if (t == typeof(object)) - { - name = "object"; - } -} - -return name; -}; - -var toQuoted = new Func((t, i) => toQuotedImpl(t, i, true)); -#> -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncQueryableEx - { -<# -// NOTE: Just including extension methods -foreach (var m in typeof(AsyncEnumerableEx).GetMethods() - .Where(m => m.IsStatic) - .Where(m => !exclude.Contains(m.Name)) - .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - .Where(m => - { - var p0 = m.GetParameters()[0].ParameterType; - if (p0.IsGenericType) - { - var p0d = p0.GetGenericTypeDefinition(); - return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); - } - - return false; - }) - .OrderBy(m => m.Name) - .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) - .ThenBy(m => m.GetParameters().Length) - .ThenBy(m => string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i) + " " + p.Name)))) -{ - var genArgs = m.GetGenericArguments(); - - var ret = toQuoted(m.ReturnType, 0); - var name = m.Name; - - if (genArgs.Length > 0) - { - name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; - } - - var isParams = false; - var lastParameterDefault = false; - var parCount = m.GetParameters().Length; - - if (parCount != 0) - { - var lastParam = m.GetParameters().Last(); - - if (lastParam.IsDefined(typeof(ParamArrayAttribute), true)) - { - isParams = true; - } - - if (lastParam.ParameterType == typeof(CancellationToken)) - { - lastParameterDefault = true; - } - } - - var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name + (i == parCount - 1 && lastParameterDefault ? " = default" : ""))); - var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); - - if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - { - pars = "this " + pars; - } - - var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; - - if (m.IsGenericMethod) - { - mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; - } - - var provider = m.GetParameters()[0].Name + ".Provider"; - var factory = ""; - var rem = ""; - var cast = ""; - var quotedArgs = new List(); - - if (m.ReturnType.IsGenericType) - { - var td = m.ReturnType.GetGenericTypeDefinition(); - - if (td.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask - { - factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - - var last = m.GetParameters().Last(); - if (last.ParameterType == typeof(CancellationToken)) - { - rem = ", " + last.Name; - } - else - { - rem = ", CancellationToken.None"; - } - } - else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) - { - factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - - if (td == typeof(IOrderedAsyncEnumerable<>)) - { - cast = "(" + toQuoted(m.ReturnType, 0) + ")"; - } - } - } - - var n = 0; - foreach (var p in m.GetParameters()) - { - var pt = p.ParameterType; - - var add = false; - - if (pt.IsGenericType) - { - var ptd = pt.GetGenericTypeDefinition(); - - if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) - { - if (n == 0) - { - quotedArgs.Add(p.Name + ".Expression"); - } - else - { - quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); - } - add = true; - } - else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) - { - quotedArgs.Add(p.Name); - add = true; - } - } - - if (!add) - { - quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); - } - - n++; - } - - var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; - - var infoofmtd = "InfoOf(() => AsyncQueryableEx." + name + "(" + quotedPars + "))"; - var infoofexpr = "Expression.Call(" + infoofmtd + ", " + string.Join(", ", quotedArgs) + ")"; -#> - public static <#=ret#> <#=name#>(<#=pars#>) - { -<# -var any = false; -foreach (var p in m.GetParameters()) -{ - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) - { - any = true; -#> - if (<#=p.Name#> == null) - throw new ArgumentNullException(nameof(<#=p.Name#>)); -<# - } -} -#> -<# -if (any) -{ -#> - -<# -} -#> -#if CRIPPLED_REFLECTION - return <#=cast#><#=provider#>.<#=factory#>(<#=infoofexpr#><#=rem#>); -#else - return <#=cast#><#=provider#>.<#=factory#>(<#=expr#><#=rem#>); -#endif - } - -<# -} +var exclude = new string[0]; #> - } -} \ No newline at end of file +<#@ include file="$(SolutionDir)\AsyncQueryableGenerator.t4" #> diff --git a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs index ba1b2bbac0..90f3dd7e91 100644 --- a/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs +++ b/Ix.NET/Source/System.Interactive.Async.Providers/System/Linq/AsyncQueryableEx.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq.Expressions; -using System.Reflection; namespace System.Linq { @@ -23,10 +22,5 @@ private static Expression GetSourceExpression(IAsyncEnumerable return Expression.Constant(source, typeof(IAsyncEnumerable)); } - - internal static MethodInfo InfoOf(Expression> f) - { - return ((MethodCallExpression)f.Body).Method; - } } } diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs index da57fd0ac2..d8c9ff5f37 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.cs @@ -12,6 +12,12 @@ namespace System.Linq { public static partial class AsyncQueryable { + private static MethodInfo s_AggregateAsync__TSource__3__0; + + private static MethodInfo AggregateAsync__TSource__3__0(Type TSource) => + (s_AggregateAsync__TSource__3__0 ?? + (s_AggregateAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(AggregateAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AggregateAsync(this IAsyncQueryable source, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) @@ -19,13 +25,15 @@ public static ValueTask AggregateAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAsync__TSource__3__0(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAsync__TSource_TAccumulate__4__0; + + private static MethodInfo AggregateAsync__TSource_TAccumulate__4__0(Type TSource, Type TAccumulate) => + (s_AggregateAsync__TSource_TAccumulate__4__0 ?? + (s_AggregateAsync__TSource_TAccumulate__4__0 = new Func, object, Expression>, CancellationToken, ValueTask>(AggregateAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate); + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, CancellationToken cancellationToken = default) { if (source == null) @@ -33,13 +41,15 @@ public static ValueTask AggregateAsync(this I if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAsync__TSource_TAccumulate__4__0(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAsync__TSource_TAccumulate_TResult__5__0; + + private static MethodInfo AggregateAsync__TSource_TAccumulate_TResult__5__0(Type TSource, Type TAccumulate, Type TResult) => + (s_AggregateAsync__TSource_TAccumulate_TResult__5__0 ?? + (s_AggregateAsync__TSource_TAccumulate_TResult__5__0 = new Func, object, Expression>, Expression>, CancellationToken, ValueTask>(AggregateAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate, TResult); + public static ValueTask AggregateAsync(this IAsyncQueryable source, TAccumulate seed, Expression> accumulator, Expression> resultSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -49,13 +59,15 @@ public static ValueTask AggregateAsync(t if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAsync__TSource_TAccumulate_TResult__5__0(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAwaitAsync__TSource__3__0; + + private static MethodInfo AggregateAwaitAsync__TSource__3__0(Type TSource) => + (s_AggregateAwaitAsync__TSource__3__0 ?? + (s_AggregateAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AggregateAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AggregateAwaitAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) @@ -63,13 +75,15 @@ public static ValueTask AggregateAwaitAsync(this IAsyncQueryab if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAwaitAsync__TSource_TAccumulate__4__0; + + private static MethodInfo AggregateAwaitAsync__TSource_TAccumulate__4__0(Type TSource, Type TAccumulate) => + (s_AggregateAwaitAsync__TSource_TAccumulate__4__0 ?? + (s_AggregateAwaitAsync__TSource_TAccumulate__4__0 = new Func, object, Expression>>, CancellationToken, ValueTask>(AggregateAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate); + public static ValueTask AggregateAwaitAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) @@ -77,13 +91,15 @@ public static ValueTask AggregateAwaitAsync(t if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAwaitAsync__TSource_TAccumulate__4__0(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAwaitAsync__TSource_TAccumulate_TResult__5__0; + + private static MethodInfo AggregateAwaitAsync__TSource_TAccumulate_TResult__5__0(Type TSource, Type TAccumulate, Type TResult) => + (s_AggregateAwaitAsync__TSource_TAccumulate_TResult__5__0 ?? + (s_AggregateAwaitAsync__TSource_TAccumulate_TResult__5__0 = new Func, object, Expression>>, Expression>>, CancellationToken, ValueTask>(AggregateAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate, TResult); + public static ValueTask AggregateAwaitAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -93,13 +109,15 @@ public static ValueTask AggregateAwaitAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAwaitAsync__TSource_TAccumulate_TResult__5__0(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo AggregateAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_AggregateAwaitWithCancellationAsync__TSource__3__0 ?? + (s_AggregateAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AggregateAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) @@ -107,13 +125,15 @@ public static ValueTask AggregateAwaitWithCancellationAsync(th if (accumulator == null) throw new ArgumentNullException(nameof(accumulator)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAwaitWithCancellationAsync__TSource_TAccumulate__4__0; + + private static MethodInfo AggregateAwaitWithCancellationAsync__TSource_TAccumulate__4__0(Type TSource, Type TAccumulate) => + (s_AggregateAwaitWithCancellationAsync__TSource_TAccumulate__4__0 ?? + (s_AggregateAwaitWithCancellationAsync__TSource_TAccumulate__4__0 = new Func, object, Expression>>, CancellationToken, ValueTask>(AggregateAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, CancellationToken cancellationToken = default) { if (source == null) @@ -121,13 +141,15 @@ public static ValueTask AggregateAwaitWithCancellationAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAwaitWithCancellationAsync__TSource_TAccumulate__4__0(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AggregateAwaitWithCancellationAsync__TSource_TAccumulate_TResult__5__0; + + private static MethodInfo AggregateAwaitWithCancellationAsync__TSource_TAccumulate_TResult__5__0(Type TSource, Type TAccumulate, Type TResult) => + (s_AggregateAwaitWithCancellationAsync__TSource_TAccumulate_TResult__5__0 ?? + (s_AggregateAwaitWithCancellationAsync__TSource_TAccumulate_TResult__5__0 = new Func, object, Expression>>, Expression>>, CancellationToken, ValueTask>(AggregateAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TAccumulate, TResult); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncQueryable source, TAccumulate seed, Expression>> accumulator, Expression>> resultSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -137,13 +159,15 @@ public static ValueTask AggregateAwaitWithCancellationAsync(Expression.Call(InfoOf(() => AsyncQueryable.AggregateAwaitWithCancellationAsync(default(IAsyncQueryable), default(TAccumulate), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AggregateAwaitWithCancellationAsync__TSource_TAccumulate_TResult__5__0(typeof(TSource), typeof(TAccumulate), typeof(TResult)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator, resultSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AllAsync__TSource__3__0; + + private static MethodInfo AllAsync__TSource__3__0(Type TSource) => + (s_AllAsync__TSource__3__0 ?? + (s_AllAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(AllAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AllAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -151,13 +175,15 @@ public static ValueTask AllAsync(this IAsyncQueryable so if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AllAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AllAwaitAsync__TSource__3__0; + + private static MethodInfo AllAwaitAsync__TSource__3__0(Type TSource) => + (s_AllAwaitAsync__TSource__3__0 ?? + (s_AllAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AllAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AllAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -165,13 +191,15 @@ public static ValueTask AllAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AllAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AllAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AllAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo AllAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_AllAwaitWithCancellationAsync__TSource__3__0 ?? + (s_AllAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AllAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AllAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -179,25 +207,29 @@ public static ValueTask AllAwaitWithCancellationAsync(this IAsync if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AllAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AllAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AnyAsync__TSource__2__0; + + private static MethodInfo AnyAsync__TSource__2__0(Type TSource) => + (s_AnyAsync__TSource__2__0 ?? + (s_AnyAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(AnyAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AnyAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AnyAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AnyAsync__TSource__3__0; + + private static MethodInfo AnyAsync__TSource__3__0(Type TSource) => + (s_AnyAsync__TSource__3__0 ?? + (s_AnyAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(AnyAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AnyAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -205,13 +237,15 @@ public static ValueTask AnyAsync(this IAsyncQueryable so if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AnyAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AnyAwaitAsync__TSource__3__0; + + private static MethodInfo AnyAwaitAsync__TSource__3__0(Type TSource) => + (s_AnyAwaitAsync__TSource__3__0 ?? + (s_AnyAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AnyAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AnyAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -219,13 +253,15 @@ public static ValueTask AnyAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AnyAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AnyAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AnyAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo AnyAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_AnyAwaitWithCancellationAsync__TSource__3__0 ?? + (s_AnyAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AnyAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AnyAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -233,145 +269,169 @@ public static ValueTask AnyAwaitWithCancellationAsync(this IAsync if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AnyAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AnyAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_Append__TSource__2__0; + + private static MethodInfo Append__TSource__2__0(Type TSource) => + (s_Append__TSource__2__0 ?? + (s_Append__TSource__2__0 = new Func, object, IAsyncQueryable>(Append).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Append(this IAsyncQueryable source, TSource element) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Append(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Append__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); } + private static MethodInfo s_AverageAsync__2__0; + + private static MethodInfo AverageAsync__2__0 => + (s_AverageAsync__2__0 ?? + (s_AverageAsync__2__0 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__0, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__1; + + private static MethodInfo AverageAsync__2__1 => + (s_AverageAsync__2__1 ?? + (s_AverageAsync__2__1 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__1, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__2; + + private static MethodInfo AverageAsync__2__2 => + (s_AverageAsync__2__2 ?? + (s_AverageAsync__2__2 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__2, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__3; + + private static MethodInfo AverageAsync__2__3 => + (s_AverageAsync__2__3 ?? + (s_AverageAsync__2__3 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__3, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__4; + + private static MethodInfo AverageAsync__2__4 => + (s_AverageAsync__2__4 ?? + (s_AverageAsync__2__4 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__4, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__5; + + private static MethodInfo AverageAsync__2__5 => + (s_AverageAsync__2__5 ?? + (s_AverageAsync__2__5 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__5, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__6; + + private static MethodInfo AverageAsync__2__6 => + (s_AverageAsync__2__6 ?? + (s_AverageAsync__2__6 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__6, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__7; + + private static MethodInfo AverageAsync__2__7 => + (s_AverageAsync__2__7 ?? + (s_AverageAsync__2__7 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__7, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__8; + + private static MethodInfo AverageAsync__2__8 => + (s_AverageAsync__2__8 ?? + (s_AverageAsync__2__8 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__8, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__2__9; + + private static MethodInfo AverageAsync__2__9 => + (s_AverageAsync__2__9 ?? + (s_AverageAsync__2__9 = new Func, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo())); + public static ValueTask AverageAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__2__9, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__0; + + private static MethodInfo AverageAsync__TSource__3__0(Type TSource) => + (s_AverageAsync__TSource__3__0 ?? + (s_AverageAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -379,13 +439,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable source, if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__1; + + private static MethodInfo AverageAsync__TSource__3__1(Type TSource) => + (s_AverageAsync__TSource__3__1 ?? + (s_AverageAsync__TSource__3__1 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -393,13 +455,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__2; + + private static MethodInfo AverageAsync__TSource__3__2(Type TSource) => + (s_AverageAsync__TSource__3__2 ?? + (s_AverageAsync__TSource__3__2 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -407,13 +471,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__3; + + private static MethodInfo AverageAsync__TSource__3__3(Type TSource) => + (s_AverageAsync__TSource__3__3 ?? + (s_AverageAsync__TSource__3__3 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -421,13 +487,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__4; + + private static MethodInfo AverageAsync__TSource__3__4(Type TSource) => + (s_AverageAsync__TSource__3__4 ?? + (s_AverageAsync__TSource__3__4 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -435,13 +503,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__5; + + private static MethodInfo AverageAsync__TSource__3__5(Type TSource) => + (s_AverageAsync__TSource__3__5 ?? + (s_AverageAsync__TSource__3__5 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -449,13 +519,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__6; + + private static MethodInfo AverageAsync__TSource__3__6(Type TSource) => + (s_AverageAsync__TSource__3__6 ?? + (s_AverageAsync__TSource__3__6 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -463,13 +535,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__7; + + private static MethodInfo AverageAsync__TSource__3__7(Type TSource) => + (s_AverageAsync__TSource__3__7 ?? + (s_AverageAsync__TSource__3__7 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -477,13 +551,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__8; + + private static MethodInfo AverageAsync__TSource__3__8(Type TSource) => + (s_AverageAsync__TSource__3__8 ?? + (s_AverageAsync__TSource__3__8 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -491,13 +567,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAsync__TSource__3__9; + + private static MethodInfo AverageAsync__TSource__3__9(Type TSource) => + (s_AverageAsync__TSource__3__9 ?? + (s_AverageAsync__TSource__3__9 = new Func, Expression>, CancellationToken, ValueTask>(AverageAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -505,13 +583,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__0; + + private static MethodInfo AverageAwaitAsync__TSource__3__0(Type TSource) => + (s_AverageAwaitAsync__TSource__3__0 ?? + (s_AverageAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -519,13 +599,15 @@ public static ValueTask AverageAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__1; + + private static MethodInfo AverageAwaitAsync__TSource__3__1(Type TSource) => + (s_AverageAwaitAsync__TSource__3__1 ?? + (s_AverageAwaitAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -533,13 +615,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__2; + + private static MethodInfo AverageAwaitAsync__TSource__3__2(Type TSource) => + (s_AverageAwaitAsync__TSource__3__2 ?? + (s_AverageAwaitAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -547,13 +631,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__3; + + private static MethodInfo AverageAwaitAsync__TSource__3__3(Type TSource) => + (s_AverageAwaitAsync__TSource__3__3 ?? + (s_AverageAwaitAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -561,13 +647,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable< if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__4; + + private static MethodInfo AverageAwaitAsync__TSource__3__4(Type TSource) => + (s_AverageAwaitAsync__TSource__3__4 ?? + (s_AverageAwaitAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -575,13 +663,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable< if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__5; + + private static MethodInfo AverageAwaitAsync__TSource__3__5(Type TSource) => + (s_AverageAwaitAsync__TSource__3__5 ?? + (s_AverageAwaitAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -589,13 +679,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__6; + + private static MethodInfo AverageAwaitAsync__TSource__3__6(Type TSource) => + (s_AverageAwaitAsync__TSource__3__6 ?? + (s_AverageAwaitAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -603,13 +695,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__7; + + private static MethodInfo AverageAwaitAsync__TSource__3__7(Type TSource) => + (s_AverageAwaitAsync__TSource__3__7 ?? + (s_AverageAwaitAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -617,13 +711,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable< if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__8; + + private static MethodInfo AverageAwaitAsync__TSource__3__8(Type TSource) => + (s_AverageAwaitAsync__TSource__3__8 ?? + (s_AverageAwaitAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -631,13 +727,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable< if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitAsync__TSource__3__9; + + private static MethodInfo AverageAwaitAsync__TSource__3__9(Type TSource) => + (s_AverageAwaitAsync__TSource__3__9 ?? + (s_AverageAwaitAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -645,13 +743,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable< if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__0 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -659,13 +759,15 @@ public static ValueTask AverageAwaitAsync(this IAsyncQueryable< if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__1; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__1(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__1 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -673,13 +775,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__2; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__2(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__2 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -687,13 +791,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__3; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__3(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__3 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -701,13 +807,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__4; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__4(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__4 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -715,13 +823,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__5; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__5(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__5 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -729,13 +839,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this I if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__6; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__6(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__6 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -743,13 +855,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this I if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__7; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__7(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__7 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -757,13 +871,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__8; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__8(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__8 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -771,13 +887,15 @@ public static ValueTask AverageAwaitWithCancellationAsync(this if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_AverageAwaitWithCancellationAsync__TSource__3__9; + + private static MethodInfo AverageAwaitWithCancellationAsync__TSource__3__9(Type TSource) => + (s_AverageAwaitWithCancellationAsync__TSource__3__9 ?? + (s_AverageAwaitWithCancellationAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(AverageAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -785,25 +903,29 @@ public static ValueTask AverageAwaitWithCancellationAsync(this if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.AverageAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(AverageAwaitWithCancellationAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_Cast__TResult__1__0; + + private static MethodInfo Cast__TResult__1__0(Type TResult) => + (s_Cast__TResult__1__0 ?? + (s_Cast__TResult__1__0 = new Func, IAsyncQueryable>(Cast).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TResult); + public static IAsyncQueryable Cast(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Cast(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(Cast__TResult__1__0(typeof(TResult)), source.Expression)); } + private static MethodInfo s_Concat__TSource__2__0; + + private static MethodInfo Concat__TSource__2__0(Type TSource) => + (s_Concat__TSource__2__0 ?? + (s_Concat__TSource__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(Concat).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Concat(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -811,49 +933,57 @@ public static IAsyncQueryable Concat(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Concat(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery(Expression.Call(Concat__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } + private static MethodInfo s_ContainsAsync__TSource__3__0; + + private static MethodInfo ContainsAsync__TSource__3__0(Type TSource) => + (s_ContainsAsync__TSource__3__0 ?? + (s_ContainsAsync__TSource__3__0 = new Func, object, CancellationToken, ValueTask>(ContainsAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask ContainsAsync(this IAsyncQueryable source, TSource value, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(ContainsAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ContainsAsync__TSource__4__0; + + private static MethodInfo ContainsAsync__TSource__4__0(Type TSource) => + (s_ContainsAsync__TSource__4__0 ?? + (s_ContainsAsync__TSource__4__0 = new Func, object, IEqualityComparer, CancellationToken, ValueTask>(ContainsAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask ContainsAsync(this IAsyncQueryable source, TSource value, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ContainsAsync(default(IAsyncQueryable), default(TSource), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(ContainsAsync__TSource__4__0(typeof(TSource)), source.Expression, Expression.Constant(value, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_CountAsync__TSource__2__0; + + private static MethodInfo CountAsync__TSource__2__0(Type TSource) => + (s_CountAsync__TSource__2__0 ?? + (s_CountAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(CountAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask CountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(CountAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_CountAsync__TSource__3__0; + + private static MethodInfo CountAsync__TSource__3__0(Type TSource) => + (s_CountAsync__TSource__3__0 ?? + (s_CountAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(CountAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask CountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -861,13 +991,15 @@ public static ValueTask CountAsync(this IAsyncQueryable s if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(CountAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_CountAwaitAsync__TSource__3__0; + + private static MethodInfo CountAwaitAsync__TSource__3__0(Type TSource) => + (s_CountAwaitAsync__TSource__3__0 ?? + (s_CountAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(CountAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask CountAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -875,13 +1007,15 @@ public static ValueTask CountAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.CountAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(CountAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_CountAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo CountAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_CountAwaitWithCancellationAsync__TSource__3__0 ?? + (s_CountAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(CountAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask CountAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -889,85 +1023,99 @@ public static ValueTask CountAwaitWithCancellationAsync(this IAsyn if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.CountAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(CountAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_DefaultIfEmpty__TSource__1__0; + + private static MethodInfo DefaultIfEmpty__TSource__1__0(Type TSource) => + (s_DefaultIfEmpty__TSource__1__0 ?? + (s_DefaultIfEmpty__TSource__1__0 = new Func, IAsyncQueryable>(DefaultIfEmpty).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(DefaultIfEmpty__TSource__1__0(typeof(TSource)), source.Expression)); } + private static MethodInfo s_DefaultIfEmpty__TSource__2__0; + + private static MethodInfo DefaultIfEmpty__TSource__2__0(Type TSource) => + (s_DefaultIfEmpty__TSource__2__0 ?? + (s_DefaultIfEmpty__TSource__2__0 = new Func, object, IAsyncQueryable>(DefaultIfEmpty).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable DefaultIfEmpty(this IAsyncQueryable source, TSource defaultValue) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.DefaultIfEmpty(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); -#endif + return source.Provider.CreateQuery(Expression.Call(DefaultIfEmpty__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); } + private static MethodInfo s_Distinct__TSource__1__0; + + private static MethodInfo Distinct__TSource__1__0(Type TSource) => + (s_Distinct__TSource__1__0 ?? + (s_Distinct__TSource__1__0 = new Func, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Distinct(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource__1__0(typeof(TSource)), source.Expression)); } + private static MethodInfo s_Distinct__TSource__2__0; + + private static MethodInfo Distinct__TSource__2__0(Type TSource) => + (s_Distinct__TSource__2__0 ?? + (s_Distinct__TSource__2__0 = new Func, IEqualityComparer, IAsyncQueryable>(Distinct).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Distinct(this IAsyncQueryable source, IEqualityComparer comparer) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Distinct(default(IAsyncQueryable), default(IEqualityComparer))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Distinct__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_ElementAtAsync__TSource__3__0; + + private static MethodInfo ElementAtAsync__TSource__3__0(Type TSource) => + (s_ElementAtAsync__TSource__3__0 ?? + (s_ElementAtAsync__TSource__3__0 = new Func, int, CancellationToken, ValueTask>(ElementAtAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask ElementAtAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(ElementAtAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ElementAtOrDefaultAsync__TSource__3__0; + + private static MethodInfo ElementAtOrDefaultAsync__TSource__3__0(Type TSource) => + (s_ElementAtOrDefaultAsync__TSource__3__0 ?? + (s_ElementAtOrDefaultAsync__TSource__3__0 = new Func, int, CancellationToken, ValueTask>(ElementAtOrDefaultAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask ElementAtOrDefaultAsync(this IAsyncQueryable source, int index, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ElementAtOrDefaultAsync(default(IAsyncQueryable), default(int), default(CancellationToken))), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(ElementAtOrDefaultAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(index, typeof(int)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_Except__TSource__2__0; + + private static MethodInfo Except__TSource__2__0(Type TSource) => + (s_Except__TSource__2__0 ?? + (s_Except__TSource__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(Except).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -975,13 +1123,15 @@ public static IAsyncQueryable Except(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery(Expression.Call(Except__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } + private static MethodInfo s_Except__TSource__3__0; + + private static MethodInfo Except__TSource__3__0(Type TSource) => + (s_Except__TSource__3__0 ?? + (s_Except__TSource__3__0 = new Func, IAsyncEnumerable, IEqualityComparer, IAsyncQueryable>(Except).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Except(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) @@ -989,25 +1139,29 @@ public static IAsyncQueryable Except(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Except(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return first.Provider.CreateQuery(Expression.Call(Except__TSource__3__0(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_FirstAsync__TSource__2__0; + + private static MethodInfo FirstAsync__TSource__2__0(Type TSource) => + (s_FirstAsync__TSource__2__0 ?? + (s_FirstAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(FirstAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_FirstAsync__TSource__3__0; + + private static MethodInfo FirstAsync__TSource__3__0(Type TSource) => + (s_FirstAsync__TSource__3__0 ?? + (s_FirstAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(FirstAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1015,13 +1169,15 @@ public static ValueTask FirstAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_FirstAwaitAsync__TSource__3__0; + + private static MethodInfo FirstAwaitAsync__TSource__3__0(Type TSource) => + (s_FirstAwaitAsync__TSource__3__0 ?? + (s_FirstAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(FirstAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1029,13 +1185,15 @@ public static ValueTask FirstAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.FirstAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_FirstAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo FirstAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_FirstAwaitWithCancellationAsync__TSource__3__0 ?? + (s_FirstAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(FirstAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1043,25 +1201,29 @@ public static ValueTask FirstAwaitWithCancellationAsync(this I if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_FirstOrDefaultAsync__TSource__2__0; + + private static MethodInfo FirstOrDefaultAsync__TSource__2__0(Type TSource) => + (s_FirstOrDefaultAsync__TSource__2__0 ?? + (s_FirstOrDefaultAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(FirstOrDefaultAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstOrDefaultAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_FirstOrDefaultAsync__TSource__3__0; + + private static MethodInfo FirstOrDefaultAsync__TSource__3__0(Type TSource) => + (s_FirstOrDefaultAsync__TSource__3__0 ?? + (s_FirstOrDefaultAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(FirstOrDefaultAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1069,13 +1231,15 @@ public static ValueTask FirstOrDefaultAsync(this IAsyncQueryab if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstOrDefaultAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_FirstOrDefaultAwaitAsync__TSource__3__0; + + private static MethodInfo FirstOrDefaultAwaitAsync__TSource__3__0(Type TSource) => + (s_FirstOrDefaultAwaitAsync__TSource__3__0 ?? + (s_FirstOrDefaultAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(FirstOrDefaultAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1083,13 +1247,15 @@ public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncQu if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstOrDefaultAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_FirstOrDefaultAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo FirstOrDefaultAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_FirstOrDefaultAwaitWithCancellationAsync__TSource__3__0 ?? + (s_FirstOrDefaultAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(FirstOrDefaultAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1097,13 +1263,15 @@ public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(Expression.Call(InfoOf(() => AsyncQueryable.FirstOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(FirstOrDefaultAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_GroupBy__TSource_TKey__2__0; + + private static MethodInfo GroupBy__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_GroupBy__TSource_TKey__2__0 ?? + (s_GroupBy__TSource_TKey__2__0 = new Func, Expression>, IAsyncQueryable>>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -1111,13 +1279,15 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupBy__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_GroupBy__TSource_TKey__3__0; + + private static MethodInfo GroupBy__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_GroupBy__TSource_TKey__3__0 ?? + (s_GroupBy__TSource_TKey__3__0 = new Func, Expression>, IEqualityComparer, IAsyncQueryable>>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer) { if (source == null) @@ -1125,13 +1295,15 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupBy__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupBy__TSource_TKey_TResult__3__0; + + private static MethodInfo GroupBy__TSource_TKey_TResult__3__0(Type TSource, Type TKey, Type TResult) => + (s_GroupBy__TSource_TKey_TResult__3__0 ?? + (s_GroupBy__TSource_TKey_TResult__3__0 = new Func, Expression>, Expression, object>>, IAsyncQueryable>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TResult); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { if (source == null) @@ -1141,13 +1313,15 @@ public static IAsyncQueryable GroupBy(this IAsy if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupBy__TSource_TKey_TResult__3__0(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); } + private static MethodInfo s_GroupBy__TSource_TKey_TElement__3__0; + + private static MethodInfo GroupBy__TSource_TKey_TElement__3__0(Type TSource, Type TKey, Type TElement) => + (s_GroupBy__TSource_TKey_TElement__3__0 ?? + (s_GroupBy__TSource_TKey_TElement__3__0 = new Func, Expression>, Expression>, IAsyncQueryable>>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector) { if (source == null) @@ -1157,13 +1331,15 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupBy__TSource_TKey_TElement__3__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); } + private static MethodInfo s_GroupBy__TSource_TKey_TResult__4__0; + + private static MethodInfo GroupBy__TSource_TKey_TResult__4__0(Type TSource, Type TKey, Type TResult) => + (s_GroupBy__TSource_TKey_TResult__4__0 ?? + (s_GroupBy__TSource_TKey_TResult__4__0 = new Func, Expression>, Expression, object>>, IEqualityComparer, IAsyncQueryable>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TResult); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1173,13 +1349,15 @@ public static IAsyncQueryable GroupBy(this IAsy if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupBy__TSource_TKey_TResult__4__0(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupBy__TSource_TKey_TElement__4__0; + + private static MethodInfo GroupBy__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_GroupBy__TSource_TKey_TElement__4__0 ?? + (s_GroupBy__TSource_TKey_TElement__4__0 = new Func, Expression>, Expression>, IEqualityComparer, IAsyncQueryable>>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static IAsyncQueryable> GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer) { if (source == null) @@ -1189,13 +1367,15 @@ public static IAsyncQueryable> GroupBy>(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupBy__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupBy__TSource_TKey_TElement_TResult__4__0; + + private static MethodInfo GroupBy__TSource_TKey_TElement_TResult__4__0(Type TSource, Type TKey, Type TElement, Type TResult) => + (s_GroupBy__TSource_TKey_TElement_TResult__4__0 ?? + (s_GroupBy__TSource_TKey_TElement_TResult__4__0 = new Func, Expression>, Expression>, Expression, object>>, IAsyncQueryable>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement, TResult); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector) { if (source == null) @@ -1207,13 +1387,15 @@ public static IAsyncQueryable GroupBy if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>))), source.Expression, keySelector, elementSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupBy__TSource_TKey_TElement_TResult__4__0(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); } + private static MethodInfo s_GroupBy__TSource_TKey_TElement_TResult__5__0; + + private static MethodInfo GroupBy__TSource_TKey_TElement_TResult__5__0(Type TSource, Type TKey, Type TElement, Type TResult) => + (s_GroupBy__TSource_TKey_TElement_TResult__5__0 ?? + (s_GroupBy__TSource_TKey_TElement_TResult__5__0 = new Func, Expression>, Expression>, Expression, object>>, IEqualityComparer, IAsyncQueryable>(GroupBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement, TResult); + public static IAsyncQueryable GroupBy(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1225,13 +1407,15 @@ public static IAsyncQueryable GroupBy if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupBy(default(IAsyncQueryable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupBy__TSource_TKey_TElement_TResult__5__0(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwait__TSource_TKey__2__0; + + private static MethodInfo GroupByAwait__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_GroupByAwait__TSource_TKey__2__0 ?? + (s_GroupByAwait__TSource_TKey__2__0 = new Func, Expression>>, IAsyncQueryable>>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -1239,13 +1423,15 @@ public static IAsyncQueryable> GroupByAwait>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwait__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_GroupByAwait__TSource_TKey__3__0; + + private static MethodInfo GroupByAwait__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_GroupByAwait__TSource_TKey__3__0 ?? + (s_GroupByAwait__TSource_TKey__3__0 = new Func, Expression>>, IEqualityComparer, IAsyncQueryable>>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) @@ -1253,13 +1439,15 @@ public static IAsyncQueryable> GroupByAwait>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwait__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwait__TSource_TKey_TResult__3__0; + + private static MethodInfo GroupByAwait__TSource_TKey_TResult__3__0(Type TSource, Type TKey, Type TResult) => + (s_GroupByAwait__TSource_TKey_TResult__3__0 ?? + (s_GroupByAwait__TSource_TKey_TResult__3__0 = new Func, Expression>>, Expression, ValueTask>>, IAsyncQueryable>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TResult); + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector) { if (source == null) @@ -1269,13 +1457,15 @@ public static IAsyncQueryable GroupByAwait(this if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwait__TSource_TKey_TResult__3__0(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); } + private static MethodInfo s_GroupByAwait__TSource_TKey_TElement__3__0; + + private static MethodInfo GroupByAwait__TSource_TKey_TElement__3__0(Type TSource, Type TKey, Type TElement) => + (s_GroupByAwait__TSource_TKey_TElement__3__0 ?? + (s_GroupByAwait__TSource_TKey_TElement__3__0 = new Func, Expression>>, Expression>>, IAsyncQueryable>>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) @@ -1285,13 +1475,15 @@ public static IAsyncQueryable> GroupByAwait>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwait__TSource_TKey_TElement__3__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); } + private static MethodInfo s_GroupByAwait__TSource_TKey_TResult__4__0; + + private static MethodInfo GroupByAwait__TSource_TKey_TResult__4__0(Type TSource, Type TKey, Type TResult) => + (s_GroupByAwait__TSource_TKey_TResult__4__0 ?? + (s_GroupByAwait__TSource_TKey_TResult__4__0 = new Func, Expression>>, Expression, ValueTask>>, IEqualityComparer, IAsyncQueryable>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TResult); + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1301,13 +1493,15 @@ public static IAsyncQueryable GroupByAwait(this if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwait__TSource_TKey_TResult__4__0(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwait__TSource_TKey_TElement__4__0; + + private static MethodInfo GroupByAwait__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_GroupByAwait__TSource_TKey_TElement__4__0 ?? + (s_GroupByAwait__TSource_TKey_TElement__4__0 = new Func, Expression>>, Expression>>, IEqualityComparer, IAsyncQueryable>>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static IAsyncQueryable> GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) @@ -1317,13 +1511,15 @@ public static IAsyncQueryable> GroupByAwait>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwait__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwait__TSource_TKey_TElement_TResult__4__0; + + private static MethodInfo GroupByAwait__TSource_TKey_TElement_TResult__4__0(Type TSource, Type TKey, Type TElement, Type TResult) => + (s_GroupByAwait__TSource_TKey_TElement_TResult__4__0 ?? + (s_GroupByAwait__TSource_TKey_TElement_TResult__4__0 = new Func, Expression>>, Expression>>, Expression, ValueTask>>, IAsyncQueryable>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement, TResult); + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector) { if (source == null) @@ -1335,13 +1531,15 @@ public static IAsyncQueryable GroupByAwait(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwait__TSource_TKey_TElement_TResult__4__0(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); } + private static MethodInfo s_GroupByAwait__TSource_TKey_TElement_TResult__5__0; + + private static MethodInfo GroupByAwait__TSource_TKey_TElement_TResult__5__0(Type TSource, Type TKey, Type TElement, Type TResult) => + (s_GroupByAwait__TSource_TKey_TElement_TResult__5__0 ?? + (s_GroupByAwait__TSource_TKey_TElement_TResult__5__0 = new Func, Expression>>, Expression>>, Expression, ValueTask>>, IEqualityComparer, IAsyncQueryable>(GroupByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement, TResult); + public static IAsyncQueryable GroupByAwait(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1353,13 +1551,15 @@ public static IAsyncQueryable GroupByAwait(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwait(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwait__TSource_TKey_TElement_TResult__5__0(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey__2__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_GroupByAwaitWithCancellation__TSource_TKey__2__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey__2__0 = new Func, Expression>>, IAsyncQueryable>>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -1367,13 +1567,15 @@ public static IAsyncQueryable> GroupByAwaitWithCan if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey__3__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_GroupByAwaitWithCancellation__TSource_TKey__3__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey__3__0 = new Func, Expression>>, IEqualityComparer, IAsyncQueryable>>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer) { if (source == null) @@ -1381,13 +1583,15 @@ public static IAsyncQueryable> GroupByAwaitWithCan if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey_TResult__3__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey_TResult__3__0(Type TSource, Type TKey, Type TResult) => + (s_GroupByAwaitWithCancellation__TSource_TKey_TResult__3__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey_TResult__3__0 = new Func, Expression>>, Expression, CancellationToken, ValueTask>>, IAsyncQueryable>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TResult); + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (source == null) @@ -1397,13 +1601,15 @@ public static IAsyncQueryable GroupByAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey_TResult__3__0(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector)); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey_TElement__3__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey_TElement__3__0(Type TSource, Type TKey, Type TElement) => + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement__3__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement__3__0 = new Func, Expression>>, Expression>>, IAsyncQueryable>>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector) { if (source == null) @@ -1413,13 +1619,15 @@ public static IAsyncQueryable> GroupByAwaitWithCa if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>))), source.Expression, keySelector, elementSelector)); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey_TElement__3__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector)); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey_TResult__4__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey_TResult__4__0(Type TSource, Type TKey, Type TResult) => + (s_GroupByAwaitWithCancellation__TSource_TKey_TResult__4__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey_TResult__4__0 = new Func, Expression>>, Expression, CancellationToken, ValueTask>>, IEqualityComparer, IAsyncQueryable>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TResult); + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1429,13 +1637,15 @@ public static IAsyncQueryable GroupByAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey_TResult__4__0(typeof(TSource), typeof(TKey), typeof(TResult)), source.Expression, keySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey_TElement__4__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement__4__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement__4__0 = new Func, Expression>>, Expression>>, IEqualityComparer, IAsyncQueryable>>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static IAsyncQueryable> GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer) { if (source == null) @@ -1445,13 +1655,15 @@ public static IAsyncQueryable> GroupByAwaitWithCa if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery>(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery>(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__4__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__4__0(Type TSource, Type TKey, Type TElement, Type TResult) => + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__4__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__4__0 = new Func, Expression>>, Expression>>, Expression, CancellationToken, ValueTask>>, IAsyncQueryable>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement, TResult); + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (source == null) @@ -1463,13 +1675,15 @@ public static IAsyncQueryable GroupByAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), source.Expression, keySelector, elementSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__4__0(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector)); } + private static MethodInfo s_GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__5__0; + + private static MethodInfo GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__5__0(Type TSource, Type TKey, Type TElement, Type TResult) => + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__5__0 ?? + (s_GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__5__0 = new Func, Expression>>, Expression>>, Expression, CancellationToken, ValueTask>>, IEqualityComparer, IAsyncQueryable>(GroupByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement, TResult); + public static IAsyncQueryable GroupByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (source == null) @@ -1481,13 +1695,15 @@ public static IAsyncQueryable GroupByAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.GroupByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return source.Provider.CreateQuery(Expression.Call(GroupByAwaitWithCancellation__TSource_TKey_TElement_TResult__5__0(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TResult)), source.Expression, keySelector, elementSelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupJoin__TOuter_TInner_TKey_TResult__5__0; + + private static MethodInfo GroupJoin__TOuter_TInner_TKey_TResult__5__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_GroupJoin__TOuter_TInner_TKey_TResult__5__0 ?? + (s_GroupJoin__TOuter_TInner_TKey_TResult__5__0 = new Func, IAsyncEnumerable, Expression>, Expression>, Expression, object>>, IAsyncQueryable>(GroupJoin).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { if (outer == null) @@ -1501,13 +1717,15 @@ public static IAsyncQueryable GroupJoin( if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif + return outer.Provider.CreateQuery(Expression.Call(GroupJoin__TOuter_TInner_TKey_TResult__5__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); } + private static MethodInfo s_GroupJoin__TOuter_TInner_TKey_TResult__6__0; + + private static MethodInfo GroupJoin__TOuter_TInner_TKey_TResult__6__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_GroupJoin__TOuter_TInner_TKey_TResult__6__0 ?? + (s_GroupJoin__TOuter_TInner_TKey_TResult__6__0 = new Func, IAsyncEnumerable, Expression>, Expression>, Expression, object>>, IEqualityComparer, IAsyncQueryable>(GroupJoin).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable GroupJoin(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -1521,13 +1739,15 @@ public static IAsyncQueryable GroupJoin( if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoin(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression, TResult>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return outer.Provider.CreateQuery(Expression.Call(GroupJoin__TOuter_TInner_TKey_TResult__6__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupJoinAwait__TOuter_TInner_TKey_TResult__5__0; + + private static MethodInfo GroupJoinAwait__TOuter_TInner_TKey_TResult__5__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_GroupJoinAwait__TOuter_TInner_TKey_TResult__5__0 ?? + (s_GroupJoinAwait__TOuter_TInner_TKey_TResult__5__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression, ValueTask>>, IAsyncQueryable>(GroupJoinAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable GroupJoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector) { if (outer == null) @@ -1541,13 +1761,15 @@ public static IAsyncQueryable GroupJoinAwait(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif + return outer.Provider.CreateQuery(Expression.Call(GroupJoinAwait__TOuter_TInner_TKey_TResult__5__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); } + private static MethodInfo s_GroupJoinAwait__TOuter_TInner_TKey_TResult__6__0; + + private static MethodInfo GroupJoinAwait__TOuter_TInner_TKey_TResult__6__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_GroupJoinAwait__TOuter_TInner_TKey_TResult__6__0 ?? + (s_GroupJoinAwait__TOuter_TInner_TKey_TResult__6__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression, ValueTask>>, IEqualityComparer, IAsyncQueryable>(GroupJoinAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable GroupJoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, ValueTask>> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -1561,13 +1783,15 @@ public static IAsyncQueryable GroupJoinAwait(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return outer.Provider.CreateQuery(Expression.Call(GroupJoinAwait__TOuter_TInner_TKey_TResult__6__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0; + + private static MethodInfo GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0 ?? + (s_GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression, CancellationToken, ValueTask>>, IAsyncQueryable>(GroupJoinAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable GroupJoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector) { if (outer == null) @@ -1581,13 +1805,15 @@ public static IAsyncQueryable GroupJoinAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif + return outer.Provider.CreateQuery(Expression.Call(GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); } + private static MethodInfo s_GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0; + + private static MethodInfo GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0 ?? + (s_GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression, CancellationToken, ValueTask>>, IEqualityComparer, IAsyncQueryable>(GroupJoinAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable GroupJoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression, CancellationToken, ValueTask>> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -1601,13 +1827,15 @@ public static IAsyncQueryable GroupJoinAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.GroupJoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression, CancellationToken, ValueTask>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return outer.Provider.CreateQuery(Expression.Call(GroupJoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_Intersect__TSource__2__0; + + private static MethodInfo Intersect__TSource__2__0(Type TSource) => + (s_Intersect__TSource__2__0 ?? + (s_Intersect__TSource__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(Intersect).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -1615,13 +1843,15 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery(Expression.Call(Intersect__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } + private static MethodInfo s_Intersect__TSource__3__0; + + private static MethodInfo Intersect__TSource__3__0(Type TSource) => + (s_Intersect__TSource__3__0 ?? + (s_Intersect__TSource__3__0 = new Func, IAsyncEnumerable, IEqualityComparer, IAsyncQueryable>(Intersect).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Intersect(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) @@ -1629,13 +1859,15 @@ public static IAsyncQueryable Intersect(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Intersect(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return first.Provider.CreateQuery(Expression.Call(Intersect__TSource__3__0(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_Join__TOuter_TInner_TKey_TResult__5__0; + + private static MethodInfo Join__TOuter_TInner_TKey_TResult__5__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_Join__TOuter_TInner_TKey_TResult__5__0 ?? + (s_Join__TOuter_TInner_TKey_TResult__5__0 = new Func, IAsyncEnumerable, Expression>, Expression>, Expression>, IAsyncQueryable>(Join).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { if (outer == null) @@ -1649,13 +1881,15 @@ public static IAsyncQueryable Join(this if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif + return outer.Provider.CreateQuery(Expression.Call(Join__TOuter_TInner_TKey_TResult__5__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); } + private static MethodInfo s_Join__TOuter_TInner_TKey_TResult__6__0; + + private static MethodInfo Join__TOuter_TInner_TKey_TResult__6__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_Join__TOuter_TInner_TKey_TResult__6__0 ?? + (s_Join__TOuter_TInner_TKey_TResult__6__0 = new Func, IAsyncEnumerable, Expression>, Expression>, Expression>, IEqualityComparer, IAsyncQueryable>(Join).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable Join(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -1669,13 +1903,15 @@ public static IAsyncQueryable Join(this if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Join(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>), default(Expression>), default(Expression>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return outer.Provider.CreateQuery(Expression.Call(Join__TOuter_TInner_TKey_TResult__6__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_JoinAwait__TOuter_TInner_TKey_TResult__5__0; + + private static MethodInfo JoinAwait__TOuter_TInner_TKey_TResult__5__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_JoinAwait__TOuter_TInner_TKey_TResult__5__0 ?? + (s_JoinAwait__TOuter_TInner_TKey_TResult__5__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression>>, IAsyncQueryable>(JoinAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable JoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { if (outer == null) @@ -1689,13 +1925,15 @@ public static IAsyncQueryable JoinAwait( if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif + return outer.Provider.CreateQuery(Expression.Call(JoinAwait__TOuter_TInner_TKey_TResult__5__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); } + private static MethodInfo s_JoinAwait__TOuter_TInner_TKey_TResult__6__0; + + private static MethodInfo JoinAwait__TOuter_TInner_TKey_TResult__6__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_JoinAwait__TOuter_TInner_TKey_TResult__6__0 ?? + (s_JoinAwait__TOuter_TInner_TKey_TResult__6__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression>>, IEqualityComparer, IAsyncQueryable>(JoinAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable JoinAwait(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -1709,13 +1947,15 @@ public static IAsyncQueryable JoinAwait( if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return outer.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return outer.Provider.CreateQuery(Expression.Call(JoinAwait__TOuter_TInner_TKey_TResult__6__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0; + + private static MethodInfo JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0 ?? + (s_JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression>>, IAsyncQueryable>(JoinAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable JoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector) { if (outer == null) @@ -1729,13 +1969,15 @@ public static IAsyncQueryable JoinAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); -#endif + return outer.Provider.CreateQuery(Expression.Call(JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__5__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector)); } + private static MethodInfo s_JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0; + + private static MethodInfo JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0(Type TOuter, Type TInner, Type TKey, Type TResult) => + (s_JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0 ?? + (s_JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0 = new Func, IAsyncEnumerable, Expression>>, Expression>>, Expression>>, IEqualityComparer, IAsyncQueryable>(JoinAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TOuter, TInner, TKey, TResult); + public static IAsyncQueryable JoinAwaitWithCancellation(this IAsyncQueryable outer, IAsyncEnumerable inner, Expression>> outerKeySelector, Expression>> innerKeySelector, Expression>> resultSelector, IEqualityComparer comparer) { if (outer == null) @@ -1749,25 +1991,29 @@ public static IAsyncQueryable JoinAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.JoinAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>), default(Expression>>), default(Expression>>), default(IEqualityComparer))), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return outer.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return outer.Provider.CreateQuery(Expression.Call(JoinAwaitWithCancellation__TOuter_TInner_TKey_TResult__6__0(typeof(TOuter), typeof(TInner), typeof(TKey), typeof(TResult)), outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector, Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_LastAsync__TSource__2__0; + + private static MethodInfo LastAsync__TSource__2__0(Type TSource) => + (s_LastAsync__TSource__2__0 ?? + (s_LastAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(LastAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LastAsync__TSource__3__0; + + private static MethodInfo LastAsync__TSource__3__0(Type TSource) => + (s_LastAsync__TSource__3__0 ?? + (s_LastAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(LastAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1775,13 +2021,15 @@ public static ValueTask LastAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.LastAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LastAwaitAsync__TSource__3__0; + + private static MethodInfo LastAwaitAsync__TSource__3__0(Type TSource) => + (s_LastAwaitAsync__TSource__3__0 ?? + (s_LastAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(LastAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1789,13 +2037,15 @@ public static ValueTask LastAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.LastAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LastAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo LastAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_LastAwaitWithCancellationAsync__TSource__3__0 ?? + (s_LastAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(LastAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1803,25 +2053,29 @@ public static ValueTask LastAwaitWithCancellationAsync(this IA if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LastOrDefaultAsync__TSource__2__0; + + private static MethodInfo LastOrDefaultAsync__TSource__2__0(Type TSource) => + (s_LastOrDefaultAsync__TSource__2__0 ?? + (s_LastOrDefaultAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(LastOrDefaultAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastOrDefaultAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LastOrDefaultAsync__TSource__3__0; + + private static MethodInfo LastOrDefaultAsync__TSource__3__0(Type TSource) => + (s_LastOrDefaultAsync__TSource__3__0 ?? + (s_LastOrDefaultAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(LastOrDefaultAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1829,13 +2083,15 @@ public static ValueTask LastOrDefaultAsync(this IAsyncQueryabl if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastOrDefaultAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LastOrDefaultAwaitAsync__TSource__3__0; + + private static MethodInfo LastOrDefaultAwaitAsync__TSource__3__0(Type TSource) => + (s_LastOrDefaultAwaitAsync__TSource__3__0 ?? + (s_LastOrDefaultAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(LastOrDefaultAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastOrDefaultAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1843,13 +2099,15 @@ public static ValueTask LastOrDefaultAwaitAsync(this IAsyncQue if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastOrDefaultAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LastOrDefaultAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo LastOrDefaultAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_LastOrDefaultAwaitWithCancellationAsync__TSource__3__0 ?? + (s_LastOrDefaultAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(LastOrDefaultAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LastOrDefaultAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1857,25 +2115,29 @@ public static ValueTask LastOrDefaultAwaitWithCancellationAsync(Expression.Call(InfoOf(() => AsyncQueryable.LastOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LastOrDefaultAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LongCountAsync__TSource__2__0; + + private static MethodInfo LongCountAsync__TSource__2__0(Type TSource) => + (s_LongCountAsync__TSource__2__0 ?? + (s_LongCountAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(LongCountAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LongCountAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LongCountAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LongCountAsync__TSource__3__0; + + private static MethodInfo LongCountAsync__TSource__3__0(Type TSource) => + (s_LongCountAsync__TSource__3__0 ?? + (s_LongCountAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(LongCountAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LongCountAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1883,13 +2145,15 @@ public static ValueTask LongCountAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LongCountAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LongCountAwaitAsync__TSource__3__0; + + private static MethodInfo LongCountAwaitAsync__TSource__3__0(Type TSource) => + (s_LongCountAwaitAsync__TSource__3__0 ?? + (s_LongCountAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(LongCountAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LongCountAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1897,13 +2161,15 @@ public static ValueTask LongCountAwaitAsync(this IAsyncQueryable< if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LongCountAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_LongCountAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo LongCountAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_LongCountAwaitWithCancellationAsync__TSource__3__0 ?? + (s_LongCountAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(LongCountAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask LongCountAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -1911,145 +2177,169 @@ public static ValueTask LongCountAwaitWithCancellationAsync(this if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.LongCountAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(LongCountAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__0; + + private static MethodInfo MaxAsync__2__0 => + (s_MaxAsync__2__0 ?? + (s_MaxAsync__2__0 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__0, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__1; + + private static MethodInfo MaxAsync__2__1 => + (s_MaxAsync__2__1 ?? + (s_MaxAsync__2__1 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__1, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__2; + + private static MethodInfo MaxAsync__2__2 => + (s_MaxAsync__2__2 ?? + (s_MaxAsync__2__2 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__2, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__3; + + private static MethodInfo MaxAsync__2__3 => + (s_MaxAsync__2__3 ?? + (s_MaxAsync__2__3 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__3, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__4; + + private static MethodInfo MaxAsync__2__4 => + (s_MaxAsync__2__4 ?? + (s_MaxAsync__2__4 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__4, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__5; + + private static MethodInfo MaxAsync__2__5 => + (s_MaxAsync__2__5 ?? + (s_MaxAsync__2__5 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__5, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__6; + + private static MethodInfo MaxAsync__2__6 => + (s_MaxAsync__2__6 ?? + (s_MaxAsync__2__6 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__6, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__7; + + private static MethodInfo MaxAsync__2__7 => + (s_MaxAsync__2__7 ?? + (s_MaxAsync__2__7 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__7, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__8; + + private static MethodInfo MaxAsync__2__8 => + (s_MaxAsync__2__8 ?? + (s_MaxAsync__2__8 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__8, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__2__9; + + private static MethodInfo MaxAsync__2__9 => + (s_MaxAsync__2__9 ?? + (s_MaxAsync__2__9 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo())); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__2__9, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__2__0; + + private static MethodInfo MaxAsync__TSource__2__0(Type TSource) => + (s_MaxAsync__TSource__2__0 ?? + (s_MaxAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__0; + + private static MethodInfo MaxAsync__TSource__3__0(Type TSource) => + (s_MaxAsync__TSource__3__0 ?? + (s_MaxAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2057,13 +2347,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__1; + + private static MethodInfo MaxAsync__TSource__3__1(Type TSource) => + (s_MaxAsync__TSource__3__1 ?? + (s_MaxAsync__TSource__3__1 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2071,13 +2363,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__2; + + private static MethodInfo MaxAsync__TSource__3__2(Type TSource) => + (s_MaxAsync__TSource__3__2 ?? + (s_MaxAsync__TSource__3__2 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2085,13 +2379,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__3; + + private static MethodInfo MaxAsync__TSource__3__3(Type TSource) => + (s_MaxAsync__TSource__3__3 ?? + (s_MaxAsync__TSource__3__3 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2099,13 +2395,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__4; + + private static MethodInfo MaxAsync__TSource__3__4(Type TSource) => + (s_MaxAsync__TSource__3__4 ?? + (s_MaxAsync__TSource__3__4 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2113,13 +2411,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__5; + + private static MethodInfo MaxAsync__TSource__3__5(Type TSource) => + (s_MaxAsync__TSource__3__5 ?? + (s_MaxAsync__TSource__3__5 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2127,13 +2427,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable s if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__6; + + private static MethodInfo MaxAsync__TSource__3__6(Type TSource) => + (s_MaxAsync__TSource__3__6 ?? + (s_MaxAsync__TSource__3__6 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2141,13 +2443,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable s if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__7; + + private static MethodInfo MaxAsync__TSource__3__7(Type TSource) => + (s_MaxAsync__TSource__3__7 ?? + (s_MaxAsync__TSource__3__7 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2155,13 +2459,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__8; + + private static MethodInfo MaxAsync__TSource__3__8(Type TSource) => + (s_MaxAsync__TSource__3__8 ?? + (s_MaxAsync__TSource__3__8 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2169,13 +2475,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable sou if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource__3__9; + + private static MethodInfo MaxAsync__TSource__3__9(Type TSource) => + (s_MaxAsync__TSource__3__9 ?? + (s_MaxAsync__TSource__3__9 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2183,13 +2491,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable so if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAsync__TSource_TResult__3__0; + + private static MethodInfo MaxAsync__TSource_TResult__3__0(Type TSource, Type TResult) => + (s_MaxAsync__TSource_TResult__3__0 ?? + (s_MaxAsync__TSource_TResult__3__0 = new Func, Expression>, CancellationToken, ValueTask>(MaxAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static ValueTask MaxAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2197,13 +2507,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAsync__TSource_TResult__3__0(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__0; + + private static MethodInfo MaxAwaitAsync__TSource__3__0(Type TSource) => + (s_MaxAwaitAsync__TSource__3__0 ?? + (s_MaxAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2211,13 +2523,15 @@ public static ValueTask MaxAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__1; + + private static MethodInfo MaxAwaitAsync__TSource__3__1(Type TSource) => + (s_MaxAwaitAsync__TSource__3__1 ?? + (s_MaxAwaitAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2225,13 +2539,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__2; + + private static MethodInfo MaxAwaitAsync__TSource__3__2(Type TSource) => + (s_MaxAwaitAsync__TSource__3__2 ?? + (s_MaxAwaitAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2239,13 +2555,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__3; + + private static MethodInfo MaxAwaitAsync__TSource__3__3(Type TSource) => + (s_MaxAwaitAsync__TSource__3__3 ?? + (s_MaxAwaitAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2253,13 +2571,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__4; + + private static MethodInfo MaxAwaitAsync__TSource__3__4(Type TSource) => + (s_MaxAwaitAsync__TSource__3__4 ?? + (s_MaxAwaitAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2267,13 +2587,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__5; + + private static MethodInfo MaxAwaitAsync__TSource__3__5(Type TSource) => + (s_MaxAwaitAsync__TSource__3__5 ?? + (s_MaxAwaitAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2281,13 +2603,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__6; + + private static MethodInfo MaxAwaitAsync__TSource__3__6(Type TSource) => + (s_MaxAwaitAsync__TSource__3__6 ?? + (s_MaxAwaitAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2295,13 +2619,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__7; + + private static MethodInfo MaxAwaitAsync__TSource__3__7(Type TSource) => + (s_MaxAwaitAsync__TSource__3__7 ?? + (s_MaxAwaitAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2309,13 +2635,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__8; + + private static MethodInfo MaxAwaitAsync__TSource__3__8(Type TSource) => + (s_MaxAwaitAsync__TSource__3__8 ?? + (s_MaxAwaitAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2323,13 +2651,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource__3__9; + + private static MethodInfo MaxAwaitAsync__TSource__3__9(Type TSource) => + (s_MaxAwaitAsync__TSource__3__9 ?? + (s_MaxAwaitAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2337,13 +2667,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitAsync__TSource_TResult__3__0; + + private static MethodInfo MaxAwaitAsync__TSource_TResult__3__0(Type TSource, Type TResult) => + (s_MaxAwaitAsync__TSource_TResult__3__0 ?? + (s_MaxAwaitAsync__TSource_TResult__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static ValueTask MaxAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2351,13 +2683,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQuer if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitAsync__TSource_TResult__3__0(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__0 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2365,13 +2699,15 @@ public static ValueTask MaxAwaitAsync(this IAsyncQuer if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__1; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__1(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__1 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2379,13 +2715,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAs if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__2; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__2(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__2 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2393,13 +2731,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAs if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__3; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__3(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__3 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2407,13 +2747,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAsy if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__4; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__4(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__4 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2421,13 +2763,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAsy if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__5; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__5(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__5 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2435,13 +2779,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAsyn if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__6; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__6(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__6 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2449,13 +2795,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAsyn if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__7; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__7(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__7 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2463,13 +2811,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__8; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__8(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__8 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2477,13 +2827,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource__3__9; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource__3__9(Type TSource) => + (s_MaxAwaitWithCancellationAsync__TSource__3__9 ?? + (s_MaxAwaitWithCancellationAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2491,13 +2843,15 @@ public static ValueTask MaxAwaitWithCancellationAsync(this IAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MaxAwaitWithCancellationAsync__TSource_TResult__3__0; + + private static MethodInfo MaxAwaitWithCancellationAsync__TSource_TResult__3__0(Type TSource, Type TResult) => + (s_MaxAwaitWithCancellationAsync__TSource_TResult__3__0 ?? + (s_MaxAwaitWithCancellationAsync__TSource_TResult__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MaxAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2505,145 +2859,169 @@ public static ValueTask MaxAwaitWithCancellationAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MaxAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MaxAwaitWithCancellationAsync__TSource_TResult__3__0(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__0; + + private static MethodInfo MinAsync__2__0 => + (s_MinAsync__2__0 ?? + (s_MinAsync__2__0 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__0, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__1; + + private static MethodInfo MinAsync__2__1 => + (s_MinAsync__2__1 ?? + (s_MinAsync__2__1 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__1, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__2; + + private static MethodInfo MinAsync__2__2 => + (s_MinAsync__2__2 ?? + (s_MinAsync__2__2 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__2, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__3; + + private static MethodInfo MinAsync__2__3 => + (s_MinAsync__2__3 ?? + (s_MinAsync__2__3 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__3, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__4; + + private static MethodInfo MinAsync__2__4 => + (s_MinAsync__2__4 ?? + (s_MinAsync__2__4 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__4, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__5; + + private static MethodInfo MinAsync__2__5 => + (s_MinAsync__2__5 ?? + (s_MinAsync__2__5 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__5, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__6; + + private static MethodInfo MinAsync__2__6 => + (s_MinAsync__2__6 ?? + (s_MinAsync__2__6 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__6, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__7; + + private static MethodInfo MinAsync__2__7 => + (s_MinAsync__2__7 ?? + (s_MinAsync__2__7 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__7, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__8; + + private static MethodInfo MinAsync__2__8 => + (s_MinAsync__2__8 ?? + (s_MinAsync__2__8 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__8, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__2__9; + + private static MethodInfo MinAsync__2__9 => + (s_MinAsync__2__9 ?? + (s_MinAsync__2__9 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo())); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__2__9, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__2__0; + + private static MethodInfo MinAsync__TSource__2__0(Type TSource) => + (s_MinAsync__TSource__2__0 ?? + (s_MinAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__0; + + private static MethodInfo MinAsync__TSource__3__0(Type TSource) => + (s_MinAsync__TSource__3__0 ?? + (s_MinAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2651,13 +3029,15 @@ public static ValueTask MinAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__1; + + private static MethodInfo MinAsync__TSource__3__1(Type TSource) => + (s_MinAsync__TSource__3__1 ?? + (s_MinAsync__TSource__3__1 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2665,13 +3045,15 @@ public static ValueTask MinAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__2; + + private static MethodInfo MinAsync__TSource__3__2(Type TSource) => + (s_MinAsync__TSource__3__2 ?? + (s_MinAsync__TSource__3__2 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2679,13 +3061,15 @@ public static ValueTask MinAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__3; + + private static MethodInfo MinAsync__TSource__3__3(Type TSource) => + (s_MinAsync__TSource__3__3 ?? + (s_MinAsync__TSource__3__3 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2693,13 +3077,15 @@ public static ValueTask MinAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__4; + + private static MethodInfo MinAsync__TSource__3__4(Type TSource) => + (s_MinAsync__TSource__3__4 ?? + (s_MinAsync__TSource__3__4 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2707,13 +3093,15 @@ public static ValueTask MinAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__5; + + private static MethodInfo MinAsync__TSource__3__5(Type TSource) => + (s_MinAsync__TSource__3__5 ?? + (s_MinAsync__TSource__3__5 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2721,13 +3109,15 @@ public static ValueTask MinAsync(this IAsyncQueryable s if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__6; + + private static MethodInfo MinAsync__TSource__3__6(Type TSource) => + (s_MinAsync__TSource__3__6 ?? + (s_MinAsync__TSource__3__6 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2735,13 +3125,15 @@ public static ValueTask MinAsync(this IAsyncQueryable s if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__7; + + private static MethodInfo MinAsync__TSource__3__7(Type TSource) => + (s_MinAsync__TSource__3__7 ?? + (s_MinAsync__TSource__3__7 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2749,13 +3141,15 @@ public static ValueTask MinAsync(this IAsyncQueryable sou if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__8; + + private static MethodInfo MinAsync__TSource__3__8(Type TSource) => + (s_MinAsync__TSource__3__8 ?? + (s_MinAsync__TSource__3__8 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2763,13 +3157,15 @@ public static ValueTask MinAsync(this IAsyncQueryable sou if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource__3__9; + + private static MethodInfo MinAsync__TSource__3__9(Type TSource) => + (s_MinAsync__TSource__3__9 ?? + (s_MinAsync__TSource__3__9 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2777,13 +3173,15 @@ public static ValueTask MinAsync(this IAsyncQueryable so if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAsync__TSource_TResult__3__0; + + private static MethodInfo MinAsync__TSource_TResult__3__0(Type TSource, Type TResult) => + (s_MinAsync__TSource_TResult__3__0 ?? + (s_MinAsync__TSource_TResult__3__0 = new Func, Expression>, CancellationToken, ValueTask>(MinAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static ValueTask MinAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2791,13 +3189,15 @@ public static ValueTask MinAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAsync__TSource_TResult__3__0(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__0; + + private static MethodInfo MinAwaitAsync__TSource__3__0(Type TSource) => + (s_MinAwaitAsync__TSource__3__0 ?? + (s_MinAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2805,13 +3205,15 @@ public static ValueTask MinAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__1; + + private static MethodInfo MinAwaitAsync__TSource__3__1(Type TSource) => + (s_MinAwaitAsync__TSource__3__1 ?? + (s_MinAwaitAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2819,13 +3221,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__2; + + private static MethodInfo MinAwaitAsync__TSource__3__2(Type TSource) => + (s_MinAwaitAsync__TSource__3__2 ?? + (s_MinAwaitAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2833,13 +3237,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__3; + + private static MethodInfo MinAwaitAsync__TSource__3__3(Type TSource) => + (s_MinAwaitAsync__TSource__3__3 ?? + (s_MinAwaitAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2847,13 +3253,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__4; + + private static MethodInfo MinAwaitAsync__TSource__3__4(Type TSource) => + (s_MinAwaitAsync__TSource__3__4 ?? + (s_MinAwaitAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2861,13 +3269,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__5; + + private static MethodInfo MinAwaitAsync__TSource__3__5(Type TSource) => + (s_MinAwaitAsync__TSource__3__5 ?? + (s_MinAwaitAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2875,13 +3285,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__6; + + private static MethodInfo MinAwaitAsync__TSource__3__6(Type TSource) => + (s_MinAwaitAsync__TSource__3__6 ?? + (s_MinAwaitAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2889,13 +3301,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__7; + + private static MethodInfo MinAwaitAsync__TSource__3__7(Type TSource) => + (s_MinAwaitAsync__TSource__3__7 ?? + (s_MinAwaitAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2903,13 +3317,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__8; + + private static MethodInfo MinAwaitAsync__TSource__3__8(Type TSource) => + (s_MinAwaitAsync__TSource__3__8 ?? + (s_MinAwaitAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2917,13 +3333,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource__3__9; + + private static MethodInfo MinAwaitAsync__TSource__3__9(Type TSource) => + (s_MinAwaitAsync__TSource__3__9 ?? + (s_MinAwaitAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2931,13 +3349,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitAsync__TSource_TResult__3__0; + + private static MethodInfo MinAwaitAsync__TSource_TResult__3__0(Type TSource, Type TResult) => + (s_MinAwaitAsync__TSource_TResult__3__0 ?? + (s_MinAwaitAsync__TSource_TResult__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static ValueTask MinAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2945,13 +3365,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQuer if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitAsync__TSource_TResult__3__0(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__0 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2959,13 +3381,15 @@ public static ValueTask MinAwaitAsync(this IAsyncQuer if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__1; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__1(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__1 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2973,13 +3397,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAs if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__2; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__2(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__2 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -2987,13 +3413,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAs if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__3; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__3(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__3 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3001,13 +3429,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAsy if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__4; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__4(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__4 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3015,13 +3445,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAsy if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__5; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__5(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__5 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3029,13 +3461,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAsyn if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__6; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__6(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__6 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3043,13 +3477,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAsyn if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__7; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__7(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__7 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3057,13 +3493,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__8; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__8(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__8 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3071,13 +3509,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource__3__9; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource__3__9(Type TSource) => + (s_MinAwaitWithCancellationAsync__TSource__3__9 ?? + (s_MinAwaitWithCancellationAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3085,13 +3525,15 @@ public static ValueTask MinAwaitWithCancellationAsync(this IAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_MinAwaitWithCancellationAsync__TSource_TResult__3__0; + + private static MethodInfo MinAwaitWithCancellationAsync__TSource_TResult__3__0(Type TSource, Type TResult) => + (s_MinAwaitWithCancellationAsync__TSource_TResult__3__0 ?? + (s_MinAwaitWithCancellationAsync__TSource_TResult__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(MinAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3099,25 +3541,29 @@ public static ValueTask MinAwaitWithCancellationAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.MinAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(MinAwaitWithCancellationAsync__TSource_TResult__3__0(typeof(TSource), typeof(TResult)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_OfType__TResult__1__0; + + private static MethodInfo OfType__TResult__1__0(Type TResult) => + (s_OfType__TResult__1__0 ?? + (s_OfType__TResult__1__0 = new Func, IAsyncQueryable>(OfType).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TResult); + public static IAsyncQueryable OfType(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OfType(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(OfType__TResult__1__0(typeof(TResult)), source.Expression)); } + private static MethodInfo s_OrderBy__TSource_TKey__2__0; + + private static MethodInfo OrderBy__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_OrderBy__TSource_TKey__2__0 ?? + (s_OrderBy__TSource_TKey__2__0 = new Func, Expression>, IOrderedAsyncQueryable>(OrderBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -3125,13 +3571,15 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderBy__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_OrderBy__TSource_TKey__3__0; + + private static MethodInfo OrderBy__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_OrderBy__TSource_TKey__3__0 ?? + (s_OrderBy__TSource_TKey__3__0 = new Func, Expression>, IComparer, IOrderedAsyncQueryable>(OrderBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderBy(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -3139,13 +3587,15 @@ public static IOrderedAsyncQueryable OrderBy(this IAsync if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderBy(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderBy__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_OrderByAwait__TSource_TKey__2__0; + + private static MethodInfo OrderByAwait__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_OrderByAwait__TSource_TKey__2__0 ?? + (s_OrderByAwait__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(OrderByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByAwait(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -3153,13 +3603,15 @@ public static IOrderedAsyncQueryable OrderByAwait(this I if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByAwait__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_OrderByAwait__TSource_TKey__3__0; + + private static MethodInfo OrderByAwait__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_OrderByAwait__TSource_TKey__3__0 ?? + (s_OrderByAwait__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(OrderByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByAwait(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -3167,13 +3619,15 @@ public static IOrderedAsyncQueryable OrderByAwait(this I if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwait(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByAwait__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_OrderByAwaitWithCancellation__TSource_TKey__2__0; + + private static MethodInfo OrderByAwaitWithCancellation__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_OrderByAwaitWithCancellation__TSource_TKey__2__0 ?? + (s_OrderByAwaitWithCancellation__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(OrderByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -3181,13 +3635,15 @@ public static IOrderedAsyncQueryable OrderByAwaitWithCancellation)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByAwaitWithCancellation__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_OrderByAwaitWithCancellation__TSource_TKey__3__0; + + private static MethodInfo OrderByAwaitWithCancellation__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_OrderByAwaitWithCancellation__TSource_TKey__3__0 ?? + (s_OrderByAwaitWithCancellation__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(OrderByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -3195,13 +3651,15 @@ public static IOrderedAsyncQueryable OrderByAwaitWithCancellation)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByAwaitWithCancellation__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_OrderByDescending__TSource_TKey__2__0; + + private static MethodInfo OrderByDescending__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_OrderByDescending__TSource_TKey__2__0 ?? + (s_OrderByDescending__TSource_TKey__2__0 = new Func, Expression>, IOrderedAsyncQueryable>(OrderByDescending).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -3209,13 +3667,15 @@ public static IOrderedAsyncQueryable OrderByDescending(t if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByDescending__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_OrderByDescending__TSource_TKey__3__0; + + private static MethodInfo OrderByDescending__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_OrderByDescending__TSource_TKey__3__0 ?? + (s_OrderByDescending__TSource_TKey__3__0 = new Func, Expression>, IComparer, IOrderedAsyncQueryable>(OrderByDescending).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByDescending(this IAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -3223,13 +3683,15 @@ public static IOrderedAsyncQueryable OrderByDescending(t if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescending(default(IAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByDescending__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_OrderByDescendingAwait__TSource_TKey__2__0; + + private static MethodInfo OrderByDescendingAwait__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_OrderByDescendingAwait__TSource_TKey__2__0 ?? + (s_OrderByDescendingAwait__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(OrderByDescendingAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByDescendingAwait(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -3237,13 +3699,15 @@ public static IOrderedAsyncQueryable OrderByDescendingAwait)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByDescendingAwait__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_OrderByDescendingAwait__TSource_TKey__3__0; + + private static MethodInfo OrderByDescendingAwait__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_OrderByDescendingAwait__TSource_TKey__3__0 ?? + (s_OrderByDescendingAwait__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(OrderByDescendingAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByDescendingAwait(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -3251,13 +3715,15 @@ public static IOrderedAsyncQueryable OrderByDescendingAwait)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwait(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByDescendingAwait__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_OrderByDescendingAwaitWithCancellation__TSource_TKey__2__0; + + private static MethodInfo OrderByDescendingAwaitWithCancellation__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_OrderByDescendingAwaitWithCancellation__TSource_TKey__2__0 ?? + (s_OrderByDescendingAwaitWithCancellation__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(OrderByDescendingAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByDescendingAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -3265,13 +3731,15 @@ public static IOrderedAsyncQueryable OrderByDescendingAwaitWithCancella if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByDescendingAwaitWithCancellation__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_OrderByDescendingAwaitWithCancellation__TSource_TKey__3__0; + + private static MethodInfo OrderByDescendingAwaitWithCancellation__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_OrderByDescendingAwaitWithCancellation__TSource_TKey__3__0 ?? + (s_OrderByDescendingAwaitWithCancellation__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(OrderByDescendingAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable OrderByDescendingAwaitWithCancellation(this IAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -3279,37 +3747,43 @@ public static IOrderedAsyncQueryable OrderByDescendingAwaitWithCancella if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.OrderByDescendingAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(OrderByDescendingAwaitWithCancellation__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_Prepend__TSource__2__0; + + private static MethodInfo Prepend__TSource__2__0(Type TSource) => + (s_Prepend__TSource__2__0 ?? + (s_Prepend__TSource__2__0 = new Func, object, IAsyncQueryable>(Prepend).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Prepend(this IAsyncQueryable source, TSource element) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Prepend(default(IAsyncQueryable), default(TSource))), source.Expression, Expression.Constant(element, typeof(TSource)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Prepend__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(element, typeof(TSource)))); } + private static MethodInfo s_Reverse__TSource__1__0; + + private static MethodInfo Reverse__TSource__1__0(Type TSource) => + (s_Reverse__TSource__1__0 ?? + (s_Reverse__TSource__1__0 = new Func, IAsyncQueryable>(Reverse).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Reverse(this IAsyncQueryable source) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Reverse(default(IAsyncQueryable))), source.Expression)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression)); -#endif + return source.Provider.CreateQuery(Expression.Call(Reverse__TSource__1__0(typeof(TSource)), source.Expression)); } + private static MethodInfo s_Select__TSource_TResult__2__0; + + private static MethodInfo Select__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_Select__TSource_TResult__2__0 ?? + (s_Select__TSource_TResult__2__0 = new Func, Expression>, IAsyncQueryable>(Select).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -3317,13 +3791,15 @@ public static IAsyncQueryable Select(this IAsyncQuery if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Select__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_Select__TSource_TResult__2__1; + + private static MethodInfo Select__TSource_TResult__2__1(Type TSource, Type TResult) => + (s_Select__TSource_TResult__2__1 ?? + (s_Select__TSource_TResult__2__1 = new Func, Expression>, IAsyncQueryable>(Select).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable Select(this IAsyncQueryable source, Expression> selector) { if (source == null) @@ -3331,13 +3807,15 @@ public static IAsyncQueryable Select(this IAsyncQuery if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Select(default(IAsyncQueryable), default(Expression>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(Select__TSource_TResult__2__1(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectAwait__TSource_TResult__2__0; + + private static MethodInfo SelectAwait__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_SelectAwait__TSource_TResult__2__0 ?? + (s_SelectAwait__TSource_TResult__2__0 = new Func, Expression>>, IAsyncQueryable>(SelectAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectAwait(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -3345,13 +3823,15 @@ public static IAsyncQueryable SelectAwait(this IAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectAwait__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectAwait__TSource_TResult__2__1; + + private static MethodInfo SelectAwait__TSource_TResult__2__1(Type TSource, Type TResult) => + (s_SelectAwait__TSource_TResult__2__1 ?? + (s_SelectAwait__TSource_TResult__2__1 = new Func, Expression>>, IAsyncQueryable>(SelectAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectAwait(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -3359,13 +3839,15 @@ public static IAsyncQueryable SelectAwait(this IAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectAwait__TSource_TResult__2__1(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectAwaitWithCancellation__TSource_TResult__2__0; + + private static MethodInfo SelectAwaitWithCancellation__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_SelectAwaitWithCancellation__TSource_TResult__2__0 ?? + (s_SelectAwaitWithCancellation__TSource_TResult__2__0 = new Func, Expression>>, IAsyncQueryable>(SelectAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectAwaitWithCancellation(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -3373,13 +3855,15 @@ public static IAsyncQueryable SelectAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectAwaitWithCancellation__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectAwaitWithCancellation__TSource_TResult__2__1; + + private static MethodInfo SelectAwaitWithCancellation__TSource_TResult__2__1(Type TSource, Type TResult) => + (s_SelectAwaitWithCancellation__TSource_TResult__2__1 ?? + (s_SelectAwaitWithCancellation__TSource_TResult__2__1 = new Func, Expression>>, IAsyncQueryable>(SelectAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectAwaitWithCancellation(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -3387,13 +3871,15 @@ public static IAsyncQueryable SelectAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.SelectAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectAwaitWithCancellation__TSource_TResult__2__1(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectMany__TSource_TResult__2__0; + + private static MethodInfo SelectMany__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_SelectMany__TSource_TResult__2__0 ?? + (s_SelectMany__TSource_TResult__2__0 = new Func, Expression>>, IAsyncQueryable>(SelectMany).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -3401,13 +3887,15 @@ public static IAsyncQueryable SelectMany(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectMany__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectMany__TSource_TResult__2__1; + + private static MethodInfo SelectMany__TSource_TResult__2__1(Type TSource, Type TResult) => + (s_SelectMany__TSource_TResult__2__1 ?? + (s_SelectMany__TSource_TResult__2__1 = new Func, Expression>>, IAsyncQueryable>(SelectMany).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> selector) { if (source == null) @@ -3415,13 +3903,15 @@ public static IAsyncQueryable SelectMany(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectMany__TSource_TResult__2__1(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectMany__TSource_TCollection_TResult__3__0; + + private static MethodInfo SelectMany__TSource_TCollection_TResult__3__0(Type TSource, Type TCollection, Type TResult) => + (s_SelectMany__TSource_TCollection_TResult__3__0 ?? + (s_SelectMany__TSource_TCollection_TResult__3__0 = new Func, Expression>>, Expression>, IAsyncQueryable>(SelectMany).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TCollection, TResult); + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) { if (source == null) @@ -3431,13 +3921,15 @@ public static IAsyncQueryable SelectMany if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectMany__TSource_TCollection_TResult__3__0(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); } + private static MethodInfo s_SelectMany__TSource_TCollection_TResult__3__1; + + private static MethodInfo SelectMany__TSource_TCollection_TResult__3__1(Type TSource, Type TCollection, Type TResult) => + (s_SelectMany__TSource_TCollection_TResult__3__1 ?? + (s_SelectMany__TSource_TCollection_TResult__3__1 = new Func, Expression>>, Expression>, IAsyncQueryable>(SelectMany).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TCollection, TResult); + public static IAsyncQueryable SelectMany(this IAsyncQueryable source, Expression>> collectionSelector, Expression> resultSelector) { if (source == null) @@ -3447,13 +3939,15 @@ public static IAsyncQueryable SelectMany if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectMany(default(IAsyncQueryable), default(Expression>>), default(Expression>))), source.Expression, collectionSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectMany__TSource_TCollection_TResult__3__1(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); } + private static MethodInfo s_SelectManyAwait__TSource_TResult__2__0; + + private static MethodInfo SelectManyAwait__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_SelectManyAwait__TSource_TResult__2__0 ?? + (s_SelectManyAwait__TSource_TResult__2__0 = new Func, Expression>>>, IAsyncQueryable>(SelectManyAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> selector) { if (source == null) @@ -3461,13 +3955,15 @@ public static IAsyncQueryable SelectManyAwait(this IA if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwait__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectManyAwait__TSource_TResult__2__1; + + private static MethodInfo SelectManyAwait__TSource_TResult__2__1(Type TSource, Type TResult) => + (s_SelectManyAwait__TSource_TResult__2__1 ?? + (s_SelectManyAwait__TSource_TResult__2__1 = new Func, Expression>>>, IAsyncQueryable>(SelectManyAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> selector) { if (source == null) @@ -3475,13 +3971,15 @@ public static IAsyncQueryable SelectManyAwait(this IA if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwait__TSource_TResult__2__1(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectManyAwait__TSource_TCollection_TResult__3__0; + + private static MethodInfo SelectManyAwait__TSource_TCollection_TResult__3__0(Type TSource, Type TCollection, Type TResult) => + (s_SelectManyAwait__TSource_TCollection_TResult__3__0 ?? + (s_SelectManyAwait__TSource_TCollection_TResult__3__0 = new Func, Expression>>>, Expression>>, IAsyncQueryable>(SelectManyAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TCollection, TResult); + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) @@ -3491,13 +3989,15 @@ public static IAsyncQueryable SelectManyAwait(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwait__TSource_TCollection_TResult__3__0(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); } + private static MethodInfo s_SelectManyAwait__TSource_TCollection_TResult__3__1; + + private static MethodInfo SelectManyAwait__TSource_TCollection_TResult__3__1(Type TSource, Type TCollection, Type TResult) => + (s_SelectManyAwait__TSource_TCollection_TResult__3__1 ?? + (s_SelectManyAwait__TSource_TCollection_TResult__3__1 = new Func, Expression>>>, Expression>>, IAsyncQueryable>(SelectManyAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TCollection, TResult); + public static IAsyncQueryable SelectManyAwait(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) @@ -3507,13 +4007,15 @@ public static IAsyncQueryable SelectManyAwait(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwait(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwait__TSource_TCollection_TResult__3__1(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); } + private static MethodInfo s_SelectManyAwaitWithCancellation__TSource_TResult__2__0; + + private static MethodInfo SelectManyAwaitWithCancellation__TSource_TResult__2__0(Type TSource, Type TResult) => + (s_SelectManyAwaitWithCancellation__TSource_TResult__2__0 ?? + (s_SelectManyAwaitWithCancellation__TSource_TResult__2__0 = new Func, Expression>>>, IAsyncQueryable>(SelectManyAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> selector) { if (source == null) @@ -3521,13 +4023,15 @@ public static IAsyncQueryable SelectManyAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwaitWithCancellation__TSource_TResult__2__0(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectManyAwaitWithCancellation__TSource_TResult__2__1; + + private static MethodInfo SelectManyAwaitWithCancellation__TSource_TResult__2__1(Type TSource, Type TResult) => + (s_SelectManyAwaitWithCancellation__TSource_TResult__2__1 ?? + (s_SelectManyAwaitWithCancellation__TSource_TResult__2__1 = new Func, Expression>>>, IAsyncQueryable>(SelectManyAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TResult); + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> selector) { if (source == null) @@ -3535,13 +4039,15 @@ public static IAsyncQueryable SelectManyAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>))), source.Expression, selector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)), source.Expression, selector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwaitWithCancellation__TSource_TResult__2__1(typeof(TSource), typeof(TResult)), source.Expression, selector)); } + private static MethodInfo s_SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__0; + + private static MethodInfo SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__0(Type TSource, Type TCollection, Type TResult) => + (s_SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__0 ?? + (s_SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__0 = new Func, Expression>>>, Expression>>, IAsyncQueryable>(SelectManyAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TCollection, TResult); + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) @@ -3551,13 +4057,15 @@ public static IAsyncQueryable SelectManyAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__0(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); } + private static MethodInfo s_SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__1; + + private static MethodInfo SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__1(Type TSource, Type TCollection, Type TResult) => + (s_SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__1 ?? + (s_SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__1 = new Func, Expression>>>, Expression>>, IAsyncQueryable>(SelectManyAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TCollection, TResult); + public static IAsyncQueryable SelectManyAwaitWithCancellation(this IAsyncQueryable source, Expression>>> collectionSelector, Expression>> resultSelector) { if (source == null) @@ -3567,13 +4075,15 @@ public static IAsyncQueryable SelectManyAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.SelectManyAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>>), default(Expression>>))), source.Expression, collectionSelector, resultSelector)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); -#endif + return source.Provider.CreateQuery(Expression.Call(SelectManyAwaitWithCancellation__TSource_TCollection_TResult__3__1(typeof(TSource), typeof(TCollection), typeof(TResult)), source.Expression, collectionSelector, resultSelector)); } + private static MethodInfo s_SequenceEqualAsync__TSource__3__0; + + private static MethodInfo SequenceEqualAsync__TSource__3__0(Type TSource) => + (s_SequenceEqualAsync__TSource__3__0 ?? + (s_SequenceEqualAsync__TSource__3__0 = new Func, IAsyncEnumerable, CancellationToken, ValueTask>(SequenceEqualAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, CancellationToken cancellationToken = default) { if (first == null) @@ -3581,13 +4091,15 @@ public static ValueTask SequenceEqualAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return first.Provider.ExecuteAsync(Expression.Call(SequenceEqualAsync__TSource__3__0(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SequenceEqualAsync__TSource__4__0; + + private static MethodInfo SequenceEqualAsync__TSource__4__0(Type TSource) => + (s_SequenceEqualAsync__TSource__4__0 ?? + (s_SequenceEqualAsync__TSource__4__0 = new Func, IAsyncEnumerable, IEqualityComparer, CancellationToken, ValueTask>(SequenceEqualAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SequenceEqualAsync(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (first == null) @@ -3595,25 +4107,29 @@ public static ValueTask SequenceEqualAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SequenceEqualAsync(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer), default(CancellationToken))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return first.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return first.Provider.ExecuteAsync(Expression.Call(SequenceEqualAsync__TSource__4__0(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleAsync__TSource__2__0; + + private static MethodInfo SingleAsync__TSource__2__0(Type TSource) => + (s_SingleAsync__TSource__2__0 ?? + (s_SingleAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(SingleAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleAsync__TSource__3__0; + + private static MethodInfo SingleAsync__TSource__3__0(Type TSource) => + (s_SingleAsync__TSource__3__0 ?? + (s_SingleAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(SingleAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -3621,13 +4137,15 @@ public static ValueTask SingleAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SingleAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleAwaitAsync__TSource__3__0; + + private static MethodInfo SingleAwaitAsync__TSource__3__0(Type TSource) => + (s_SingleAwaitAsync__TSource__3__0 ?? + (s_SingleAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(SingleAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -3635,13 +4153,15 @@ public static ValueTask SingleAwaitAsync(this IAsyncQueryable< if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo SingleAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_SingleAwaitWithCancellationAsync__TSource__3__0 ?? + (s_SingleAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(SingleAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -3649,25 +4169,29 @@ public static ValueTask SingleAwaitWithCancellationAsync(this if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleOrDefaultAsync__TSource__2__0; + + private static MethodInfo SingleOrDefaultAsync__TSource__2__0(Type TSource) => + (s_SingleOrDefaultAsync__TSource__2__0 ?? + (s_SingleOrDefaultAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(SingleOrDefaultAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleOrDefaultAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleOrDefaultAsync__TSource__3__0; + + private static MethodInfo SingleOrDefaultAsync__TSource__3__0(Type TSource) => + (s_SingleOrDefaultAsync__TSource__3__0 ?? + (s_SingleOrDefaultAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(SingleOrDefaultAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleOrDefaultAsync(this IAsyncQueryable source, Expression> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -3675,13 +4199,15 @@ public static ValueTask SingleOrDefaultAsync(this IAsyncQuerya if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleOrDefaultAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleOrDefaultAwaitAsync__TSource__3__0; + + private static MethodInfo SingleOrDefaultAwaitAsync__TSource__3__0(Type TSource) => + (s_SingleOrDefaultAwaitAsync__TSource__3__0 ?? + (s_SingleOrDefaultAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(SingleOrDefaultAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -3689,13 +4215,15 @@ public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncQ if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleOrDefaultAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SingleOrDefaultAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo SingleOrDefaultAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_SingleOrDefaultAwaitWithCancellationAsync__TSource__3__0 ?? + (s_SingleOrDefaultAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(SingleOrDefaultAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> predicate, CancellationToken cancellationToken = default) { if (source == null) @@ -3703,37 +4231,43 @@ public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(Expression.Call(InfoOf(() => AsyncQueryable.SingleOrDefaultAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SingleOrDefaultAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, predicate, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_Skip__TSource__2__0; + + private static MethodInfo Skip__TSource__2__0(Type TSource) => + (s_Skip__TSource__2__0 ?? + (s_Skip__TSource__2__0 = new Func, int, IAsyncQueryable>(Skip).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Skip(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Skip(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Skip__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } + private static MethodInfo s_SkipLast__TSource__2__0; + + private static MethodInfo SkipLast__TSource__2__0(Type TSource) => + (s_SkipLast__TSource__2__0 ?? + (s_SkipLast__TSource__2__0 = new Func, int, IAsyncQueryable>(SkipLast).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable SkipLast(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif + return source.Provider.CreateQuery(Expression.Call(SkipLast__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } + private static MethodInfo s_SkipWhile__TSource__2__0; + + private static MethodInfo SkipWhile__TSource__2__0(Type TSource) => + (s_SkipWhile__TSource__2__0 ?? + (s_SkipWhile__TSource__2__0 = new Func, Expression>, IAsyncQueryable>(SkipWhile).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -3741,13 +4275,15 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(SkipWhile__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_SkipWhile__TSource__2__1; + + private static MethodInfo SkipWhile__TSource__2__1(Type TSource) => + (s_SkipWhile__TSource__2__1 ?? + (s_SkipWhile__TSource__2__1 = new Func, Expression>, IAsyncQueryable>(SkipWhile).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable SkipWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -3755,13 +4291,15 @@ public static IAsyncQueryable SkipWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(SkipWhile__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_SkipWhileAwait__TSource__2__0; + + private static MethodInfo SkipWhileAwait__TSource__2__0(Type TSource) => + (s_SkipWhileAwait__TSource__2__0 ?? + (s_SkipWhileAwait__TSource__2__0 = new Func, Expression>>, IAsyncQueryable>(SkipWhileAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable SkipWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -3769,13 +4307,15 @@ public static IAsyncQueryable SkipWhileAwait(this IAsyncQuerya if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(SkipWhileAwait__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_SkipWhileAwait__TSource__2__1; + + private static MethodInfo SkipWhileAwait__TSource__2__1(Type TSource) => + (s_SkipWhileAwait__TSource__2__1 ?? + (s_SkipWhileAwait__TSource__2__1 = new Func, Expression>>, IAsyncQueryable>(SkipWhileAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable SkipWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -3783,13 +4323,15 @@ public static IAsyncQueryable SkipWhileAwait(this IAsyncQuerya if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(SkipWhileAwait__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_SkipWhileAwaitWithCancellation__TSource__2__0; + + private static MethodInfo SkipWhileAwaitWithCancellation__TSource__2__0(Type TSource) => + (s_SkipWhileAwaitWithCancellation__TSource__2__0 ?? + (s_SkipWhileAwaitWithCancellation__TSource__2__0 = new Func, Expression>>, IAsyncQueryable>(SkipWhileAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable SkipWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -3797,13 +4339,15 @@ public static IAsyncQueryable SkipWhileAwaitWithCancellation(t if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(SkipWhileAwaitWithCancellation__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_SkipWhileAwaitWithCancellation__TSource__2__1; + + private static MethodInfo SkipWhileAwaitWithCancellation__TSource__2__1(Type TSource) => + (s_SkipWhileAwaitWithCancellation__TSource__2__1 ?? + (s_SkipWhileAwaitWithCancellation__TSource__2__1 = new Func, Expression>>, IAsyncQueryable>(SkipWhileAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable SkipWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -3811,133 +4355,155 @@ public static IAsyncQueryable SkipWhileAwaitWithCancellation(t if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.SkipWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(SkipWhileAwaitWithCancellation__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_SumAsync__2__0; + + private static MethodInfo SumAsync__2__0 => + (s_SumAsync__2__0 ?? + (s_SumAsync__2__0 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__0, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__1; + + private static MethodInfo SumAsync__2__1 => + (s_SumAsync__2__1 ?? + (s_SumAsync__2__1 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__1, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__2; + + private static MethodInfo SumAsync__2__2 => + (s_SumAsync__2__2 ?? + (s_SumAsync__2__2 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__2, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__3; + + private static MethodInfo SumAsync__2__3 => + (s_SumAsync__2__3 ?? + (s_SumAsync__2__3 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__3, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__4; + + private static MethodInfo SumAsync__2__4 => + (s_SumAsync__2__4 ?? + (s_SumAsync__2__4 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__4, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__5; + + private static MethodInfo SumAsync__2__5 => + (s_SumAsync__2__5 ?? + (s_SumAsync__2__5 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__5, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__6; + + private static MethodInfo SumAsync__2__6 => + (s_SumAsync__2__6 ?? + (s_SumAsync__2__6 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__6, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__7; + + private static MethodInfo SumAsync__2__7 => + (s_SumAsync__2__7 ?? + (s_SumAsync__2__7 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__7, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__8; + + private static MethodInfo SumAsync__2__8 => + (s_SumAsync__2__8 ?? + (s_SumAsync__2__8 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__8, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__2__9; + + private static MethodInfo SumAsync__2__9 => + (s_SumAsync__2__9 ?? + (s_SumAsync__2__9 = new Func, CancellationToken, ValueTask>(SumAsync).GetMethodInfo())); + public static ValueTask SumAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call((MethodInfo)MethodBase.GetCurrentMethod(), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__2__9, source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__0; + + private static MethodInfo SumAsync__TSource__3__0(Type TSource) => + (s_SumAsync__TSource__3__0 ?? + (s_SumAsync__TSource__3__0 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3945,13 +4511,15 @@ public static ValueTask SumAsync(this IAsyncQueryable source, Cancel if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__1; + + private static MethodInfo SumAsync__TSource__3__1(Type TSource) => + (s_SumAsync__TSource__3__1 ?? + (s_SumAsync__TSource__3__1 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3959,13 +4527,15 @@ public static ValueTask SumAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__2; + + private static MethodInfo SumAsync__TSource__3__2(Type TSource) => + (s_SumAsync__TSource__3__2 ?? + (s_SumAsync__TSource__3__2 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3973,13 +4543,15 @@ public static ValueTask SumAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__3; + + private static MethodInfo SumAsync__TSource__3__3(Type TSource) => + (s_SumAsync__TSource__3__3 ?? + (s_SumAsync__TSource__3__3 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -3987,13 +4559,15 @@ public static ValueTask SumAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__4; + + private static MethodInfo SumAsync__TSource__3__4(Type TSource) => + (s_SumAsync__TSource__3__4 ?? + (s_SumAsync__TSource__3__4 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4001,13 +4575,15 @@ public static ValueTask SumAsync(this IAsyncQueryable if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__5; + + private static MethodInfo SumAsync__TSource__3__5(Type TSource) => + (s_SumAsync__TSource__3__5 ?? + (s_SumAsync__TSource__3__5 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4015,13 +4591,15 @@ public static ValueTask SumAsync(this IAsyncQueryable s if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__6; + + private static MethodInfo SumAsync__TSource__3__6(Type TSource) => + (s_SumAsync__TSource__3__6 ?? + (s_SumAsync__TSource__3__6 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4029,13 +4607,15 @@ public static ValueTask SumAsync(this IAsyncQueryable s if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__7; + + private static MethodInfo SumAsync__TSource__3__7(Type TSource) => + (s_SumAsync__TSource__3__7 ?? + (s_SumAsync__TSource__3__7 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4043,13 +4623,15 @@ public static ValueTask SumAsync(this IAsyncQueryable sou if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__8; + + private static MethodInfo SumAsync__TSource__3__8(Type TSource) => + (s_SumAsync__TSource__3__8 ?? + (s_SumAsync__TSource__3__8 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4057,13 +4639,15 @@ public static ValueTask SumAsync(this IAsyncQueryable sou if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAsync__TSource__3__9; + + private static MethodInfo SumAsync__TSource__3__9(Type TSource) => + (s_SumAsync__TSource__3__9 ?? + (s_SumAsync__TSource__3__9 = new Func, Expression>, CancellationToken, ValueTask>(SumAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAsync(this IAsyncQueryable source, Expression> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4071,13 +4655,15 @@ public static ValueTask SumAsync(this IAsyncQueryable so if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__0; + + private static MethodInfo SumAwaitAsync__TSource__3__0(Type TSource) => + (s_SumAwaitAsync__TSource__3__0 ?? + (s_SumAwaitAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4085,13 +4671,15 @@ public static ValueTask SumAsync(this IAsyncQueryable so if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__1; + + private static MethodInfo SumAwaitAsync__TSource__3__1(Type TSource) => + (s_SumAwaitAsync__TSource__3__1 ?? + (s_SumAwaitAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4099,13 +4687,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__2; + + private static MethodInfo SumAwaitAsync__TSource__3__2(Type TSource) => + (s_SumAwaitAsync__TSource__3__2 ?? + (s_SumAwaitAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4113,13 +4703,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__3; + + private static MethodInfo SumAwaitAsync__TSource__3__3(Type TSource) => + (s_SumAwaitAsync__TSource__3__3 ?? + (s_SumAwaitAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4127,13 +4719,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__4; + + private static MethodInfo SumAwaitAsync__TSource__3__4(Type TSource) => + (s_SumAwaitAsync__TSource__3__4 ?? + (s_SumAwaitAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4141,13 +4735,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__5; + + private static MethodInfo SumAwaitAsync__TSource__3__5(Type TSource) => + (s_SumAwaitAsync__TSource__3__5 ?? + (s_SumAwaitAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4155,13 +4751,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__6; + + private static MethodInfo SumAwaitAsync__TSource__3__6(Type TSource) => + (s_SumAwaitAsync__TSource__3__6 ?? + (s_SumAwaitAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4169,13 +4767,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__7; + + private static MethodInfo SumAwaitAsync__TSource__3__7(Type TSource) => + (s_SumAwaitAsync__TSource__3__7 ?? + (s_SumAwaitAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4183,13 +4783,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__8; + + private static MethodInfo SumAwaitAsync__TSource__3__8(Type TSource) => + (s_SumAwaitAsync__TSource__3__8 ?? + (s_SumAwaitAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4197,13 +4799,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitAsync__TSource__3__9; + + private static MethodInfo SumAwaitAsync__TSource__3__9(Type TSource) => + (s_SumAwaitAsync__TSource__3__9 ?? + (s_SumAwaitAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4211,13 +4815,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__0; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__0(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__0 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__0 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4225,13 +4831,15 @@ public static ValueTask SumAwaitAsync(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__0(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__1; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__1(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__1 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__1 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4239,13 +4847,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAs if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__1(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__2; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__2(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__2 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__2 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4253,13 +4863,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAs if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__2(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__3; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__3(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__3 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__3 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4267,13 +4879,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAsy if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__3(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__4; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__4(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__4 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__4 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4281,13 +4895,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAsy if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__4(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__5; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__5(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__5 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__5 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4295,13 +4911,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAsyn if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__5(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__6; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__6(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__6 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__6 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4309,13 +4927,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAsyn if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__6(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__7; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__7(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__7 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__7 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4323,13 +4943,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__7(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__8; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__8(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__8 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__8 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4337,13 +4959,15 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQ if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__8(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_SumAwaitWithCancellationAsync__TSource__3__9; + + private static MethodInfo SumAwaitWithCancellationAsync__TSource__3__9(Type TSource) => + (s_SumAwaitWithCancellationAsync__TSource__3__9 ?? + (s_SumAwaitWithCancellationAsync__TSource__3__9 = new Func, Expression>>, CancellationToken, ValueTask>(SumAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> selector, CancellationToken cancellationToken = default) { if (source == null) @@ -4351,37 +4975,43 @@ public static ValueTask SumAwaitWithCancellationAsync(this IAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.SumAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(SumAwaitWithCancellationAsync__TSource__3__9(typeof(TSource)), source.Expression, selector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_Take__TSource__2__0; + + private static MethodInfo Take__TSource__2__0(Type TSource) => + (s_Take__TSource__2__0 ?? + (s_Take__TSource__2__0 = new Func, int, IAsyncQueryable>(Take).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Take(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Take(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif + return source.Provider.CreateQuery(Expression.Call(Take__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } + private static MethodInfo s_TakeLast__TSource__2__0; + + private static MethodInfo TakeLast__TSource__2__0(Type TSource) => + (s_TakeLast__TSource__2__0 ?? + (s_TakeLast__TSource__2__0 = new Func, int, IAsyncQueryable>(TakeLast).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable TakeLast(this IAsyncQueryable source, int count) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeLast(default(IAsyncQueryable), default(int))), source.Expression, Expression.Constant(count, typeof(int)))); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); -#endif + return source.Provider.CreateQuery(Expression.Call(TakeLast__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)))); } + private static MethodInfo s_TakeWhile__TSource__2__0; + + private static MethodInfo TakeWhile__TSource__2__0(Type TSource) => + (s_TakeWhile__TSource__2__0 ?? + (s_TakeWhile__TSource__2__0 = new Func, Expression>, IAsyncQueryable>(TakeWhile).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -4389,13 +5019,15 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(TakeWhile__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_TakeWhile__TSource__2__1; + + private static MethodInfo TakeWhile__TSource__2__1(Type TSource) => + (s_TakeWhile__TSource__2__1 ?? + (s_TakeWhile__TSource__2__1 = new Func, Expression>, IAsyncQueryable>(TakeWhile).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable TakeWhile(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -4403,13 +5035,15 @@ public static IAsyncQueryable TakeWhile(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhile(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(TakeWhile__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_TakeWhileAwait__TSource__2__0; + + private static MethodInfo TakeWhileAwait__TSource__2__0(Type TSource) => + (s_TakeWhileAwait__TSource__2__0 ?? + (s_TakeWhileAwait__TSource__2__0 = new Func, Expression>>, IAsyncQueryable>(TakeWhileAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable TakeWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -4417,13 +5051,15 @@ public static IAsyncQueryable TakeWhileAwait(this IAsyncQuerya if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(TakeWhileAwait__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_TakeWhileAwait__TSource__2__1; + + private static MethodInfo TakeWhileAwait__TSource__2__1(Type TSource) => + (s_TakeWhileAwait__TSource__2__1 ?? + (s_TakeWhileAwait__TSource__2__1 = new Func, Expression>>, IAsyncQueryable>(TakeWhileAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable TakeWhileAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -4431,13 +5067,15 @@ public static IAsyncQueryable TakeWhileAwait(this IAsyncQuerya if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(TakeWhileAwait__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_TakeWhileAwaitWithCancellation__TSource__2__0; + + private static MethodInfo TakeWhileAwaitWithCancellation__TSource__2__0(Type TSource) => + (s_TakeWhileAwaitWithCancellation__TSource__2__0 ?? + (s_TakeWhileAwaitWithCancellation__TSource__2__0 = new Func, Expression>>, IAsyncQueryable>(TakeWhileAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable TakeWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -4445,13 +5083,15 @@ public static IAsyncQueryable TakeWhileAwaitWithCancellation(t if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(TakeWhileAwaitWithCancellation__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_TakeWhileAwaitWithCancellation__TSource__2__1; + + private static MethodInfo TakeWhileAwaitWithCancellation__TSource__2__1(Type TSource) => + (s_TakeWhileAwaitWithCancellation__TSource__2__1 ?? + (s_TakeWhileAwaitWithCancellation__TSource__2__1 = new Func, Expression>>, IAsyncQueryable>(TakeWhileAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable TakeWhileAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -4459,13 +5099,15 @@ public static IAsyncQueryable TakeWhileAwaitWithCancellation(t if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.TakeWhileAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(TakeWhileAwaitWithCancellation__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_ThenBy__TSource_TKey__2__0; + + private static MethodInfo ThenBy__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_ThenBy__TSource_TKey__2__0 ?? + (s_ThenBy__TSource_TKey__2__0 = new Func, Expression>, IOrderedAsyncQueryable>(ThenBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -4473,13 +5115,15 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenBy__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_ThenBy__TSource_TKey__3__0; + + private static MethodInfo ThenBy__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ThenBy__TSource_TKey__3__0 ?? + (s_ThenBy__TSource_TKey__3__0 = new Func, Expression>, IComparer, IOrderedAsyncQueryable>(ThenBy).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenBy(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -4487,13 +5131,15 @@ public static IOrderedAsyncQueryable ThenBy(this IOrdere if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenBy(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenBy__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_ThenByAwait__TSource_TKey__2__0; + + private static MethodInfo ThenByAwait__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_ThenByAwait__TSource_TKey__2__0 ?? + (s_ThenByAwait__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(ThenByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByAwait(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -4501,13 +5147,15 @@ public static IOrderedAsyncQueryable ThenByAwait(this IO if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwait(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByAwait__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_ThenByAwait__TSource_TKey__3__0; + + private static MethodInfo ThenByAwait__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ThenByAwait__TSource_TKey__3__0 ?? + (s_ThenByAwait__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(ThenByAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByAwait(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -4515,13 +5163,15 @@ public static IOrderedAsyncQueryable ThenByAwait(this IO if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwait(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByAwait__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_ThenByAwaitWithCancellation__TSource_TKey__2__0; + + private static MethodInfo ThenByAwaitWithCancellation__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_ThenByAwaitWithCancellation__TSource_TKey__2__0 ?? + (s_ThenByAwaitWithCancellation__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(ThenByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -4529,13 +5179,15 @@ public static IOrderedAsyncQueryable ThenByAwaitWithCancellation)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByAwaitWithCancellation__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_ThenByAwaitWithCancellation__TSource_TKey__3__0; + + private static MethodInfo ThenByAwaitWithCancellation__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ThenByAwaitWithCancellation__TSource_TKey__3__0 ?? + (s_ThenByAwaitWithCancellation__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(ThenByAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -4543,13 +5195,15 @@ public static IOrderedAsyncQueryable ThenByAwaitWithCancellation)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByAwaitWithCancellation__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_ThenByDescending__TSource_TKey__2__0; + + private static MethodInfo ThenByDescending__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_ThenByDescending__TSource_TKey__2__0 ?? + (s_ThenByDescending__TSource_TKey__2__0 = new Func, Expression>, IOrderedAsyncQueryable>(ThenByDescending).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector) { if (source == null) @@ -4557,13 +5211,15 @@ public static IOrderedAsyncQueryable ThenByDescending(th if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByDescending__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_ThenByDescending__TSource_TKey__3__0; + + private static MethodInfo ThenByDescending__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ThenByDescending__TSource_TKey__3__0 ?? + (s_ThenByDescending__TSource_TKey__3__0 = new Func, Expression>, IComparer, IOrderedAsyncQueryable>(ThenByDescending).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByDescending(this IOrderedAsyncQueryable source, Expression> keySelector, IComparer comparer) { if (source == null) @@ -4571,13 +5227,15 @@ public static IOrderedAsyncQueryable ThenByDescending(th if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescending(default(IOrderedAsyncQueryable), default(Expression>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByDescending__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_ThenByDescendingAwait__TSource_TKey__2__0; + + private static MethodInfo ThenByDescendingAwait__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_ThenByDescendingAwait__TSource_TKey__2__0 ?? + (s_ThenByDescendingAwait__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(ThenByDescendingAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByDescendingAwait(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -4585,13 +5243,15 @@ public static IOrderedAsyncQueryable ThenByDescendingAwait)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwait(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByDescendingAwait__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_ThenByDescendingAwait__TSource_TKey__3__0; + + private static MethodInfo ThenByDescendingAwait__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ThenByDescendingAwait__TSource_TKey__3__0 ?? + (s_ThenByDescendingAwait__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(ThenByDescendingAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByDescendingAwait(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -4599,13 +5259,15 @@ public static IOrderedAsyncQueryable ThenByDescendingAwait)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwait(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByDescendingAwait__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_ThenByDescendingAwaitWithCancellation__TSource_TKey__2__0; + + private static MethodInfo ThenByDescendingAwaitWithCancellation__TSource_TKey__2__0(Type TSource, Type TKey) => + (s_ThenByDescendingAwaitWithCancellation__TSource_TKey__2__0 ?? + (s_ThenByDescendingAwaitWithCancellation__TSource_TKey__2__0 = new Func, Expression>>, IOrderedAsyncQueryable>(ThenByDescendingAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector) { if (source == null) @@ -4613,13 +5275,15 @@ public static IOrderedAsyncQueryable ThenByDescendingAwaitWithCancellat if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>))), source.Expression, keySelector)); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByDescendingAwaitWithCancellation__TSource_TKey__2__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector)); } + private static MethodInfo s_ThenByDescendingAwaitWithCancellation__TSource_TKey__3__0; + + private static MethodInfo ThenByDescendingAwaitWithCancellation__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ThenByDescendingAwaitWithCancellation__TSource_TKey__3__0 ?? + (s_ThenByDescendingAwaitWithCancellation__TSource_TKey__3__0 = new Func, Expression>>, IComparer, IOrderedAsyncQueryable>(ThenByDescendingAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static IOrderedAsyncQueryable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncQueryable source, Expression>> keySelector, IComparer comparer) { if (source == null) @@ -4627,25 +5291,29 @@ public static IOrderedAsyncQueryable ThenByDescendingAwaitWithCancellat if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ThenByDescendingAwaitWithCancellation(default(IOrderedAsyncQueryable), default(Expression>>), default(IComparer))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#else - return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); -#endif + return (IOrderedAsyncQueryable)source.Provider.CreateQuery(Expression.Call(ThenByDescendingAwaitWithCancellation__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer)))); } + private static MethodInfo s_ToArrayAsync__TSource__2__0; + + private static MethodInfo ToArrayAsync__TSource__2__0(Type TSource) => + (s_ToArrayAsync__TSource__2__0 ?? + (s_ToArrayAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>(ToArrayAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask ToArrayAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync(Expression.Call(InfoOf(() => AsyncQueryable.ToArrayAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync(Expression.Call(ToArrayAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAsync__TSource_TKey__3__0; + + private static MethodInfo ToDictionaryAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ToDictionaryAsync__TSource_TKey__3__0 ?? + (s_ToDictionaryAsync__TSource_TKey__3__0 = new Func, Expression>, CancellationToken, ValueTask>>(ToDictionaryAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4653,13 +5321,15 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAsync__TSource_TKey__4__0; + + private static MethodInfo ToDictionaryAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_ToDictionaryAsync__TSource_TKey__4__0 ?? + (s_ToDictionaryAsync__TSource_TKey__4__0 = new Func, Expression>, IEqualityComparer, CancellationToken, ValueTask>>(ToDictionaryAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4667,13 +5337,15 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAsync__TSource_TKey_TElement__4__0; + + private static MethodInfo ToDictionaryAsync__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_ToDictionaryAsync__TSource_TKey_TElement__4__0 ?? + (s_ToDictionaryAsync__TSource_TKey_TElement__4__0 = new Func, Expression>, Expression>, CancellationToken, ValueTask>>(ToDictionaryAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4683,13 +5355,15 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAsync__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAsync__TSource_TKey_TElement__5__0; + + private static MethodInfo ToDictionaryAsync__TSource_TKey_TElement__5__0(Type TSource, Type TKey, Type TElement) => + (s_ToDictionaryAsync__TSource_TKey_TElement__5__0 ?? + (s_ToDictionaryAsync__TSource_TKey_TElement__5__0 = new Func, Expression>, Expression>, IEqualityComparer, CancellationToken, ValueTask>>(ToDictionaryAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToDictionaryAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4699,13 +5373,15 @@ public static ValueTask> ToDictionaryAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAsync__TSource_TKey_TElement__5__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitAsync__TSource_TKey__3__0; + + private static MethodInfo ToDictionaryAwaitAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ToDictionaryAwaitAsync__TSource_TKey__3__0 ?? + (s_ToDictionaryAwaitAsync__TSource_TKey__3__0 = new Func, Expression>>, CancellationToken, ValueTask>>(ToDictionaryAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4713,13 +5389,15 @@ public static ValueTask> ToDictionaryAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitAsync__TSource_TKey__4__0; + + private static MethodInfo ToDictionaryAwaitAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_ToDictionaryAwaitAsync__TSource_TKey__4__0 ?? + (s_ToDictionaryAwaitAsync__TSource_TKey__4__0 = new Func, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToDictionaryAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4727,13 +5405,15 @@ public static ValueTask> ToDictionaryAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitAsync__TSource_TKey_TElement__4__0; + + private static MethodInfo ToDictionaryAwaitAsync__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_ToDictionaryAwaitAsync__TSource_TKey_TElement__4__0 ?? + (s_ToDictionaryAwaitAsync__TSource_TKey_TElement__4__0 = new Func, Expression>>, Expression>>, CancellationToken, ValueTask>>(ToDictionaryAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4743,13 +5423,15 @@ public static ValueTask> ToDictionaryAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitAsync__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitAsync__TSource_TKey_TElement__5__0; + + private static MethodInfo ToDictionaryAwaitAsync__TSource_TKey_TElement__5__0(Type TSource, Type TKey, Type TElement) => + (s_ToDictionaryAwaitAsync__TSource_TKey_TElement__5__0 ?? + (s_ToDictionaryAwaitAsync__TSource_TKey_TElement__5__0 = new Func, Expression>>, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToDictionaryAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4759,13 +5441,15 @@ public static ValueTask> ToDictionaryAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitAsync__TSource_TKey_TElement__5__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey__3__0; + + private static MethodInfo ToDictionaryAwaitWithCancellationAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey__3__0 ?? + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey__3__0 = new Func, Expression>>, CancellationToken, ValueTask>>(ToDictionaryAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4773,13 +5457,15 @@ public static ValueTask> ToDictionaryAwaitWithCancella if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitWithCancellationAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey__4__0; + + private static MethodInfo ToDictionaryAwaitWithCancellationAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey__4__0 ?? + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey__4__0 = new Func, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToDictionaryAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4787,13 +5473,15 @@ public static ValueTask> ToDictionaryAwaitWithCancella if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitWithCancellationAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__4__0; + + private static MethodInfo ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__4__0 ?? + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__4__0 = new Func, Expression>>, Expression>>, CancellationToken, ValueTask>>(ToDictionaryAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4803,13 +5491,15 @@ public static ValueTask> ToDictionaryAwaitWithCancell if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__5__0; + + private static MethodInfo ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__5__0(Type TSource, Type TKey, Type TElement) => + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__5__0 ?? + (s_ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__5__0 = new Func, Expression>>, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToDictionaryAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4819,49 +5509,57 @@ public static ValueTask> ToDictionaryAwaitWithCancell if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToDictionaryAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToDictionaryAwaitWithCancellationAsync__TSource_TKey_TElement__5__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToHashSetAsync__TSource__2__0; + + private static MethodInfo ToHashSetAsync__TSource__2__0(Type TSource) => + (s_ToHashSetAsync__TSource__2__0 ?? + (s_ToHashSetAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>>(ToHashSetAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask> ToHashSetAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToHashSetAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToHashSetAsync__TSource__3__0; + + private static MethodInfo ToHashSetAsync__TSource__3__0(Type TSource) => + (s_ToHashSetAsync__TSource__3__0 ?? + (s_ToHashSetAsync__TSource__3__0 = new Func, IEqualityComparer, CancellationToken, ValueTask>>(ToHashSetAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask> ToHashSetAsync(this IAsyncQueryable source, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToHashSetAsync(default(IAsyncQueryable), default(IEqualityComparer), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToHashSetAsync__TSource__3__0(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToListAsync__TSource__2__0; + + private static MethodInfo ToListAsync__TSource__2__0(Type TSource) => + (s_ToListAsync__TSource__2__0 ?? + (s_ToListAsync__TSource__2__0 = new Func, CancellationToken, ValueTask>>(ToListAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static ValueTask> ToListAsync(this IAsyncQueryable source, CancellationToken cancellationToken = default) { if (source == null) throw new ArgumentNullException(nameof(source)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToListAsync(default(IAsyncQueryable), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToListAsync__TSource__2__0(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAsync__TSource_TKey__3__0; + + private static MethodInfo ToLookupAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ToLookupAsync__TSource_TKey__3__0 ?? + (s_ToLookupAsync__TSource_TKey__3__0 = new Func, Expression>, CancellationToken, ValueTask>>(ToLookupAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4869,13 +5567,15 @@ public static ValueTask> ToLookupAsync(thi if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAsync__TSource_TKey__4__0; + + private static MethodInfo ToLookupAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_ToLookupAsync__TSource_TKey__4__0 ?? + (s_ToLookupAsync__TSource_TKey__4__0 = new Func, Expression>, IEqualityComparer, CancellationToken, ValueTask>>(ToLookupAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4883,13 +5583,15 @@ public static ValueTask> ToLookupAsync(thi if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAsync__TSource_TKey_TElement__4__0; + + private static MethodInfo ToLookupAsync__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_ToLookupAsync__TSource_TKey_TElement__4__0 ?? + (s_ToLookupAsync__TSource_TKey_TElement__4__0 = new Func, Expression>, Expression>, CancellationToken, ValueTask>>(ToLookupAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4899,13 +5601,15 @@ public static ValueTask> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAsync__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAsync__TSource_TKey_TElement__5__0; + + private static MethodInfo ToLookupAsync__TSource_TKey_TElement__5__0(Type TSource, Type TKey, Type TElement) => + (s_ToLookupAsync__TSource_TKey_TElement__5__0 ?? + (s_ToLookupAsync__TSource_TKey_TElement__5__0 = new Func, Expression>, Expression>, IEqualityComparer, CancellationToken, ValueTask>>(ToLookupAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToLookupAsync(this IAsyncQueryable source, Expression> keySelector, Expression> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4915,13 +5619,15 @@ public static ValueTask> ToLookupAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAsync(default(IAsyncQueryable), default(Expression>), default(Expression>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAsync__TSource_TKey_TElement__5__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitAsync__TSource_TKey__3__0; + + private static MethodInfo ToLookupAwaitAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ToLookupAwaitAsync__TSource_TKey__3__0 ?? + (s_ToLookupAwaitAsync__TSource_TKey__3__0 = new Func, Expression>>, CancellationToken, ValueTask>>(ToLookupAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4929,13 +5635,15 @@ public static ValueTask> ToLookupAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitAsync__TSource_TKey__4__0; + + private static MethodInfo ToLookupAwaitAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_ToLookupAwaitAsync__TSource_TKey__4__0 ?? + (s_ToLookupAwaitAsync__TSource_TKey__4__0 = new Func, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToLookupAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4943,13 +5651,15 @@ public static ValueTask> ToLookupAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitAsync__TSource_TKey_TElement__4__0; + + private static MethodInfo ToLookupAwaitAsync__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_ToLookupAwaitAsync__TSource_TKey_TElement__4__0 ?? + (s_ToLookupAwaitAsync__TSource_TKey_TElement__4__0 = new Func, Expression>>, Expression>>, CancellationToken, ValueTask>>(ToLookupAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4959,13 +5669,15 @@ public static ValueTask> ToLookupAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitAsync__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitAsync__TSource_TKey_TElement__5__0; + + private static MethodInfo ToLookupAwaitAsync__TSource_TKey_TElement__5__0(Type TSource, Type TKey, Type TElement) => + (s_ToLookupAwaitAsync__TSource_TKey_TElement__5__0 ?? + (s_ToLookupAwaitAsync__TSource_TKey_TElement__5__0 = new Func, Expression>>, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToLookupAwaitAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToLookupAwaitAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -4975,13 +5687,15 @@ public static ValueTask> ToLookupAwaitAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitAsync__TSource_TKey_TElement__5__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitWithCancellationAsync__TSource_TKey__3__0; + + private static MethodInfo ToLookupAwaitWithCancellationAsync__TSource_TKey__3__0(Type TSource, Type TKey) => + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey__3__0 ?? + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey__3__0 = new Func, Expression>>, CancellationToken, ValueTask>>(ToLookupAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, CancellationToken cancellationToken = default) { if (source == null) @@ -4989,13 +5703,15 @@ public static ValueTask> ToLookupAwaitWithCancellationAsy if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitWithCancellationAsync__TSource_TKey__3__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitWithCancellationAsync__TSource_TKey__4__0; + + private static MethodInfo ToLookupAwaitWithCancellationAsync__TSource_TKey__4__0(Type TSource, Type TKey) => + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey__4__0 ?? + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey__4__0 = new Func, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToLookupAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -5003,13 +5719,15 @@ public static ValueTask> ToLookupAwaitWithCancellationAsy if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitWithCancellationAsync__TSource_TKey__4__0(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__4__0; + + private static MethodInfo ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__4__0(Type TSource, Type TKey, Type TElement) => + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__4__0 ?? + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__4__0 = new Func, Expression>>, Expression>>, CancellationToken, ValueTask>>(ToLookupAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, CancellationToken cancellationToken = default) { if (source == null) @@ -5019,13 +5737,15 @@ public static ValueTask> ToLookupAwaitWithCancellationAs if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__4__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__5__0; + + private static MethodInfo ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__5__0(Type TSource, Type TKey, Type TElement) => + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__5__0 ?? + (s_ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__5__0 = new Func, Expression>>, Expression>>, IEqualityComparer, CancellationToken, ValueTask>>(ToLookupAwaitWithCancellationAsync).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource, TKey, TElement); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncQueryable source, Expression>> keySelector, Expression>> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) @@ -5035,13 +5755,15 @@ public static ValueTask> ToLookupAwaitWithCancellationAs if (elementSelector == null) throw new ArgumentNullException(nameof(elementSelector)); -#if CRIPPLED_REFLECTION - return source.Provider.ExecuteAsync>(Expression.Call(InfoOf(() => AsyncQueryable.ToLookupAwaitWithCancellationAsync(default(IAsyncQueryable), default(Expression>>), default(Expression>>), default(IEqualityComparer), default(CancellationToken))), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#else - return source.Provider.ExecuteAsync>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); -#endif + return source.Provider.ExecuteAsync>(Expression.Call(ToLookupAwaitWithCancellationAsync__TSource_TKey_TElement__5__0(typeof(TSource), typeof(TKey), typeof(TElement)), source.Expression, keySelector, elementSelector, Expression.Constant(comparer, typeof(IEqualityComparer)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken); } + private static MethodInfo s_Union__TSource__2__0; + + private static MethodInfo Union__TSource__2__0(Type TSource) => + (s_Union__TSource__2__0 ?? + (s_Union__TSource__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>(Union).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -5049,13 +5771,15 @@ public static IAsyncQueryable Union(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery(Expression.Call(Union__TSource__2__0(typeof(TSource)), first.Expression, GetSourceExpression(second))); } + private static MethodInfo s_Union__TSource__3__0; + + private static MethodInfo Union__TSource__3__0(Type TSource) => + (s_Union__TSource__3__0 ?? + (s_Union__TSource__3__0 = new Func, IAsyncEnumerable, IEqualityComparer, IAsyncQueryable>(Union).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Union(this IAsyncQueryable first, IAsyncEnumerable second, IEqualityComparer comparer) { if (first == null) @@ -5063,13 +5787,15 @@ public static IAsyncQueryable Union(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Union(default(IAsyncQueryable), default(IAsyncEnumerable), default(IEqualityComparer))), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); -#endif + return first.Provider.CreateQuery(Expression.Call(Union__TSource__3__0(typeof(TSource)), first.Expression, GetSourceExpression(second), Expression.Constant(comparer, typeof(IEqualityComparer)))); } + private static MethodInfo s_Where__TSource__2__0; + + private static MethodInfo Where__TSource__2__0(Type TSource) => + (s_Where__TSource__2__0 ?? + (s_Where__TSource__2__0 = new Func, Expression>, IAsyncQueryable>(Where).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -5077,13 +5803,15 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(Where__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_Where__TSource__2__1; + + private static MethodInfo Where__TSource__2__1(Type TSource) => + (s_Where__TSource__2__1 ?? + (s_Where__TSource__2__1 = new Func, Expression>, IAsyncQueryable>(Where).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable Where(this IAsyncQueryable source, Expression> predicate) { if (source == null) @@ -5091,13 +5819,15 @@ public static IAsyncQueryable Where(this IAsyncQueryable(Expression.Call(InfoOf(() => AsyncQueryable.Where(default(IAsyncQueryable), default(Expression>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(Where__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_WhereAwait__TSource__2__0; + + private static MethodInfo WhereAwait__TSource__2__0(Type TSource) => + (s_WhereAwait__TSource__2__0 ?? + (s_WhereAwait__TSource__2__0 = new Func, Expression>>, IAsyncQueryable>(WhereAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable WhereAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -5105,13 +5835,15 @@ public static IAsyncQueryable WhereAwait(this IAsyncQueryable< if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(WhereAwait__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_WhereAwait__TSource__2__1; + + private static MethodInfo WhereAwait__TSource__2__1(Type TSource) => + (s_WhereAwait__TSource__2__1 ?? + (s_WhereAwait__TSource__2__1 = new Func, Expression>>, IAsyncQueryable>(WhereAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable WhereAwait(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -5119,13 +5851,15 @@ public static IAsyncQueryable WhereAwait(this IAsyncQueryable< if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwait(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(WhereAwait__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_WhereAwaitWithCancellation__TSource__2__0; + + private static MethodInfo WhereAwaitWithCancellation__TSource__2__0(Type TSource) => + (s_WhereAwaitWithCancellation__TSource__2__0 ?? + (s_WhereAwaitWithCancellation__TSource__2__0 = new Func, Expression>>, IAsyncQueryable>(WhereAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable WhereAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -5133,13 +5867,15 @@ public static IAsyncQueryable WhereAwaitWithCancellation(this if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(WhereAwaitWithCancellation__TSource__2__0(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_WhereAwaitWithCancellation__TSource__2__1; + + private static MethodInfo WhereAwaitWithCancellation__TSource__2__1(Type TSource) => + (s_WhereAwaitWithCancellation__TSource__2__1 ?? + (s_WhereAwaitWithCancellation__TSource__2__1 = new Func, Expression>>, IAsyncQueryable>(WhereAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TSource); + public static IAsyncQueryable WhereAwaitWithCancellation(this IAsyncQueryable source, Expression>> predicate) { if (source == null) @@ -5147,13 +5883,15 @@ public static IAsyncQueryable WhereAwaitWithCancellation(this if (predicate == null) throw new ArgumentNullException(nameof(predicate)); -#if CRIPPLED_REFLECTION - return source.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.WhereAwaitWithCancellation(default(IAsyncQueryable), default(Expression>>))), source.Expression, predicate)); -#else - return source.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, predicate)); -#endif + return source.Provider.CreateQuery(Expression.Call(WhereAwaitWithCancellation__TSource__2__1(typeof(TSource)), source.Expression, predicate)); } + private static MethodInfo s_Zip__TFirst_TSecond_TResult__3__0; + + private static MethodInfo Zip__TFirst_TSecond_TResult__3__0(Type TFirst, Type TSecond, Type TResult) => + (s_Zip__TFirst_TSecond_TResult__3__0 ?? + (s_Zip__TFirst_TSecond_TResult__3__0 = new Func, IAsyncEnumerable, Expression>, IAsyncQueryable>(Zip).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TFirst, TSecond, TResult); + public static IAsyncQueryable Zip(this IAsyncQueryable first, IAsyncEnumerable second, Expression> selector) { if (first == null) @@ -5163,13 +5901,15 @@ public static IAsyncQueryable Zip(this IAsync if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>))), first.Expression, GetSourceExpression(second), selector)); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); -#endif + return first.Provider.CreateQuery(Expression.Call(Zip__TFirst_TSecond_TResult__3__0(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); } + private static MethodInfo s_ZipAwait__TFirst_TSecond_TResult__3__0; + + private static MethodInfo ZipAwait__TFirst_TSecond_TResult__3__0(Type TFirst, Type TSecond, Type TResult) => + (s_ZipAwait__TFirst_TSecond_TResult__3__0 ?? + (s_ZipAwait__TFirst_TSecond_TResult__3__0 = new Func, IAsyncEnumerable, Expression>>, IAsyncQueryable>(ZipAwait).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TFirst, TSecond, TResult); + public static IAsyncQueryable ZipAwait(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) { if (first == null) @@ -5179,13 +5919,15 @@ public static IAsyncQueryable ZipAwait(this I if (selector == null) throw new ArgumentNullException(nameof(selector)); -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery(Expression.Call(InfoOf(() => AsyncQueryable.ZipAwait(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); -#endif + return first.Provider.CreateQuery(Expression.Call(ZipAwait__TFirst_TSecond_TResult__3__0(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); } + private static MethodInfo s_ZipAwaitWithCancellation__TFirst_TSecond_TResult__3__0; + + private static MethodInfo ZipAwaitWithCancellation__TFirst_TSecond_TResult__3__0(Type TFirst, Type TSecond, Type TResult) => + (s_ZipAwaitWithCancellation__TFirst_TSecond_TResult__3__0 ?? + (s_ZipAwaitWithCancellation__TFirst_TSecond_TResult__3__0 = new Func, IAsyncEnumerable, Expression>>, IAsyncQueryable>(ZipAwaitWithCancellation).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TFirst, TSecond, TResult); + public static IAsyncQueryable ZipAwaitWithCancellation(this IAsyncQueryable first, IAsyncEnumerable second, Expression>> selector) { if (first == null) @@ -5195,12 +5937,8 @@ public static IAsyncQueryable ZipAwaitWithCancellation(Expression.Call(InfoOf(() => AsyncQueryable.ZipAwaitWithCancellation(default(IAsyncQueryable), default(IAsyncEnumerable), default(Expression>>))), first.Expression, GetSourceExpression(second), selector)); -#else - return first.Provider.CreateQuery(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); -#endif + return first.Provider.CreateQuery(Expression.Call(ZipAwaitWithCancellation__TFirst_TSecond_TResult__3__0(typeof(TFirst), typeof(TSecond), typeof(TResult)), first.Expression, GetSourceExpression(second), selector)); } } -} \ No newline at end of file +} diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt index 3f1079d6ea..82b1907f5d 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.Generated.tt @@ -3,292 +3,13 @@ // See the LICENSE file in the project root for more information. <#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ assembly name="System.Runtime" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> <#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Threading" #> -<#@ import namespace="System.Threading.Tasks" #> -<#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# +var asyncEnumerableType = typeof(AsyncEnumerable); +var className = "AsyncQueryable"; var nullableParameterNames = new[] { "comparer" }; var exclude = new[] { "ForEachAsync", "ForEachAwaitAsync", "ForEachAwaitWithCancellationAsync", "ToEnumerable", "ToAsyncEnumerable", "ToObservable", "AsAsyncEnumerable", "WithCancellation" }; - -var toQuotedImpl = default(Func); -toQuotedImpl = (t, i, b) => -{ -var name = t.Name; - -if (t.IsGenericType) -{ - var genDef = t.GetGenericTypeDefinition(); - name = genDef.Name.Substring(0, genDef.Name.LastIndexOf('`')); - - var genArgs = "<" + string.Join(", ", t.GetGenericArguments().Select(a => toQuotedImpl(a, i, false))) + ">"; - - if (b) - { - if (name == "Func" || name == "Action") - { - name = "Expression<" + name + genArgs + ">"; - } - else if (name == "IAsyncEnumerable" && i == 0) - { - name = "IAsyncQueryable" + genArgs; - } - else if (name == "IOrderedAsyncEnumerable" && i == 0) - { - name = "IOrderedAsyncQueryable" + genArgs; - } - else - { - name += genArgs; - } - } - else - { - if (name == "Nullable") - { - name = genArgs.Substring(1, genArgs.Length - 2) + "?"; - } - else - { - name += genArgs; - } - } -} -else if (t.IsArray) -{ - var elem = toQuotedImpl(t.GetElementType(), i, b); - name = elem + "[]"; -} -else -{ - if (t == typeof(int)) - { - name = "int"; - } - else if (t == typeof(long)) - { - name = "long"; - } - else if (t == typeof(float)) - { - name = "float"; - } - else if (t == typeof(double)) - { - name = "double"; - } - else if (t == typeof(decimal)) - { - name = "decimal"; - } - else if (t == typeof(bool)) - { - name = "bool"; - } - else if (t == typeof(object)) - { - name = "object"; - } -} - -return name; -}; - -var toQuoted = new Func((t, i) => toQuotedImpl(t, i, true)); -#> -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - public static partial class AsyncQueryable - { -<# -// NOTE: Just including extension methods -foreach (var m in typeof(AsyncEnumerable).GetMethods() - .Where(m => m.IsStatic) - .Where(m => !exclude.Contains(m.Name)) - .Where(m => m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - .Where(m => - { - var p0 = m.GetParameters()[0].ParameterType; - if (p0.IsGenericType) - { - var p0d = p0.GetGenericTypeDefinition(); - return p0d == typeof(IAsyncEnumerable<>) || p0d == typeof(IOrderedAsyncEnumerable<>); - } - - return false; - }) - .OrderBy(m => m.Name) - .ThenBy(m => m.IsGenericMethod ? m.GetGenericArguments().Length : 0) - .ThenBy(m => m.GetParameters().Length) - .ThenBy(m => string.Join(", ", m.GetParameters().Select((p, i) => toQuoted(p.ParameterType, i) + " " + p.Name)))) -{ - var genArgs = m.GetGenericArguments(); - - var ret = toQuoted(m.ReturnType, 0); - var name = m.Name; - - if (genArgs.Length > 0) - { - name += "<" + string.Join(", ", genArgs.Select(a => a.Name)) + ">"; - } - - var isParams = false; - var lastParameterDefault = false; - var parCount = m.GetParameters().Length; - - if (parCount != 0) - { - var lastParam = m.GetParameters().Last(); - - if (lastParam.IsDefined(typeof(ParamArrayAttribute), true)) - { - isParams = true; - } - - if (lastParam.ParameterType == typeof(CancellationToken)) - { - lastParameterDefault = true; - } - } - - var pars = string.Join(", ", m.GetParameters().Select((p, i) => (i == parCount - 1 && isParams ? "params " : "") + toQuoted(p.ParameterType, i) + " " + p.Name + (i == parCount - 1 && lastParameterDefault ? " = default" : ""))); - var quotedPars = string.Join(", ", m.GetParameters().Select((p, i) => "default(" + toQuoted(p.ParameterType, i) + ")")); - - if (m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true)) - { - pars = "this " + pars; - } - - var mtd = "(MethodInfo)MethodBase.GetCurrentMethod()"; - - if (m.IsGenericMethod) - { - mtd = "(" + mtd + ").MakeGenericMethod(" + string.Join(", ", genArgs.Select(a => "typeof(" + a.Name + ")")) + ")"; - } - - var provider = m.GetParameters()[0].Name + ".Provider"; - var factory = ""; - var rem = ""; - var cast = ""; - var quotedArgs = new List(); - - if (m.ReturnType.IsGenericType) - { - var td = m.ReturnType.GetGenericTypeDefinition(); - - if (td.Name.EndsWith("Task`1")) // NB: Covers Task and ValueTask - { - factory = "ExecuteAsync<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - - var last = m.GetParameters().Last(); - if (last.ParameterType == typeof(CancellationToken)) - { - rem = ", " + last.Name; - } - else - { - rem = ", CancellationToken.None"; - } - } - else if (td == typeof(IAsyncEnumerable<>) || td == typeof(IOrderedAsyncEnumerable<>)) - { - factory = "CreateQuery<" + toQuotedImpl(m.ReturnType.GetGenericArguments()[0], -1, false) + ">"; - - if (td == typeof(IOrderedAsyncEnumerable<>)) - { - cast = "(" + toQuoted(m.ReturnType, 0) + ")"; - } - } - } - - var n = 0; - foreach (var p in m.GetParameters()) - { - var pt = p.ParameterType; - - var add = false; - - if (pt.IsGenericType) - { - var ptd = pt.GetGenericTypeDefinition(); - - if (ptd == typeof(IAsyncEnumerable<>) || ptd == typeof(IOrderedAsyncEnumerable<>)) - { - if (n == 0) - { - quotedArgs.Add(p.Name + ".Expression"); - } - else - { - quotedArgs.Add("GetSourceExpression(" + p.Name + ")"); - } - add = true; - } - else if (ptd.Name.StartsWith("Func") || ptd.Name.StartsWith("Action")) - { - quotedArgs.Add(p.Name); - add = true; - } - } - - if (!add) - { - quotedArgs.Add("Expression.Constant(" + p.Name + ", typeof(" + toQuoted(pt, -1) + "))"); - } - - n++; - } - - var expr = "Expression.Call(" + mtd + ", " + string.Join(", ", quotedArgs) + ")"; - - var infoofmtd = "InfoOf(() => AsyncQueryable." + name + "(" + quotedPars + "))"; - var infoofexpr = "Expression.Call(" + infoofmtd + ", " + string.Join(", ", quotedArgs) + ")"; -#> - public static <#=ret#> <#=name#>(<#=pars#>) - { -<# -var any = false; -foreach (var p in m.GetParameters()) -{ - if (!p.ParameterType.IsValueType && !p.ParameterType.IsGenericParameter && !nullableParameterNames.Contains(p.Name)) - { - any = true; -#> - if (<#=p.Name#> == null) - throw new ArgumentNullException(nameof(<#=p.Name#>)); -<# - } -} -#> -<# -if (any) -{ -#> - -<# -} -#> -#if CRIPPLED_REFLECTION - return <#=cast#><#=provider#>.<#=factory#>(<#=infoofexpr#><#=rem#>); -#else - return <#=cast#><#=provider#>.<#=factory#>(<#=expr#><#=rem#>); -#endif - } - -<# -} #> - } -} \ No newline at end of file +<#@ include file="$(SolutionDir)\AsyncQueryableGenerator.t4" #> diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs index 5f3731d8fc..eb482900e5 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs @@ -35,6 +35,12 @@ public static IAsyncQueryable AsAsyncQueryable(this IAsyncEn } #if HAS_VALUETUPLE + private static MethodInfo s_Zip__TFirst_TSecond__2__0; + + private static MethodInfo Zip__TFirst_TSecond__2__0(Type TFirst, Type TSecond) => + (s_Zip__TFirst_TSecond__2__0 ?? + (s_Zip__TFirst_TSecond__2__0 = new Func, IAsyncEnumerable, IAsyncQueryable>>(Zip).GetMethodInfo().GetGenericMethodDefinition())).MakeGenericMethod(TFirst, TSecond); + public static IAsyncQueryable<(TFirst First, TSecond Second)> Zip(this IAsyncQueryable first, IAsyncEnumerable second) { if (first == null) @@ -42,11 +48,7 @@ public static IAsyncQueryable AsAsyncQueryable(this IAsyncEn if (second == null) throw new ArgumentNullException(nameof(second)); -#if CRIPPLED_REFLECTION - return first.Provider.CreateQuery<(TFirst, TSecond)>(Expression.Call(InfoOf(() => AsyncQueryable.Zip(default(IAsyncQueryable), default(IAsyncEnumerable))), first.Expression, GetSourceExpression(second))); -#else - return first.Provider.CreateQuery<(TFirst, TSecond)>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond)), first.Expression, GetSourceExpression(second))); -#endif + return first.Provider.CreateQuery<(TFirst, TSecond)>(Expression.Call(s_Zip__TFirst_TSecond__2__0(typeof(TFirst), typeof(TSecond)), first.Expression, GetSourceExpression(second))); } #endif @@ -59,10 +61,5 @@ private static Expression GetSourceExpression(IAsyncEnumerable return Expression.Constant(source, typeof(IAsyncEnumerable)); } - - internal static MethodInfo InfoOf(Expression> f) - { - return ((MethodCallExpression)f.Body).Method; - } } } From b49a479aabcc20d7721fbf4c455f3ca76ed64a28 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 21:06:08 -0800 Subject: [PATCH 843/862] Fix AsyncQueryable.Zip. --- .../System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs index eb482900e5..a0aeac1b26 100644 --- a/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs +++ b/Ix.NET/Source/System.Linq.Async.Queryable/System/Linq/AsyncQueryable.cs @@ -48,7 +48,7 @@ private static MethodInfo Zip__TFirst_TSecond__2__0(Type TFirst, Type TSecond) = if (second == null) throw new ArgumentNullException(nameof(second)); - return first.Provider.CreateQuery<(TFirst, TSecond)>(Expression.Call(s_Zip__TFirst_TSecond__2__0(typeof(TFirst), typeof(TSecond)), first.Expression, GetSourceExpression(second))); + return first.Provider.CreateQuery<(TFirst, TSecond)>(Expression.Call(Zip__TFirst_TSecond__2__0(typeof(TFirst), typeof(TSecond)), first.Expression, GetSourceExpression(second))); } #endif From 73ee1d29498ae06b8327059f8547cf658f9ea0fc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 21:11:49 -0800 Subject: [PATCH 844/862] Clean up tests for Average. --- .../Linq/Operators/Average.Generated.cs | 240 ++++++++++++ .../Linq/Operators/Average.Generated.tt | 48 +++ .../System/Linq/Operators/Average.cs | 348 ------------------ 3 files changed, 288 insertions(+), 348 deletions(-) delete mode 100644 Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs index 88017bb473..ce067f574e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.cs @@ -13,6 +13,12 @@ namespace Tests { public class AverageAsync : AsyncEnumerableTests { + [Fact] + public async Task AverageAsync_Int32_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Int32_Empty() { @@ -28,6 +34,13 @@ public async Task AverageAsync_Int32_Many() Assert.Equal(xs.Average(), await ys.AverageAsync()); } + [Fact] + public async Task AverageAsync_Selector_Int32_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + } + [Fact] public async Task AverageAsync_Selector_Int32_Empty() { @@ -43,6 +56,13 @@ public async Task AverageAsync_Selector_Int32_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Int32_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitAsync_Selector_Int32_Empty() { @@ -59,6 +79,13 @@ public async Task AverageAwaitAsync_Selector_Int32_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Empty() { @@ -75,6 +102,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Many() } #endif + [Fact] + public async Task AverageAsync_Int32_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Int32_Nullable_Empty() { @@ -105,6 +138,14 @@ public async Task AverageAsync_Selector_Int32_Nullable_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Int32_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + + [Fact] public async Task AverageAwaitAsync_Selector_Int32_Nullable_Empty() { @@ -121,6 +162,13 @@ public async Task AverageAwaitAsync_Selector_Int32_Nullable_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Nullable_Empty() { @@ -137,6 +185,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Int32_Nullable_Many } #endif + [Fact] + public async Task AverageAsync_Int64_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Int64_Empty() { @@ -152,6 +206,13 @@ public async Task AverageAsync_Int64_Many() Assert.Equal(xs.Average(), await ys.AverageAsync()); } + [Fact] + public async Task AverageAsync_Selector_Int64_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + } + [Fact] public async Task AverageAsync_Selector_Int64_Empty() { @@ -167,6 +228,13 @@ public async Task AverageAsync_Selector_Int64_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Int64_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitAsync_Selector_Int64_Empty() { @@ -183,6 +251,13 @@ public async Task AverageAwaitAsync_Selector_Int64_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Empty() { @@ -199,6 +274,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Many() } #endif + [Fact] + public async Task AverageAsync_Int64_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Int64_Nullable_Empty() { @@ -229,6 +310,14 @@ public async Task AverageAsync_Selector_Int64_Nullable_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Int64_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + + [Fact] public async Task AverageAwaitAsync_Selector_Int64_Nullable_Empty() { @@ -245,6 +334,13 @@ public async Task AverageAwaitAsync_Selector_Int64_Nullable_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Nullable_Empty() { @@ -261,6 +357,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Int64_Nullable_Many } #endif + [Fact] + public async Task AverageAsync_Single_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Single_Empty() { @@ -276,6 +378,13 @@ public async Task AverageAsync_Single_Many() Assert.Equal(xs.Average(), await ys.AverageAsync()); } + [Fact] + public async Task AverageAsync_Selector_Single_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + } + [Fact] public async Task AverageAsync_Selector_Single_Empty() { @@ -291,6 +400,13 @@ public async Task AverageAsync_Selector_Single_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Single_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitAsync_Selector_Single_Empty() { @@ -307,6 +423,13 @@ public async Task AverageAwaitAsync_Selector_Single_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Single_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Single_Empty() { @@ -323,6 +446,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Single_Many() } #endif + [Fact] + public async Task AverageAsync_Single_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Single_Nullable_Empty() { @@ -353,6 +482,14 @@ public async Task AverageAsync_Selector_Single_Nullable_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Single_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + + [Fact] public async Task AverageAwaitAsync_Selector_Single_Nullable_Empty() { @@ -369,6 +506,13 @@ public async Task AverageAwaitAsync_Selector_Single_Nullable_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Single_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Single_Nullable_Empty() { @@ -385,6 +529,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Single_Nullable_Man } #endif + [Fact] + public async Task AverageAsync_Double_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Double_Empty() { @@ -400,6 +550,13 @@ public async Task AverageAsync_Double_Many() Assert.Equal(xs.Average(), await ys.AverageAsync()); } + [Fact] + public async Task AverageAsync_Selector_Double_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + } + [Fact] public async Task AverageAsync_Selector_Double_Empty() { @@ -415,6 +572,13 @@ public async Task AverageAsync_Selector_Double_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Double_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitAsync_Selector_Double_Empty() { @@ -431,6 +595,13 @@ public async Task AverageAwaitAsync_Selector_Double_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Double_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Double_Empty() { @@ -447,6 +618,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Double_Many() } #endif + [Fact] + public async Task AverageAsync_Double_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Double_Nullable_Empty() { @@ -477,6 +654,14 @@ public async Task AverageAsync_Selector_Double_Nullable_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Double_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + + [Fact] public async Task AverageAwaitAsync_Selector_Double_Nullable_Empty() { @@ -493,6 +678,13 @@ public async Task AverageAwaitAsync_Selector_Double_Nullable_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Double_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Double_Nullable_Empty() { @@ -509,6 +701,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Double_Nullable_Man } #endif + [Fact] + public async Task AverageAsync_Decimal_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Decimal_Empty() { @@ -524,6 +722,13 @@ public async Task AverageAsync_Decimal_Many() Assert.Equal(xs.Average(), await ys.AverageAsync()); } + [Fact] + public async Task AverageAsync_Selector_Decimal_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); + } + [Fact] public async Task AverageAsync_Selector_Decimal_Empty() { @@ -539,6 +744,13 @@ public async Task AverageAsync_Selector_Decimal_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Decimal_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitAsync_Selector_Decimal_Empty() { @@ -555,6 +767,13 @@ public async Task AverageAwaitAsync_Selector_Decimal_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Empty() { @@ -571,6 +790,12 @@ public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Many() } #endif + [Fact] + public async Task AverageAsync_Decimal_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); + } + [Fact] public async Task AverageAsync_Decimal_Nullable_Empty() { @@ -601,6 +826,14 @@ public async Task AverageAsync_Selector_Decimal_Nullable_Many() Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_Decimal_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + + [Fact] public async Task AverageAwaitAsync_Selector_Decimal_Nullable_Empty() { @@ -617,6 +850,13 @@ public async Task AverageAwaitAsync_Selector_Decimal_Nullable_Many() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Nullable_Empty() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt index 067549d6a4..38beb77161 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.Generated.tt @@ -43,6 +43,12 @@ foreach (var t in types) { var cs = toCSharp(t); #> + [Fact] + public async Task AverageAsync_<#=t.Name#>_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable<<#=cs#>>)).AsTask()); + } + [Fact] public async Task AverageAsync_<#=t.Name#>_Empty() { @@ -58,6 +64,13 @@ foreach (var t in types) Assert.Equal(xs.Average(), await ys.AverageAsync()); } + [Fact] + public async Task AverageAsync_Selector_<#=t.Name#>_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable<<#=cs#>>), x => x).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); + } + [Fact] public async Task AverageAsync_Selector_<#=t.Name#>_Empty() { @@ -73,6 +86,13 @@ foreach (var t in types) Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable<<#=cs#>>), x => new ValueTask<<#=cs#>>(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>>)).AsTask()); + } + [Fact] public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Empty() { @@ -89,6 +109,13 @@ foreach (var t in types) } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable<<#=cs#>>), (x, ct) => new ValueTask<<#=cs#>>(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Empty() { @@ -105,6 +132,12 @@ foreach (var t in types) } #endif + [Fact] + public async Task AverageAsync_<#=t.Name#>_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable<<#=cs#>?>)).AsTask()); + } + [Fact] public async Task AverageAsync_<#=t.Name#>_Nullable_Empty() { @@ -135,6 +168,14 @@ foreach (var t in types) Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); } + [Fact] + public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable<<#=cs#>?>), x => new ValueTask<<#=cs#>?>(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func?>>)).AsTask()); + } + + [Fact] public async Task AverageAwaitAsync_Selector_<#=t.Name#>_Nullable_Empty() { @@ -151,6 +192,13 @@ foreach (var t in types) } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Nullable_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable<<#=cs#>?>), (x, ct) => new ValueTask<<#=cs#>?>(x)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func?>>)).AsTask()); + } + [Fact] public async Task AverageAwaitWithCancellationAsync_Selector_<#=t.Name#>_Nullable_Empty() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs deleted file mode 100644 index f6154e421a..0000000000 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Average.cs +++ /dev/null @@ -1,348 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Tests -{ - public class Average : AsyncEnumerableTests - { - [Fact] - public async Task Average_Null() - { - // Average(IAE

) - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable)).AsTask()); - - // Average(IAE

, CT) - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), CancellationToken.None).AsTask()); - - // Average(IAE, Func) - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func)).AsTask()); - - // Average(IAE, Func, CT) - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(default(IAsyncEnumerable), x => x, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAsync(AsyncEnumerable.Empty(), default(Func), CancellationToken.None).AsTask()); - - // Average(IAE, Func>) - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>)).AsTask()); - - // Average(IAE, Func>, CT) - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(default(IAsyncEnumerable), x => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - -#if !NO_DEEP_CANCELLATION - // Average(IAE, Func>, CT) - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(default(IAsyncEnumerable), (x, ct) => new ValueTask(x), CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.AverageAwaitWithCancellationAsync(AsyncEnumerable.Empty(), default(Func>), CancellationToken.None).AsTask()); -#endif - } - - [Fact] - public async Task Average1() - { - var xs = new[] { 1, 2, 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average2() - { - var xs = new[] { 1, default(int?), 3 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average3() - { - var xs = new[] { 1L, 2L, 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average4() - { - var xs = new[] { 1L, default(long?), 3L }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average5() - { - var xs = new[] { 1.0, 2.0, 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average6() - { - var xs = new[] { 1.0, default(double?), 3.0 }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average7() - { - var xs = new[] { 1.0f, 2.0f, 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average8() - { - var xs = new[] { 1.0f, default(float?), 3.0f }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average9() - { - var xs = new[] { 1.0m, 2.0m, 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average10() - { - var xs = new[] { 1.0m, default(decimal?), 3.0m }; - var ys = xs.ToAsyncEnumerable(); - Assert.Equal(xs.Average(), await ys.AverageAsync()); - Assert.Equal(xs.Average(), await ys.AverageAsync(x => x)); - Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask(x))); - } - - [Fact] - public async Task Average11() - { - var xs = new int[0]; - var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); - } - - [Fact] - public async Task Average12() - { - var xs = new int?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync()); - } - - [Fact] - public async Task Average13() - { - var xs = new long[0]; - var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); - } - - [Fact] - public async Task Average14() - { - var xs = new long?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync()); - } - - [Fact] - public async Task Average15() - { - var xs = new double[0]; - var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); - } - - [Fact] - public async Task Average16() - { - var xs = new double?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync()); - } - - [Fact] - public async Task Average17() - { - var xs = new float[0]; - var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); - } - - [Fact] - public async Task Average18() - { - var xs = new float?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync()); - } - - [Fact] - public async Task Average19() - { - var xs = new decimal[0]; - var ys = xs.ToAsyncEnumerable(); - await Assert.ThrowsAsync(() => ys.AverageAsync().AsTask()); - } - - [Fact] - public async Task Average20() - { - var xs = new decimal?[0]; - var ys = xs.ToAsyncEnumerable(); - Assert.Null(await ys.AverageAsync()); - } - } -} From 39856c17739877403f984af8985f13f7d952a097 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 21:49:59 -0800 Subject: [PATCH 845/862] Clean up [First|Last][OrDefault] tests. --- .../System/Linq/Operators/First.cs | 45 +++++++++++------- .../System/Linq/Operators/FirstOrDefault.cs | 47 +++++++++++-------- .../System/Linq/Operators/Last.cs | 47 +++++++++++-------- .../System/Linq/Operators/LastOrDefault.cs | 47 +++++++++++-------- 4 files changed, 111 insertions(+), 75 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs index 40c047739e..7024cf68fc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/First.cs @@ -16,25 +16,7 @@ public class First : AsyncEnumerableTests public async Task FirstAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(Return42, default).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(Return42, default, CancellationToken.None).AsTask()); - -#if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); -#endif } [Fact] @@ -94,6 +76,16 @@ public async Task FirstAsync_NoParam_Many() Assert.Equal(42, await res); } + [Fact] + public async Task FirstAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default(Func)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task FirstAsync_Predicate_Empty() { @@ -172,6 +164,16 @@ public async Task FirstAsync_Predicate_PredicateThrows() await AssertThrowsAsync(res.AsTask()); } + [Fact] + public async Task FirstAwaitAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(Return42, default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task FirstAwaitAsync_Predicate_Empty() { @@ -251,6 +253,13 @@ public async Task FirstAwaitAsync_Predicate_AsyncPredicateThrows() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task FirstAwaitWithCancellationAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task FirstAwaitWithCancellationAsync_Predicate_Empty() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs index 5af5877bab..79aac7eb6d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/FirstOrDefault.cs @@ -13,28 +13,10 @@ namespace Tests public class FirstOrDefault : AsyncEnumerableTests { [Fact] - public async Task FirstOrDefault_Null() + public async Task FirstOrDefaultAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(Return42, default).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(Return42, default, CancellationToken.None).AsTask()); - -#if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); -#endif } [Fact] @@ -95,6 +77,16 @@ public async Task FirstOrDefaultAsync_NoParam_Many() Assert.Equal(42, await res); } + [Fact] + public async Task FirstOrDefaultAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default(Func)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task FirstOrDefaultAsync_Predicate_Empty() { @@ -173,6 +165,16 @@ public async Task FirstOrDefaultAsync_Predicate_PredicateThrows() await AssertThrowsAsync(res.AsTask()); } + [Fact] + public async Task FirstOrDefaultAwaitAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(Return42, default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task FirstOrDefaultAwaitAsync_Predicate_Empty() { @@ -252,6 +254,13 @@ public async Task FirstOrDefaultAwaitAsync_Predicate_AsyncPredicateThrows() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.FirstOrDefaultAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task FirstOrDefaultAwaitWithCancellationAsync_Predicate_Empty() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs index 026ebe24f9..a2b54d937f 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Last.cs @@ -13,28 +13,10 @@ namespace Tests public class Last : AsyncEnumerableTests { [Fact] - public async Task Last_Null() + public async Task LastAsync_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(Return42, default).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(Return42, default, CancellationToken.None).AsTask()); - -#if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); -#endif } [Fact] @@ -94,6 +76,16 @@ public async Task LastAsync_NoParam_Many() Assert.Equal(44, await res); } + [Fact] + public async Task LastAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default(Func)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task LastAsync_Predicate_Empty() { @@ -172,6 +164,16 @@ public async Task LastAsync_Predicate_PredicateThrows() await AssertThrowsAsync(res.AsTask()); } + [Fact] + public async Task LastAwaitAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(Return42, default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task LastAwaitAsync_Predicate_Empty() { @@ -251,6 +253,13 @@ public async Task LastAwaitAsync_Predicate_AsyncPredicateThrows() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task LastAwaitWithCancellationAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task LastAwaitWithCancellationAsync_Predicate_Empty() { diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs index 9f39b5738e..0b86e06fc9 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LastOrDefault.cs @@ -13,28 +13,10 @@ namespace Tests public class LastOrDefault : AsyncEnumerableTests { [Fact] - public async Task LastOrDefault_Null() + public async Task LastOrDefaultAsync_NoParam_Null() { await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func)).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default, CancellationToken.None).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(default, x => new ValueTask(true)).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(Return42, default).AsTask()); - - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(Return42, default, CancellationToken.None).AsTask()); - -#if !NO_DEEP_CANCELLATION - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); - await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); -#endif } [Fact] @@ -94,6 +76,16 @@ public async Task LastOrDefaultAsync_NoParam_Many() Assert.Equal(44, await res); } + [Fact] + public async Task LastOrDefaultAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default(Func)).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(default, x => true, CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task LastOrDefaultAsync_Predicate_Empty() { @@ -172,6 +164,16 @@ public async Task LastOrDefaultAsync_Predicate_PredicateThrows() await AssertThrowsAsync(res.AsTask()); } + [Fact] + public async Task LastOrDefaultAwaitAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(default, x => new ValueTask(true)).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(Return42, default).AsTask()); + + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(default, x => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task LastOrDefaultAwaitAsync_Predicate_Empty() { @@ -251,6 +253,13 @@ public async Task LastOrDefaultAwaitAsync_Predicate_AsyncPredicateThrows() } #if !NO_DEEP_CANCELLATION + [Fact] + public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Null() + { + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitWithCancellationAsync(default, (x, ct) => new ValueTask(true), CancellationToken.None).AsTask()); + await Assert.ThrowsAsync(() => AsyncEnumerable.LastOrDefaultAwaitWithCancellationAsync(Return42, default, CancellationToken.None).AsTask()); + } + [Fact] public async Task LastOrDefaultAwaitWithCancellationAsync_Predicate_Empty() { From bd4dccc76402476762b370db05c9d8b04d1a1056 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 21:50:17 -0800 Subject: [PATCH 846/862] Clean up [Ap|Pre]pend tests. --- .../System/Linq/Operators/Append.cs | 77 +++++++++++++++---- .../System/Linq/Operators/Prepend.cs | 65 ++++++++++++---- 2 files changed, 111 insertions(+), 31 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs index 72dac446f6..ccf5f50c3d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Append.cs @@ -19,7 +19,7 @@ public void Append_Null() } [Fact] - public async Task Append1() + public async Task Append_Simple() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -35,7 +35,7 @@ public async Task Append1() } [Fact] - public async Task Append2() + public async Task Append_IAsyncIListProvider_ICollection_ToArray() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -48,7 +48,7 @@ public async Task Append2() } [Fact] - public async Task Append3() + public async Task Append_IAsyncIListProvider_ICollection_ToList() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -61,7 +61,7 @@ public async Task Append3() } [Fact] - public async Task Append4() + public async Task Append_IAsyncIListProvider_ICollection_Count() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -71,9 +71,9 @@ public async Task Append4() } [Fact] - public async Task Append5() + public async Task Append_IAsyncIListProvider_ToArray() { - var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + var xs = new[] { 1, 2, 3 }.Where(x => true).ToAsyncEnumerable(); var res = xs.Append(4); @@ -84,9 +84,22 @@ public async Task Append5() } [Fact] - public async Task Append6() + public async Task Append_IAsyncIListProvider_ToList() { - var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + var xs = new[] { 1, 2, 3 }.Where(x => true).ToAsyncEnumerable(); + + var res = xs.Append(4); + + var a = new List { 1, 2, 3, 4 }; + + var arr = await res.ToListAsync(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Append_IAsyncIListProvider_Count() + { + var xs = new[] { 1, 2, 3 }.Where(x => true).ToAsyncEnumerable(); var res = xs.Append(4); @@ -94,7 +107,20 @@ public async Task Append6() } [Fact] - public async Task Append7() + public async Task Append_ToArray() + { + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + + var res = xs.Append(4); + + var a = new[] { 1, 2, 3, 4 }; + + var arr = await res.ToArrayAsync(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Append_ToList() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -106,9 +132,28 @@ public async Task Append7() Assert.Equal(a, arr); } + [Fact] + public async Task Append_Count() + { + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + + var res = xs.Append(4); + + Assert.Equal(4, await res.CountAsync()); + } + + [Fact] + public async Task Append_SequenceIdentity() + { + var xs = AsyncEnumerable.Range(1, 3).Where(i => true); + + var res = xs.Append(4); + + await SequenceIdentity(res); + } [Fact] - public async Task AppendN1() + public async Task Append_Many_Simple() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -128,7 +173,7 @@ public async Task AppendN1() } [Fact] - public async Task AppendN2() + public async Task Append_Many_IAsyncIListProvider_ToArray() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -143,7 +188,7 @@ public async Task AppendN2() } [Fact] - public async Task AppendN3() + public async Task Append_Many_IAsyncIListProvider_ToList() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -158,7 +203,7 @@ public async Task AppendN3() } [Fact] - public async Task AppendN4() + public async Task Append_Many_IAsyncIListProvider_Count() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -170,7 +215,7 @@ public async Task AppendN4() } [Fact] - public async Task AppendN5() + public async Task Append_Many_ToArray() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -185,7 +230,7 @@ public async Task AppendN5() } [Fact] - public async Task AppendN6() + public async Task Append_Many_ToList() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -200,7 +245,7 @@ public async Task AppendN6() } [Fact] - public async Task AppendN7() + public async Task Append_Many_Count() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs index 95513d3d2d..983d289b16 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Prepend.cs @@ -19,7 +19,7 @@ public void Prepend_Null() } [Fact] - public async Task Prepend1Async() + public async Task Prepend_Simple() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -35,7 +35,7 @@ public async Task Prepend1Async() } [Fact] - public async Task Prepend2() + public async Task Prepend_IAsyncIListProvider_ICollection_ToArray() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -48,7 +48,7 @@ public async Task Prepend2() } [Fact] - public async Task Prepend3() + public async Task Prepend_IAsyncIListProvider_ICollection_ToList() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -61,7 +61,7 @@ public async Task Prepend3() } [Fact] - public async Task Prepend4() + public async Task Prepend_IAsyncIListProvider_ICollection_Count() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -70,7 +70,42 @@ public async Task Prepend4() } [Fact] - public async Task Prepend5() + public async Task Prepend_IAsyncIListProvider_ToArray() + { + var xs = new[] { 1, 2, 3 }.Where(x => true).ToAsyncEnumerable(); + + var res = xs.Prepend(4); + + var a = new[] { 4, 1, 2, 3 }; + + var arr = await res.ToArrayAsync(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Prepend_IAsyncIListProvider_ToList() + { + var xs = new[] { 1, 2, 3 }.Where(x => true).ToAsyncEnumerable(); + + var res = xs.Prepend(4); + + var a = new List { 4, 1, 2, 3 }; + + var arr = await res.ToListAsync(); + Assert.Equal(a, arr); + } + + [Fact] + public async Task Prepend_IAsyncIListProvider_Count() + { + var xs = new[] { 1, 2, 3 }.Where(x => true).ToAsyncEnumerable(); + + var res = xs.Prepend(4); + Assert.Equal(4, await res.CountAsync()); + } + + [Fact] + public async Task Prepend_ToArray() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -83,7 +118,7 @@ public async Task Prepend5() } [Fact] - public async Task Prepend6() + public async Task Prepend_ToList() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -96,7 +131,7 @@ public async Task Prepend6() } [Fact] - public async Task Prepend7() + public async Task Prepend_Count() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -105,7 +140,7 @@ public async Task Prepend7() } [Fact] - public async Task Prepend8() + public async Task Prepend_SequenceIdentity() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -115,7 +150,7 @@ public async Task Prepend8() } [Fact] - public async Task PrependN1Async() + public async Task Prepend_Many_Simple() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -135,7 +170,7 @@ public async Task PrependN1Async() } [Fact] - public async Task PrependN2() + public async Task Prepend_Many_IAsyncIListProvider_ToArray() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -150,7 +185,7 @@ public async Task PrependN2() } [Fact] - public async Task PrependN3() + public async Task Prepend_Many_IAsyncIListProvider_ToList() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -165,7 +200,7 @@ public async Task PrependN3() } [Fact] - public async Task PrependN4() + public async Task Prepend_Many_IAsyncIListProvider_Count() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); @@ -177,7 +212,7 @@ public async Task PrependN4() } [Fact] - public async Task PrependN5() + public async Task Prepend_Many_ToArray() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -192,7 +227,7 @@ public async Task PrependN5() } [Fact] - public async Task PrependN6() + public async Task Prepend_Many_ToList() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); @@ -207,7 +242,7 @@ public async Task PrependN6() } [Fact] - public async Task PrependN7() + public async Task Prepend_Many_Count() { var xs = AsyncEnumerable.Range(1, 3).Where(i => true); From 0e5c7f836449924e2cf73a190bc4f04c6253f0d4 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 21:50:29 -0800 Subject: [PATCH 847/862] Clean up Cast and OfType tests. --- .../System/Linq/Operators/Cast.cs | 28 +++++++++++++++++-- .../System/Linq/Operators/OfType.cs | 14 +++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs index 9402d381a5..f21ac9b48b 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Cast.cs @@ -18,7 +18,20 @@ public void Cast_Null() } [Fact] - public async Task Cast1() + public async Task Cast_References() + { + var xs = new object[] { "bar", "foo", "qux" }.ToAsyncEnumerable(); + var ys = xs.Cast(); + + var e = ys.GetAsyncEnumerator(); + await HasNextAsync(e, "bar"); + await HasNextAsync(e, "foo"); + await HasNextAsync(e, "qux"); + await NoNextAsync(e); + } + + [Fact] + public async Task Cast_Values() { var xs = new object[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Cast(); @@ -32,7 +45,18 @@ public async Task Cast1() } [Fact] - public void Cast2() + public async Task Cast_InvalidCast() + { + var xs = new object[] { 42, "foo", 43 }.ToAsyncEnumerable(); + var ys = xs.Cast(); + + var e = ys.GetAsyncEnumerator(); + await HasNextAsync(e, 42); + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); + } + + [Fact] + public void Cast_Aliasing() { var xs = new[] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable(); var ys = xs.Cast(); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs index d48cb92eab..a012f46ede 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/OfType.cs @@ -18,7 +18,7 @@ public void OfType_Null() } [Fact] - public async Task OfType1Async() + public async Task OfType_Int32() { var xs = new object[] { 1, 1.2, true, 4, "" }.ToAsyncEnumerable(); var ys = xs.OfType(); @@ -28,5 +28,17 @@ public async Task OfType1Async() await HasNextAsync(e, 4); await NoNextAsync(e); } + + [Fact] + public async Task OfType_String() + { + var xs = new object[] { "bar", 42, "foo", 43 }.ToAsyncEnumerable(); + var ys = xs.OfType(); + + var e = ys.GetAsyncEnumerator(); + await HasNextAsync(e, "bar"); + await HasNextAsync(e, "foo"); + await NoNextAsync(e); + } } } From afda630367bc6639651bb236f6f8ca6c51a603ac Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 21:50:39 -0800 Subject: [PATCH 848/862] Clean up Concat tests. --- .../System/Linq/Operators/Concat.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs index a15459b070..290460edcc 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Concat.cs @@ -20,7 +20,7 @@ public void Concat_Null() } [Fact] - public async Task Concat1Async() + public async Task Concat_Simple() { var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); @@ -35,7 +35,7 @@ public async Task Concat1Async() } [Fact] - public async Task Concat2Async() + public async Task Concat_Throw_Second() { var ex = new Exception("Bang"); var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Concat(Throw(ex)); @@ -48,7 +48,7 @@ public async Task Concat2Async() } [Fact] - public async Task Concat3Async() + public async Task Concat_Throw_First() { var ex = new Exception("Bang"); var ys = Throw(ex).Concat(new[] { 4, 5, 6 }.ToAsyncEnumerable()); @@ -58,7 +58,7 @@ public async Task Concat3Async() } [Fact] - public async Task Concat7Async() + public async Task Concat_Four() { var ws = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var xs = new[] { 4, 5 }.ToAsyncEnumerable(); @@ -83,7 +83,7 @@ public async Task Concat7Async() } [Fact] - public async Task Concat8() + public async Task Concat_SequenceIdentity() { var ws = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var xs = new[] { 4, 5 }.ToAsyncEnumerable(); @@ -96,7 +96,7 @@ public async Task Concat8() } [Fact] - public async Task Concat10() + public async Task Concat_Three_ToArray() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5 }.ToAsyncEnumerable(); @@ -109,7 +109,7 @@ public async Task Concat10() } [Fact] - public async Task Concat11() + public async Task Concat_Three_ToList() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5 }.ToAsyncEnumerable(); @@ -122,7 +122,7 @@ public async Task Concat11() } [Fact] - public async Task Concat12() + public async Task Concat_Three_Count() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5 }.ToAsyncEnumerable(); From f0e8a535a08cdbadfc7a0fae043bbf04903aca6d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 21:50:48 -0800 Subject: [PATCH 849/862] Clean up Distinct tests. --- .../System/Linq/Operators/Distinct.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs index 3917d28925..c3e4da7aff 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Distinct.cs @@ -20,7 +20,7 @@ public void Distinct_Null() } [Fact] - public async Task Distinct1() + public async Task Distinct_Simple() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); @@ -34,7 +34,7 @@ public async Task Distinct1() } [Fact] - public async Task Distinct2() + public async Task Distinct_Comparer() { var xs = new[] { 1, -2, -1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(new Eq()); @@ -48,7 +48,7 @@ public async Task Distinct2() } [Fact] - public async Task Distinct3() + public async Task Distinct_ToArray() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); @@ -57,7 +57,7 @@ public async Task Distinct3() } [Fact] - public async Task Distinct4() + public async Task Distinct_ToList() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); @@ -66,7 +66,7 @@ public async Task Distinct4() } [Fact] - public async Task Distinct5() + public async Task Distinct_Count() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); @@ -74,7 +74,7 @@ public async Task Distinct5() } [Fact] - public async Task Distinct10() + public async Task Distinct_SequenceIdentity() { var xs = new[] { 1, 2, 1, 3, 5, 2, 1, 4 }.ToAsyncEnumerable().Distinct(); @@ -82,7 +82,7 @@ public async Task Distinct10() } [Fact] - public async Task Distinct12() + public async Task Distinct_Empty() { var xs = AsyncEnumerable.Empty().Distinct(); From 2cdc2afe9b3a71f4069f6cafadb842204c2e9eba Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 22:45:39 -0800 Subject: [PATCH 850/862] Improve tests for To*. --- .../System/Linq/Operators/ToArray.cs | 26 +++++++++++++++---- .../System/Linq/Operators/ToHashSet.cs | 17 +++++++++++- .../System/Linq/Operators/ToList.cs | 6 ++--- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 849a7fb520..7e39c00584 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -21,7 +21,7 @@ public async Task ToArray_Null() } [Fact] - public async Task ToArray1() + public async Task ToArray_IAsyncIListProvider_Simple() { var xs = new[] { 42, 25, 39 }; var res = xs.ToAsyncEnumerable().ToArrayAsync(); @@ -29,7 +29,23 @@ public async Task ToArray1() } [Fact] - public async Task ToArray2() + public async Task ToArray_IAsyncIListProvider_Empty1() + { + var xs = new int[0]; + var res = xs.ToAsyncEnumerable().ToArrayAsync(); + Assert.True((await res).SequenceEqual(xs)); + } + + [Fact] + public async Task ToArray_IAsyncIListProvider_Empty2() + { + var xs = new HashSet(); + var res = xs.ToAsyncEnumerable().ToArrayAsync(); + Assert.True((await res).SequenceEqual(xs)); + } + + [Fact] + public async Task ToArray_Empty() { var xs = AsyncEnumerable.Empty(); var res = xs.ToArrayAsync(); @@ -37,7 +53,7 @@ public async Task ToArray2() } [Fact] - public async Task ToArray3Async() + public async Task ToArray_Throw() { var ex = new Exception("Bang!"); var res = Throw(ex).ToArrayAsync(); @@ -45,7 +61,7 @@ public async Task ToArray3Async() } [Fact] - public async Task ToArray4() + public async Task ToArray_Query() { var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArrayAsync(); var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; @@ -54,7 +70,7 @@ public async Task ToArray4() } [Fact] - public async Task ToArray5() + public async Task ToArray_Set() { var res = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; var xs = new HashSet(res); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index d39069616f..2ba83c0705 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -23,11 +23,26 @@ public async Task ToHashSet_Null() } [Fact] - public async Task ToHashSet1() + public async Task ToHashSet_Simple() { var xs = new[] { 1, 2, 1, 2, 3, 4, 1, 2, 3, 4 }; var res = xs.ToAsyncEnumerable().ToHashSetAsync(); Assert.True((await res).OrderBy(x => x).SequenceEqual(new[] { 1, 2, 3, 4 })); } + + [Fact] + public async Task ToHashSet_Comparer() + { + var xs = new[] { 1, 12, 11, 2, 3, 14, 1, 12, 13, 4 }; + var res = xs.ToAsyncEnumerable().ToHashSetAsync(new Eq()); + Assert.True((await res).OrderBy(x => x).SequenceEqual(new[] { 1, 3, 12, 14 })); + } + + private class Eq : IEqualityComparer + { + public bool Equals(int x, int y) => x % 10 == y % 10; + + public int GetHashCode(int obj) => obj % 10; + } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index 70c25723ed..e699c0ff0d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -20,7 +20,7 @@ public async Task ToList_Null() } [Fact] - public async Task ToList1() + public async Task ToList_Simple() { var xs = new[] { 42, 25, 39 }; var res = xs.ToAsyncEnumerable().ToListAsync(); @@ -28,7 +28,7 @@ public async Task ToList1() } [Fact] - public async Task ToList2() + public async Task ToList_Empty() { var xs = AsyncEnumerable.Empty(); var res = xs.ToListAsync(); @@ -36,7 +36,7 @@ public async Task ToList2() } [Fact] - public async Task ToList3Async() + public async Task ToList_Throw() { var ex = new Exception("Bang!"); var res = Throw(ex).ToListAsync(); From 9168f5695d14443af55a78877dd50197c4214e0b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 22:45:51 -0800 Subject: [PATCH 851/862] Clean up [Skip|Take]Last tests. --- .../System/Linq/Operators/SkipLast.cs | 32 +++++++++++++++---- .../System/Linq/Operators/TakeLast.cs | 19 ++++++++--- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs index 44ef76664e..ed27815e07 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/SkipLast.cs @@ -19,7 +19,7 @@ public void SkipLast_Null() } [Fact] - public async Task SkipLast1Async() + public async Task SkipLast_Few() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); @@ -30,7 +30,7 @@ public async Task SkipLast1Async() } [Fact] - public async Task SkipLast2Async() + public async Task SkipLast_All() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(5); @@ -39,7 +39,7 @@ public async Task SkipLast2Async() } [Fact] - public async Task SkipLast3() + public async Task SkipLast_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(2); @@ -47,11 +47,14 @@ public async Task SkipLast3() } [Fact] - public async Task SkipLast4Async() + public async Task SkipLast_Zero() { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().SkipLast(0); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = xs.SkipLast(0); - var e = xs.GetAsyncEnumerator(); + Assert.Same(xs, ys); + + var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); await HasNextAsync(e, 2); @@ -59,5 +62,22 @@ public async Task SkipLast4Async() await HasNextAsync(e, 4); await NoNextAsync(e); } + +#if USE_ASYNC_ITERATOR + [Fact] + public void SkipLast_Zero_NoAlias() + { + var xs = Xs(); + var ys = xs.SkipLast(0); + + Assert.NotSame(xs, ys); + } + + private async IAsyncEnumerable Xs() + { + await Task.Yield(); + yield return 1; + } +#endif } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs index 9f7edc2592..89a0cd9c8e 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/TakeLast.cs @@ -19,7 +19,7 @@ public void TakeLast_Null() } [Fact] - public async Task TakeLast0() + public async Task TakeLast_Negative() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(-2); @@ -28,7 +28,7 @@ public async Task TakeLast0() } [Fact] - public async Task TakeLast1() + public async Task TakeLast_Positive() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); @@ -39,7 +39,7 @@ public async Task TakeLast1() } [Fact] - public async Task TakeLast2() + public async Task TakeLast_TooMany() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(5); @@ -52,7 +52,18 @@ public async Task TakeLast2() } [Fact] - public async Task TakeLast3() + public async Task TakeLast_BreakEarly_Take() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(3).Take(2); + + var e = xs.GetAsyncEnumerator(); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await NoNextAsync(e); + } + + [Fact] + public async Task TakeLast_SequenceIdentity() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable().TakeLast(2); From bcd1aa1fe1754c6af8766a093fc174b5ecfadbfc Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 22:46:01 -0800 Subject: [PATCH 852/862] Clean up tests for ToAsyncEnumerable. --- .../Linq/Operators/ToAsyncEnumerable.cs | 235 +++++++++++------- 1 file changed, 150 insertions(+), 85 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs index 44ad2f8030..793046d5e6 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs @@ -14,15 +14,13 @@ namespace Tests public class ToAsyncEnumerable : AsyncEnumerableTests { [Fact] - public void ToAsyncEnumerable_Null() + public void ToAsyncEnumerable_Enumerable_Null() { Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(IEnumerable))); - Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); - Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); } [Fact] - public async Task ToAsyncEnumerable_Array1_Async() + public async Task ToAsyncEnumerable_Enumerable_Array() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); @@ -34,74 +32,86 @@ public async Task ToAsyncEnumerable_Array1_Async() } [Fact] - public async Task ToAsyncEnumerable_Enumerable1_Async() + public async Task ToAsyncEnumerable_Enumerable_Array_ToArray() { - var ex = new Exception("Bang"); - var xs = ToAsyncEnumerable_Sequence(ex).ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - await HasNextAsync(e, 42); - await AssertThrowsAsync(e.MoveNextAsync(), ex); - } + var arr = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; - private IEnumerable ToAsyncEnumerable_Sequence(Exception e) - { - yield return 42; - throw e; + var xs = arr.ToAsyncEnumerable(); + + var res = await xs.ToArrayAsync(); + + Assert.Equal(arr, res); } [Fact] - public async Task ToAsyncEnumerable_Observable1_Async() + public async Task ToAsyncEnumerable_Enumerable_Array_ToList() { - var subscribed = false; - - var xs = new MyObservable(obs => - { - subscribed = true; - - obs.OnNext(42); - obs.OnCompleted(); - - return new MyDisposable(() => { }); - }).ToAsyncEnumerable(); - - Assert.False(subscribed); + var arr = new[] { 1, 2, 3, 4 }; + var xs = arr.ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); + var res = await xs.ToListAsync(); - // NB: Breaking change to align with lazy nature of async iterators. - // Assert.True(subscribed); - - await HasNextAsync(e, 42); - await NoNextAsync(e); + Assert.Equal(arr, res); } [Fact] - public async Task ToAsyncEnumerable_Observable2_Async() + public async Task ToAsyncEnumerable_Enumerable_Array_Count() { - var ex = new Exception("Bang!"); - var subscribed = false; + var arr = new[] { 1, 2, 3, 4 }; + var xs = arr.ToAsyncEnumerable(); - var xs = new MyObservable(obs => - { - subscribed = true; + var c = await xs.CountAsync(); - obs.OnError(ex); + Assert.Equal(arr.Length, c); + } - return new MyDisposable(() => { }); - }).ToAsyncEnumerable(); + [Fact] + public async Task ToAsyncEnumerable_Enumerable_Array_SequenceIdentity() + { + var arr = new[] { 1, 2, 3, 4 }; + var xs = arr.ToAsyncEnumerable(); - Assert.False(subscribed); + await SequenceIdentity(xs); + } + [Fact] + public async Task ToAsyncEnumerable_Enumerable_Iterator() + { + var xs = ToAsyncEnumerable_Sequence().ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); + await HasNextAsync(e, 1); + await HasNextAsync(e, 2); + await HasNextAsync(e, 3); + await HasNextAsync(e, 4); + await NoNextAsync(e); + } - // NB: Breaking change to align with lazy nature of async iterators. - // Assert.True(subscribed); + private IEnumerable ToAsyncEnumerable_Sequence() + { + yield return 1; + yield return 2; + yield return 3; + yield return 4; + } + [Fact] + public async Task ToAsyncEnumerable_Enumerable_Iterator_Throw() + { + var ex = new Exception("Bang"); + var xs = ToAsyncEnumerable_Sequence_Throw(ex).ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + await HasNextAsync(e, 42); await AssertThrowsAsync(e.MoveNextAsync(), ex); } + private IEnumerable ToAsyncEnumerable_Sequence_Throw(Exception e) + { + yield return 42; + throw e; + } + [Fact] - public async Task ToAsyncEnumerable_Enumerable2_Async() + public async Task ToAsyncEnumerable_Enumerable_HashSet() { var set = new HashSet(new[] { 1, 2, 3, 4 }); @@ -115,7 +125,7 @@ public async Task ToAsyncEnumerable_Enumerable2_Async() } [Fact] - public async Task ToAsyncEnumerable_Enumerable3_Async() + public async Task ToAsyncEnumerable_Enumerable_HashSet_ToArray() { var set = new HashSet(new[] { 1, 2, 3, 4, 5, 6, 7, 8 }); @@ -127,7 +137,7 @@ public async Task ToAsyncEnumerable_Enumerable3_Async() } [Fact] - public async Task ToAsyncEnumerable_Enumerable4_Async() + public async Task ToAsyncEnumerable_Enumerable_HashSet_ToList() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -138,7 +148,7 @@ public async Task ToAsyncEnumerable_Enumerable4_Async() } [Fact] - public async Task ToAsyncEnumerable_Enumerable5_Async() + public async Task ToAsyncEnumerable_Enumerable_HashSet_Count() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -149,7 +159,7 @@ public async Task ToAsyncEnumerable_Enumerable5_Async() } [Fact] - public async Task ToAsyncEnumerable_Enumerable6_Async() + public async Task ToAsyncEnumerable_Enumerable_HashSet_SequenceIdentity() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -158,14 +168,7 @@ public async Task ToAsyncEnumerable_Enumerable6_Async() } [Fact] - public async Task ToAsyncEnumerable_Array2_Async() - { - var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); - await SequenceIdentity(xs); - } - - [Fact] - public void ToAsyncEnumerable_Enumerable7() + public void ToAsyncEnumerable_Enumerable_HashSet_ICollection() { var set = new HashSet(new[] { 1, 2, 3, 4 }); var xs = set.ToAsyncEnumerable(); @@ -190,7 +193,7 @@ public void ToAsyncEnumerable_Enumerable7() } [Fact] - public void ToAsyncEnumerable_Enumerable8() + public void ToAsyncEnumerable_Enumerable_List_IList() { var set = new List { 1, 2, 3, 4 }; var xs = set.ToAsyncEnumerable(); @@ -221,49 +224,67 @@ public void ToAsyncEnumerable_Enumerable8() Assert.True(arr.SequenceEqual(xl)); xl.Clear(); Assert.Equal(0, xl.Count); - } [Fact] - public async Task ToAsyncEnumerable_With_Completed_TaskAsync() + public void ToAsyncEnumerable_Observable_Null() { - var task = Task.Factory.StartNew(() => 36); - - var xs = task.ToAsyncEnumerable(); - var e = xs.GetAsyncEnumerator(); - - Assert.True(await e.MoveNextAsync()); - Assert.Equal(36, e.Current); - Assert.False(await e.MoveNextAsync()); + Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(IObservable))); } [Fact] - public async Task ToAsyncEnumerable_With_Faulted_TaskAsync() + public async Task ToAsyncEnumerable_Observable_Return() { - var ex = new InvalidOperationException(); - var tcs = new TaskCompletionSource(); - tcs.SetException(ex); + var subscribed = false; + + var xs = new MyObservable(obs => + { + subscribed = true; + + obs.OnNext(42); + obs.OnCompleted(); + + return new MyDisposable(() => { }); + }).ToAsyncEnumerable(); + + Assert.False(subscribed); - var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - await AssertThrowsAsync(e.MoveNextAsync(), ex); + // NB: Breaking change to align with lazy nature of async iterators. + // Assert.True(subscribed); + + await HasNextAsync(e, 42); + await NoNextAsync(e); } [Fact] - public async Task ToAsyncEnumerable_With_Canceled_TaskAsync() + public async Task ToAsyncEnumerable_Observable_Throw() { - var tcs = new TaskCompletionSource(); - tcs.SetCanceled(); + var ex = new Exception("Bang!"); + var subscribed = false; + + var xs = new MyObservable(obs => + { + subscribed = true; + + obs.OnError(ex); + + return new MyDisposable(() => { }); + }).ToAsyncEnumerable(); + + Assert.False(subscribed); - var xs = tcs.Task.ToAsyncEnumerable(); var e = xs.GetAsyncEnumerator(); - await AssertThrowsAsync(e.MoveNextAsync().AsTask()); + // NB: Breaking change to align with lazy nature of async iterators. + // Assert.True(subscribed); + + await AssertThrowsAsync(e.MoveNextAsync(), ex); } [Fact] - public async Task ToAsyncEnumerable_Observable3_Async() + public async Task ToAsyncEnumerable_Observable_Dispose() { var stop = new ManualResetEvent(false); @@ -297,7 +318,7 @@ public async Task ToAsyncEnumerable_Observable3_Async() } [Fact] - public async Task ToAsyncEnumerable_Observable4_Async() + public async Task ToAsyncEnumerable_Observable_Zip() { var subCount = 0; @@ -337,7 +358,7 @@ public async Task ToAsyncEnumerable_Observable4_Async() } [Fact] - public async Task ToAsyncEnumerable_Observable5_Async() + public async Task ToAsyncEnumerable_Observable_Cancel() { var stop = new ManualResetEvent(false); @@ -408,6 +429,50 @@ public async Task ToAsyncEnumerable_Observable6_Async() // TODO: Add more tests for Observable conversion. + [Fact] + public void ToAsyncEnumerable_Task_Null() + { + Assert.Throws(() => AsyncEnumerable.ToAsyncEnumerable(default(Task))); + } + + [Fact] + public async Task ToAsyncEnumerable_Task_With_Completed_TaskAsync() + { + var task = Task.Factory.StartNew(() => 36); + + var xs = task.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + + Assert.True(await e.MoveNextAsync()); + Assert.Equal(36, e.Current); + Assert.False(await e.MoveNextAsync()); + } + + [Fact] + public async Task ToAsyncEnumerable_Task_With_Faulted_TaskAsync() + { + var ex = new InvalidOperationException(); + var tcs = new TaskCompletionSource(); + tcs.SetException(ex); + + var xs = tcs.Task.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task ToAsyncEnumerable_Task_With_Canceled_TaskAsync() + { + var tcs = new TaskCompletionSource(); + tcs.SetCanceled(); + + var xs = tcs.Task.ToAsyncEnumerable(); + var e = xs.GetAsyncEnumerator(); + + await AssertThrowsAsync(e.MoveNextAsync().AsTask()); + } + private sealed class MyObservable : IObservable { private readonly Func, IDisposable> _subscribe; From caeb5268065579c8a0179948bde7e556f772bd3a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 22:46:09 -0800 Subject: [PATCH 853/862] Clean up tests for Zip. --- .../System/Linq/Operators/Zip.cs | 294 +++++++++++++++++- 1 file changed, 287 insertions(+), 7 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs index e2a082170c..d4075152c7 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Zip.cs @@ -4,6 +4,7 @@ using System; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Xunit; @@ -20,7 +21,7 @@ public void Zip_Null() } [Fact] - public async Task Zip1Async() + public async Task Zip_EqualLength() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); @@ -34,7 +35,7 @@ public async Task Zip1Async() } [Fact] - public async Task Zip2Async() + public async Task Zip_LeftShorter() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); @@ -48,7 +49,7 @@ public async Task Zip2Async() } [Fact] - public async Task Zip3Async() + public async Task Zip_RightShorter() { var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); @@ -62,7 +63,7 @@ public async Task Zip3Async() } [Fact] - public async Task Zip4Async() + public async Task Zip_Throws_Right() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -74,7 +75,7 @@ public async Task Zip4Async() } [Fact] - public async Task Zip5Async() + public async Task Zip_Throws_Left() { var ex = new Exception("Bang!"); var xs = Throw(ex); @@ -86,7 +87,7 @@ public async Task Zip5Async() } [Fact] - public async Task Zip6Async() + public async Task Zip_Throws_Selector() { var ex = new Exception("Bang!"); var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); @@ -98,7 +99,7 @@ public async Task Zip6Async() } [Fact] - public async Task Zip7() + public async Task Zip_SequenceIdentity() { var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); @@ -106,5 +107,284 @@ public async Task Zip7() await SequenceIdentity(res); } + + [Fact] + public void ZipAwait_Null() + { + Assert.Throws(() => AsyncEnumerable.ZipAwait(default, Return42, (x, y) => new ValueTask(x + y))); + Assert.Throws(() => AsyncEnumerable.ZipAwait(Return42, default, (x, y) => new ValueTask(x + y))); + Assert.Throws(() => AsyncEnumerable.ZipAwait(Return42, Return42, default(Func>))); + } + + [Fact] + public async Task ZipAwait_EqualLength() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.ZipAwait(ys, (x, y) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); + } + + [Fact] + public async Task ZipAwait_LeftShorter() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); + var res = xs.ZipAwait(ys, (x, y) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); + } + + [Fact] + public async Task ZipAwait_RightShorter() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.ZipAwait(ys, (x, y) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); + } + + [Fact] + public async Task ZipAwait_Throws_Right() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = Throw(ex); + var res = xs.ZipAwait(ys, (x, y) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task ZipAwait_Throws_Left() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.ZipAwait(ys, (x, y) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task ZipAwait_Throws_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.ZipAwait(ys, (x, y) => { if (x > 0) throw ex; return new ValueTask(x * y); }); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task ZipAwait_SequenceIdentity() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.ZipAwait(ys, (x, y) => new ValueTask(x * y)); + + await SequenceIdentity(res); + } + +#if !NO_DEEP_CANCELLATION + [Fact] + public void ZipAwaitWithCancellation_Null() + { + Assert.Throws(() => AsyncEnumerable.ZipAwaitWithCancellation(default, Return42, (x, y, ct) => new ValueTask(x + y))); + Assert.Throws(() => AsyncEnumerable.ZipAwaitWithCancellation(Return42, default, (x, y, ct) => new ValueTask(x + y))); + Assert.Throws(() => AsyncEnumerable.ZipAwaitWithCancellation(Return42, Return42, default(Func>))); + } + + [Fact] + public async Task ZipAwaitWithCancellation_EqualLength() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.ZipAwaitWithCancellation(ys, (x, y, ct) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); + } + + [Fact] + public async Task ZipAwaitWithCancellation_LeftShorter() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); + var res = xs.ZipAwaitWithCancellation(ys, (x, y, ct) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); + } + + [Fact] + public async Task ZipAwaitWithCancellation_RightShorter() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.ZipAwaitWithCancellation(ys, (x, y, ct) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, 1 * 4); + await HasNextAsync(e, 2 * 5); + await HasNextAsync(e, 3 * 6); + await NoNextAsync(e); + } + + [Fact] + public async Task ZipAwaitWithCancellation_Throws_Right() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = Throw(ex); + var res = xs.ZipAwaitWithCancellation(ys, (x, y, ct) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task ZipAwaitWithCancellation_Throws_Left() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.ZipAwaitWithCancellation(ys, (x, y, ct) => new ValueTask(x * y)); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task ZipAwaitWithCancellation_Throws_Selector() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.ZipAwaitWithCancellation(ys, (x, y, ct) => { if (x > 0) throw ex; return new ValueTask(x * y); }); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task ZipAwaitWithCancellation_SequenceIdentity() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.ZipAwaitWithCancellation(ys, (x, y, ct) => new ValueTask(x * y)); + + await SequenceIdentity(res); + } +#endif + +#if HAS_VALUETUPLE + [Fact] + public void Zip_Tuple_Null() + { + Assert.Throws(() => AsyncEnumerable.Zip(default, Return42)); + Assert.Throws(() => AsyncEnumerable.Zip(Return42, default)); + } + + [Fact] + public async Task Zip_Tuple_EqualLength() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.Zip(ys); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, (1, 4)); + await HasNextAsync(e, (2, 5)); + await HasNextAsync(e, (3, 6)); + await NoNextAsync(e); + } + + [Fact] + public async Task Zip_Tuple_LeftShorter() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6, 7 }.ToAsyncEnumerable(); + var res = xs.Zip(ys); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, (1, 4)); + await HasNextAsync(e, (2, 5)); + await HasNextAsync(e, (3, 6)); + await NoNextAsync(e); + } + + [Fact] + public async Task Zip_Tuple_RightShorter() + { + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.Zip(ys); + + var e = res.GetAsyncEnumerator(); + await HasNextAsync(e, (1, 4)); + await HasNextAsync(e, (2, 5)); + await HasNextAsync(e, (3, 6)); + await NoNextAsync(e); + } + + [Fact] + public async Task Zip_Tuple_Throws_Right() + { + var ex = new Exception("Bang!"); + var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var ys = Throw(ex); + var res = xs.Zip(ys); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task Zip_Tuple_Throws_Left() + { + var ex = new Exception("Bang!"); + var xs = Throw(ex); + var ys = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); + var res = xs.Zip(ys); + + var e = res.GetAsyncEnumerator(); + await AssertThrowsAsync(e.MoveNextAsync(), ex); + } + + [Fact] + public async Task Zip_Tuple_SequenceIdentity() + { + var xs = new[] { 1, 2, 3 }.ToAsyncEnumerable(); + var ys = new[] { 4, 5, 6 }.ToAsyncEnumerable(); + var res = xs.Zip(ys); + + await SequenceIdentity(res); + } +#endif } } From eb98b21b840100254a79f09d9d652ad6ac1123c7 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Tue, 26 Feb 2019 22:46:17 -0800 Subject: [PATCH 854/862] Clean up tests for Throw. --- .../System.Linq.Async.Tests/System/Linq/Operators/Throw.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs index 30d56e6906..70a56282df 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Throw.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Threading.Tasks; using Xunit; namespace Tests @@ -16,7 +17,7 @@ public void Throw_Null() } [Fact] - public async System.Threading.Tasks.Task Throw1Async() + public async Task Throw_Simple() { var ex = new Exception("Bang"); var xs = Throw(ex); From f298f6404c0c68fe90c8efda149407e4a743eb04 Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 27 Feb 2019 10:19:43 -0800 Subject: [PATCH 855/862] Fix System.Interactive.Providers --- .../System.Interactive.Providers.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index 1dc90c1d94..49aaded65b 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -7,6 +7,10 @@ Ix;Interactive;Extensions;Enumerable + + $(DefineConstants);CRIPPLED_REFLECTION + + From 25610a59fa8ebfcbd4b30e40947cb9d479590c9f Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 27 Feb 2019 10:32:02 -0800 Subject: [PATCH 856/862] Fix System.Interactive.Providers --- .../System.Interactive.Providers.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj index 49aaded65b..e7015409d7 100644 --- a/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj +++ b/Ix.NET/Source/System.Interactive.Providers/System.Interactive.Providers.csproj @@ -7,7 +7,7 @@ Ix;Interactive;Extensions;Enumerable - + $(DefineConstants);CRIPPLED_REFLECTION From be1b8566170bbeb6d65927df8e5edb4ba3af6acb Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Wed, 27 Feb 2019 10:45:25 -0800 Subject: [PATCH 857/862] Fixing System.Interactive.Providers.Ref --- Ix.NET/Source/System.Interactive/System.Interactive.csproj | 2 -- .../System.Interactive.Providers.Ref.csproj | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Ix.NET/Source/System.Interactive/System.Interactive.csproj b/Ix.NET/Source/System.Interactive/System.Interactive.csproj index 2fe04e7d54..f3effe33a5 100644 --- a/Ix.NET/Source/System.Interactive/System.Interactive.csproj +++ b/Ix.NET/Source/System.Interactive/System.Interactive.csproj @@ -12,7 +12,5 @@ - - diff --git a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj index d9eb1a846a..020dd5331c 100644 --- a/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj +++ b/Ix.NET/Source/refs/System.Interactive.Providers.Ref/System.Interactive.Providers.Ref.csproj @@ -7,6 +7,10 @@ Ix;Interactive;Extensions;Enumerable + + $(DefineConstants);CRIPPLED_REFLECTION + + From 03dbe96cb35e0b64962802211afe4780f7f5bbec Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Wed, 27 Feb 2019 15:29:34 -0500 Subject: [PATCH 858/862] update link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68726f028b..9c24fed45d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Catch us in the #rxnet channel over at http://reactiveui.net/slack ### v4.0 changes Ix Async 4.0 has a breaking change from prior versions due to being the first LINQ implementation -to support the new C# 8 [async streams](https://github.com/dotnet/csharplang/blob/master/proposals/csharp-8.0/async-streams.md) feature. This means for .NET Standard 2.1 and .NET Core 3 targets, we use the in-box interfaces for `IAsyncEnumerable` and friends. On other platforms, we provide the implementation, so you can use `await foreach` and create async iterators as you would expect. The types will unify to the system ones where the platform provides it. +to support the new C# 8 [async streams](https://github.com/dotnet/roslyn/blob/master/docs/features/async-streams.md) feature. This means for .NET Standard 2.1 and .NET Core 3 targets, we use the in-box interfaces for `IAsyncEnumerable` and friends. On other platforms, we provide the implementation, so you can use `await foreach` and create async iterators as you would expect. The types will unify to the system ones where the platform provides it. The code should be code-compatible, so recompiling should take care of most of it; note that binary compatibility will not work. From 791d078ff8a0bbfb5a486aade3d531e5895a88c1 Mon Sep 17 00:00:00 2001 From: Oren Novotny Date: Wed, 27 Feb 2019 17:40:25 -0500 Subject: [PATCH 859/862] Update visibility on AsyncEnumberableExtensions to hideit from the ref on .NET Standard 2.1 --- .../Tasks/AsyncEnumerableExtensions.cs | 43 +++++-------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs index b8e310ef85..d3595bfe44 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs @@ -7,7 +7,14 @@ namespace System.Threading.Tasks { - public static class AsyncEnumerableExtensions + + // This type is only public for ref assms < .NET Standard 2.1 and implementations +#if !BCL_HAS_CONFIGUREAWAIT || !REFERENCE_ASSEMBLY + public +#else + internal +#endif + static class AsyncEnumerableExtensions { #if !BCL_HAS_CONFIGUREAWAIT // https://github.com/dotnet/coreclr/pull/21939 @@ -37,8 +44,9 @@ public static ConfiguredCancelableAsyncEnumerable WithCancellation( new ConfiguredCancelableAsyncEnumerable(source, continueOnCapturedContext: true, cancellationToken); -#elif !REFERENCE_ASSEMBLY - // we need to carry an impl that delegates to the BCL version of these +#else + // we need to carry an impl that delegates to the BCL version of these in the lib + // They won't be in the ref ///

Configures how awaits on the tasks returned from an async disposable will be performed. /// The source async disposable. @@ -65,35 +73,6 @@ public static ConfiguredCancelableAsyncEnumerable ConfigureAwait( [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ConfiguredCancelableAsyncEnumerable WithCancellation( this IAsyncEnumerable source, CancellationToken cancellationToken) => TaskExtensions.WithCancellation(source, cancellationToken); - -#else - // Reference assembly, these won't be emitted, but keep these internal so we can compile - - /// Configures how awaits on the tasks returned from an async disposable will be performed. - /// The source async disposable. - /// Whether to capture and marshal back to the current context. - /// The configured async disposable. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static ConfiguredAsyncDisposable ConfigureAwait(this IAsyncDisposable source, bool continueOnCapturedContext) => - TaskExtensions.ConfigureAwait(source, continueOnCapturedContext); - - /// Configures how awaits on the tasks returned from an async iteration will be performed. - /// The type of the objects being iterated. - /// The source enumerable being iterated. - /// Whether to capture and marshal back to the current context. - /// The configured enumerable. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static ConfiguredCancelableAsyncEnumerable ConfigureAwait( - this IAsyncEnumerable source, bool continueOnCapturedContext) => TaskExtensions.ConfigureAwait(source, continueOnCapturedContext); - - /// Sets the to be passed to when iterating. - /// The type of the objects being iterated. - /// The source enumerable being iterated. - /// The to use. - /// The configured enumerable. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static ConfiguredCancelableAsyncEnumerable WithCancellation( - this IAsyncEnumerable source, CancellationToken cancellationToken) => TaskExtensions.WithCancellation(source, cancellationToken); #endif } } From 895cae3801c3638747d677ae24bb37baf8b58e3d Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Mar 2019 11:17:44 -0800 Subject: [PATCH 860/862] Generic API surface for async overloads. --- .../System.Linq.Async.csproj | 17 +- .../Linq/AsyncEnumerable.AsyncOverloads.cs | 217 ++++++++++++++++++ .../Linq/AsyncEnumerable.AsyncOverloads.tt | 116 ++++++++++ 3 files changed, 348 insertions(+), 2 deletions(-) create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs create mode 100644 Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt diff --git a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj index 45592b09f3..9aa36fea38 100644 --- a/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj +++ b/Ix.NET/Source/System.Linq.Async/System.Linq.Async.csproj @@ -5,6 +5,11 @@ + + True + True + AsyncEnumerable.AsyncOverloads.tt + True True @@ -18,12 +23,16 @@ - + + + True + True + AsyncEnumerable.AsyncOverloads.tt + Average.Generated.tt True @@ -52,6 +61,10 @@ + + TextTemplatingFileGenerator + AsyncEnumerable.AsyncOverloads.cs + Average.Generated.cs TextTemplatingFileGenerator diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs new file mode 100644 index 0000000000..59f03c4c65 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs @@ -0,0 +1,217 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +#if SUPPORT_FLAT_ASYNC_API + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + partial class AsyncEnumerable + { + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsync(source, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsync(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitAsync(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitAsync(source, predicate, cancellationToken); + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitAsync(source, predicate, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitAsync(source, predicate, cancellationToken); + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitAsync(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitAsync(source, predicate, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsync(source, action, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsync(source, action, cancellationToken); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwait(source, keySelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, comparer); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwait(source, keySelector, elementSelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwait(source, keySelector, resultSelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwait(source, keySelector, elementSelector, resultSelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, elementSelector, resultSelector, comparer); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitAsync(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitAsync(source, predicate, cancellationToken); + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitAsync(source, predicate, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwait(source, keySelector); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwait(source, keySelector, comparer); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwait(source, keySelector); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwait(source, keySelector, comparer); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwait(source, selector); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwait(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwait(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwait(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwait(source, collectionSelector, resultSelector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwait(source, collectionSelector, resultSelector); + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitAsync(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitAsync(source, predicate, cancellationToken); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwait(source, predicate); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwait(source, predicate); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwait(source, predicate); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwait(source, predicate); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwait(source, keySelector); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwait(source, keySelector, comparer); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwait(source, keySelector); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwait(source, keySelector, comparer); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, elementSelector, comparer, cancellationToken); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwait(source, predicate); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwait(source, predicate); + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwait(first, second, selector); + +#if !NO_DEEP_CANCELLATION + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsync(source, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsync(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsync(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsync(source, action, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsync(source, action, cancellationToken); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellation(source, keySelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, comparer); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellation(source, keySelector, elementSelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellation(source, keySelector, resultSelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellation(source, keySelector, elementSelector, resultSelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, elementSelector, resultSelector, comparer); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellation(source, keySelector); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellation(source, keySelector, comparer); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellation(source, keySelector); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitWithCancellation(source, keySelector, comparer); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellation(source, selector); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellation(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellation(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellation(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellation(source, collectionSelector, resultSelector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellation(source, collectionSelector, resultSelector); + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitWithCancellationAsync(source, predicate, cancellationToken); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellation(source, predicate); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellation(source, predicate); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellation(source, predicate); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellation(source, predicate); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellation(source, keySelector); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellation(source, keySelector, comparer); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellation(source, keySelector); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellation(source, keySelector, comparer); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer, cancellationToken); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellation(source, predicate); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellation(source, predicate); + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellation(first, second, selector); +#endif + } +} + +#endif diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt new file mode 100644 index 0000000000..884d65e124 --- /dev/null +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt @@ -0,0 +1,116 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Threading.Tasks.Extensions.dll" #> +<#@ assembly name="$(ProjectDir)\..\System.Linq.Async\bin\$(Configuration)\net46\System.Linq.Async.dll" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="System.Runtime" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Reflection" #> +<#@ output extension=".cs" #> +#if SUPPORT_FLAT_ASYNC_API + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Linq +{ + partial class AsyncEnumerable + { +<# +Func toCSharp = null; +toCSharp = t => +{ + if (t.IsGenericType) + { + var def = t.GetGenericTypeDefinition(); + if (def == typeof(Nullable<>)) + { + return toCSharp(t.GetGenericArguments()[0]) + "?"; + } + else + { + return def.Name.Substring(0, def.Name.IndexOf('`')) + "<" + string.Join(", ", t.GetGenericArguments().Select(toCSharp)) + ">"; + } + } + else if (t.IsArray) + { + return toCSharp(t.GetElementType()) + "[]"; + } + else + { + if (t == typeof(int)) + { + return "int"; + } + else if (t == typeof(long)) + { + return "long"; + } + else if (t == typeof(float)) + { + return "float"; + } + else if (t == typeof(double)) + { + return "double"; + } + else if (t == typeof(decimal)) + { + return "decimal"; + } + else if (t == typeof(bool)) + { + return "bool"; + } + else if (t == typeof(object)) + { + return "object"; + } + + return t.Name; + } +}; + +var methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.Public | BindingFlags.Static); +var asyncMethods = methods.Where(m => m.Name.Contains("Await")).OrderBy(m => m.Name).ThenBy(m => m.GetParameters().Length); +foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation"))) +{ + if (g.Key) + { +#> + +#if !NO_DEEP_CANCELLATION +<# + } + + foreach (var m in g) + { + var longName = m.Name; + var shortName = m.Name.Replace("WithCancellation", "").Replace("Await", ""); + var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : ""; + var returnType = toCSharp(m.ReturnType); + var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true); + var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name)); + var args = string.Join(", ", m.GetParameters().Select(p => p.Name)); +#> + public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>) => <#=longName#><#=genArgs#>(<#=args#>); +<# + } + + if (g.Key) + { +#> +#endif +<# + } +} +#> + } +} + +#endif From b8c42e1bb9344dd803021e4af8b0a6041c91043a Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Mar 2019 11:55:38 -0800 Subject: [PATCH 861/862] Introduce a single place where all public async overloads are maintained to evaluate design options using a single SUPPORT_FLAT_ASYNC_API flag. --- .../Linq/AsyncEnumerable.AsyncOverloads.cs | 598 ++++++++++++------ .../Linq/AsyncEnumerable.AsyncOverloads.tt | 63 +- .../System/Linq/Operators/Aggregate.cs | 12 +- .../System/Linq/Operators/All.cs | 4 +- .../System/Linq/Operators/Any.cs | 4 +- .../Linq/Operators/Average.Generated.cs | 40 +- .../Linq/Operators/Average.Generated.tt | 6 +- .../System/Linq/Operators/Count.cs | 4 +- .../System/Linq/Operators/First.cs | 4 +- .../System/Linq/Operators/FirstOrDefault.cs | 4 +- .../System/Linq/Operators/ForEach.cs | 8 +- .../System/Linq/Operators/GroupBy.cs | 40 +- .../System/Linq/Operators/GroupJoin.cs | 12 +- .../System/Linq/Operators/Join.cs | 12 +- .../System/Linq/Operators/Last.cs | 4 +- .../System/Linq/Operators/LastOrDefault.cs | 4 +- .../System/Linq/Operators/LongCount.cs | 4 +- .../System/Linq/Operators/Max.cs | 4 +- .../System/Linq/Operators/Min.cs | 4 +- .../System/Linq/Operators/MinMax.Generated.cs | 80 +-- .../System/Linq/Operators/MinMax.Generated.tt | 7 +- .../System/Linq/Operators/OrderBy.cs | 32 +- .../System/Linq/Operators/Select.cs | 8 +- .../System/Linq/Operators/SelectMany.cs | 16 +- .../System/Linq/Operators/Single.cs | 4 +- .../System/Linq/Operators/SingleOrDefault.cs | 4 +- .../System/Linq/Operators/SkipWhile.cs | 8 +- .../System/Linq/Operators/Sum.Generated.cs | 40 +- .../System/Linq/Operators/Sum.Generated.tt | 6 +- .../System/Linq/Operators/TakeWhile.cs | 8 +- .../System/Linq/Operators/ToDictionary.cs | 24 +- .../System/Linq/Operators/ToLookup.cs | 24 +- .../System/Linq/Operators/Where.cs | 8 +- .../System/Linq/Operators/Zip.cs | 4 +- 34 files changed, 672 insertions(+), 432 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs index 59f03c4c65..b2e93bdf52 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. -#if SUPPORT_FLAT_ASYNC_API - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -12,206 +10,406 @@ namespace System.Linq { partial class AsyncEnumerable { - public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsync(source, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsync(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitAsync(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitAsync(source, predicate, cancellationToken); - public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitAsync(source, predicate, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsync(source, selector, cancellationToken); - public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitAsync(source, predicate, cancellationToken); - public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitAsync(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitAsync(source, predicate, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsync(source, action, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsync(source, action, cancellationToken); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwait(source, keySelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, comparer); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwait(source, keySelector, elementSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwait(source, keySelector, resultSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwait(source, keySelector, elementSelector, resultSelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, elementSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwait(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitAsync(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitAsync(source, predicate, cancellationToken); - public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitAsync(source, predicate, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsync(source, selector, cancellationToken); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwait(source, keySelector); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwait(source, keySelector, comparer); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwait(source, keySelector); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwait(source, keySelector, comparer); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwait(source, selector); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwait(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwait(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwait(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwait(source, collectionSelector, resultSelector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwait(source, collectionSelector, resultSelector); - public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitAsync(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitAsync(source, predicate, cancellationToken); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwait(source, predicate); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwait(source, predicate); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsync(source, selector, cancellationToken); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwait(source, predicate); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwait(source, predicate); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwait(source, keySelector); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwait(source, keySelector, comparer); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwait(source, keySelector); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwait(source, keySelector, comparer); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsync(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsync(source, keySelector, elementSelector, comparer, cancellationToken); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwait(source, predicate); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwait(source, predicate); - public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwait(first, second, selector); +#if SUPPORT_FLAT_ASYNC_API + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitCore(source, keySelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, comparer); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitCore(source, keySelector, elementSelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector, comparer); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitCore(source, keySelector, comparer); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitCore(source, keySelector, comparer); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitCore(first, second, selector); #if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsync(source, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsync(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsync(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsync(source, action, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsync(source, action, cancellationToken); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellation(source, keySelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, comparer); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellation(source, keySelector, elementSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellation(source, keySelector, resultSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellation(source, keySelector, elementSelector, resultSelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, elementSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellation(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector); - public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsync(source, selector, cancellationToken); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellation(source, keySelector); - public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellation(source, keySelector, comparer); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellation(source, keySelector); - public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitWithCancellation(source, keySelector, comparer); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellation(source, selector); - public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellation(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellation(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellation(source, selector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellation(source, collectionSelector, resultSelector); - public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellation(source, collectionSelector, resultSelector); - public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitWithCancellationAsync(source, predicate, cancellationToken); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellation(source, predicate); - public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellation(source, predicate); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsync(source, selector, cancellationToken); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellation(source, predicate); - public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellation(source, predicate); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellation(source, keySelector); - public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellation(source, keySelector, comparer); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellation(source, keySelector); - public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellation(source, keySelector, comparer); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer, cancellationToken); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellation(source, predicate); - public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellation(source, predicate); - public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellation(first, second, selector); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellationCore(source, keySelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector, comparer); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellationCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitWithCancellationCore(source, keySelector, comparer); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable Select(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); + public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellationCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellationCore(source, keySelector, comparer); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellationCore(first, second, selector); #endif - } -} +#else + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitCore(source, keySelector); + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, comparer); + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitCore(source, keySelector, elementSelector); + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector); + public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector, comparer); + public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static ValueTask LastAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitCore(source, keySelector, comparer); + public static IAsyncEnumerable SelectAwait(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); + public static IAsyncEnumerable SelectAwait(this IAsyncEnumerable source, Func> selector) => SelectAwaitCore(source, selector); + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); + public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); + public static ValueTask SingleAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); + public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); + public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); + public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitCore(source, keySelector, comparer); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); + public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); + public static IAsyncEnumerable ZipAwait(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitCore(first, second, selector); +#if !NO_DEEP_CANCELLATION + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); + public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellationCore(source, keySelector); + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector); + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector); + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector, comparer); + public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); + public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); + public static ValueTask LastAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellationCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByDescendingAwaitWithCancellationCore(source, keySelector, comparer); + public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) => SelectAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); + public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); + public static ValueTask SingleAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); + public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellationCore(source, keySelector, comparer); + public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellationCore(source, keySelector); + public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellationCore(source, keySelector, comparer); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); + public static IAsyncEnumerable ZipAwaitWithCancellation(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellationCore(first, second, selector); +#endif #endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt index 884d65e124..957763b6ba 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt @@ -11,16 +11,6 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Reflection" #> <#@ output extension=".cs" #> -#if SUPPORT_FLAT_ASYNC_API - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace System.Linq -{ - partial class AsyncEnumerable - { <# Func toCSharp = null; toCSharp = t => @@ -75,9 +65,21 @@ toCSharp = t => return t.Name; } }; +#> +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; -var methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.Public | BindingFlags.Static); -var asyncMethods = methods.Where(m => m.Name.Contains("Await")).OrderBy(m => m.Name).ThenBy(m => m.GetParameters().Length); +namespace System.Linq +{ + partial class AsyncEnumerable + { +<# +var methods = typeof(AsyncEnumerable).GetMethods(BindingFlags.NonPublic | BindingFlags.Static); +var asyncMethods = methods.Where(m => m.Name.Contains("Await") && m.Name.EndsWith("Core")).OrderBy(m => m.Name).ThenBy(m => m.GetParameters().Length); +#> +#if SUPPORT_FLAT_ASYNC_API +<# foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation"))) { if (g.Key) @@ -91,7 +93,7 @@ foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation")) foreach (var m in g) { var longName = m.Name; - var shortName = m.Name.Replace("WithCancellation", "").Replace("Await", ""); + var shortName = m.Name.Replace("WithCancellation", "").Replace("Await", "").Replace("Core", ""); var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : ""; var returnType = toCSharp(m.ReturnType); var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true); @@ -110,7 +112,40 @@ foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation")) } } #> +#else +<# +foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation"))) +{ + if (g.Key) + { +#> + +#if !NO_DEEP_CANCELLATION +<# } -} + foreach (var m in g) + { + var longName = m.Name; + var shortName = m.Name.Replace("Core", ""); + var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : ""; + var returnType = toCSharp(m.ReturnType); + var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true); + var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name)); + var args = string.Join(", ", m.GetParameters().Select(p => p.Name)); +#> + public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>) => <#=longName#><#=genArgs#>(<#=args#>); +<# + } + + if (g.Key) + { +#> #endif +<# + } +} +#> +#endif + } +} diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs index d2dab5cc1a..25a2dca49a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Aggregate.cs @@ -40,7 +40,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AggregateAwaitAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + internal static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,7 +71,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) + internal static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -124,7 +124,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAcc } } - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + internal static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -147,7 +147,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAcc } #if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) + internal static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -194,7 +194,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAccumul } } - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + internal static ValueTask AggregateAwaitAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -219,7 +219,7 @@ static async ValueTask Core(IAsyncEnumerable _source, TAccumul } #if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) + internal static ValueTask AggregateAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs index 46041173f8..a3a3dcc604 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/All.cs @@ -33,7 +33,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AllAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask AllAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -57,7 +57,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AllAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask AllAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs index 550581f028..9bfa93f50f 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Any.cs @@ -49,7 +49,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AnyAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask AnyAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -73,7 +73,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AnyAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask AnyAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs index d6aa470397..f6b25602c4 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.cs @@ -76,7 +76,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -111,7 +111,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -212,7 +212,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -247,7 +247,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -348,7 +348,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -383,7 +383,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -484,7 +484,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -519,7 +519,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -620,7 +620,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -655,7 +655,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -772,7 +772,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -815,7 +815,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -940,7 +940,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -983,7 +983,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1108,7 +1108,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1151,7 +1151,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1276,7 +1276,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1319,7 +1319,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1444,7 +1444,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1487,7 +1487,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask AverageAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt index e7a0ef8393..e4cca983db 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Average.Generated.tt @@ -191,7 +191,8 @@ else } } - public static ValueTask<<#=o.res#>> AverageAwaitAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + internal static ValueTask<<#=o.res#>> AverageAsyncCore(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -266,7 +267,8 @@ else } #if !NO_DEEP_CANCELLATION - public static ValueTask<<#=o.res#>> AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + internal static ValueTask<<#=o.res#>> AverageWithCancellationAsyncCore(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs index f0ac22ddf9..a6ac535a2e 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Count.cs @@ -72,7 +72,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func CountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask CountAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -101,7 +101,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func CountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask CountAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs index 98f06c9f95..0eb78c39b8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/First.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask FirstAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask FirstAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs index 2869761cb7..0fc1358c61 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/FirstOrDefault.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask FirstOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func FirstOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask FirstOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs index 8e68b35990..8ad5d65dcb 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs @@ -55,7 +55,7 @@ static async Task Core(IAsyncEnumerable _source, Action _ } } - public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) + internal static Task ForEachAwaitAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -73,7 +73,7 @@ static async Task Core(IAsyncEnumerable _source, Func _a } } - public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + internal static Task ForEachAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -91,7 +91,7 @@ static async Task Core(IAsyncEnumerable _source, Func(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) + internal static Task ForEachAwaitAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -111,7 +111,7 @@ static async Task Core(IAsyncEnumerable _source, Func(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) + internal static Task ForEachAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs index c4477ce4d0..7893d79d35 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupBy.cs @@ -16,17 +16,17 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerable(source, keySelector, comparer); - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector) => + internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer: null); - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => + internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null); - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer); #endif @@ -36,17 +36,17 @@ public static IAsyncEnumerable> GroupBy> GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerable(source, keySelector, elementSelector, comparer); - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer: null); - public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable> GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTask(source, keySelector, elementSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => + internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer: null); - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable> GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => new GroupedAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, comparer); #endif @@ -56,17 +56,17 @@ public static IAsyncEnumerable GroupBy(this IAs public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func keySelector, Func, TResult> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerable(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => + internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => + internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, resultSelector, comparer); #endif @@ -76,17 +76,17 @@ public static IAsyncEnumerable GroupBy GroupBy(this IAsyncEnumerable source, Func keySelector, Func elementSelector, Func, TResult> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerable(source, keySelector, elementSelector, resultSelector, comparer); - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => + internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable GroupByAwaitCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTask(source, keySelector, elementSelector, resultSelector, comparer); #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => + internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => + internal static IAsyncEnumerable GroupByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => new GroupedResultAsyncEnumerableWithTaskAndCancellation(source, keySelector, elementSelector, resultSelector, comparer); #endif @@ -220,7 +220,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwaitCore(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -310,7 +310,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwaitCore(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -493,7 +493,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwaitCore(async g => await _resultSelector(g.Key, g).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; @@ -585,7 +585,7 @@ protected override async ValueTask MoveNextCore() { case AsyncIteratorState.Allocated: _lookup = await Internal.LookupWithTask.CreateAsync(_source, _keySelector, _elementSelector, _comparer, _cancellationToken).ConfigureAwait(false); - _enumerator = _lookup.SelectAwait(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? + _enumerator = _lookup.SelectAwaitCore(async g => await _resultSelector(g.Key, g, _cancellationToken).ConfigureAwait(false)).GetAsyncEnumerator(_cancellationToken); // REVIEW: Introduce another ApplyResultSelector? _state = AsyncIteratorState.Iterating; goto case AsyncIteratorState.Iterating; diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs index c9415468ae..d67038a2e6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/GroupJoin.cs @@ -52,10 +52,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => - GroupJoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + internal static IAsyncEnumerable GroupJoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => + GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) + internal static IAsyncEnumerable GroupJoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -95,10 +95,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => - GroupJoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + internal static IAsyncEnumerable GroupJoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => + GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) + internal static IAsyncEnumerable GroupJoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs index b00948e7b8..c638c3d6b8 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Join.cs @@ -69,10 +69,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => - JoinAwait(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + internal static IAsyncEnumerable JoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + internal static IAsyncEnumerable JoinAwaitCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); @@ -128,10 +128,10 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => - JoinAwaitWithCancellation(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); + internal static IAsyncEnumerable JoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => + JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer: null); - public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) + internal static IAsyncEnumerable JoinAwaitWithCancellationCore(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) { if (outer == null) throw Error.ArgumentNull(nameof(outer)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs index 45e1d101b9..b92681e705 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Last.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask LastAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask LastAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs index cf8b15e19f..66e1f2618d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LastOrDefault.cs @@ -42,7 +42,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask LastOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LastOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask LastOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs index 3a7134e022..c48995ea6d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/LongCount.cs @@ -61,7 +61,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LongCountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask LongCountAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -90,7 +90,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func LongCountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask LongCountAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs index 4d61d9f082..3e49b367e6 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Max.cs @@ -164,7 +164,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -244,7 +244,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs index 9a7889e8ed..88797df30b 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Min.cs @@ -166,7 +166,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -246,7 +246,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs index c8770a7e2d..29485d7830 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.cs @@ -80,7 +80,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -117,7 +117,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -302,7 +302,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -378,7 +378,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -524,7 +524,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -561,7 +561,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -746,7 +746,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -822,7 +822,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -998,7 +998,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1050,7 +1050,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1242,7 +1242,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1314,7 +1314,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1486,7 +1486,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1538,7 +1538,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1730,7 +1730,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1802,7 +1802,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1944,7 +1944,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -1981,7 +1981,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2114,7 +2114,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2164,7 +2164,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MaxAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2284,7 +2284,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2321,7 +2321,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2458,7 +2458,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2510,7 +2510,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2632,7 +2632,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2669,7 +2669,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2806,7 +2806,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -2858,7 +2858,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3012,7 +3012,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3065,7 +3065,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3250,7 +3250,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3318,7 +3318,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3488,7 +3488,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3541,7 +3541,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3726,7 +3726,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3794,7 +3794,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3932,7 +3932,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -3969,7 +3969,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4102,7 +4102,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -4152,7 +4152,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask MinAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt index 6022691633..c72e6f78e1 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/MinMax.Generated.tt @@ -284,8 +284,11 @@ foreach (var overload in new[] { new { selector = "Func>", invoke = "await _selector(e.Current, _cancellationToken).ConfigureAwait(false)" }, }) { + var isAsync = overload.invoke.StartsWith("await"); var isDeepCancellation = overload.selector.Contains("CancellationToken"); - var suffix = overload.invoke.StartsWith("await") ? "Await" : ""; + var suffix = isAsync ? "Await" : ""; + var visibility = isAsync ? "internal" : "public"; + var core = isAsync ? "Core" : ""; if (isDeepCancellation) { @@ -295,7 +298,7 @@ foreach (var overload in new[] { <# } #> - public static ValueTask<<#=t#>> <#=m#><#=suffix#>Async(this IAsyncEnumerable source, <#=overload.selector#> selector, CancellationToken cancellationToken = default) + <#=visibility#> static ValueTask<<#=t#>> <#=m#><#=suffix#>Async<#=core#>(this IAsyncEnumerable source, <#=overload.selector#> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs index 34d2e8dd6c..93650da980 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/OrderBy.cs @@ -13,44 +13,44 @@ public static partial class AsyncEnumerable public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector) => new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: false, parent: null); - public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector) => + internal static IOrderedAsyncEnumerable OrderByAwaitCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => + internal static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: false, parent: null); #endif public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => new OrderedAsyncEnumerable(source, keySelector, comparer, descending: false, parent: null); - public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + internal static IOrderedAsyncEnumerable OrderByAwaitCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: false, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + internal static IOrderedAsyncEnumerable OrderByAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: false, parent: null); #endif public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector) => new OrderedAsyncEnumerable(source, keySelector, comparer: null, descending: true, parent: null); - public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector) => + internal static IOrderedAsyncEnumerable OrderByDescendingAwaitCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer: null, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => + internal static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer: null, descending: true, parent: null); #endif public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func keySelector, IComparer comparer) => new OrderedAsyncEnumerable(source, keySelector, comparer, descending: true, parent: null); - public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + internal static IOrderedAsyncEnumerable OrderByDescendingAwaitCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTask(source, keySelector, comparer, descending: true, parent: null); #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => + internal static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellationCore(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => new OrderedAsyncEnumerableWithTaskAndCancellation(source, keySelector, comparer, descending: true, parent: null); #endif @@ -62,7 +62,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: false); } - public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector) + internal static IOrderedAsyncEnumerable ThenByAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -71,7 +71,7 @@ public static IOrderedAsyncEnumerable ThenByAwait(this I } #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) + internal static IOrderedAsyncEnumerable ThenByAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -88,7 +88,7 @@ public static IOrderedAsyncEnumerable ThenBy(this IOrder return source.CreateOrderedEnumerable(keySelector, comparer, descending: false); } - public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + internal static IOrderedAsyncEnumerable ThenByAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -97,7 +97,7 @@ public static IOrderedAsyncEnumerable ThenByAwait(this I } #if !NO_DEEP_CANCELLATION - public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + internal static IOrderedAsyncEnumerable ThenByAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer: null, descending: true); } - public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector) + internal static IOrderedAsyncEnumerable ThenByDescendingAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -123,7 +123,7 @@ public static IOrderedAsyncEnumerable ThenByDescendingAwait ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) + internal static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -140,7 +140,7 @@ public static IOrderedAsyncEnumerable ThenByDescending(t return source.CreateOrderedEnumerable(keySelector, comparer, descending: true); } - public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + internal static IOrderedAsyncEnumerable ThenByDescendingAwaitCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -149,7 +149,7 @@ public static IOrderedAsyncEnumerable ThenByDescendingAwait ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) + internal static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellationCore(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs index b84d1edc73..b1c5822584 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Select.cs @@ -58,7 +58,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SelectAwait(this IAsyncEnumerable source, Func> selector) + internal static IAsyncEnumerable SelectAwaitCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -77,7 +77,7 @@ public static IAsyncEnumerable SelectAwait(this IAsyn } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) + internal static IAsyncEnumerable SelectAwaitWithCancellationCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -96,7 +96,7 @@ public static IAsyncEnumerable SelectAwaitWithCancellation SelectAwait(this IAsyncEnumerable source, Func> selector) + internal static IAsyncEnumerable SelectAwaitCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectAwaitWithCancellation(this IAsyncEnumerable source, Func> selector) + internal static IAsyncEnumerable SelectAwaitWithCancellationCore(this IAsyncEnumerable source, Func> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs index eb209f270c..74a5a8dc39 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SelectMany.cs @@ -23,7 +23,7 @@ public static IAsyncEnumerable SelectMany(this IAsync // REVIEW: Should we keep these overloads that return ValueTask>? One could argue the selector is async twice. - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) + internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -34,7 +34,7 @@ public static IAsyncEnumerable SelectManyAwait(this I } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) + internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -79,7 +79,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) + internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -114,7 +114,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) + internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> selector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -178,7 +178,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -208,7 +208,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -274,7 +274,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + internal static IAsyncEnumerable SelectManyAwaitCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -311,7 +311,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) + internal static IAsyncEnumerable SelectManyAwaitWithCancellationCore(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs index 609ed5885a..3babf8ec24 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Single.cs @@ -85,7 +85,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SingleAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask SingleAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -122,7 +122,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SingleAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask SingleAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs index b5ac28f153..00090c60a7 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleOrDefault.cs @@ -85,7 +85,7 @@ async ValueTask Core(IAsyncEnumerable _source, Func SingleOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask SingleOrDefaultAwaitAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -122,7 +122,7 @@ async ValueTask Core(IAsyncEnumerable _source, Func SingleOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) + internal static ValueTask SingleOrDefaultAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs index 46b968a06f..93190009c9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipWhile.cs @@ -92,7 +92,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable SkipWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -130,7 +130,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable SkipWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -168,7 +168,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif - public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable SkipWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -213,7 +213,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable SkipWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs index bb0f4da0d8..8d5f917ed2 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.cs @@ -60,7 +60,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -88,7 +88,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -166,7 +166,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -194,7 +194,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -266,7 +266,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -291,7 +291,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -360,7 +360,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -385,7 +385,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -454,7 +454,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -479,7 +479,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -554,7 +554,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -582,7 +582,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -660,7 +660,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -688,7 +688,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -760,7 +760,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -785,7 +785,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -854,7 +854,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -879,7 +879,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -948,7 +948,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -973,7 +973,7 @@ static async ValueTask Core(IAsyncEnumerable _source, Func SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) + internal static ValueTask SumAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt index 8233e40832..0604f6a48a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Sum.Generated.tt @@ -111,7 +111,8 @@ else } } - public static ValueTask<<#=o.type#>> SumAwaitAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + internal static ValueTask<<#=o.type#>> SumAsyncCore(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -152,7 +153,8 @@ else } #if !NO_DEEP_CANCELLATION - public static ValueTask<<#=o.type#>> SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + internal static ValueTask<<#=o.type#>> SumWithCancellationAsyncCore(this IAsyncEnumerable source, Func>> selector, CancellationToken cancellationToken = default) + { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs index 9ddd1a2c31..cb31144c20 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/TakeWhile.cs @@ -72,7 +72,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable TakeWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -100,7 +100,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable TakeWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -128,7 +128,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #endif - public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable TakeWhileAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -163,7 +163,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable TakeWhileAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs index f91dc4fea1..8e5bdb2a91 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToDictionary.cs @@ -37,10 +37,10 @@ static async ValueTask> Core(IAsyncEnumerable } } - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToDictionaryAwaitAsync(source, keySelector, comparer: null, cancellationToken); + internal static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitAsyncCore(source, keySelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -65,10 +65,10 @@ static async ValueTask> Core(IAsyncEnumerable } #if !NO_DEEP_CANCELLATION - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToDictionaryAwaitWithCancellationAsync(source, keySelector, comparer: null, cancellationToken); + internal static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -123,10 +123,10 @@ static async ValueTask> Core(IAsyncEnumerable> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToDictionaryAwaitAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + internal static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToDictionaryAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -154,10 +154,10 @@ static async ValueTask> Core(IAsyncEnumerable> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToDictionaryAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + internal static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToDictionaryAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs index eaa65d9690..681252dc5a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToLookup.cs @@ -28,10 +28,10 @@ static async ValueTask> Core(IAsyncEnumerable _s } } - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToLookupAwaitAsync(source, keySelector, comparer:null, cancellationToken); + internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToLookupAwaitAsyncCore(source, keySelector, comparer:null, cancellationToken); - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -47,10 +47,10 @@ async ValueTask> Core(IAsyncEnumerable _source, } #if !NO_DEEP_CANCELLATION - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => - ToLookupAwaitWithCancellationAsync(source, keySelector, comparer: null, cancellationToken); + internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => + ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer: null, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -86,10 +86,10 @@ static async ValueTask> Core(IAsyncEnumerable _ } } - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToLookupAwaitAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToLookupAwaitAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -107,10 +107,10 @@ static async ValueTask> Core(IAsyncEnumerable _ } #if !NO_DEEP_CANCELLATION - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => - ToLookupAwaitWithCancellationAsync(source, keySelector, elementSelector, comparer: null, cancellationToken); + internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => + ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer: null, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) + internal static ValueTask> ToLookupAwaitWithCancellationAsyncCore(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs index 2c307bd2d3..f329431be9 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Where.cs @@ -59,7 +59,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable WhereAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -76,7 +76,7 @@ public static IAsyncEnumerable WhereAwait(this IAsyncEnumerabl } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable WhereAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -93,7 +93,7 @@ public static IAsyncEnumerable WhereAwaitWithCancellation(this } #endif - public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable WhereAwaitCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); @@ -126,7 +126,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) + internal static IAsyncEnumerable WhereAwaitWithCancellationCore(this IAsyncEnumerable source, Func> predicate) { if (source == null) throw Error.ArgumentNull(nameof(source)); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs index cef5bf0947..182ebae643 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/Zip.cs @@ -71,7 +71,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) #endif } - public static IAsyncEnumerable ZipAwait(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + internal static IAsyncEnumerable ZipAwaitCore(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) throw Error.ArgumentNull(nameof(first)); @@ -102,7 +102,7 @@ async IAsyncEnumerator Core(CancellationToken cancellationToken) } #if !NO_DEEP_CANCELLATION - public static IAsyncEnumerable ZipAwaitWithCancellation(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) + internal static IAsyncEnumerable ZipAwaitWithCancellationCore(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) { if (first == null) throw Error.ArgumentNull(nameof(first)); From 9e72e4620fbed2c7b4de6eb63e3eea42a2181d9b Mon Sep 17 00:00:00 2001 From: Bart De Smet Date: Fri, 1 Mar 2019 12:22:27 -0800 Subject: [PATCH 862/862] Fix optional parameters for async overloads --- .../Linq/AsyncEnumerable.AsyncOverloads.cs | 528 +++++++++--------- .../Linq/AsyncEnumerable.AsyncOverloads.tt | 14 +- 2 files changed, 276 insertions(+), 266 deletions(-) diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs index b2e93bdf52..e16e5c343d 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.cs @@ -11,63 +11,63 @@ namespace System.Linq partial class AsyncEnumerable { #if SUPPORT_FLAT_ASYNC_API - public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); - public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitCore(source, keySelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, comparer); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitCore(source, keySelector, elementSelector); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector, comparer); public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitCore(source, keySelector); public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitCore(source, keySelector); @@ -78,96 +78,96 @@ partial class AsyncEnumerable public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); - public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitCore(source, keySelector); public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitCore(source, keySelector); public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitCore(source, keySelector, comparer); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitCore(first, second, selector); #if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); public static Task ForEachAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellationCore(source, keySelector); + public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector); public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector); - public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); + public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); public static IAsyncEnumerable> GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, comparer); public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); public static IAsyncEnumerable GroupBy(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector, comparer); public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable GroupJoin(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable Join(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask LastAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellationCore(source, keySelector); public static IOrderedAsyncEnumerable OrderBy(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellationCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable OrderByDescending(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellationCore(source, keySelector); @@ -178,96 +178,96 @@ partial class AsyncEnumerable public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); public static IAsyncEnumerable SelectMany(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); - public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable SkipWhile(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable TakeWhile(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellationCore(source, keySelector); public static IOrderedAsyncEnumerable ThenBy(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellationCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellationCore(source, keySelector); public static IOrderedAsyncEnumerable ThenByDescending(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellationCore(source, keySelector, comparer); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable Where(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable Zip(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellationCore(first, second, selector); #endif #else - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask AnyAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask CountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); - public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAwaitAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); + public static Task ForEachAwaitAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken = default) => ForEachAwaitAsyncCore(source, action, cancellationToken); public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitCore(source, keySelector); - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, comparer); public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitCore(source, keySelector, elementSelector); - public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, resultSelector); public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector); public static IAsyncEnumerable> GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, comparer); + public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, resultSelector, comparer); public static IAsyncEnumerable GroupByAwait(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitCore(source, keySelector, elementSelector, resultSelector, comparer); public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable GroupJoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable JoinAwait(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask LongCountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask LastAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitAsyncCore(source, selector, cancellationToken); public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitCore(source, keySelector); public static IOrderedAsyncEnumerable OrderByAwait(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable OrderByDescendingAwait(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitCore(source, keySelector); @@ -278,96 +278,96 @@ partial class AsyncEnumerable public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitCore(source, selector); public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); public static IAsyncEnumerable SelectManyAwait(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitCore(source, collectionSelector, resultSelector); - public static ValueTask SingleAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitAsyncCore(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAwaitAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitAsyncCore(source, predicate, cancellationToken); public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); public static IAsyncEnumerable SkipWhileAwait(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitCore(source, predicate); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitAsyncCore(source, selector, cancellationToken); public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); public static IAsyncEnumerable TakeWhileAwait(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitCore(source, predicate); public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitCore(source, keySelector); public static IOrderedAsyncEnumerable ThenByAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitCore(source, keySelector); public static IOrderedAsyncEnumerable ThenByDescendingAwait(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitCore(source, keySelector, comparer); - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); public static IAsyncEnumerable WhereAwait(this IAsyncEnumerable source, Func> predicate) => WhereAwaitCore(source, predicate); public static IAsyncEnumerable ZipAwait(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitCore(first, second, selector); #if !NO_DEEP_CANCELLATION - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); - public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); - public static ValueTask AllAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AnyAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask CountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, accumulator, cancellationToken); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, cancellationToken); + public static ValueTask AggregateAwaitWithCancellationAsync(this IAsyncEnumerable source, TAccumulate seed, Func> accumulator, Func> resultSelector, CancellationToken cancellationToken = default) => AggregateAwaitWithCancellationAsyncCore(source, seed, accumulator, resultSelector, cancellationToken); + public static ValueTask AllAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AllAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AnyAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => AnyAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask AverageAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => AverageAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask CountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => CountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask FirstOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => FirstOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); public static Task ForEachAwaitWithCancellationAsync(this IAsyncEnumerable source, Func action, CancellationToken cancellationToken) => ForEachAwaitWithCancellationAsyncCore(source, action, cancellationToken); public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => GroupByAwaitWithCancellationCore(source, keySelector); + public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector); public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector); - public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, comparer); + public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); public static IAsyncEnumerable> GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, comparer); public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, resultSelector, comparer); - public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector); public static IAsyncEnumerable GroupByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupByAwaitWithCancellationCore(source, keySelector, elementSelector, resultSelector, comparer); public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable GroupJoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func, CancellationToken, ValueTask> resultSelector, IEqualityComparer comparer) => GroupJoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector); public static IAsyncEnumerable JoinAwaitWithCancellation(this IAsyncEnumerable outer, IAsyncEnumerable inner, Func> outerKeySelector, Func> innerKeySelector, Func> resultSelector, IEqualityComparer comparer) => JoinAwaitWithCancellationCore(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); - public static ValueTask LastAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LastOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask LongCountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask LastAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LastOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LastOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask LongCountAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => LongCountAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MaxAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MaxAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask MinAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => MinAwaitWithCancellationAsyncCore(source, selector, cancellationToken); public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => OrderByAwaitWithCancellationCore(source, keySelector); public static IOrderedAsyncEnumerable OrderByAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector, IComparer comparer) => OrderByAwaitWithCancellationCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable OrderByDescendingAwaitWithCancellation(this IAsyncEnumerable source, Func> keySelector) => OrderByDescendingAwaitWithCancellationCore(source, keySelector); @@ -378,34 +378,34 @@ partial class AsyncEnumerable public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> selector) => SelectManyAwaitWithCancellationCore(source, selector); public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); public static IAsyncEnumerable SelectManyAwaitWithCancellation(this IAsyncEnumerable source, Func>> collectionSelector, Func> resultSelector) => SelectManyAwaitWithCancellationCore(source, collectionSelector, resultSelector); - public static ValueTask SingleAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); - public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); + public static ValueTask SingleOrDefaultAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> predicate, CancellationToken cancellationToken = default) => SingleOrDefaultAwaitWithCancellationAsyncCore(source, predicate, cancellationToken); public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable SkipWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => SkipWhileAwaitWithCancellationCore(source, predicate); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); - public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); + public static ValueTask SumAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> selector, CancellationToken cancellationToken = default) => SumAwaitWithCancellationAsyncCore(source, selector, cancellationToken); public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable TakeWhileAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => TakeWhileAwaitWithCancellationCore(source, predicate); public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByAwaitWithCancellationCore(source, keySelector); public static IOrderedAsyncEnumerable ThenByAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByAwaitWithCancellationCore(source, keySelector, comparer); public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector) => ThenByDescendingAwaitWithCancellationCore(source, keySelector); public static IOrderedAsyncEnumerable ThenByDescendingAwaitWithCancellation(this IOrderedAsyncEnumerable source, Func> keySelector, IComparer comparer) => ThenByDescendingAwaitWithCancellationCore(source, keySelector, comparer); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); - public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToDictionaryAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToDictionaryAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, comparer, cancellationToken); + public static ValueTask> ToLookupAwaitWithCancellationAsync(this IAsyncEnumerable source, Func> keySelector, Func> elementSelector, IEqualityComparer comparer, CancellationToken cancellationToken = default) => ToLookupAwaitWithCancellationAsyncCore(source, keySelector, elementSelector, comparer, cancellationToken); public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable WhereAwaitWithCancellation(this IAsyncEnumerable source, Func> predicate) => WhereAwaitWithCancellationCore(source, predicate); public static IAsyncEnumerable ZipAwaitWithCancellation(this IAsyncEnumerable first, IAsyncEnumerable second, Func> selector) => ZipAwaitWithCancellationCore(first, second, selector); diff --git a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt index 957763b6ba..ae3cd34e2a 100644 --- a/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt +++ b/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.AsyncOverloads.tt @@ -65,6 +65,16 @@ toCSharp = t => return t.Name; } }; + +Func getOptionalSuffix = p => +{ + if (p.IsOptional) + { + return " = default"; + } + + return ""; +}; #> using System.Collections.Generic; using System.Threading; @@ -97,7 +107,7 @@ foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation")) var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : ""; var returnType = toCSharp(m.ReturnType); var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true); - var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name)); + var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name + getOptionalSuffix(p))); var args = string.Join(", ", m.GetParameters().Select(p => p.Name)); #> public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>) => <#=longName#><#=genArgs#>(<#=args#>); @@ -131,7 +141,7 @@ foreach (var g in asyncMethods.GroupBy(m => m.Name.Contains("WithCancellation")) var genArgs = m.IsGenericMethod ? "<" + string.Join(", ", m.GetGenericArguments().Select(t => t.Name)) + ">" : ""; var returnType = toCSharp(m.ReturnType); var isExtension = m.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), true); - var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name)); + var pars = (isExtension ? "this " : "") + string.Join(", ", m.GetParameters().Select(p => toCSharp(p.ParameterType) + " " + p.Name + getOptionalSuffix(p))); var args = string.Join(", ", m.GetParameters().Select(p => p.Name)); #> public static <#=returnType#> <#=shortName#><#=genArgs#>(<#=pars#>) => <#=longName#><#=genArgs#>(<#=args#>);